Hello,
We have noticed that exporting a WinGrid to Excel by using the UltraGridExcelExporter causes a InitializeRow to be triggered on every row during the initialization phase of the export (this is before the event ExportStarted is triggered).
We have a grid with rather complex functionality being processed in the initializerow, and this causes a long delay in the total export process. We are wondering if this is normal behaviour, or if there is a setting we can set to avoid this ?
Kind regards,
Michael
PS: version 11.2.20112.1010
I have an app where InitializeRow colors the BackgroundColor of each row according to a hierarchy:
But I want those colors to be omitted when I export to Excel. I tried using if (!r.Band.Layout.IsExportLayout) on the lines that color the background, and it correctly skips those lines during export. But the colors come through anyway:
How can I prevent this from happening?
Thanks.
Hi Eddy,
180 is a very small number of rows. Are you saying that the code in your InitializeRow event is so complex that it causes a problem when it runs only 180 times?
InitializeRow fires a lot. It fires every time the grid creates a row, and any time any value in any cell of that row is changed. So it's really not a good place to put any kind of memory-intensive of performance-intensive code.
What kinds of things are you doing in this event that are causing a problem?
Have you read the WinGrid Performance Guide. If not, you should check it out. It gives a lot of advice about how to make the grid more efficient.
Hi Mike,
We are also having the same issue. Unfortunately, there aren't that many other processes that I can removed to help free up resources. What other options do we have?
I've tried to use e.Row.Band.Layout.IsExportLayout and conditionally exclude numerous columns when exporting and that still didn't work.
I'm testing with about 180 records and it's already having these problems. Our users will need to export over 1000 records.
And when we export just a few records, there is no problem at all. Everything exports just fine.
Any suggestions?
Thank you in advance.
Eddy
Hey Mike,
Thank you for the quick reply. It is exactly what I was looking for.
Hi Michael,
This is correct behavior. The export process involves cloning the grid rows for exporting, so that you can modify the rows of the export without changing the on-screen rows. So the cloned rows have to be initialized.
If there is some part of your processing that you do not need to do in the export rows, then you could detect when the row is an export row like so:
e.Row.Band.Layout.IsExportLayout