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

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

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

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

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

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

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

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

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

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

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.

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

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.

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

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

param: float $timestampValue
return: bool

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.

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

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

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

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

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