Greetings,
I'm exporting data from a WebGrid to Excel via UltraWebGridExcelExporter. Some cells are strings and others are numbers. Does anyone have code examples of how to get UltraWebGridExcelExporter to properly export numeric values as actual Integer/Double Excel cells?
In other words, right now I'm getting the software to export an Excel spreadsheet but every cell is a String format. I must manually modify cells into Double format.
Thanks!
Hi Dimi,
In the ExportToExcel.Click override method, I set the WebGrid.Column(##).DataType = "System.Integer". This seemed to do the trick. It also works for System.Double.
Thank you for your help. It's great to see that Infragistics has such quick customer support. Cheers! =)
Hi,
During the exporting process you can assign the formatting in to the RowExporting or CellExported event and on the desired cell set the correct formatting.
You can do it also after but if you do it before this will not work. This approach is described here:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0?page=WebGridExcelExporter_Transposing_Rows_and_Columns_using_WebGrid_Excel_Exporter.html
Please let me know if this solve your issue.
Hello Dimi,
Thank you very much for following up with me. I'm still not able to solve this issue.
I applied the following formatting to each cell:
worksheet.Rows.Item(row).Cells.Item(col).CellFormat.FormatString = "#,##0.00"
When I open the exported Excel workbook, each of the cells are still formatted as text, not numbers. People that use these exported Excel workbooks must do something like the following: http://office.microsoft.com/en-us/excel-help/convert-numbers-stored-as-text-to-numbers-HP003055900.aspx
We're using Infragistics version 8.3 (2008), Excel 2003.
Thanks in advance!
Hi Al,
I am just checking if you got the exporter working or you have any furthered questions.
I think you can find the answer here: http://ko.infragistics.com/community/forums/p/77670/392201.aspx
In general you should set the CellFormat FormatString of the desired columns or cells to something like this "worksheet.Rows[4].Cells[0].CellFormat.FormatString = “#,##0.00"
worksheet.Rows[4].Cells[0].CellFormat.FormatString = “
More about the excel exporting process: http://help.infragistics.com/Help/NetAdvantage/ASPNET/2011.1/CLR4.0/html/WebGridExcelExporter_Export_Data_to_Excel.html and the exporting can be read here: http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0?page=WebGridExcelExporter_Transposing_Rows_and_Columns_using_WebGrid_Excel_Exporter.html
Let me know if you have any furthered questions.