Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有带小数的金额(300.11 和 9801.98),我将它们导出 Excel,一切都很好。
但有时我的金额带有尾随零,我想在导出时保留这些零?例如,当导出到 Excel 时,300.00 变为 300。我怎样才能解决这个问题?
这是导出发生之前的代码。
AmountCCC 是 double 类型。
row.Amount = row.AmountCCC.ToString(CultureInfo.InvariantCulture);
在屏幕截图中查看记录是如何导出的。
您可以使用N2
N2
row.AmountCCC.ToString("N2", CultureInfo.InvariantCulture);
数字 ("N") 格式说明符