U
Ugo
Hi,
I am having a problem exporting a Datagrid to excel in asp.net. For
some reason I am getting a blank excel page. I set up in IIS the Mime for
..xls. My code is below any help would be appreciated..
Thanks
CODE:
private void ExportToExcel()
{
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Charset = "";
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
DataGrid dg = new DataGrid();
dg.DataSource = (DataSet) Cache["dataset"];
dg.DataBind();
dg.RenderControl(hw);
Response.Write(tw.ToString());
Response.Flush() ;
Response.Close();
}
I am having a problem exporting a Datagrid to excel in asp.net. For
some reason I am getting a blank excel page. I set up in IIS the Mime for
..xls. My code is below any help would be appreciated..
Thanks
CODE:
private void ExportToExcel()
{
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Charset = "";
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
DataGrid dg = new DataGrid();
dg.DataSource = (DataSet) Cache["dataset"];
dg.DataBind();
dg.RenderControl(hw);
Response.Write(tw.ToString());
Response.Flush() ;
Response.Close();
}