以前我使用 POI 3.1.7 和 setCellFormula 没有任何问题。现在我已经迁移到 4.1.1 并注意到虽然单元格正确设置了公式,但它不显示任何值(例如,单元格设置为“会计”格式,单元格显示 =PRODUCT(I4*L4),在屏幕上它显示 $ - . 代码如下:
XSSFCell cell = null;
cell = row.createCell(12);
cell.setCellFormula("PRODUCT(I"+(processingRow+1)+",L"+(processingRow+1)+")");
cell.setCellStyle(getCellStyle("ACCOUNTING", sheet, true,true, false,false));
顺便说一句,我在 Excel 2013 上使用它(我认为这不会有任何影响?)。如果我要进入公式单元格并在公式末尾按 Enter,则该值只会按应有的方式显示。我错过了什么吗?