hi,
I try to load nearly a million records to my data structure and page those records using ultrawinGrid only 1000 at a time. This helps me avoid System.OutOfMemory exceptions which could cause otherwise trying to load them directly to an ultrawingrid.
But I have a functionality to export this grid (the entire pages and not 1000 pages alone) to excel. In order to achieve this, I programatically create an ultraWinGrid, and use an ultraDatasource to point to my already loaded data structure. Although I set up my ultraGrid.Datasource property to this ultraDatasource, I am not able to export it using ultraGridExcelExporter. Should I call InitializeRow on all the rows in the programatically created ultrawinGrid?
Thanks for the help in advance.
Shankar
Hi Shankar,
shankarchandru said:Although I set up my ultraGrid.Datasource property to this ultraDatasource, I am not able to export it using ultraGridExcelExporter.
Why not? What's the problem?
If you are creating a WinGrid in code and it's never parented to a form, then my guess is that it's not working because the grid has no BindingContext and so it has no data. Try setting the grid's BindingContext to the same BindingContext as the "real" grid that you are displaying, or to the BindinginContext of the form.
Thanks for the quick update. That was the problem indeed. I am able to export the grid properly from a load on Demand WinGrid.
As I said earlier, I am trying to export a lot of rows. So I had to export the grid to multiple tabs in Excel due to row limitation of Excel. Also, I read another reply from you on a separate forum thread.
http://news.infragistics.com/forums/p/36060/210139.aspx#210139
This article was helpful to export to multiple worksheets in Excel, but I am running into a problem where the FileLimit behavior doesn't stop when we reach 65536 rows in Excel. It seems to stop randomly beyond this. This is a problem since, I have to ensure I add the header row of the grid in each of the worksheets before I start exporting rest of the rows.
Every datagrid row I am exporting into excel strictly uses only 1 row in Excel as well. So I am not sure why this would go wrong.
Thanks for all your help in this matter.
shankarchandru said:You had mentioned in the other post to use a ultragrid variable to keep track of how many rows got exported, I was trying to handle this with a member variable which works for me, but if you could clarify more on this, it would be helpful, since I don't need to keep a track of this.
Huh? :)
I'm not sure what post of mine you are referring to, so I'm afraid I don't understand what you are trying to keep track of or why.
shankarchandru said:Also ultraGridExcelExporter loops through all the rows even if we have TruncateData option. This means, it is actually going through all the rows in the datasource associated in the Grid. This might be a performance issue. Let say I have around 250,000 rows that Load on Demand, then when I export this to excel, excel exporter would be looping through 250,000 rows atleast 4 times.
I don't think there's anything that can be done about this. The grid has to create all of the rows and fire InitializeRow for the rows in the export layout before it ever starts exporting them to Excel. So there's no way to know that the data will be truncated until after the rows are already created.
Hi Mike,Sorry if I did not explain that right. There was another post where you explain exporting to multiple tab sheets and I was refering to it. Below is the link to the posthttp://news.infragistics.com/forums/p/36060/210139.aspx#210139In the above post, you had mentioned about tracking how many records have been exported using an ultragrid member variable. This was my question. Currently I use a member variable in my class to keep track of grid's row count and how many times I need to call Export and use that. Regarding looping through records 4 times question, I observed the following,I used ultraGridExcelExporter's RowExported event to get last row exported index. And I had around 250000 rows in my ultraGrid. I would assume that UltraGridExcelExporter's RowExported event should have stopped after 65,535 rows in my ultraGrid. Instead it kept going till all records in my ultraGrid (250000 rows). Afterwhich EndExport event is triggered. I create a loop to handle exporting rows to multiple tab sheets in Excel. As I said, if there are 250,000 rows in my grid, I would end up looping through 250,000 4 times, before I export all rows to 4 different excel worksheets. So I was asking if there is a way around it.Hope I explained this better this time.
Hi,
Well, it may depend on what your member variable is keeping track of, but that sounds like a bug. I can't see any reason why the event should keep firing for rows that are not actually being exported.
The grid might actually have to loop through the rows, anyway, but it shouldn't be firing the event at the very least. What is the CurrentRowIndex that is passed into the event? Does it show a number greater than 65,535? That would be really odd - since if you tried to access that row in the work sheet, it would raise an exception.
Hi Mike,
I keep track of ultragrid row count and call export on the same workbook by adding and setting an active worksheet before calling export method. The Export method is called based on the total row count instead of this last row exported and I use skip row option as had mentioned in the earlier post (Export to multiple tab sheets in excel).
I am attaching a snapshot indicating the value of e.CurrentRowIndex property. You can see that it has already crossed 65640
We are using NetAdvantage 2008 for .Net (Infragistics 2008 Vol1 CLR 2.0). Please let me know if there is a workaround.
ThanksShankar
Attached Image:
Hello Shankar,
The following case has been created based on your issue: CAS-55950-X6ZX52
Please let me know if you need any further assistance.
Hi Hardik,
What version of the Infragistics controls are you using? Infragistics2 just means that the assemblies are built against CLR2. So I don't know what version you are using. If you are saying you are using NetAdvantage 2.0, then no, that version was released long before Excel2007 existed and therefore it cannot possibly support exporting to Excel2007 format. That feature could not possibly have been added before version 7 or maybe even later.
Is there any way to export to 2007 format(.xlsx) by using infragistics2 and CLR 2.
because i told to upgrade my application which export the reports in 2007 format.but when i have tried by adding the extension it is throwing me an error.
Regards,
Hardik
I'm a little confused by your question. As far as I know, exporting to Excel2007 or higher format requires CLR3 or higher. Otherwise, you would have to write your own compression class and provide it to the export method. So I'm not sure how you could be exporting at all.
Hi Friends,
I am using Infragestics2 with .net framework 2.0.
I am using the Export functionality which is working fine for .xls format (2003) But i want to add support for the .xlsx (2007/2010) too.
I have tried to add the extension .xlsx but it is throwing error saying "Excel cannot open the file because the file format or file extension is not valid.varify that the file has not been corrupted and that the file extension matches the format of the file.
Any Idea ?
Please help.
When you export the grid, the grid creates a clone of it's DisplayLayout along with a clone of the rows collection. This allows you to modify the export layout or the export rows without modifying the on-screen grid.
The exporter expands all of the cloned rows, on the assumption that you want to export all of the grid rows, and that the export should not be based on the current expanded state of a row on the screen.
I think what you can do is trap the InitializeRow event on the UltraGridExcelExporter and set e.SkipDescendants to true for any parent row whose children you do not want to export.