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: 296 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: CellValueFormatter  - X-Ref

Class CellValueFormatter
This class provides helper functions to format cell values

__construct($sharedStringsManager, $styleManager, $shouldFormatDates, $shouldUse1904Dates, $escaper)   X-Ref

param: SharedStringsManager $sharedStringsManager Manages shared strings
param: StyleManager $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: \Box\Spout\Common\Helper\Escaper\XLSX $escaper Used to unescape XML data

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

return: string|int|float|bool|\DateTime The value associated with the cell
param: \DOMNode $node

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

return: string The value associated with the cell
param: \DOMNode $node

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

return: string The value associated with the cell
param: \DOMNode $node

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

return: string The value associated with the cell
param: string $nodeValue

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

return: string The value associated with the cell
param: string $nodeValue

formatNumericCellValue($nodeValue, $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.

return: int|float|\DateTime The value associated with the cell
param: string $nodeValue
param: int $cellStyleId 0 being the default style

formatExcelTimestampValue($nodeValue, $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.

return: \DateTime The value associated with the cell
param: float $nodeValue
param: int $cellStyleId 0 being the default style

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

return: bool
param: float $timestampValue

formatExcelTimestampValueAsDateTimeValue($nodeValue, $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.

return: \DateTime|string The value associated with the cell
param: float $nodeValue
param: int $cellStyleId 0 being the default style

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

return: bool The value associated with the cell
param: string $nodeValue

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

return: \DateTime|string The value associated with the cell
param: string $nodeValue ISO 8601 Date string