PHP Class Box\Spout\Reader\ODS\RowIterator

Inheritance: implements Box\Spout\Reader\IteratorInterface
Datei anzeigen Open project: box/spout

Protected Properties

Property Type Description
$cellValueFormatter Helper to format cell values
$currentlyProcessedRowData Contains the data for the currently processed row (key = cell index, value = cell value)
$hasAlreadyBeenRewound Whether the iterator has already been rewound once
$hasAlreadyReadOneCellInCurrentRow Whether at least one cell has been read for the row currently being processed
$hasReachedEndOfFile Indicates whether all rows have been read
$lastProcessedCellValue Value of the last processed cell (because when reading cell at column N+1, cell N is processed)
$lastRowIndexProcessed Last row index processed (one-based)
$nextRowIndexToBeProcessed Row index to be processed next (one-based)
$numColumnsRepeated Number of times the last cell value should be copied to the cells on its right
$numRowsRepeated Number of times the last processed row should be repeated
$rowDataBuffer Buffer used to store the row data, while checking if there are more rows to read
$shouldPreserveEmptyRows Whether empty rows should be returned or skipped
$xmlProcessor Helper Object to process XML nodes
$xmlReader The XMLReader object that will help read sheet's XML data

Public Methods

Method Description
__construct ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader, Box\Spout\Reader\ODS\ReaderOptions $options )
current ( ) : array | null Return the current element, from the buffer.
end ( ) : void Cleans up what was created to iterate over the object.
key ( ) : integer Return the key of the current element
next ( ) : void Move forward to next element. Empty rows will be skipped.
rewind ( ) : void Rewind the Iterator to the first element.
valid ( ) : boolean Checks if current position is valid

Protected Methods

Method Description
doesNeedDataForNextRowToBeProcessed ( ) : boolean Returns whether we need data for the next row to be processed.
getCellValue ( DOMNode $node ) : string | integer | float | boolean | DateTime | DateInterval | null Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.
getNumColumnsRepeatedForCurrentNode ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
getNumRowsRepeatedForCurrentNode ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
isEmptyRow ( array $rowData, $lastReadCellValue ) : boolean After finishing processing each cell, a row is considered empty if it contains no cells or if the value of the last read cell is an empty string.
processCellStartingNode ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
processRowEndingNode ( ) : integer
processRowStartingNode ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
processTableEndingNode ( ) : integer
readDataForNextRow ( ) : void

Method Details

__construct() public method

public __construct ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader, Box\Spout\Reader\ODS\ReaderOptions $options )
$xmlReader Box\Spout\Reader\Wrapper\XMLReader XML Reader, positioned on the "" element
$options Box\Spout\Reader\ODS\ReaderOptions Reader's current options

current() public method

Return the current element, from the buffer.
public current ( ) : array | null
return array | null

doesNeedDataForNextRowToBeProcessed() protected method

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
protected doesNeedDataForNextRowToBeProcessed ( ) : boolean
return boolean Whether we need data for the next row to be processed.

end() public method

Cleans up what was created to iterate over the object.
public end ( ) : void
return void

getCellValue() protected method

Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.
protected getCellValue ( DOMNode $node ) : string | integer | float | boolean | DateTime | DateInterval | null
$node DOMNode
return string | integer | float | boolean | DateTime | DateInterval | null The value associated with the cell, empty string if cell's type is void/undefined, null on error

getNumColumnsRepeatedForCurrentNode() protected method

protected getNumColumnsRepeatedForCurrentNode ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
$xmlReader Box\Spout\Reader\Wrapper\XMLReader XMLReader object, positioned on a "" starting node
return integer The value of "table:number-columns-repeated" attribute of the current node, or 1 if attribute missing

getNumRowsRepeatedForCurrentNode() protected method

protected getNumRowsRepeatedForCurrentNode ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
$xmlReader Box\Spout\Reader\Wrapper\XMLReader XMLReader object, positioned on a "" starting node
return integer The value of "table:number-rows-repeated" attribute of the current node, or 1 if attribute missing

isEmptyRow() protected method

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).
protected isEmptyRow ( array $rowData, $lastReadCellValue ) : boolean
$rowData array
return boolean Whether the row is empty

key() public method

Return the key of the current element
public key ( ) : integer
return integer

next() public method

Move forward to next element. Empty rows will be skipped.
public next ( ) : void
return void

processCellStartingNode() protected method

protected processCellStartingNode ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
$xmlReader Box\Spout\Reader\Wrapper\XMLReader XMLReader object, positioned on a "" starting node
return integer A return code that indicates what action should the processor take next

processRowEndingNode() protected method

protected processRowEndingNode ( ) : integer
return integer A return code that indicates what action should the processor take next

processRowStartingNode() protected method

protected processRowStartingNode ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
$xmlReader Box\Spout\Reader\Wrapper\XMLReader XMLReader object, positioned on a "" starting node
return integer A return code that indicates what action should the processor take next

processTableEndingNode() protected method

protected processTableEndingNode ( ) : integer
return integer A return code that indicates what action should the processor take next

readDataForNextRow() protected method

protected readDataForNextRow ( ) : void
return void

rewind() public method

NOTE: It can only be done once, as it is not possible to read an XML file backwards.
public rewind ( ) : void
return void

valid() public method

Checks if current position is valid
public valid ( ) : boolean
return boolean

Property Details

$cellValueFormatter protected_oe property

Helper to format cell values
protected $cellValueFormatter

$currentlyProcessedRowData protected_oe property

Contains the data for the currently processed row (key = cell index, value = cell value)
protected $currentlyProcessedRowData

$hasAlreadyBeenRewound protected_oe property

Whether the iterator has already been rewound once
protected $hasAlreadyBeenRewound

$hasAlreadyReadOneCellInCurrentRow protected_oe property

Whether at least one cell has been read for the row currently being processed
protected $hasAlreadyReadOneCellInCurrentRow

$hasReachedEndOfFile protected_oe property

Indicates whether all rows have been read
protected $hasReachedEndOfFile

$lastProcessedCellValue protected_oe property

Value of the last processed cell (because when reading cell at column N+1, cell N is processed)
protected $lastProcessedCellValue

$lastRowIndexProcessed protected_oe property

Last row index processed (one-based)
protected $lastRowIndexProcessed

$nextRowIndexToBeProcessed protected_oe property

Row index to be processed next (one-based)
protected $nextRowIndexToBeProcessed

$numColumnsRepeated protected_oe property

Number of times the last cell value should be copied to the cells on its right
protected $numColumnsRepeated

$numRowsRepeated protected_oe property

Number of times the last processed row should be repeated
protected $numRowsRepeated

$rowDataBuffer protected_oe property

Buffer used to store the row data, while checking if there are more rows to read
protected $rowDataBuffer

$shouldPreserveEmptyRows protected_oe property

Whether empty rows should be returned or skipped
protected $shouldPreserveEmptyRows

$xmlProcessor protected_oe property

Helper Object to process XML nodes
protected $xmlProcessor

$xmlReader protected_oe property

The XMLReader object that will help read sheet's XML data
protected $xmlReader