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

Export from gridgroupingcontrol not exported as numeric

I am using gridgroupingcontrol to show data.
Then it is exported to excel 

I have not done any special formating to the gridgroupingcontrol columns
The grid shows all numeric values but when i export to excel the data is exported as string in excel

How can I fix this

5 Replies

AK Adhikesevan Kothandaraman Syncfusion Team September 14, 2015 12:49 PM UTC

Hi Remmie,

Thank you for contacting Syncfusion Support.


If you want to export the Numeric value to the excel, it can be achieved by setting the CellValueType of particular column. If the CellValueType is not specified for the columns, it takes the data on it’s as the general type or text. Therefore the numeric value is also treated like the string while exporting. if you want to display the exported value as Numeric, need to set the CellValueType in the GridGroupingControl or while creating the data source specify the Column value type as double (or) int.

If you are using whole table as the numeric value then you can set the CellValueType of the table as follows,
Code Snippet:

//Set the CellValue type for Grid
this.gridGroupingControl1.Appearance.AnyRecordFieldCell.CellValueType = typeof(double);

//Set the CellValueType for particular column which is want to be exported as Numeric
this.gridGroupingControl1.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.CellValueType = typeof(int);

KB Link:
http://www.syncfusion.com/kb/691/How-to-move-the-contents-of-GridGroupingControl-to-Excel

Sample:
http://www.syncfusion.com/downloads/support/forum/120233/ze/ExportToExcel1506606008

Regards,
Adhi




RA Rem Aza September 14, 2015 01:38 PM UTC

Thank you Adhi

it exports now as numeric when i made the column of type decimal.

However there is one minor issue -
decimal values like 1.00 is exported as 1  , 4.50 is exported as 4.5 
I mean it loses the decimal 0 in excel . in the grid it is showing fine only problem is in the excel

How can that be fixed




AK Adhikesevan Kothandaraman Syncfusion Team September 15, 2015 12:36 PM UTC

Hi Remmie,

Thanks for your update.

We were unable to reproduce the issue at our end. It might be caused by the use of different Converter for exporting. Instead, use the GroupingGridExcelConverterControl to export the columns with the decimal values. Please refer to the following code example,

Code Example:

private void button1_Click(object sender, EventArgs e)

{

    //Create Converter for exporting

    GroupingGridExcelConverterControl converter = new GroupingGridExcelConverterControl();

    SaveFileDialog saveFileDialog = new SaveFileDialog();

    saveFileDialog.Filter = "Files(*.xls)|*.xls";

    saveFileDialog.DefaultExt = ".xls";

    if (saveFileDialog.ShowDialog() == DialogResult.OK)

    {

        //Export the Grid to excel

        converter.GroupingGridToExcel(this.gridGroupingControl1, saveFileDialog.FileName, Syncfusion.GridExcelConverter.ConverterOptions.Default);

        if (MessageBox.Show("Do you wish to open the xls fnnile now?", "Export to Excel", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

        {

            Process proc = new Process();

            proc.StartInfo.FileName = saveFileDialog.FileName;

            proc.Start();

        }

    }       

}

Sample:
http://www.syncfusion.com/downloads/support/forum/120233/ze/ExportToExcel_(3)-1130548645

If you are still facing the same problem, please let me know your product version of Essential studio.

Regards,
Adhi



RA Rem Aza September 16, 2015 03:59 AM UTC

Hi Adhi

Same problem remains with this code

I use version 12.4.0.24





AK Adhikesevan Kothandaraman Syncfusion Team September 18, 2015 04:00 AM UTC

Hi Remmie,

Thanks for your update.

We have analyzed your reported scenario at our end. But we were unable to reproduce the issue. Please provide the detailed description of that issue, It will be more helpful for us to provide the prompt solution.


Regards,
Adhi.


Loader.
Live Chat Icon For mobile
Up arrow icon