EPPlus 格式单元格为 "Accounting" 数字

EPPlus Format Cell as "Accounting" Number

在 Excel 中,您可以按以下格式格式化数字:

我想在 EPPlus 中使用这种格式格式化单元格,但我没有看到 属性 可用:

我看过 , , but none of them are the same. I also tried to set "BuildIn" 号码(它没有 setter,这没用)。我正在尝试使用系统格式,而不是使用我自己的自定义格式。 EPPlus 可以使用 "Accounting" 格式吗?

我不知道会计数字格式是什么样的,但是如果你想要数字后面的美元符号,你可以这样做。

ws.Cells["A1:A25"].Style.Numberformat.Format = "#,##0.00 $";

EPPlus 不包含 Excel 内置的数字格式,因此您必须手动设置。

Excel中的所有内置格式都有实际的数字格式。对于会计,格式为:

-$* #,##0.00-;-$* #,##0.00_-;-$* "-"??-;-@-

以上格式可能因您的 region/settings 而异。要查看任何内置格式的格式:

  1. 右键单击一个单元格并 select 格式化单元格

  2. 单击您的内置格式,在本例中为 会计

  3. 单击 自定义 查看之前 selected 的格式 格式

将格式应用于您的单元格:

ws.Cells["A1:A5"].Style.Numberformat.Format = "_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \"-\"??_-;_-@_-";

我在 Excel.

中使用此格式模拟与 "Accounting Number" 相同
ws.Cells["A1:A5"].Style.Numberformat.Format = "_($* #,##0.00_);_($* (#,##0.00);_($* \"-\"??_);_(@_)"