diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index 0c40d26fb1..a9ec08adaa 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -19,6 +19,7 @@ package org.apache.poi.xssf.usermodel; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -172,9 +173,15 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, IterablePackage object, - * see www.openxml4j.org. + * see http://poi.apache.org/oxml4j/. + * + * Once you have finished working with the Workbook, you should close the package + * by calling pkg.close, to avoid leaving file handles open. + * + * Creating a XSSFWorkbook from a file-backed OPC Package has a lower memory + * footprint than an InputStream backed one. * - * @param pkg the OpenXML4J Package object. + * @param pkg the OpenXML4J OPC Package object. */ public XSSFWorkbook(OPCPackage pkg) throws IOException { super(pkg); @@ -183,6 +190,20 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable + * OPCPackage pkg = OPCPackage.open(path); + * XSSFWorkbook wb = new XSSFWorkbook(pkg); + * // work with the wb object + * ...... + * pkg.close(); // gracefully closes the underlying zip file + * + */ public XSSFWorkbook(InputStream is) throws IOException { super(PackageHelper.open(is));