|
| __construct ($filePath, $workbookRelationshipsManager, $entityFactory) |
|
| getNumberFormatCode ($styleId) |
| Returns the format as defined in "styles.xml" of the given style.
|
|
| shouldFormatNumericValueAsDate ($styleId) |
| Returns whether the style with the given ID should consider numeric values as timestamps and format the cell as a date.
|
|
|
const | DEFAULT_STYLE_ID = 0 |
| By convention, default style ID is 0.
|
|
const | NUMBER_FORMAT_GENERAL = 'General' |
|
const | XML_ATTRIBUTE_APPLY_NUMBER_FORMAT = 'applyNumberFormat' |
|
const | XML_ATTRIBUTE_FORMAT_CODE = 'formatCode' |
|
const | XML_ATTRIBUTE_NUM_FMT_ID = 'numFmtId' |
| Attributes used to find relevant information in the styles XML file.
|
|
const | XML_NODE_CELL_XFS = 'cellXfs' |
|
const | XML_NODE_NUM_FMT = 'numFmt' |
|
const | XML_NODE_NUM_FMTS = 'numFmts' |
| Nodes used to find relevant information in the styles XML file.
|
|
const | XML_NODE_XF = 'xf' |
|
|
array | $builtinNumFmtIdIndicatingDates |
| Array containing the IDs of built-in number formats indicating a date.
|
|
array | $customNumberFormats |
| Array containing a mapping NUM_FMT_ID => FORMAT_CODE.
|
|
InternalEntityFactory | $entityFactory |
| Factory to create entities.
|
|
string | $filePath |
| Path of the XLSX file being read.
|
|
bool | $hasStylesXMLFile |
| Whether the XLSX file contains a styles XML file.
|
|
array | $numFmtIdToIsDateFormatCache = [] |
| Cache containing a mapping NUM_FMT_ID => IS_DATE_FORMAT.
|
|
array | $stylesAttributes |
| Array containing a mapping STYLE_ID => [STYLE_ATTRIBUTES].
|
|
string null | $stylesXMLFilePath |
| Path of the styles XML file.
|
|
◆ __construct()
Box\Spout\Reader\XLSX\Manager\StyleManager::__construct |
( |
| $filePath, |
|
|
| $workbookRelationshipsManager, |
|
|
| $entityFactory ) |
- Parameters
-
string | $filePath | Path of the XLSX file being read |
WorkbookRelationshipsManager | $workbookRelationshipsManager | Helps retrieving workbook relationships |
InternalEntityFactory | $entityFactory | Factory to create entities |
◆ doesNumFmtIdIndicateDate()
Box\Spout\Reader\XLSX\Manager\StyleManager::doesNumFmtIdIndicateDate |
( |
| $numFmtId | ) |
|
|
protected |
Returns whether the number format ID indicates that the number is a date.
The result is cached to avoid recomputing the same thing over and over, as "numFmtId" attributes can be shared between multiple styles.
- Parameters
-
- Return values
-
bool | Whether the number format ID indicates that the number is a date |
◆ doesStyleIndicateDate()
Box\Spout\Reader\XLSX\Manager\StyleManager::doesStyleIndicateDate |
( |
| $styleAttributes | ) |
|
|
protected |
- Parameters
-
array | $styleAttributes | Array containing the style attributes (2 keys: "applyNumberFormat" and "numFmtId") |
- Return values
-
bool | Whether the style with the given attributes indicates that the number is a date |
◆ extractNumberFormats()
Box\Spout\Reader\XLSX\Manager\StyleManager::extractNumberFormats |
( |
| $xmlReader | ) |
|
|
protected |
Extracts number formats from the "numFmt" nodes.
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.
- Parameters
-
- Return values
-
◆ extractRelevantInfo()
Box\Spout\Reader\XLSX\Manager\StyleManager::extractRelevantInfo |
( |
| ) |
|
|
protected |
Reads the styles.xml file and extract the relevant information from the file.
- Return values
-
◆ extractStyleAttributes()
Box\Spout\Reader\XLSX\Manager\StyleManager::extractStyleAttributes |
( |
| $xmlReader | ) |
|
|
protected |
Extracts style attributes from the "xf" nodes, inside the "cellXfs" section.
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.
- Parameters
-
- Return values
-
◆ getCustomNumberFormats()
Box\Spout\Reader\XLSX\Manager\StyleManager::getCustomNumberFormats |
( |
| ) |
|
|
protected |
- Return values
-
array | The custom number formats |
◆ getFormatCodeForNumFmtId()
Box\Spout\Reader\XLSX\Manager\StyleManager::getFormatCodeForNumFmtId |
( |
| $numFmtId | ) |
|
|
protected |
- Parameters
-
- Return values
-
string|null | The custom number format or NULL if none defined for the given numFmtId |
◆ getNumberFormatCode()
Box\Spout\Reader\XLSX\Manager\StyleManager::getNumberFormatCode |
( |
| $styleId | ) |
|
Returns the format as defined in "styles.xml" of the given style.
NOTE: It is assumed that the style DOES have a number format associated to it.
- Parameters
-
int | $styleId | Zero-based style ID |
- Return values
-
string | The number format code associated with the given style |
◆ getStylesAttributes()
Box\Spout\Reader\XLSX\Manager\StyleManager::getStylesAttributes |
( |
| ) |
|
|
protected |
- Return values
-
array | The styles attributes |
◆ isFormatCodeCustomDateFormat()
Box\Spout\Reader\XLSX\Manager\StyleManager::isFormatCodeCustomDateFormat |
( |
| $formatCode | ) |
|
|
protected |
- Parameters
-
- Return values
-
bool | Whether the given format code indicates that the number is a date |
◆ isFormatCodeMatchingDateFormatPattern()
Box\Spout\Reader\XLSX\Manager\StyleManager::isFormatCodeMatchingDateFormatPattern |
( |
| $formatCode | ) |
|
|
protected |
- Parameters
-
- Return values
-
bool | Whether the given format code matches a date format pattern |
◆ isNumFmtIdBuiltInDateFormat()
Box\Spout\Reader\XLSX\Manager\StyleManager::isNumFmtIdBuiltInDateFormat |
( |
| $numFmtId | ) |
|
|
protected |
- Parameters
-
- Return values
-
bool | Whether the number format ID indicates that the number is a date |
◆ shouldFormatNumericValueAsDate()
Box\Spout\Reader\XLSX\Manager\StyleManager::shouldFormatNumericValueAsDate |
( |
| $styleId | ) |
|
Returns whether the style with the given ID should consider numeric values as timestamps and format the cell as a date.
- Parameters
-
int | $styleId | Zero-based style ID |
- Return values
-
bool | Whether the cell with the given cell should display a date instead of a numeric value |
◆ $builtinNumFmtIdToNumFormatMapping
array Box\Spout\Reader\XLSX\Manager\StyleManager::$builtinNumFmtIdToNumFormatMapping |
|
staticprotected |
Initial value:= [
14 => 'm/d/yyyy',
15 => 'd-mmm-yy',
16 => 'd-mmm',
17 => 'mmm-yy',
18 => 'h:mm AM/PM',
19 => 'h:mm:ss AM/PM',
20 => 'h:mm',
21 => 'h:mm:ss',
22 => 'm/d/yyyy h:mm',
45 => 'mm:ss',
46 => '[h]:mm:ss',
47 => 'mm:ss.0',
]
- See also
- https://msdn.microsoft.com/en-us/library/ff529597(v=office.12).aspx Mapping between built-in numFmtId and the associated format - for dates only
◆ $numFmtIdToIsDateFormatCache
array Box\Spout\Reader\XLSX\Manager\StyleManager::$numFmtIdToIsDateFormatCache = [] |
|
protected |
Cache containing a mapping NUM_FMT_ID => IS_DATE_FORMAT.
Used to avoid lots of recalculations
The documentation for this class was generated from the following file:
- lib/spout/src/Spout/Reader/XLSX/Manager/StyleManager.php