我的office Excel以法语格式确认(分隔符decimal = Point,分隔符thousand = space)我加载了一个带有CSV文件的表格,该文件带有法国格式的十进制数字:
我代码: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();
但是我有一个异常在"sheet.Calculate();"如果我改变十进制数的格式那很好,我的XLSX文件生成了但是当我打开Excel时出现了一个错误,因为我的十进制格式不被我的法语版本的Excel识别
我也遇到过类似的问题。在我的例子中,将格式字符串设置为"#,##0.00"
就成功了。