Moodle PHP Documentation 4.1
Moodle 4.1.19+ (Build: 20250711) (5f47dc23ffc)
Box\Spout\Reader\ODS\RowIterator Class Reference
Inheritance diagram for Box\Spout\Reader\ODS\RowIterator:
Box\Spout\Reader\IteratorInterface

Public Member Functions

 __construct (XMLReader $xmlReader, OptionsManagerInterface $optionsManager, CellValueFormatter $cellValueFormatter, XMLProcessor $xmlProcessor, RowManager $rowManager, InternalEntityFactory $entityFactory)
 
 current ()
 Return the current element, from the buffer.
 
 end ()
 Cleans up what was created to iterate over the object.
 
 key ()
 Return the key of the current element.
 
 next ()
 Move forward to next element.
 
 rewind ()
 Rewind the Iterator to the first element.
 
 valid ()
 Checks if current position is valid.
 

Public Attributes

const MAX_COLUMNS_EXCEL = 16384
 
const XML_ATTRIBUTE_NUM_COLUMNS_REPEATED = 'table:number-columns-repeated'
 
const XML_ATTRIBUTE_NUM_ROWS_REPEATED = 'table:number-rows-repeated'
 Definition of XML attribute used to parse data.
 
const XML_NODE_CELL = 'table:table-cell'
 
const XML_NODE_ROW = 'table:table-row'
 
const XML_NODE_TABLE = 'table:table'
 Definition of XML nodes names used to parse data.
 

Protected Member Functions

 doesNeedDataForNextRowToBeProcessed ()
 Returns whether we need data for the next row to be processed.
 
 getCell ($node)
 Returns the cell with (unescaped) correctly marshalled, cell value associated to the given XML node.
 
 getNumColumnsRepeatedForCurrentNode ($xmlReader)
 
 getNumRowsRepeatedForCurrentNode ($xmlReader)
 
 isEmptyRow ($currentRow, $lastReadCell)
 After finishing processing each cell, a row is considered empty if it contains no cells or if the last read cell is empty.
 
 processCellStartingNode ($xmlReader)
 
 processRowEndingNode ()
 
 processRowStartingNode ($xmlReader)
 
 processTableEndingNode ()
 
 readDataForNextRow ()
 

Protected Attributes

Helper CellValueFormatter $cellValueFormatter
 Helper to format cell values.
 
Row $currentlyProcessedRow
 The currently processed row.
 
InternalEntityFactory $entityFactory
 Factory to create entities.
 
bool $hasAlreadyBeenRewound = false
 Whether the iterator has already been rewound once.
 
bool $hasAlreadyReadOneCellInCurrentRow = false
 Whether at least one cell has been read for the row currently being processed.
 
bool $hasReachedEndOfFile = false
 Indicates whether all rows have been read.
 
Cell $lastProcessedCell
 Last processed cell (because when reading cell at column N+1, cell N is processed)
 
int $lastRowIndexProcessed = 0
 Last row index processed (one-based)
 
int $nextRowIndexToBeProcessed = 1
 Row index to be processed next (one-based)
 
int $numColumnsRepeated = 1
 Number of times the last cell value should be copied to the cells on its right.
 
int $numRowsRepeated = 1
 Number of times the last processed row should be repeated.
 
Row $rowBuffer
 Buffer used to store the current row, while checking if there are more rows to read.
 
RowManager $rowManager
 Manages rows.
 
bool $shouldPreserveEmptyRows
 Whether empty rows should be returned or skipped.
 
Box Spout Reader Common XMLProcessor $xmlProcessor
 Helper Object to process XML nodes.
 
Box Spout Reader Wrapper XMLReader $xmlReader
 The XMLReader object that will help read sheet's XML data.
 

Constructor & Destructor Documentation

◆ __construct()

Box\Spout\Reader\ODS\RowIterator::__construct ( XMLReader $xmlReader,
OptionsManagerInterface $optionsManager,
CellValueFormatter $cellValueFormatter,
XMLProcessor $xmlProcessor,
RowManager $rowManager,
InternalEntityFactory $entityFactory )
Parameters
XMLReader$xmlReaderXML Reader, positioned on the "<table:table>" element
OptionsManagerInterface$optionsManagerReader's options manager
CellValueFormatter$cellValueFormatterHelper to format cell values
XMLProcessor$xmlProcessorHelper to process XML files
RowManager$rowManagerManages rows
InternalEntityFactory$entityFactoryFactory to create entities

Member Function Documentation

◆ current()

Box\Spout\Reader\ODS\RowIterator::current ( )

Return the current element, from the buffer.

See also
http://php.net/manual/en/iterator.current.php
Return values
Row

◆ doesNeedDataForNextRowToBeProcessed()

