为什么csv文件中小于千的值在excel中不能显示小数点后2位,而在notepad++中却能显示?

Why the value in csv file which less than thousand could not display 2 decimal places in excel but display in notepad++?

csv 文件由 java 程序生成。我打开notepad++的文件,如上图所示,数值保留2位小数。但是当我打开 excel 中的文件时,一些小于千的值不是 2 位小数格式。 为什么会这样?

代码就像。

        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
    symbols.setDecimalSeparator('.');
    DecimalFormat formatter = new DecimalFormat("#,###.00", symbols);

    fileWriter.append(String.valueOf(detailsContent.getAppliedAmount() == null ? "" : "\"" + formatter.format(new BigDecimal(detailsContent.getAppliedAmount()).setScale(2, BigDecimal.ROUND_DOWN)) + "\""));
    fileWriter.append(String.valueOf(detailsContent.getAmountSaving() == null ? "" : "\"" + formatter.format(new BigDecimal(detailsContent.getAmountSaving()).setScale(2, BigDecimal.ROUND_DOWN)) + "\""));

对于大于 1000 的数字,Excel 发现 CSV 中的字符串使用千位分隔符,因此它对单元格应用数字格式。它从文本中获取提示,即千位分隔符和两位小数。如果源中没有千位分隔符,Excel 将应用通用格式。

对于较小的数字,Excel 应用通用格式,该格式将省略零作为小数。源文件有两位小数这一事实不足以触发 Excel 应用特定的数字格式。