问题
Apache POI 4.x here. I see there are two types of Workbook
implementations:
- HSSF Workbook
- XSSF Workbook
I need to write a Java 8 app that reads Excel sheets with either ".xls
" (XLS) or ".xlsx
" (XLSX) extensions. Meaning, Excel files that were saved in the "old" (pre 2003) format, or the newer one.
Is it safe to assume I use HSSF for XLS files, and XSSF for XLSX files? Or is the mapping logic a little bit more complicated there? This answer seems to indicate I'm correct, but that doesn't leave me feeling totally sure that I understand the mapping and "when to use" logic of HSSF vs XSSF.
I've scoured the POI documentation but can't find a clear answer for the life of me.
回答1:
HSSF (org.apache.poi.hssf.usermodel
package) is for XLS files format
XSSF (org.apache.poi.xssf.usermodel
package) is for XLSX files format (newer one)
Model classes from both packages (xssf and hssf) implements common interfaces from org.apache.poi.ss.usermodel
package. So, you potentially can write a code using ss
package and it will work with abstractions over xssf or hssf.
来源:https://stackoverflow.com/questions/58883341/mapping-of-apache-poi-hssf-xssf-to-xls-xlsx