We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

String/Number format problem when exporting data using GridToExcel

Hello,

I have a test.xls with
Cell("A1") = 10
Cell("A2") = 20
Cell("A3") is a formula = AVERAGE("A1","A2")
In MS EXCEL, Cell("A3") = 15 of course

when I use ExcelToGrid to import the excel
and edit the "A1" cell to be any number like 2
and use GridToExcel to save the grid content back to orig excel worksheet, Cell("A3") would become "Devided by zero".
And all three cell has some error, I have to using "Convert to Number" to correct it and get correct value.

Is it the conversion of cell format affect the result?
Or how should I do to get a correct xls back after I save from grid?

Thanks in advance.

1 Reply

RC Rajadurai C Syncfusion Team July 31, 2009 01:46 PM UTC

Hi Mia,

Thanks for your interest in Syncfusion Products.

While exporting the grid values to excel sheet, all get exported as string type by default. If you would like to export the values with the type it holds in the excel sheet, please try to handle the QueryImportExportCellInfo event with the following code.

void gecc_QueryImportExportCellInfo(object sender, Syncfusion.GridExcelConverter.GridImportExportCellInfoEventArgs e)
{
if (e.Action == Syncfusion.GridExcelConverter.GridConverterAction.Export)
{
e.ExcelCell.Value = e.GridCell.Text;
e.Handled = true;
}
}

Here is a sample for your reference.
http://files.syncfusion.com/support/samples/Grid.Windows/7.3.0.20/F88501.zip

Regards,
Rajadurai

Loader.
Live Chat Icon For mobile
Up arrow icon