Class XSSFReader.SheetIterator

java.lang.Object
org.apache.poi.xssf.eventusermodel.XSSFReader.SheetIterator
All Implemented Interfaces:
Iterator<InputStream>
Direct Known Subclasses:
XSSFBReader.SheetIterator
Enclosing class:
XSSFReader

public static class XSSFReader.SheetIterator extends Object implements Iterator<InputStream>
Iterator over sheet data.
  • Field Details

    • sheetMap

      protected final Map<String,PackagePart> sheetMap
      Maps relId and the corresponding PackagePart
    • xssfSheetRef

      protected XSSFReader.XSSFSheetRef xssfSheetRef
      Current sheet reference
    • sheetIterator

      protected final Iterator<XSSFReader.XSSFSheetRef> sheetIterator
      Iterator over CTSheet objects, returns sheets in logical order. We can't rely on the Ooxml4J's relationship iterator because it returns objects in physical order, i.e. as they are stored in the underlying package
  • Constructor Details

  • Method Details

    • getSheetRefs

      public List<XSSFReader.XSSFSheetRef> getSheetRefs()
      Returns all the sheet references, in logical order, regardless of the position of this iterator. Use with getSheetPart(XSSFSheetRef) for random access to the sheets.
      Returns:
      unmodifiable list of the sheet references
      Since:
      6.0.0
    • getSheetPart

      public PackagePart getSheetPart(XSSFReader.XSSFSheetRef sheetRef)
      Returns the package part for a sheet, regardless of the position of this iterator.
      Parameters:
      sheetRef - one of the sheet references returned by getSheetRefs()
      Returns:
      the package part holding the sheet data, or null if it is missing
      Since:
      6.0.0
    • createSheetIteratorFromWB

      protected Iterator<XSSFReader.XSSFSheetRef> createSheetIteratorFromWB(PackagePart wb) throws IOException
      Throws:
      IOException
    • getSheetRelationships

      protected Set<String> getSheetRelationships()
      Gets string representations of relationships that are sheet-like. Added to allow subclassing by XSSFBReader. This is used to decide what relationships to load into the sheetRefs
      Returns:
      all relationships that are sheet-like
    • hasNext

      public boolean hasNext()
      Returns true if the iteration has more elements.
      Specified by:
      hasNext in interface Iterator<InputStream>
      Returns:
      true if the iterator has more elements.
    • next

      public InputStream next()
      Returns input stream of the next sheet in the iteration
      Specified by:
      next in interface Iterator<InputStream>
      Returns:
      input stream of the next sheet in the iteration
      Throws:
      POIXMLException - if the sheet part is invalid
    • getSheetName

      public String getSheetName()
      Returns name of the current sheet
      Returns:
      name of the current sheet
    • getSheetComments

      public Comments getSheetComments()
      Returns the comments associated with this sheet, or null if there aren't any
    • parseComments

      protected Comments parseComments(PackagePart commentsPart) throws IOException
      Throws:
      IOException
    • getShapes

      public List<XSSFShape> getShapes()
      Returns the shapes associated with this sheet, an empty list or null if there is an exception
    • getSheetPart

      public PackagePart getSheetPart()
    • remove

      public void remove()
      We're read only, so remove isn't supported
      Specified by:
      remove in interface Iterator<InputStream>