Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

(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.

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

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.

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

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.

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

getCustomNumberFormats()   X-Ref

return: array The custom number formats

getStylesAttributes()   X-Ref

return: array The styles attributes

doesStyleIndicateDate($styleAttributes)   X-Ref

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

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.

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

getFormatCodeForNumFmtId($numFmtId)   X-Ref

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

isNumFmtIdBuiltInDateFormat($numFmtId)   X-Ref

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

isFormatCodeCustomDateFormat($formatCode)   X-Ref

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

isFormatCodeMatchingDateFormatPattern($formatCode)   X-Ref

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

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.

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