0

I noticed that when a spreadsheet is created using POI, the default style set for comma style, as set when opening in Excel and clicking the button Comma Style, in Office 2007 onward, results in a format which includes the currency symbol (contrary to the definition of Comma Style in Excel).

This occurs without any format changing code in the source, so it seems to be built into POI and its effect is worksheet-wide.

By creating such a file and setting a cell to Comma Style from Excel and then doing a cell format (right click etc.), it appears to be a custom format, of the form

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

In a normal Excel file, the expected format would have been Accounting without the currency symbol.

Is there a way to change the default styles within POI in order to correct the behavior for Comma Style?

I am testing this with NPOI 1.2.5, the NET Framework port, which i suppose is full equivalent of Apache POI form which it is derived.

4

2 回答 2

1

我遇到了同样的问题,可以确认该问题已在 3.10 版本中修复

于 2014-07-14T08:19:52.210 回答
1

我遇到了一些困难,我找到了原因,我作为参考来回答。

我正在使用 NPOI 的最新稳定版本。这是1.2.5。

检查定义标准格式的源(在文件 BuiltinFormats.cs 中),我发现以下内容

PutFormat(m, 0x2b, "_(\"$\"* #,##0.00_);_(\"$\"* (#,##0.00);_(\"$\"* \"-\"??_);_(@_)");
PutFormat(m, 0x2c, "_(* #,##0.00_);_(* (#,##0.00);_(* \"-\"??_);_(@_)");

在包含标准格式列表的http://support.microsoft.com/kb/147942中,有两个有问题的条目是

0x2b      _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)
0x2c      _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)

NPOI 源中的这种反转似乎导致了逗号样式的无效行为。

于 2013-06-14T12:12:30.787 回答