poi IFERROR的使用记录
使用poi导出excel使用了iferror,但是导出的excel中显示iferror公式处为#NAME?,双击编辑后公式生效
百度查找使用 sheet.setForceFormulaRecalculation(true); 但是并未生效
百般查找后终于找到了根源问题
Apache poi's HSSF produces *.xls files in binary BIFF format of Excel 97 - 2003. But the IFERROR function was introduced in Excel 2007. So HSSF cannot store IFERROR function properly. Only XSSF is able to do so since XSSF produces *.xlsx files in Office Open XML format of Excel 2007
项目使用了HSSF导出excel,HSSF支持的excel版本是03之前的,而iferror函数是07版本才有的,所以HSSF并不支持该函数。
要解决该问题,要么换成XSSF导出excel,要么就使用if手动判断而不是使用iferror