Convert to integer in excel using EPPlus (asp.net)

I load data into excel from a datatable using a method LoadFromDataTable, and then change the cell format to an integer until it shows an error . The number in this cell is formatted as text or precedes an apostrophe .

Cell

showed only the right side and number format only for the cell property.

Still I don’t understand why I am getting this error ??.

Dim wsManufacturing As ExcelWorksheet = pck.Workbook.Worksheets.Add("Manufacturing")
wsManufacturing.Cells("A1").LoadFromDataTable(dtManufacturing, True)
 Using col As ExcelRange = wsManufacturing.Cells(2, 2, 2 + dtManufacturing.Rows.Count, 2)
    col.Style.Numberformat.Format = "#,##0"
    col.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right
 End Using

enter image description here

+5
source share
2 answers

You can do the following:

//strValue="98.5%";
double realValue=double.Parse(strValue.Replace("%", string.Empty));
Worksheet.Cells[row + 1, col].Style.Numberformat.Format = "#0\\.00%";
Worksheet.Cells[row + 1, col].Value = realValue;
+2
source

Changing the format from text to number does not change the nature of the record that was in the cell before changing the format.

,

  • Number
  • 1
  • Edit/Copy
  • ()
  • /
  • 1
-1

All Articles