DataGrid to Excel

D

DOKOM

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 advanc
Patric
 
D

DOKOM

One more Information:

InitializeComponent() at the start of the Webpage is not called, when Clicking the "Excel-Sxport" Button" and the IEXPLORE.EXE process has about 170 Megs of memory
 
J

Jeffrey Tan[MSFT]

Hi Patrick,

Based on my understanding, you meet the problem of converting big block of
datagrid into Excel.

Actually, there is a KB teaches you how to do the converting:
"HOW TO: Export Data in a DataGrid on an ASP . NET WebForm to Microsoft
Excel"
http://support.microsoft.com/default.aspx?scid=kb;en-us;317719

But, I did not see any problem in your code of doing this. Can you show me
the detail error of "does not work"? What error message do you get?

Also, how many rows will cause this error?

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
R

Rick Spiewak

Make sure you turn off viewstate on the datagrid before converting it.

DOKOM 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.
 
D

DOKOM

Hi Jeffrey

thank you for your answer
The main problem is, that there is no error. The IE as I already wrote has 170 Megs of memory
To export the grid I use a Export - Button. I put a breakpoint at in the 'first line' override protected void OnInit(EventArgs e). It is never called when the grid has this size. When I have abot 200 rows everything just works fine
I performed several tests with changing Row-Cont.
At 13.285 rows the Export-Click leads to the described 'error'. 13.284 works fine

Greeting
Patrick
 
J

Jeffrey Tan[MSFT]

Hi Patrick,

Thanks very much for your feedback.

I have inserted a large number of rows and I have reproduced out your
issue, although is not the 13285 rows.

I will spend some more time on this issue. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
R

Rick Spiewak

Have you tried turning off viewstate? If viewstate is enabled, there is a
large amount of extraneous data sent into Excel, and it can fail.

DOKOM said:
Hi Jeffrey,

thank you for your answer.
The main problem is, that there is no error. The IE as I already wrote has 170 Megs of memory.
To export the grid I use a Export - Button. I put a breakpoint at in the
'first line' override protected void OnInit(EventArgs e). It is never called
when the grid has this size. When I have abot 200 rows everything just
works fine.
 
D

DOKOM

Hi Rick

thanks for your hint, but I turn off the viewstate in line 3 of my function: 'this.EnableViewState = false;' before I send the stream to Excel

Regard
Patrick
 
J

Jeffrey Tan[MSFT]

Hi Patrick,

I still can not find any known issue about this problem. I will consult
internally for this issue.

Please wait for a little more time. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
D

DOKOM

Hello Jeffrey, hello Yanhong

I'm still trying to fix the problem without succes yet
Please keep your investigations up

Thanks in advance for your help and regard

Patrick
 
Y

Yan-Hong Huang[MSFT]

Hi Patrick,

Sure. I will contact our product group on it and update in the newsgroup as
soon as possible. Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Y

Yan-Hong Huang[MSFT]

Hi Patrick,

We have performed much research on it. Currently the behavior is somewhat
different on our side. It seems that when the dataset contains too much
data, those data can't be transferred to client side by response object.

The test that we have performed:

1) In button click handler, add code slice to save string info in server
side to see whether the string info can be got correctly from dataset. In
our test, it can be saved to a file.

2) Then we use response object to directly send the string to the client
side without involving Excel (remove mime tyep in the code). That is just a
table. However, it is also not shown. So it seems that when the string is
too large, it can't be sent to client side now.

We will perform more research to see whether it is caused by some
limitation. I suggest you also simply the table schema to see whether you
can get more rows under the test. Currently if we use array list to
transfer 60000 rows, it doesn't have any error.

For the time being, could you use the technology in that KB artilce as a
workaround? That is to say, automating excel in the client side to show the
data in Excel.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

DOKOM

Hi again

I have tried the suggestions made by you
Unfortunately the button click handler is not called after filling my datagrid with that huge load of data
Therefore you're workaraound did not work on my site

As you suggested I have Excel set up to retrieve the data directly which works well, bur for future projects it would be helpful to know, why the Export fails. Maybe you could do some more research on that to help me on that question

Regard
Patrick
 
Y

Yan-Hong Huang[MSFT]

Hi Patrick,

Sure. We are performing research on it with dev team. Thanks very much for your feedback.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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
474,039
Messages
2,570,375
Members
47,020
Latest member
anuradha

Latest Threads

Top