Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems exporting gridView to Excel
    primarykey
    data
    text
    <p>I am trying to export a <code>GridView</code> to Excel. </p> <p>I have tried to follow steps found here:</p> <ol> <li><a href="http://www.programming-free.com/2012/09/aspnet-export-grid-view-to-excel.html#.UhUREpK1F9o" rel="nofollow noreferrer">http://www.programming-free.com/2012/09/aspnet-export-grid-view-to-excel.html#.UhUREpK1F9o</a> </li> <li><a href="https://stackoverflow.com/questions/8094573/export-gridview-to-excel-file">export gridview to excel file</a> </li> </ol> <p>And other similar sites.</p> <p>My <code>GridView</code> does not have any special properties different from default and my <code>SqlDataSource</code> uses <code>filterExpression</code> if that is important.</p> <p>When I try the above mentioned solutions no exception occurs, but the excel is not produced. </p> <p><strong>UPDATE</strong></p> <p>I forgot to mention that the <code>GridView</code> is inside a <code>asp:Content</code> control. I heard this might matter.</p> <p>My code-behind goes something like this ( I have tried multiple things ).</p> <pre><code>Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=FileName.xls"); Response.Charset = String.Empty; EnableViewState = false; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); GridView3.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); HttpContext.Current.ApplicationInstance.CompleteRequest(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload