PHP Класс Box\Spout\Reader\XLSX\Helper\StyleHelper

Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$builtinNumFmtIdIndicatingDates Array containing the IDs of built-in number formats indicating a date
$builtinNumFmtIdToNumFormatMapping Mapping between built-in numFmtId and the associated format - for dates only
$customNumberFormats Array containing a mapping NUM_FMT_ID => FORMAT_CODE
$filePath Path of the XLSX file being read
$numFmtIdToIsDateFormatCache Cache containing a mapping NUM_FMT_ID => IS_DATE_FORMAT. Used to avoid lots of recalculations
$stylesAttributes Array containing a mapping STYLE_ID => [STYLE_ATTRIBUTES]

Открытые методы

Метод Описание
__construct ( string $filePath )
getNumberFormatCode ( integer $styleId ) : string Returns the format as defined in "styles.xml" of the given style.
shouldFormatNumericValueAsDate ( integer $styleId ) : boolean Returns whether the style with the given ID should consider numeric values as timestamps and format the cell as a date.

Защищенные методы

Метод Описание
doesNumFmtIdIndicateDate ( integer $numFmtId ) : boolean Returns whether the number format ID indicates that the number is a date.
doesStyleIndicateDate ( array $styleAttributes ) : boolean
extractNumberFormats ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : void Extracts number formats from the "numFmt" nodes.
extractRelevantInfo ( ) : void Reads the styles.xml file and extract the relevant information from the file.
extractStyleAttributes ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : void Extracts style attributes from the "xf" nodes, inside the "cellXfs" section.
getCustomNumberFormats ( ) : array
getFormatCodeForNumFmtId ( integer $numFmtId ) : string | null
getStylesAttributes ( ) : array
isFormatCodeCustomDateFormat ( string | null $formatCode ) : boolean
isFormatCodeMatchingDateFormatPattern ( string $formatCode ) : boolean
isNumFmtIdBuiltInDateFormat ( integer $numFmtId ) : boolean

Описание методов

__construct() публичный Метод

public __construct ( string $filePath )
$filePath string Path of the XLSX file being read

doesNumFmtIdIndicateDate() защищенный Метод

The result is cached to avoid recomputing the same thing over and over, as "numFmtId" attributes can be shared between multiple styles.
protected doesNumFmtIdIndicateDate ( integer $numFmtId ) : boolean
$numFmtId integer
Результат boolean Whether the number format ID indicates that the number is a date

doesStyleIndicateDate() защищенный Метод

protected doesStyleIndicateDate ( array $styleAttributes ) : boolean
$styleAttributes array Array containing the style attributes (2 keys: "applyNumberFormat" and "numFmtId")
Результат boolean Whether the style with the given attributes indicates that the number is a date

extractNumberFormats() защищенный Метод

For simplicity, the styles attributes are kept in memory. This is possible thanks to the reuse of formats. So 1 million cells should not use 1 million formats.
protected extractNumberFormats ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : void
$xmlReader Box\Spout\Reader\Wrapper\XMLReader XML Reader positioned on the "numFmts" node
Результат void

extractRelevantInfo() защищенный Метод

Reads the styles.xml file and extract the relevant information from the file.
protected extractRelevantInfo ( ) : void
Результат void

extractStyleAttributes() защищенный Метод

For simplicity, the styles attributes are kept in memory. This is possible thanks to the reuse of styles. So 1 million cells should not use 1 million styles.
protected extractStyleAttributes ( Box\Spout\Reader\Wrapper\XMLReader $xmlReader ) : void
$xmlReader Box\Spout\Reader\Wrapper\XMLReader XML Reader positioned on the "cellXfs" node
Результат void

getCustomNumberFormats() защищенный Метод

protected getCustomNumberFormats ( ) : array
Результат array The custom number formats

getFormatCodeForNumFmtId() защищенный Метод

protected getFormatCodeForNumFmtId ( integer $numFmtId ) : string | null
$numFmtId integer
Результат string | null The custom number format or NULL if none defined for the given numFmtId

getNumberFormatCode() публичный Метод

NOTE: It is assumed that the style DOES have a number format associated to it.
public getNumberFormatCode ( integer $styleId ) : string
$styleId integer Zero-based style ID
Результат string The number format code associated with the given style

getStylesAttributes() защищенный Метод

protected getStylesAttributes ( ) : array
Результат array The styles attributes

isFormatCodeCustomDateFormat() защищенный Метод

protected isFormatCodeCustomDateFormat ( string | null $formatCode ) : boolean
$formatCode string | null
Результат boolean Whether the given format code indicates that the number is a date

isFormatCodeMatchingDateFormatPattern() защищенный Метод

protected isFormatCodeMatchingDateFormatPattern ( string $formatCode ) : boolean
$formatCode string
Результат boolean Whether the given format code matches a date format pattern

isNumFmtIdBuiltInDateFormat() защищенный Метод

protected isNumFmtIdBuiltInDateFormat ( integer $numFmtId ) : boolean
$numFmtId integer
Результат boolean Whether the number format ID indicates that the number is a date

shouldFormatNumericValueAsDate() публичный Метод

Returns whether the style with the given ID should consider numeric values as timestamps and format the cell as a date.
public shouldFormatNumericValueAsDate ( integer $styleId ) : boolean
$styleId integer Zero-based style ID
Результат boolean Whether the cell with the given cell should display a date instead of a numeric value

Описание свойств

$builtinNumFmtIdIndicatingDates защищенное свойство

Array containing the IDs of built-in number formats indicating a date
protected $builtinNumFmtIdIndicatingDates

$builtinNumFmtIdToNumFormatMapping защищенное статическое свойство

Mapping between built-in numFmtId and the associated format - for dates only
См. также: https://msdn.microsoft.com/en-us/library/ff529597(v=office.12).aspx
protected static $builtinNumFmtIdToNumFormatMapping

$customNumberFormats защищенное свойство

Array containing a mapping NUM_FMT_ID => FORMAT_CODE
protected $customNumberFormats

$filePath защищенное свойство

Path of the XLSX file being read
protected $filePath

$numFmtIdToIsDateFormatCache защищенное свойство

Cache containing a mapping NUM_FMT_ID => IS_DATE_FORMAT. Used to avoid lots of recalculations
protected $numFmtIdToIsDateFormatCache

$stylesAttributes защищенное свойство

Array containing a mapping STYLE_ID => [STYLE_ATTRIBUTES]
protected $stylesAttributes