markknowsley
Programmer
I have used the following code to export the content of a datagrid to an Excel spreadsheet:
Response.Clear();
Response.AddHeader("content disposition", "attachment;filename=myexcelspreadsheet.xls");
Response.Charset = "";
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);
dgAllHRUsers.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
When I compile the code I get the standard Windows file download box, and an error message saying that
"Internet Explorer cannot download 'filename.aspx' from localhost"
The address of the .aspx page containing the datagrid is
Any ideas?
Response.Clear();
Response.AddHeader("content disposition", "attachment;filename=myexcelspreadsheet.xls");
Response.Charset = "";
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);
dgAllHRUsers.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
When I compile the code I get the standard Windows file download box, and an error message saying that
"Internet Explorer cannot download 'filename.aspx' from localhost"
The address of the .aspx page containing the datagrid is
Any ideas?