Convert DataGrid to Excel

G

Guest

Hi,
I wrote a small function, thaht converts a DataGrid to Excel from a Web-Application (C#).
Running the function with 100-200 rows it just works fine.
Starting a "special" Report produces a DataDrid with about 13650 Rows. Now the conversion to Excel does not work.
Are there any known restrictions?
The code looks like this:
<---->
private void btnExcel_Click(object sender, System.EventArgs e)
{
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter(System.Globalization.CultureInfo.CurrentCulture);
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
ReportGrid.RenderControl(hw);
Response.Write(makeHTMLcode(tw.ToString()));
Response.End();
}
<---->
Thanks in advance
Patrick
 
R

Rick Spiewak

Turn off the viewstate on the datagrid before you complete the download. The
extra data kills the ability of Excel to load it. That will fix this
problem.

Patrick S. said:
Hi,
I wrote a small function, thaht converts a DataGrid to Excel from a Web-Application (C#).
Running the function with 100-200 rows it just works fine.
Starting a "special" Report produces a DataDrid with about 13650 Rows. Now
the conversion to Excel does not work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top