的Apache POI:問題與Excel更新, 新的值寫入單元格後: java.lang.IllegalStateException:不能從字符串細胞的Apache POI:更新Excel文件
什麼可以得到一個數值是問題嗎?如何解決它?
我使用5個文件工作,其中3個工作正常,另外2個不工作。 針對2個錯誤文件的解決方法: Runtime.getRuntime()。exec(「cmd/c start」+ excel.getAbsolutePath());
// ---------------------------------------------------------------------------
// Here: new values are written into the cells
workbook.getCreationHelper().createFormulaEvaluator().evaluateAll();
workbook.setForceFormulaRecalculation(true);
OutputStream output = new FileOutputStream(excel.getAbsolutePath());
workbook.write(output);
output.flush();
output.close();
// Here, new values are subtracted from the cells,
after Excel resolves with new values
// ---------------------------------------------------------------------------
// Value in bad Cell: =B24
java.lang.IllegalStateException: Cannot get a NUMERIC value from a STRING cell
at org.apache.poi.xssf.usermodel.XSSFCell.typeMismatch(XSSFCell.java:1050)
at org.apache.poi.xssf.usermodel.XSSFCell.getNumericCellValue(XSSFCell.java:310)
at quicc.excel.api.ExcelHandlerXSSF.handleCell(ExcelHandlerXSSF.java:275)
at quicc.excel.api.ExcelHandlerXSSF.readCell(ExcelHandlerXSSF.java:251)
錯誤是相當清楚的。您在ExcelHandlerXSSF.java的第275行中的代碼使用了'XSSFCell.getNumericCellValue',但單元格不包含數字,而是包含一個字符串。所以看看你的'ExcelHandlerXSSF.java'。 –