Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting into integer in excel using EPPlus (asp.net)

I am loading data into excel from datatable using LoadFromDataTable method then changed cell format to integer still it is showing error "The number in this cell is formatted as text or preceded by apostrophe".

cell was showing to right side only and number format only on cell property.

still I am not understanding 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

like image 863
James123 Avatar asked Nov 13 '22 03:11

James123


1 Answers

You can do like this:

//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;
like image 55
zhoufoxcn Avatar answered Dec 10 '22 14:12

zhoufoxcn