According to the Apache POI Quick Guide, the POIFSFileSystem
(or similarly, NPOIFSFileSystem
) is only used with .xls (Excel versions through 2003) documents.
The equivalent for .xlsx documents (Excel 2007+) is OPCPackage
.
OPCPackage pkg = OPCPackage.open(new File("file.xlsx"));
You can create an XSSFWorkbook
from the OPCPackage
:
XSSFWorkbook wb = new XSSFWorkbook(pkg);
Or you can just create it directly:
XSSFWorkbook wb = new XSSFWorkbook(new File("file.xlsx"));
Generally it’s better to create the workbook using a File
instead of an InputStream
, to save memory.
Also, if you want code that doesn’t care whether it’s an .xls or an .xlsx:
// or "file.xlsx"
Workbook wb = WorkbookFactory.create(new File("MyExcel.xls"));