From f33843810a3730031259367e5c493230c87fc7ba Mon Sep 17 00:00:00 2001
From: Nick Burch Opening a XSSFWorkbook from a file has a lower memory footprint
+ * than opening from an InputStream
+ *
+ * @param file the file to open
+ */
+ public XSSFWorkbook(File file) throws IOException, InvalidFormatException {
+ this(OPCPackage.open(file));
+ }
+
/**
* Constructs a XSSFWorkbook object given a file name.
*
- *
- * This constructor is deprecated since POI-3.8 because it does not close
- * the underlying .zip file stream. In short, there are two ways to open a OPC package:
- *
- * It should be noted, that (2) uses quite a bit more memory than (1), which
- * doesn't need to hold the whole zip file in memory, and can take advantage
- * of native methods.
- *
- * To construct a workbook from file use the
- * {@link #XSSFWorkbook(org.apache.poi.openxml4j.opc.OPCPackage)} constructor:
- *
- *
- *
- *
- * OPCPackage pkg = OPCPackage.open(path);
- * XSSFWorkbook wb = new XSSFWorkbook(pkg);
- * // work with the wb object
- * ......
- * pkg.close(); // gracefully closes the underlying zip file
- *
Once you have finished working with the Workbook, you should close + * the package by calling {@link #close()}, to avoid leaving file + * handles open. + * + *
Opening a XSSFWorkbook from a file has a lower memory footprint + * than opening from an InputStream * - * @param path the file name. - * @deprecated + * @param path the file name. */ - @Deprecated public XSSFWorkbook(String path) throws IOException { this(openPackage(path)); }