Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / May 2004

Tip: Looking for answers? Try searching our database.

DataGrid to Excel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DOKOM - 11 May 2004 10:36 GMT
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
DOKOM - 11 May 2004 12:26 GMT
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
"Jeffrey Tan[MSFT]" - 12 May 2004 04:02 GMT
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
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

DOKOM - 12 May 2004 11:56 GMT
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
"Jeffrey Tan[MSFT]" - 13 May 2004 04:36 GMT
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
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Rick Spiewak - 13 May 2004 05:15 GMT
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.

> 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.
>
> Greetings
> Patrick
DOKOM - 13 May 2004 08:11 GMT
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
"Jeffrey Tan[MSFT]" - 17 May 2004 03:40 GMT
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
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

DOKOM - 17 May 2004 08:21 GMT
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
Yan-Hong Huang[MSFT] - 18 May 2004 02:11 GMT
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.
Yan-Hong Huang[MSFT] - 19 May 2004 09:46 GMT
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.
DOKOM - 24 May 2004 08:51 GMT
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
Yan-Hong Huang[MSFT] - 24 May 2004 09:59 GMT
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.
Rick Spiewak - 12 May 2004 05:13 GMT
Make sure you turn off viewstate on the datagrid before converting it.

> Hi,
> I wrote a small function, thaht converts a DataGrid to Excel from a Web-Application (C#).
[quoted text clipped - 17 lines]
> Thanks in advance
> Patrick

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.