On Thu, 3 May 2012, liaobert wrote:
I'm currently reading in an excel file to create a new XSSFWorkbook.
When I'm done, I want to close the workbook and delete that excel file,
but it's not working. Here's what I have:
File vifList = new File("viflist.xlsx");
FileInputStream vifStream = new FileInputStream(vifList.getName());
XSSFWorkbook wb = new XSSFWorkbook(vifStream);
If you've got a file, don't create the XSSFWorkbook from a stream! With a
file we can do random access, with a stream we have to buffer the lot into
memory
You should be doing something like:
OPCPackage pkg = OPCPackage.open(path);
XSSFWorkbook wb = new XSSFWorkbook(pkg);
....
pkg.close()
After the package close call, you'll be able to delete the file without
issues
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]