Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 39 and 400]

(no description)

File Size: 344 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: StyleManager  - X-Ref

Class StyleManager
This class manages XLSX styles

__construct($filePath, $workbookRelationshipsManager, $entityFactory)   X-Ref

param: string $filePath Path of the XLSX file being read
param: WorkbookRelationshipsManager $workbookRelationshipsManager Helps retrieving workbook relationships
param: InternalEntityFactory $entityFactory Factory to create entities

shouldFormatNumericValueAsDate($styleId)   X-Ref
Returns whether the style with the given ID should consider
numeric values as timestamps and format the cell as a date.

return: bool Whether the cell with the given cell should display a date instead of a numeric value
param: int $styleId Zero-based style ID

extractRelevantInfo()   X-Ref
Reads the styles.xml file and extract the relevant information from the file.

return: void

extractNumberFormats($xmlReader)   X-Ref
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.

return: void
param: \Box\Spout\Reader\Wrapper\XMLReader $xmlReader XML Reader positioned on the "numFmts" node

extractStyleAttributes($xmlReader)   X-Ref
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.

return: void
param: \Box\Spout\Reader\Wrapper\XMLReader $xmlReader XML Reader positioned on the "cellXfs" node

getCustomNumberFormats()   X-Ref

return: array The custom number formats

getStylesAttributes()   X-Ref

return: array The styles attributes

doesStyleIndicateDate($styleAttributes)   X-Ref

return: bool Whether the style with the given attributes indicates that the number is a date
param: array $styleAttributes Array containing the style attributes (2 keys: "applyNumberFormat" and "numFmtId")

doesNumFmtIdIndicateDate($numFmtId)   X-Ref
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.

return: bool Whether the number format ID indicates that the number is a date
param: int $numFmtId

getFormatCodeForNumFmtId($numFmtId)   X-Ref

return: string|null The custom number format or NULL if none defined for the given numFmtId
param: int $numFmtId

isNumFmtIdBuiltInDateFormat($numFmtId)   X-Ref

return: bool Whether the number format ID indicates that the number is a date
param: int $numFmtId

isFormatCodeCustomDateFormat($formatCode)   X-Ref

return: bool Whether the given format code indicates that the number is a date
param: string|null $formatCode

isFormatCodeMatchingDateFormatPattern($formatCode)   X-Ref

return: bool Whether the given format code matches a date format pattern
param: string $formatCode

getNumberFormatCode($styleId)   X-Ref
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.

return: string The number format code associated with the given style
param: int $styleId Zero-based style ID