A while back, Duane wrote an article in this forum detailing how to do an ajax postback that resulted in the Excel document downloading. It was quite good and pretty deep, but I never got a chance to implement it.
Now I am back to try it, and I can't find the article. It looks like somebody cleaned out the forums, deleting some good content in the process.
Can somebody please retrieve it?
And can somebody please give your developers someplace they can post this kind of stuff without worrying about a moderator deleting it?
While the article doesn't appear to be publicly visible (can't find it through search or by browsing the forum), it is available by direct link.
Here is the link, if it's helpful to anyone else.
http://forums.infragistics.com/forums/t/55904.aspx
Thanks Duane! Keep it coming!
Wow, this is doubly cool... it solves another issue I have been having as well, trying to export large datasets with the WebexcelExporter.
Right now, there is no such statement as WebExcelExporter1.Export(myworksheet).... or WebExcelExporter1.Export(myDataSet)... or WebExcelExporter1.Export(mySqlDataReader)... (feature requests there, hint hint).
This article shows how to take the Worksheet object directly to the response stream without the WebExcelExporter.
A person could modify this code to accept a simple sqldatareader, minimizing memory requirements for exporting large datasets. Speaking of large datasets, I bet this is faster than WebExcelExporter too.
Hello Rob Hudson,
Thanks for the update.
As far as exporting 1 million records may be more than what is expected for the machine that is hosting the web server to handle when saving to excel. Also what you are wanting to accomplish would simply be more involved in the actual web server processing than the WebExcelExporter control. In this case if you have a sample that shows efficient exporting for 1 million records using .NET code then I can submit a feature request on this in particular. This will help as far as a proof of concept and automation on the NetAdvantage product.
Let me know if you have any questions with this matter. Thank you.
Hey Duane,
I don't agree that exporting large datasets is outside the ability of a web server.
I put together a simple little app that generates large recordsets, and then tests the time it takes to export that recordset using various methods. Have a look at this:
For a recordset of 50,000 rows, the WebExcelExporter took over 4 minutes! That is really too long, regardless of what environment you are in. All of the other methods returned a memory stream in a matter of seconds.
The result that was really stunning though was the BIFF format. This is probably the fastest possible method to export data to Excel, being that it is direct-to-binary. It shows just how "within the scope of a web server" the export of these files can be. I was startled to click the button and see the worksheet pop up almost instantly. Unfortunately, the BIFF format is limited to 65k records per spreadsheet.
It would be interesting to do a solution where you could output large recordsets to BIFF, and have it wrap onto new spreadsheets when it reaches the row limit of one spreadsheet. There's your proof of concept that it is possible to export very large numbers of records at crazy-fast speeds. By my calculation, BIFF could export 1 million rows in 15 seconds, with a super-small memory footprint to boot.
Regarding Infragistics Excel, I was also pleased to see that with larger resultsets, parallel processing dramatically reduces the time it takes to populate the Worksheet object. This is on my single-CPU workstation. Time was cut from 59 seconds to 35 seconds.
However, SpreadsheetGear has you beat soundly (and also proves the concept). Note that the SpreadsheetGear solution was able to generate a worksheet with 1 million rows and also stream it in under 1 minute. That is acceptable for an async operation in my environment.
Some good news for you guys... With parallel loading, I was able to populate your Worksheet object in a time very close to theirs. However, I was unable to execute Workbook.Save() because of other issues... which brings me to the next topic.
There seems something very wrong with Workbook.Save(). It is extraordinarily expensive, both in terms of memory, and processing time. I can populate 600,000 rows into an IG Worksheet object in 11 seconds, but it takes 74 seconds (and a lot of memory) for Workbook.Save to write to the memorystream. I can't process row counts larger than that without Workbook.Save crashing.
Workbook.Save() is the bottleneck. With that improved, you have a path to a high performance Excel exporter that would compete with SpreadsheetGear.
I tried attaching my project as a .zip file to this post. If it didn't take, let me know, and I will be glad to send it by other means.
Thanks for the attached sample on the thread.
I ran the sample and clicked on the Test save option and "Run Test" button using the WebExcelExporter method. For 50,000 records with 12 columns on my local machine took about 1 min, 18 secs, 84 ms that is much faster than 4 min, 57 sec, 673 ms. Clearly what's being reported and the sample attached that I ran I believe looks to be a difference to the environment.
Also when using the WebExcelExporter control is a feature for the WebDataGrid that is used for the WebDataGrid control directly. As far as doing a comparison on SpreadsheetGear, is there a feature in using SpreadsheetGear that provides a web interface in the ASP.NET platform that would render a grid and export to excel? Most likely this would be a more direct comparison.
When using the WebExcelExporter control there is definitely a lot of features and functionality provided to be productive on. In the samples browser demonstrates the key usage here: http://samples.infragistics.com/aspnet/Samples/WebDataGrid/Data/Excel-Exporter/Default.aspx?cn=excel-exporter&sid=325f8ea4-0a5f-4a1a-87fd-1d39d4f746d2. There is a rich feature list and also supporting many of the formats such as Excel 97, 2003, and 2007 that may involve a tradeoff to performance which is expected.
Duane,
Thanks for the feedback..
I know that WebExcelExporter isn't ever going to match SpreadsheetGear. It has a lot more work to do as far as applying CSS, etc, and is tied closely to the WebDataGrid control. That's ok.
What I am looking for is an acceptable solution that bypasses the WebExcelExporter and uses Infragistics.Documents.Excel. If we were to do a feature comparison, it would be between Infragistics.Documents.Excel and SpreadsheetGear.
I am trying to get Infragistics.Documents.Excel to work for these exports. SpreadsheetGear is another $1k per license, and I have already purchased a library that is supposed to handle Excel exporting.
Were you able to duplicate the resource issues that I noted with Workbook.Save?
I will submit this as a log for our engineers to take a look at. First I would like to demonstrate this as a console application. The main reason is because demonstrating the performance would not be involved in a particular platform.
The fix for development issue 89817 is now in the latest service release. You can download within My Keys & Downloads page.
Just pinging you guys to see if there has been an update to this issue for the next release.
I am experiencing more pressure from the client to have a solution, and I need to know whether I should wait for Infragistics.
Thanks for the update on the thread.
For the performance improvements on using the Excel library I have logged bug id 89817 on this using the sample code that was provided in this thread to have our engineers look into this. Also private case CAS-72672-JNFCD2 has been created and you can find this case number in the support activity page here: https://ko.infragistics.com/Membership/MySupport.aspx.
Understood... Duane, the reason I didn't have handling for the try/catch block is that my intent was to just ignore the error... I was just trying to get a build time.
I understand (while being surprised) about it not being thread safe. I will submit a feature request.
The objects in the Excel library are not thread safe, so you should not be using Parallel.ForEach to populate a Worksheet with data. You can submit a feature request to make these objects thread safe. Until that is implemented, you should be populating the objects synchronously.