I'm trying to use the Excel Exporter (I'm using Infra 3 12.1) but some of the cells in my grid have > 32KB so it does not work.
To get around this I tried to used the CellExporting event - but the obvious method of setting e.value to be the adjusted string I want written unfortunately also updates the grid.
So following some other advice on the Infra site I tried:
e.Workbook.WindowOptions.SelectedWorksheet.Rows(e.CurrentRowIndex).Cells(e.CurrentColumnIndex).Value = my_adjusted_value
I then find that I need to set e.cancel = True to stop it trying to write the value from the grid.
So now I have the correct data in my excel sheet. BUT, it hasn't set the format the same as the other cells and so my data is presented differently from the rest of the cells.
What is the correct approach to achieve this????
Hello Gwyn,
Thank you for contacting Infragistics. We've recently seen an Unhandled Exception at runtime when loading the grid with a grid that contains a cell, loaded with an XML file with over 32k amount of data. Note, this ONLY occurs in Windows Server 2012. It was not reported in WS 2008 and Windows 7. Does this relate to the behavior you've seen?
Are you receiving the following issue? "Infragistics.Win.DrawUtility.DrawStringHelper - A generic error occurred in GDI+".
I believe the issue deals with the xml configuration (aka schema). But I'll need to test your data your attempting to load in the cell that's exported. It would also help to know if any shorter ones under 32k work. I can modify and increase them over 32k to see if the issue occurs.
I recommend loading another xml file that has a similar structure to the one I attached and see if the behavior occurs. Alternatively you can set the grid to be GDI instead of GDI+ rendering by setting the TextRenderingMode and see if that helps. Note, this prevents the exception, but the xml was never loaded into the cell. I get the same results with the inbox Textbox control.
ultraGrid1.TextRenderingMode = Infragistics.Win.TextRenderingMode.GDI;
Let me know if this helps and if you have any questions regarding this matter.
Hi Michael, thanks for your response however you seem to have offered a solution to a different problem that I was trying to describe!
I'm simply trying to make a grid cell exportable to Excel by reducing the size of the exported text. In my case I only want 8000 characters.
But if I overwrite e.value in the UltraGridExcelExporter.CellExporting event then it also updates the grid cell (which I don't want)
And if I take the alternative approach of trying to write the correct value directly to the worksheet, instead of allowing the exporter to do it using:
e.Workbook.WindowOptions.SelectedWorksheet.Rows(e.CurrentRowIndex).Cells(e.CurrentColumnIndex).Value = e.value.tostring.substring(0,8000)
then it leaves the grid cell as it was (tick) and exports the correct text to the worksheet (tick) but it does not apply any formatting to the worksheet cell and therefore this cell appears in an inconsistent format to the rest of the worksheet.
[I feel I've just rewritten my original post]
Hi Michael - trouble is there is no apparent way to do that.
If I don't do anything in the cell exporting event then an error is thrown about the 32KB limit because it tries to write the current grid value.
So I *have* to do something about the long grid cell value in the exporting event and not set it in the exported event.
And the only two options appear to be:
1. Temporarily set the cell to the smaller value that can be exported - works but is clumsy
2. Cancel the exporting event and write my own value - doesn't style the excel cell properly
Do you have more details about the "right approach" that you mention?
Hello,
I am following up to let you know that the CellExporting event should include an event arg called "ExportValue" to override the cell in Excel and not the grid value in your application. Despite this, I attached a sample which demonstrates to loop through the grid cells and write the formatted cell values to excel manually. You may find this as a cleaner work around currently. Let me know if you have any questions regarding this matter. I apologize for any confusion earlier as it wasn't clear to me exactly what the issues were for the requirements you need.
Sincerely,
Michael Di FilippoAssociate Software DeveloperInfragistics, Inc.www.infragistics.com/support
Hopefully CellExporting will include this event arg in the future.
Thanks for your mini-project but it is essentially rerolling the exporter and whilst it works in this simplistic case it won't work where the grid has been grouped by columns etc!
I will continue with my bodge as it's the simplest way of meeting the need and look forward to the new ExportValue in the future.
I have opened a private case for you so that I can link it to an internal development issue. This way you will be notified automatically when the dev issue is updated. The case number is CAS-165097-N5F9R6. You will see it shortly in your account located here: https://ko.infragistics.com/my-account/support-activity
Let me know if you have any questions regarding this matter.
All,
This issue has been addressed in service release versions WinForms_15.2.20152.2023, WinForms_15.1.20151.2203, 2016.1.