My office Excel is confirate in French Format (separator decimal = Point and separator thousand = space ) i load a sheet with csv file with french format decimal number :
My code:
var range = sheet.Cells["A3"].LoadFromText(new FileInfo(fileCSVFull), format, TableStyles.Medium27, true);
var numStyle = package.Workbook.Styles.CreateNamedStyle("TableNumber");
numStyle.Style.Numberformat.Format = "# ##0,00";
var tbl = sheet.Tables[0];
tbl.ShowTotal = true;
tbl.Columns[0].TotalsRowLabel = "Total";
tbl.Columns[1].TotalsRowFunction = RowFunctions.Sum;
tbl.Columns[1].DataCellStyleName = "TableNumber";
tbl.Columns[2].TotalsRowFunction = RowFunctions.Sum;
tbl.Columns[2].DataCellStyleName = "TableNumber";
tbl.Columns[3].TotalsRowFunction = RowFunctions.Sum;
tbl.Columns[3].DataCellStyleName = "TableNumber";
string numcell = "E4:E"+(3 + nbline);
sheet.Cells[numcell].Formula = "B4*C4";
sheet.Cells[numcell].StyleName = "TableNumber";
sheet.View.ShowGridLines = false;
sheet.Calculate();
sheet.Cells[sheet.Dimension.Address].AutoFitColumns();
But i have an exception on "sheet.Calculate();" What if I change the format of my decimal number that's good my XLSX file is generated but I have an error when I open Excel as my decimal format is not recognized by my French version of Excel.
I faced the similar issue. Setting format string to "#,##0.00"
did the trick in my case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With