We have an Infragistics grid with dates formatted 2 different ways. + For US we have 2011-04-26 2:30 PM + For UK we have 26-04-2011 7:30 PM (adjusted for timezones)
Everything works great, except when you export to Excel a UK formatted date the 7:30 turns into "19:30" in excel (a 24 hour format). Our users are not use to seeing this time format. It is strange that the US formatted dates export perfectly, meaning it retains the "2:20 PM" formatting.
We are using Infragistics3.Excel.v10.1and Infragistics2.Win.UltraWinGrid.v10.1.We do not have control over what company approved Infragistics version we use. We can just upgrade until a new version is approved for the compnay.
Does anyone know how to fix this? It seems like a small bug that could have easily gone unnoticed.
Thanks.
I found the problem (or turns out not to be a problem)
The UltraGridExelExport(grid, worksheet) uses the CurrentCulture of the thread for formatting dates. I just need to change my settings in the Control Panel for 'en-BG'.
Thanks! False alarm. :)
Thanks!! I will investigate the UltraGridExcelExporter's CellExported event.
Well, not I am not so sure about the isl file. I don't know how the formatting is being applied in Excel. I do not see anything of our code doing it. :/
Anomoly said:I am not doing anything to change the Excel format. Apparently a grid using AppStyling = true when the application loads Office2007Blue.isl automatically keeps the formatting from the grid when exported. Office2007Blue.isl was downloaded from your site or bundled in your samples. It was not one we created. I removed the isl file from the project and the format no longer exported over to Excel.
That's puzzling. I don't see how the isl could possibly affect the format of the exported data in any way.
The UltraGridExcelExporter does not export any formatting. It cannot, because Excel Formats are not the same as DotNet format and there's no way to translate from one to the other. So the only way values in the exported Excel sheet will get formatted is if you set the format in the InitializeColumn event or if you set it in some other event of the export process.
Anyway, the easiest thing for you to do is trap the UltraGridExcelExporter's CellExported event. You can examine the cell in which the date was exported and apply whatever value or formatting you want.
Hi Mike, thanks for the reply.
I am not doing anything to change the Excel format. Apparently a grid using AppStyling = true when the application loads Office2007Blue.isl automatically keeps the formatting from the grid when exported. Office2007Blue.isl was downloaded from your site or bundled in your samples. It was not one we created. I removed the isl file from the project and the format no longer exported over to Excel.
To add formatting to the grid I use: UltraGrid.DisplayLayout.Bands[0].Columns[0].Format = "...";It is just odd that dates formatted in for US worked, but UK does not. I see no ryme or reason. :(