PHP Class Box\Spout\Reader\XLSX\Helper\CellValueFormatter

Datei anzeigen Open project: box/spout

Protected Properties

Property Type Description
$escaper Used to unescape XML data
$sharedStringsHelper Helper to work with shared strings
$shouldFormatDates Whether date/time values should be returned as PHP objects or be formatted as strings
$styleHelper Helper to work with styles

Public Methods

Method Description
__construct ( SharedStringsHelper $sharedStringsHelper, StyleHelper $styleHelper, boolean $shouldFormatDates )
extractAndFormatNodeValue ( DOMNode $node ) : string | integer | float | boolean | DateTime | null Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.

Protected Methods

Method Description
formatBooleanCellValue ( string $nodeValue ) : boolean Returns the cell Boolean value from a specific node's Value.
formatDateCellValue ( string $nodeValue ) : DateTime | string | null Returns a cell's PHP Date value, associated to the given stored nodeValue.
formatExcelTimestampValue ( float $nodeValue, integer $cellStyleId ) : DateTime | null Returns a cell's PHP Date value, associated to the given timestamp.
formatExcelTimestampValueAsDateValue ( float $nodeValue, integer $cellStyleId ) : DateTime | string | null Returns a cell's PHP Date value, associated to the given timestamp.
formatExcelTimestampValueAsTimeValue ( float $nodeValue, integer $cellStyleId ) : DateTime | string Returns a cell's PHP DateTime value, associated to the given timestamp.
formatInlineStringCellValue ( DOMNode $node ) : string Returns the cell String value where string is inline.
formatNumericCellValue ( string $nodeValue, integer $cellStyleId ) : integer | float | DateTime | null Returns the cell Numeric value from string of nodeValue.
formatSharedStringCellValue ( string $nodeValue ) : string Returns the cell String value from shared-strings file using nodeValue index.
formatStrCellValue ( string $nodeValue ) : string Returns the cell String value, where string is stored in value node.
getVNodeValue ( DOMNode $node ) : string Returns the cell's string value from a node's nested value node

Method Details

__construct() public method

public __construct ( SharedStringsHelper $sharedStringsHelper, StyleHelper $styleHelper, boolean $shouldFormatDates )
$sharedStringsHelper SharedStringsHelper Helper to work with shared strings
$styleHelper StyleHelper Helper to work with styles
$shouldFormatDates boolean Whether date/time values should be returned as PHP objects or be formatted as strings

extractAndFormatNodeValue() public method

Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.
public extractAndFormatNodeValue ( 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)

formatBooleanCellValue() protected method

Returns the cell Boolean value from a specific node's Value.
protected formatBooleanCellValue ( string $nodeValue ) : boolean
$nodeValue string
return boolean The value associated with the cell

formatDateCellValue() protected method

Returns a cell's PHP Date value, associated to the given stored nodeValue.
protected formatDateCellValue ( string $nodeValue ) : DateTime | string | null
$nodeValue string ISO 8601 Date string
return DateTime | string | null The value associated with the cell or NULL if invalid date value

formatExcelTimestampValue() protected method

NOTE: The timestamp is a float representing the number of days since January 1st, 1900. NOTE: The timestamp can also represent a time, if it is a value between 0 and 1.
protected formatExcelTimestampValue ( float $nodeValue, integer $cellStyleId ) : DateTime | null
$nodeValue float
$cellStyleId integer 0 being the default style
return DateTime | null The value associated with the cell or NULL if invalid date value

formatExcelTimestampValueAsDateValue() protected method

NOTE: The timestamp is a float representing the number of days since January 1st, 1900.
protected formatExcelTimestampValueAsDateValue ( float $nodeValue, integer $cellStyleId ) : DateTime | string | null
$nodeValue float
$cellStyleId integer 0 being the default style
return DateTime | string | null The value associated with the cell or NULL if invalid date value

formatExcelTimestampValueAsTimeValue() protected method

Only the time value matters. The date part is set to Jan 1st, 1900 (base Excel date).
protected formatExcelTimestampValueAsTimeValue ( float $nodeValue, integer $cellStyleId ) : DateTime | string
$nodeValue float
$cellStyleId integer 0 being the default style
return DateTime | string The value associated with the cell

formatInlineStringCellValue() protected method

Returns the cell String value where string is inline.
protected formatInlineStringCellValue ( DOMNode $node ) : string
$node DOMNode
return string The value associated with the cell (null when the cell has an error)

formatNumericCellValue() protected method

The value can also represent a timestamp and a DateTime will be returned.
protected formatNumericCellValue ( string $nodeValue, integer $cellStyleId ) : integer | float | DateTime | null
$nodeValue string
$cellStyleId integer 0 being the default style
return integer | float | DateTime | null The value associated with the cell

formatSharedStringCellValue() protected method

Returns the cell String value from shared-strings file using nodeValue index.
protected formatSharedStringCellValue ( string $nodeValue ) : string
$nodeValue string
return string The value associated with the cell (null when the cell has an error)

formatStrCellValue() protected method

Returns the cell String value, where string is stored in value node.
protected formatStrCellValue ( string $nodeValue ) : string
$nodeValue string
return string The value associated with the cell (null when the cell has an error)

getVNodeValue() protected method

Returns the cell's string value from a node's nested value node
protected getVNodeValue ( DOMNode $node ) : string
$node DOMNode
return string The value associated with the cell

Property Details

$escaper protected_oe property

Used to unescape XML data
protected $escaper

$sharedStringsHelper protected_oe property

Helper to work with shared strings
protected $sharedStringsHelper

$shouldFormatDates protected_oe property

Whether date/time values should be returned as PHP objects or be formatted as strings
protected $shouldFormatDates

$styleHelper protected_oe property

Helper to work with styles
protected $styleHelper