I am currently working on trying to figure out why Custom formatting gets lost when exporting to excel. We use the following formatting:
aBand.Columns[OrderKeys.ContractValue].Format = "C";aBand.Columns[OrderKeys.CancelDate].Format = "MM/dd/yyyy";
When we export to excel we don't get those columns in the date format or currency format. They are exported with the General Format in excel. The user has to manually change the column in excel to the expected cell format. Has anyone run into this problem before? Can it be fixed in code before I export?
thanks -Ken
Thanks mike....Actually the latest update to my controls fixed the Date formatting issue in the excel files. It was a bug that was reported some time ago and a hotfix was introduced for 7.2 and 7.3.
I upgraded from 7.2 to 8.1 yesterday and dates were fixed without any addition code. The currency issue wasn't fixed though, so I had to handle how you suggested. I do the following and it worked fine:
void OnInitializeColumnDataExcelExporter(object sender, InitializeColumnEventArgs e) { if(e.Column.Format == "C") { e.ExcelFormatStr = "$#,##0.00;($#,##0.00);-"; } }
Thanks again!
Hi Ken,
The UltraGridExcelExporter can't reasonably convert DotNet numeric formats into Excel formats. So it's left to you to handle this. All you have to do is handle the InitializeColumn event and translate the format of the column into the appropriate format for Excel on the event args.