PHP Class Box\Spout\Reader\XLSX\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)
$filePath Path of the XLSX file being read
$hasReachedEndOfFile Indicates whether all rows have been read
$lastColumnIndexProcessed Last column index processed (zero-based)
$lastRowIndexProcessed Last row index processed (one-based)
$nextRowIndexToBeProcessed Row index to be processed next (one-based)
$numColumns The number of columns the sheet has (0 meaning undefined)
$numReadRows TODO: This variable can be deleted when row indices get preserved
$rowDataBuffer Buffer used to store the row data, while checking if there are more rows to read
$sheetDataXMLFilePath string Path of the sheet data XML file as in [Content_Types].xml
$shouldPreserveEmptyRows Whether empty rows should be returned or skipped
$styleHelper Box\Spout\Reader\XLSX\Helper\StyleHelper Helper to work with styles
$xmlProcessor Helper Object to process XML nodes
$xmlReader The XMLReader object that will help read sheet's XML data

Public Methods

Method Description
__construct ( string $filePath, string $sheetDataXMLFilePath, ReaderOptions $options, SharedStringsHelper $sharedStringsHelper )
current ( ) : array | null Return the current element, either an empty row or from the buffer.
end ( ) : void Cleans up what was created to iterate over the object.
key ( ) : integer Return the key of the current element. Here, the row index.
next ( ) : void Move forward to next element. Reads data describing the next unprocessed row.
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 | null Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.
getColumnIndex ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
getRowIndex ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
isEmptyRow ( array $rowData ) : boolean
normalizeSheetDataXMLFilePath ( string $sheetDataXMLFilePath ) : string
processCellStartingNode ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
processDimensionStartingNode ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
processRowEndingNode ( ) : integer
processRowStartingNode ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
processWorksheetEndingNode ( ) : integer
readDataForNextRow ( ) : void

Method Details

__construct() public method

public __construct ( string $filePath, string $sheetDataXMLFilePath, ReaderOptions $options, SharedStringsHelper $sharedStringsHelper )
$filePath string Path of the XLSX file being read
$sheetDataXMLFilePath string Path of the sheet data XML file as in [Content_Types].xml
$options ReaderOptions Reader's current options
$sharedStringsHelper Box\Spout\Reader\XLSX\Helper\SharedStringsHelper Helper to work with shared strings

current() public method

Return the current element, either an empty row or from the buffer.
public current ( ) : array | null
return array | null

doesNeedDataForNextRowToBeProcessed() protected method

We don't need to read data if: we have already read at least one row AND we need to preserve empty rows AND the last row that was read is not the row that need to be processed (i.e. if we need to return empty rows)
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 | null
$node DOMNode
return string | integer | float | boolean | DateTime | null The value associated with the cell (null when the cell has an error)

getColumnIndex() protected method

protected getColumnIndex ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
$xmlReader Box\Spout\Reader\Wrapper\XMLReader XMLReader object, positioned on a "" node
return integer Column index

getRowIndex() protected method

protected getRowIndex ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : integer
$xmlReader Box\Spout\Reader\Wrapper\XMLReader XMLReader object, positioned on a "" node
return integer Row index

isEmptyRow() protected method

protected isEmptyRow ( array $rowData ) : boolean
$rowData array
return boolean Whether the given row is empty

key() public method

Return the key of the current element. Here, the row index.
public key ( ) : integer
return integer

next() public method

Move forward to next element. Reads data describing the next unprocessed row.
public next ( ) : void
return void

normalizeSheetDataXMLFilePath() protected method

protected normalizeSheetDataXMLFilePath ( string $sheetDataXMLFilePath ) : string
$sheetDataXMLFilePath string Path of the sheet data XML file as in [Content_Types].xml
return string Path of the XML file containing the sheet data, without the leading slash.

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

processDimensionStartingNode() protected method

protected processDimensionStartingNode ( 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

processWorksheetEndingNode() protected method

protected processWorksheetEndingNode ( ) : 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

Initializes the XMLReader object that reads the associated sheet data. The XMLReader is configured to be safe from billion laughs attack.
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

$filePath protected_oe property

Path of the XLSX file being read
protected $filePath

$hasReachedEndOfFile protected_oe property

Indicates whether all rows have been read
protected $hasReachedEndOfFile

$lastColumnIndexProcessed protected_oe property

Last column index processed (zero-based)
protected $lastColumnIndexProcessed

$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

$numColumns protected_oe property

The number of columns the sheet has (0 meaning undefined)
protected $numColumns

$numReadRows protected_oe property

TODO: This variable can be deleted when row indices get preserved
protected $numReadRows

$rowDataBuffer protected_oe property

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

$sheetDataXMLFilePath protected_oe property

Path of the sheet data XML file as in [Content_Types].xml
protected string $sheetDataXMLFilePath
return string

$shouldPreserveEmptyRows protected_oe property

Whether empty rows should be returned or skipped
protected $shouldPreserveEmptyRows

$styleHelper protected_oe property

Helper to work with styles
protected StyleHelper,Box\Spout\Reader\XLSX\Helper $styleHelper
return Box\Spout\Reader\XLSX\Helper\StyleHelper

$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