The error message suggests that the data you are trying to process is in the OLE2 format, which is the binary file format used by older versions of Microsoft Office. However, you are currently using POI's OOXML module, which is designed to handle the newer Office Open XML format.

To resolve this issue, you need to switch to using a different part of POI that can handle the OLE2 format. In this case, you should use the HSSF module instead of XSSF.

Here's an example of how you can modify your code to use HSSF:

// Import the necessary POI classes for HSSF
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;

// Create a new HSSFWorkbook object to work with the OLE2 data
HSSFWorkbook workbook = new HSSFWorkbook(inputStream);

// Get the first sheet from the workbook
HSSFSheet sheet = workbook.getSheetAt(0);

// Iterate over the rows and cells of the sheet
for (Row row : sheet) {
    for (Cell cell : row) {
        // Process each cell as needed
        // ...
    }
}

// Don't forget to close the workbook and input stream when you're done
workbook.close();
inputStream.close();

By using the HSSF classes, you can process the OLE2 data successfully

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

原文地址: http://www.cveoy.top/t/topic/hRmA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录