Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 402 and 403]

(no description)

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

Defines 1 class


Class: CellValueFormatter  - X-Ref

This class provides helper functions to format cell values.

__construct(SharedStringsManager $sharedStringsManager,StyleManagerInterface $styleManager,bool $shouldFormatDates,bool $shouldUse1904Dates,XLSX $escaper)   X-Ref

param: SharedStringsManager  $sharedStringsManager Manages shared strings
param: StyleManagerInterface $styleManager         Manages styles
param: bool                  $shouldFormatDates    Whether date/time values should be returned as PHP objects or be formatted as strings
param: bool                  $shouldUse1904Dates   Whether date/time values should use a calendar starting in 1904 instead of 1900
param: XLSX                  $escaper              Used to unescape XML data

extractAndFormatNodeValue(DOMElement $node)   X-Ref
Returns the (unescaped) correctly marshalled, cell value associated to the given XML node.

return: bool|DateTimeImmutable|float|int|string The value associated with the cell

getVNodeValue(DOMElement $node)   X-Ref
Returns the cell's string value from a node's nested value node.

return: string The value associated with the cell

formatInlineStringCellValue(DOMElement $node)   X-Ref
Returns the cell String value where string is inline.

return: string The value associated with the cell

formatSharedStringCellValue(string $nodeValue)   X-Ref
Returns the cell String value from shared-strings file using nodeValue index.

return: string The value associated with the cell

formatStrCellValue(string $nodeValue)   X-Ref
Returns the cell String value, where string is stored in value node.

return: string The value associated with the cell

formatNumericCellValue(int|float|string $nodeValue, int $cellStyleId)   X-Ref
Returns the cell Numeric value from string of nodeValue.
The value can also represent a timestamp and a DateTime will be returned.

param: int $cellStyleId 0 being the default style

formatExcelTimestampValue(float $nodeValue, int $cellStyleId)   X-Ref
Returns a cell's PHP Date value, associated to the given timestamp.
NOTE: The timestamp is a float representing the number of days since the base Excel date:
Dec 30th 1899, 1900 or Jan 1st, 1904, depending on the Workbook setting.
NOTE: The timestamp can also represent a time, if it is a value between 0 and 1.

param: int $cellStyleId 0 being the default style

isValidTimestampValue(float $timestampValue)   X-Ref
Returns whether the given timestamp is supported by SpreadsheetML.


formatExcelTimestampValueAsDateTimeValue(float $nodeValue, int $cellStyleId)   X-Ref
Returns a cell's PHP DateTime value, associated to the given timestamp.
Only the time value matters. The date part is set to the base Excel date:
Dec 30th 1899, 1900 or Jan 1st, 1904, depending on the Workbook setting.

param: int $cellStyleId 0 being the default style

formatBooleanCellValue(string $nodeValue)   X-Ref
Returns the cell Boolean value from a specific node's Value.

return: bool The value associated with the cell

formatDateCellValue(string $nodeValue)   X-Ref
Returns a cell's PHP Date value, associated to the given stored nodeValue.

param: string $nodeValue ISO 8601 Date string