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.
Syncfusion Feedback

Export from gridgroupingcontrol not exported as numeric

Thread ID:

Created:

Updated:

Platform:

Replies:

120233 Sep 12,2015 08:14 AM UTC Sep 18,2015 04:00 AM UTC Windows Forms 5
loading
Tags: GridGroupingControl
Rem Aza
Asked On September 12, 2015 08:14 AM UTC

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

Adhikesevan Kothandaraman [Syncfusion]
Replied On 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



Rem Aza
Replied On 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



Adhikesevan Kothandaraman [Syncfusion]
Replied On 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


Rem Aza
Replied On September 16, 2015 03:59 AM UTC

Hi Adhi

Same problem remains with this code

I use version 12.4.0.24




Adhikesevan Kothandaraman [Syncfusion]
Replied On 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.


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.

Warning Icon 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.Close Icon

;