Box\Spout\Reader\ODS\RowIterator::doesNeedDataForNextRowToBeProcessed ( )
protected

Returns whether we need data for the next row to be processed.

We DO need to read data if:

  • we have not read any rows yet OR
  • the next row to be processed immediately follows the last read row
Return values
boolWhether we need data for the next row to be processed.

◆ end()

Box\Spout\Reader\ODS\RowIterator::end ( )

Cleans up what was created to iterate over the object.

Return values
void

Implements Box\Spout\Reader\IteratorInterface.

◆ getCell()

Box\Spout\Reader\ODS\RowIterator::getCell ( $node)
protected

Returns the cell with (unescaped) correctly marshalled, cell value associated to the given XML node.

Parameters
DOMNode$node
Return values
CellThe cell set with the associated with the cell

◆ getNumColumnsRepeatedForCurrentNode()

Box\Spout\Reader\ODS\RowIterator::getNumColumnsRepeatedForCurrentNode ( $xmlReader)
protected
Parameters
Box\Spout\Reader\Wrapper\XMLReader$xmlReaderXMLReader object, positioned on a "<table:table-cell>" starting node
Return values
intThe value of "table:number-columns-repeated" attribute of the current node, or 1 if attribute missing

◆ getNumRowsRepeatedForCurrentNode()

Box\Spout\Reader\ODS\RowIterator::getNumRowsRepeatedForCurrentNode ( $xmlReader)
protected
Parameters
Box\Spout\Reader\Wrapper\XMLReader$xmlReaderXMLReader object, positioned on a "<table:table-row>" starting node
Return values
intThe value of "table:number-rows-repeated" attribute of the current node, or 1 if attribute missing

◆ isEmptyRow()

Box\Spout\Reader\ODS\RowIterator::isEmptyRow ( $currentRow,
$lastReadCell )
protected

After finishing processing each cell, a row is considered empty if it contains no cells or if the last read cell is empty.

After finishing processing each cell, the last read cell is not part of the row data yet (as we still need to apply the "num-columns-repeated" attribute).

Parameters
Row$currentRow
Cell$lastReadCellThe last read cell
Return values
boolWhether the row is empty

◆ key()

Box\Spout\Reader\ODS\RowIterator::key ( )

Return the key of the current element.

See also
http://php.net/manual/en/iterator.key.php
Return values
int

◆ next()

Box\Spout\Reader\ODS\RowIterator::next ( )

Move forward to next element.

Empty rows will be skipped.

See also
http://php.net/manual/en/iterator.next.php
Exceptions
Box\Spout\Reader\Exception\SharedStringNotFoundExceptionIf a shared string was not found
Box\Spout\Common\Exception\IOExceptionIf unable to read the sheet data XML
Return values
void

◆ processCellStartingNode()

Box\Spout\Reader\ODS\RowIterator::processCellStartingNode ( $xmlReader)
protected
Parameters
Box\Spout\Reader\Wrapper\XMLReader$xmlReaderXMLReader object, positioned on a "<table:table-cell>" starting node
Return values
intA return code that indicates what action should the processor take next

◆ processRowEndingNode()

Box\Spout\Reader\ODS\RowIterator::processRowEndingNode ( )
protected
Return values
intA return code that indicates what action should the processor take next

◆ processRowStartingNode()

Box\Spout\Reader\ODS\RowIterator::processRowStartingNode ( $xmlReader)
protected
Parameters
Box\Spout\Reader\Wrapper\XMLReader$xmlReaderXMLReader object, positioned on a "<table:table-row>" starting node
Return values
intA return code that indicates what action should the processor take next

◆ processTableEndingNode()

Box\Spout\Reader\ODS\RowIterator::processTableEndingNode ( )
protected
Return values
intA return code that indicates what action should the processor take next

◆ readDataForNextRow()

Box\Spout\Reader\ODS\RowIterator::readDataForNextRow ( )
protected
Exceptions
Box\Spout\Reader\Exception\SharedStringNotFoundExceptionIf a shared string was not found
Box\Spout\Common\Exception\IOExceptionIf unable to read the sheet data XML
Return values
void

◆ rewind()

Box\Spout\Reader\ODS\RowIterator::rewind ( )

Rewind the Iterator to the first element.

NOTE: It can only be done once, as it is not possible to read an XML file backwards.

See also
http://php.net/manual/en/iterator.rewind.php
Exceptions
Box\Spout\Reader\Exception\IteratorNotRewindableExceptionIf the iterator is rewound more than once
Return values
void

◆ valid()

Box\Spout\Reader\ODS\RowIterator::valid ( )

Checks if current position is valid.

See also
http://php.net/manual/en/iterator.valid.php
Return values
bool

The documentation for this class was generated from the following file: