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
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.
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
My code is as following:
Dim columnPeople As New GridViewDecimalColumn("People", "People")
columnPeople.DecimalPlaces = 0
columnPeople.ExcelExportType = Telerik.WinControls.UI.Export.DisplayFormatType.Custom
columnPeople.ExcelExportFormatString = "#,##0"
columnPeople.MinWidth = 50
columnPeople.Minimum = 0
columnPeople.HeaderText = translate(language, "T_passenger", "PAX")
columnPeople.Name = "People"
columnPeople.ReadOnly = True
columnPeople.AllowFiltering = False
columnPeople.TextAlignment = ContentAlignment.MiddleRight
If hiddenColumnsWithExtras.Contains(columnPeople.Name) Then
columnPeople.IsVisible = False
End If
But the solution doesn't seem to work. I still get something like 242,00 for example, in my excel export. Is there something that should be done differently in VB .NET?
Hello, George,
Thank you for sharing your code snippet.
Generally, there are no differences in the properties or methods used in C# and VB. The main difference lies in the syntax. Code that works in C# should also work in VB, as both languages use the same underlying .NET libraries.
I noticed that you also set columnPeople.DecimalPlaces property. Can you please remove it and test how it works then?
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.
