D
Dave Bailey via DotNetMonster.com
I am using the following code to export a datagrid to excel from an asp
page:
private void exportButton_Click(object sender, System.EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
hw.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Html);
this.ClearControls(reportGrid);
reportGrid.RenderControl(hw);
hw.RenderEndTag();
Response.Write(tw);
Response.End();
}
When I run this code I only get the first column returned to the
spreadsheet.
The is no other control on the datagrid so I am at a loss. Any suggestions
would be appreciated.
Thanks,
Dave
page:
private void exportButton_Click(object sender, System.EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
hw.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Html);
this.ClearControls(reportGrid);
reportGrid.RenderControl(hw);
hw.RenderEndTag();
Response.Write(tw);
Response.End();
}
When I run this code I only get the first column returned to the
spreadsheet.
The is no other control on the datagrid so I am at a loss. Any suggestions
would be appreciated.
Thanks,
Dave