How to change decimal format in EpPlus?

My Excel office is compatible in French (decimal separator = dot and thousands separator = space) I load a csv sheet with a decimal number in french format:

My code is:

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, which is a good XLSX file, but I have an error opening Excel because my decimal format is not recognized by my French version of Excel.

+6
source share
1 answer

I ran into a similar problem. Setting the format string to "#,##0.00" did the trick in my case.

+3
source

Source: https://habr.com/ru/post/987574/


All Articles