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.
Unfortunately, activation email could not send to your email. Please try again.

String/Number format problem when exporting data using GridToExcel

Thread ID:

Created:

Updated:

Platform:

Replies:

88501 Jul 27,2009 11:36 AM Jul 31,2009 09:46 AM Windows Forms 1
loading
Tags: GridControl
Mia Cheng
Asked On July 27, 2009 11:36 AM

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.

Rajadurai C [Syncfusion]
Replied On July 31, 2009 09:46 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;