我正在尝试通过调用从 file.xlsx 创建 XSSFWorkbook:
1. XSSFWorkbookFactory.create(file) -> return HSSFWorkbook
2. WorkbookFactory.createXSSFWorkbook(file) -> While trying to invoke 'createWorkbook' on factory org.apache.poi.xssf.usermodel.XSSFWorkbookFactory and arguments [path to file.xlsx]
3. OPCPackage.open(file) -> The supplied data appears to be in the OLE2 Format. You are calling the part of POI that deals with OOXML (Office Open XML) Documents. You need to call a different part of POI to process this data (eg HSSF instead of XSSF)
XSSFWorkbook wb = new XSSFWorkbook(pkg);
4. XSSFWorkbookFactory.createWorkbook(new FileInputStream(file)) -> The supplied data appears to be in the OLE2 Format. You are calling the part of POI that deals with OOXML (Office Open XML) Documents. You need to call a different part of POI to process this data (eg HSSF instead of XSSF)
我需要以XSSFWorkbook的形式读取文件以读取图表并将新参数设置为图表。任何想法,为什么我会发现这个错误以及为什么从第 1 项返回HSSFWorkbook?
我检查了几次,该文件具有 .xlsx 扩展名。