我需要将某些列的内容设置为会计格式。
这次尝试:
public static readonly string NUMBER_FORMAT_ACCOUNTING = "$";
. . .
bidPriceCell.Style.Numberformat.Format = NUMBER_FORMAT_ACCOUNTING;
...只需将“$”和“ - $”作为值。
这次尝试:
public static readonly string NUMBER_FORMAT_ACCOUNTING = "$0.00";
. . .
bidPriceCell.Style.Numberformat.Format = NUMBER_FORMAT_ACCOUNTING;
...给了我一些价值,例如“$ 24.09”和“ - $ 0.91”
用户想要的是美元符号和值之间的空格,以及负值周围的空白,例如“$ 24.09”和“$(0.91)”
我需要为Numberformat.Format属性分配什么字符串?
答案 0 :(得分:3)
找到Wildpinkler here的答案,即:
@"_(""$""* #,##0.00_);_(""$""* \(#,##0.00\);_(""$""* ""-""??_);_(@_)";
...以便以下工作:
public static readonly String NUMBER_FORMAT_ACCOUNTING = @"_(""$""* #,##0.00_);_(""$""* \(#,##0.00\);_(""$""* ""-""??_);_(@_)";
. . .
bidPriceCell.Style.Numberformat.Format = RoboReporterConstsAndUtils.NUMBER_FORMAT_ACCOUNTING;
答案 1 :(得分:0)
由于我需要欧元和西班牙语语言环境的货币格式(例如1.000.000,00€)。我必须:
styles.xml:
<numFmts count="2">
<numFmt numFmtId="44" formatCode="_-* #,##0.00\ "€"_-;\-* #,##0.00\ "€"_-;_-* "-"??\ "€"_-;_-@_-"/>
</numFmts>
因此,您可以使用以下格式:
sheet.Cells["A1"].Style.Numberformat.Format = @"_-* #,##0.00\ ""€""_-;\-* #,##0.00\ ""€""_-;_-* ""-""??\ ""€""_-;_-@_-";