来自公式的 EPPlus 格式化值
EPPlus formatting value from formula
我有一个使用 EPPlus 生成的 Excel 电子表格。最后一列使用公式包含整行的总计。
ws.Cells[rowIndex, colIndex].Formula = formulaString.ToString().Substring(0, formulaString.Length - 1);
我在赋值公式后使用Calculate()方法:
ws.Cells[rowIndex, colIndex].Calculate();
然后使用它来格式化单元格:
ws.Cells[rowIndex, colIndex].Style.Numberformat.Format = "### ### ### ###";
公式是正确的,但是当我设置单元格样式时,如果单元格的值为 0,它只会变成空白。如果单元格的值大于 0,则它的样式完美。
有人遇到过这个问题吗?
这几乎就是它应该做的。 #
基本上意味着它是一个可选数字,没有显示它不存在或 0。这是一个 excel 的东西,而不是真正的 epplus。
我想你想要的是
ws.Cells[rowIndex, colIndex].Style.Numberformat.Format = "### ### ### ##0";
我有一个使用 EPPlus 生成的 Excel 电子表格。最后一列使用公式包含整行的总计。
ws.Cells[rowIndex, colIndex].Formula = formulaString.ToString().Substring(0, formulaString.Length - 1);
我在赋值公式后使用Calculate()方法:
ws.Cells[rowIndex, colIndex].Calculate();
然后使用它来格式化单元格:
ws.Cells[rowIndex, colIndex].Style.Numberformat.Format = "### ### ### ###";
公式是正确的,但是当我设置单元格样式时,如果单元格的值为 0,它只会变成空白。如果单元格的值大于 0,则它的样式完美。
有人遇到过这个问题吗?
这几乎就是它应该做的。 #
基本上意味着它是一个可选数字,没有显示它不存在或 0。这是一个 excel 的东西,而不是真正的 epplus。
我想你想要的是
ws.Cells[rowIndex, colIndex].Style.Numberformat.Format = "### ### ### ##0";