Bug 59678 - Write to a closed workbook
Summary: Write to a closed workbook
Status: RESOLVED DUPLICATE of bug 59634
Alias: None
Product: POI
Classification: Unclassified
Component: SS Common (show other bugs)
Version: 3.15-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on: 59634
  Show dependency tree
Reported: 2016-06-09 09:03 UTC by Jürgens
Modified: 2016-06-09 09:40 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Jürgens 2016-06-09 09:03:42 UTC
This code fragment raises an

import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

File file = new File(...);
Workbook workbook = WorkbookFactory.create(file, "", false);
File outfile = new File(...);
FileOutputStream outputStream = new FileOutputStream(outfile);
// exception in following line
Comment 1 Dominik Stadler 2016-06-09 09:40:07 UTC
I think this is more or less a duplicate of Bug 59634 where we discuss the exact contract of the close(). The discussion there currently tends to state "do not use the Workbook after closing" which is consistent with many other Java classes that implement the Closeable interface.

So you can easily fix this by deferring the close() call to after the Workbook is written out.

Bug 59634 might also adjust the code to provide a more meaningful error message.

*** This bug has been marked as a duplicate of bug 59634 ***