aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
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-ooxml
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-ooxml')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java3
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java16
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java2
3 files changed, 19 insertions, 2 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java
index bf730e79d1..85f04f7bd8 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFBReader.java
@@ -107,9 +107,10 @@ public class XSSFBReader extends XSSFReader {
* @return iterator of {@link InputStream}s
* @throws InvalidFormatException if the sheet data format is invalid
* @throws IOException if there is an I/O issue reading the data
+ * @since POI 5.3.1
*/
@Override
- public Iterator<InputStream> getSheetsData() throws IOException, InvalidFormatException {
+ public SheetIterator getSheetIterator() throws IOException, InvalidFormatException {
return new SheetIterator(workbookPart);
}
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java
index 8bd52bb9e8..bb656b281d 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java
@@ -265,8 +265,24 @@ public class XSSFReader {
*
* @throws InvalidFormatException if the sheet data format is invalid
* @throws IOException if there is an I/O issue reading the data
+ * @see #getSheetIterator()
*/
public Iterator<InputStream> getSheetsData() throws IOException, InvalidFormatException {
+ return getSheetIterator();
+ }
+
+ /**
+ * Returns an Iterator which will let you get at all the
+ * different Sheets in turn.
+ * Each sheet's InputStream is only opened when fetched
+ * from the Iterator. It's up to you to close the
+ * InputStreams when done with each one.
+ *
+ * @throws InvalidFormatException if the sheet data format is invalid
+ * @throws IOException if there is an I/O issue reading the data
+ * @since POI 5.3.1
+ */
+ public SheetIterator getSheetIterator() throws IOException, InvalidFormatException {
return new SheetIterator(workbookPart);
}
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
index cec4181569..872c6cd374 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
@@ -156,7 +156,7 @@ public final class TestXSSFReader {
XSSFReader r = new XSSFReader(pkg);
String[] sheetNames = {"Sheet4", "Sheet2", "Sheet3", "Sheet1"};
- XSSFReader.SheetIterator it = (XSSFReader.SheetIterator) r.getSheetsData();
+ XSSFReader.SheetIterator it = r.getSheetIterator();
int count = 0;
while (it.hasNext()) {