Bug 59358

Summary: save xlsx is not possible
Product: POI Reporter: Ivan Horvath <ivan.horvath>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P2    
Version: 3.14-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: netbeans project and sample xlsx

Description Ivan Horvath 2016-04-20 12:03:43 UTC
Hi,

i need to make some change on an existing xlsx file, and save it with a new name.
tried to follow the examples, but didn't work with my solution

test2.xlsx is the existing file, i would like to open..modify..save to a new name
netbeans project is attached too

thanks in advance for your help!
Ivan
Comment 1 Ivan Horvath 2016-04-20 12:06:56 UTC
Created attachment 33781 [details]
netbeans project and sample xlsx
Comment 2 Dominik Stadler 2016-05-17 19:32:03 UTC
This is likely due to the fact that you close the OPCPackage while the Workbook is still accessed, you should rather use the constructor of XSSFWorkbook which receives a filename instead to keep resources open until the workbook is closed at the end.

    try (OPCPackage pkg = OPCPackage.open(new File(filename))) {
      _WB = new XSSFWorkbook(pkg);
    }

If that does not solve the problem, then please reopen this bug with a more reduced test-case that shows your problem with as little code as possible.