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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top