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

GridView.ExportToWorkbook set numeric format to cell

1 Answer 23 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vladimir
Top achievements
Rank 1
Vladimir asked on 16 Jul 2018, 09:22 AM

Hi,

Following your documentation (number-formats) I'm trying to set a "# ##0" format to a cell to get a result like in the attached file 'Screenshot No1.png': 

1.CellSelection cell = worksheet.Cells[rowIndex, columnIndex];
2.ICellValue value = cell.GetValue().Value;
3.if (value.ValueType == CellValueType.Number)
4.{
5.    cell.SetFormat(new CellValueFormat("# ##0"));
6. }

 

But I get escaped space format "#\ ##0" in the resultant excel, like in the attached file "Screenshot No2.png"

How to get the exact result "# ##0" in the exported Excel file ?

 

Thanks

1 Answer, 1 is accepted

Sort by
0
Vladimir
Top achievements
Rank 1
answered on 16 Jul 2018, 09:41 AM
Looks like the code below solves my issue
cell.SetFormat(new CellValueFormat("#\u00a0##0"));
Tags
GridView
Asked by
Vladimir
Top achievements
Rank 1
Answers by
Vladimir
Top achievements
Rank 1
Share this question
or