This is a migrated thread and some comments may be shown as answers.

Exported Excel columns not same as on grid!

3 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Deasun
Top achievements
Rank 1
Deasun asked on 05 Sep 2018, 07:16 PM

Good evening,

I have a number of integer columns that show up fine in the grid but after exporting to excel they appear with .00 at the end of them.

How do I make the exported doc look the same as the grid?

Example:

On the winforms grid value in cell  = 330249, and on the excel cell = 330249.00.

 

Thanks.

Deasun

3 Answers, 1 is accepted

Sort by
0
Deasun
Top achievements
Rank 1
answered on 05 Sep 2018, 07:25 PM

Forgot to say:

Telerik.WinControls.Export.GridViewSpreadExport spreadExporter = new Telerik.WinControls.Export.GridViewSpreadExport(this.gridNoIDX);
Telerik.WinControls.Export.SpreadExportRenderer exportRenderer = new Telerik.WinControls.Export.SpreadExportRenderer();

spreadExporter.ExportVisualSettings = true;

spreadExporter.RunExport(strPathToMyDocuments + @"\" + strFileName + ".xlsx", exportRenderer);

is how I am doing it.

0
Accepted
Dimitar
Telerik team
answered on 06 Sep 2018, 10:05 AM
Hello Deasun,

You can set the format manually. There are two properties on each column for this. Here is the code:
var col = radGridView1.Columns[0] as GridViewDecimalColumn;
col.ExcelExportType = Telerik.WinControls.UI.Export.DisplayFormatType.Custom;
col.ExcelExportFormatString = "#,##0";

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Deasun
Top achievements
Rank 1
answered on 06 Sep 2018, 12:24 PM

Thanks.

went with: objGrid.Columns[intIDX].ExcelExportType = Telerik.WinControls.UI.Export.DisplayFormatType.None;

Have a function that loops thru the columns of the particular grid I send it. It checks the datatype and sets it to the correct export type.

Tags
GridView
Asked by
Deasun
Top achievements
Rank 1
Answers by
Deasun
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or