By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

Convert DataGrid to Excel

P: n/a
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.Cultur eInfo.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
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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." <DO***@community.nospam> wrote in message
news:59**********************************@microsof t.com...
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.Cultur eInfo.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

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.