473,504 Members | 13,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error exporting DataGrid to excel file using RenderControl

I have a button in my html page for exporting to excel files using the
RenderControl function. When the table generated is small in rows size it
works fine, but when there are much more rows (more than 5000) the excel loss
format in the last rows mainly in Rowsan or Colspan property for the table.
This is the code I'm using

Response.Clear();
Response.Buffer=true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
System.Web.UI.HtmlTextWriter(oStringWriter);

Page.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
Some help?
Nov 16 '05 #1
3 4259
I can't believe, it isn't the first time I need help from this newsgroup
without any answer, especially in asp.net tecnology. How can I solve problems
without help?
"Andres Romero" wrote:
I have a button in my html page for exporting to excel files using the
RenderControl function. When the table generated is small in rows size it
works fine, but when there are much more rows (more than 5000) the excel loss
format in the last rows mainly in Rowsan or Colspan property for the table.
This is the code I'm using

Response.Clear();
Response.Buffer=true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
System.Web.UI.HtmlTextWriter(oStringWriter);

Page.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
Some help?

Nov 16 '05 #2
Beats me. Have you tried adding a "Response.Flush()" just before the
Response.End() ??
Peter

"Andres Romero" <An**********@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com...
I can't believe, it isn't the first time I need help from this newsgroup
without any answer, especially in asp.net tecnology. How can I solve problems without help?
"Andres Romero" wrote:
I have a button in my html page for exporting to excel files using the
RenderControl function. When the table generated is small in rows size it works fine, but when there are much more rows (more than 5000) the excel loss format in the last rows mainly in Rowsan or Colspan property for the table. This is the code I'm using

Response.Clear();
Response.Buffer=true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
System.Web.UI.HtmlTextWriter(oStringWriter);

Page.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
Some help?

Nov 16 '05 #3
Thanks Peter

I put the Response.Flush as you tell me but I'm still having the same bug,
some other idea?

Especifically the bug is when tranforming Rowspan with more than 280 of
value (rows) to merging rows in excel, the total rows in file is greater than
4000 or 5000

If you can help me I can send you the output web page and the excel file
exported to some e-mail. My email is an********@hotmail.com. Please I need
help.

"Peter Bromberg [MVP]" wrote:
Beats me. Have you tried adding a "Response.Flush()" just before the
Response.End() ??
Peter

"Andres Romero" <An**********@discussions.microsoft.com> wrote in message
news:7A**********************************@microsof t.com...
I can't believe, it isn't the first time I need help from this newsgroup
without any answer, especially in asp.net tecnology. How can I solve

problems
without help?
"Andres Romero" wrote:
I have a button in my html page for exporting to excel files using the
RenderControl function. When the table generated is small in rows size it works fine, but when there are much more rows (more than 5000) the excel loss format in the last rows mainly in Rowsan or Colspan property for the table. This is the code I'm using

Response.Clear();
Response.Buffer=true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new
System.Web.UI.HtmlTextWriter(oStringWriter);

Page.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
Some help?


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3078
by: Neil | last post by:
Hi I'm currently exporting my datagrid to excel, taking advantage of the fact that excel can render html, the problem is that when i click the button to export it opens in browser, I want the button...
2
2465
by: Steve Chatham | last post by:
I use the following code: Private Sub RbtnExport_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbtnExport.SelectedIndexChanged Dim sFile As String =...
1
2300
by: ad | last post by:
I use the code below to export the content of a data set to Excel, the code come form http://www.dotnetjohn.com/articles.aspx?articleid=36 But it always use the web form's name as the default...
1
1447
by: http://www.visual-basic-data-mining.net/forum | last post by:
I have a web form in which I have a datagrid, I need to export this data to a Microsoft Excel sheet. I'm doing it thus: Response.Clear();
1
2293
by: NancyA | last post by:
I am using the following code to write data from a datagrid to an Excel file: Dim tw As New System.IO.StringWriter Dim hw As New System.Web.UI.HtmlTextWriter(tw) dg.RenderControl(hw)...
6
2529
by: Opa | last post by:
Hi, I have a DataGrid, whose sourceI am exporting to Excel. This works fine except for the Column ordering. My datasource is not a datatable, with a typical SELECT statement where I can...
0
1269
by: forumaic | last post by:
Hello, I am trying to export data to excel from datagrid, and I am getting an error: "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)." ...
3
5069
by: =?Utf-8?B?Sm9obiBXYWxrZXI=?= | last post by:
Hi, Is there anything wrong with the code below in sending my browser page to Excel? Before my page opens in Excel there's a message "Problems came up in the following areas during load:" and it...
0
1641
by: PerumalSamy | last post by:
Hi I need to export datagrid to excel. below is the coding what i had tried Dim stringwrite As New StringWriter Response.Clear() Response.AddHeader("content-disposition",...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.