Reputation: 23
I am creating a new xlsx file and trying to open it with apache-poi
File file = new File("file.xlsx");
XSSFWorkbook wb=new XSSFWorkbook(file);
Yet I am getting the following error when trying to execute
org.apache.poi.openxml4j.exceptions.InvalidOperationException: Can't open the specified file: 'file.xlsx'
Upvotes: 0
Views: 1200
Reputation: 2110
org.apache.poi.openxml4j.exceptions.InvalidOperationException: Can't open the specified file: 'file.xlsx'
Maybe you should use the full path to your file inside your filesystem, because it could not find it, or your user has not the permissions to open a file in the current execution filepath, etc.
You can look at the according section in the Apache POI Busy Developers' Guide :
XSSFWorkbook wb = WorkbookFactory.create(new File("MyExcel.xlsx"));
AND do you open it with code-like below?
// XSSFWorkbook, File
OPCPackage pkg = OPCPackage.open(new File("file.xlsx"));
XSSFWorkbook wb = new XSSFWorkbook(pkg);
....
pkg.close();
Upvotes: 1