aboutsummaryrefslogtreecommitdiffstats
path: root/poi-examples
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2024-10-26 15:22:52 +0000
committerPJ Fanning <fanningpj@apache.org>2024-10-26 15:22:52 +0000
commitc9c8653e6efa0ad86ad53c6dd511d552a5dc1296 (patch)
treea81e0f827d82292ad8030089c42a410616158f7d /poi-examples
parenta528d43590b3f71aa94310de881a35af887fdd0f (diff)
downloadpoi-c9c8653e6efa0ad86ad53c6dd511d552a5dc1296.tar.gz
poi-c9c8653e6efa0ad86ad53c6dd511d552a5dc1296.zip
[bug-69411] add XSSFReader.getSheetIterator
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1921571 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-examples')
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java
index 25c900965a..55cd2c552f 100644
--- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java
+++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java
@@ -20,12 +20,12 @@
package org.apache.poi.examples.xssf.eventusermodel;
import java.io.InputStream;
+import java.util.Iterator;
import org.apache.poi.examples.xssf.usermodel.LoadPasswordProtectedXlsx;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.poifs.crypt.temp.AesZipFileZipEntrySource;
import org.apache.poi.xssf.eventusermodel.XSSFReader;
-import org.apache.poi.xssf.eventusermodel.XSSFReader.SheetIterator;
/**
* An example that loads a password protected workbook and counts the sheets.
@@ -48,11 +48,12 @@ public final class LoadPasswordProtectedXlsxStreaming {
try (AesZipFileZipEntrySource source = AesZipFileZipEntrySource.createZipEntrySource(inputStream);
OPCPackage pkg = OPCPackage.open(source)) {
XSSFReader reader = new XSSFReader(pkg);
- SheetIterator iter = (SheetIterator)reader.getSheetsData();
+ Iterator<InputStream> iter = reader.getSheetsData();
int count = 0;
while(iter.hasNext()) {
- iter.next();
- count++;
+ try (InputStream stream = iter.next()) {
+ count++;
+ }
}
System.out.println("sheet count: " + count);
}