Which version of POI? Can you post the stack trace? Is the file opened
by Excel while the Java program is running?
The following code works fine with current trunk:
String masterPath = "D:\\temp\\original.xlsx";
XSSFWorkbook wb = new XSSFWorkbook(masterPath);
wb.getSheetAt(0).getRow(0).getCell(0).setCellValue("xxx");
FileOutputStream out = new FileOutputStream(masterPath);
wb.write(out);
out.close();
Yegor
Sorry. I missed a line in the code. The last 2 lines are:
FileOutputStream out = new FileOutputStream(masterPath);
wb.write(out); //Fails because the file is locked.
I am trying to read an excel 2007 document, modify it, and write it back
out to the same file. When I instantiate XSSFWorkbook, the operating
system (windows XP) will not allow me to change the file until the java
program closes. I've tried everything I can think of to get the file to
release. The lock even exists long after my XSSFWorkbook object is out
of scope.
What I am trying to do is simple.
String masterpath = "some valid path on my C drive";
XSSFWorkbook wb = new XSSFWorkbook(masterPath);
--change a few cell values
wb.write(out); //Fails because the file is locked.
Any ideas?
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]