I was wondering if the latest version allows the programmer to format cells and/or columns in other numeric formats other than general? I'm currently using the latest 2008 version I notice it does not. Any help would appreciated.
Thanks,
Patrick
Hi Patrick,
I'm pretty sure that the Infragistics.Excel assembly supports setting the format on a cell to any format that Excel can support, and always has.
Are you exporting a grid? Or writing to an Excel file yourself? Have you tried setting the Format property on the cell?
First, your response of "I'm pretty sure" indicates you don't know for certain. Not ver reassuring
Second, I am exporting a grid to an Excel spreadsheet and I have not found any example with the 2008 and/or 2009 samples of the API reference. As a matter of fact I find the same example for setting the "Cellformat" in many locations wihing your Online help. But, nothing on setting the cell format to a numeric value
When a grid is exported (you can read what data type the grid is passing into the cell) i've noticed that all spreadsheet cells are of "general" Number type, even though the grid may be an integer, a decimal, double, etc..
Third, if you have a link to an example, please include it with your response. Thanks Mike.
The reason I said "I'm pretty sure" is that I didn't want to give you a definitive answer without knowing exactly what the question was. :)
If you are using the UltraGridExcelExporter, then this is very easy. What you do is handle the InitializeColumn event of the exporter component. This event is specifically designer to help you copy numeric formats from the grid to Excel.
The tricky thing is that DotNet numeric format strings and Excel format strings are not always exactly the same. So this event will fire and give you the format you have applied to the grid column and then it allows you to set a form in the Excel column. This gives you the change to translate the DotNet format into the equivalent Excel format.
In fact, most of the time, you can just set one to the other.
private void ultraGridExcelExporter1_InitializeColumn(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.InitializeColumnEventArgs e) { e.ExcelFormatStr = e.FrameworkFormatStr; }