Documentation

NumberFormat extends Supervisor
in package

Table of Contents

Constants

DATE_TIME_INDEX  = 22
DATE_TIME_OR_DATETIME_ARRAY  = [self::FORMAT_DATE_YYYYMMDD, self::FORMAT_DATE_DDMMYYYY, self::FORMAT_DATE_DMYSLASH, self::FORMAT_DATE_DMYMINUS, self::FORMAT_DATE_DMMINUS, self::FORMAT_DATE_MYMINUS, self::FORMAT_DATE_XLSX14, self::FORMAT_DATE_XLSX14_ACTUAL, self::FORMAT_DATE_XLSX15, self::FORMAT_DATE_XLSX16, self::FORMAT_DATE_XLSX17, self::FORMAT_DATE_XLSX22, self::FORMAT_DATE_XLSX22_ACTUAL, self::FORMAT_DATE_DATETIME, self::FORMAT_DATE_TIME1, self::FORMAT_DATE_TIME2, self::FORMAT_DATE_TIME3, self::FORMAT_DATE_TIME4, self::FORMAT_DATE_TIME5, self::FORMAT_DATE_TIME6, self::FORMAT_DATE_TIME7, self::FORMAT_DATE_TIME8, self::FORMAT_DATE_YYYYMMDDSLASH, self::FORMAT_DATE_LONG_DATE]
FORMAT_ACCOUNTING_EUR  = '_("€"* #,##0.00_);_("€"* \(#,##0.00\);_("€"* "-"??_);_(@_)'
FORMAT_ACCOUNTING_USD  = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)'
FORMAT_CURRENCY_EUR  = '#,##0.00_-[$€]'
FORMAT_CURRENCY_EUR_INTEGER  = '#,##0_-[$€]'
FORMAT_CURRENCY_USD  = '$#,##0.00_-'
FORMAT_CURRENCY_USD_INTEGER  = '$#,##0_-'
FORMAT_DATE_DATETIME  = 'd/m/yy h:mm'
FORMAT_DATE_DDMMYYYY  = 'dd/mm/yyyy'
FORMAT_DATE_DMMINUS  = 'd-m'
FORMAT_DATE_DMYMINUS  = 'd-m-yy'
FORMAT_DATE_DMYSLASH  = 'd/m/yy'
FORMAT_DATE_LONG_DATE  = 'dddd, mmmm d, yyyy'
FORMAT_DATE_MYMINUS  = 'm-yy'
FORMAT_DATE_TIME1  = 'h:mm AM/PM'
FORMAT_DATE_TIME2  = 'h:mm:ss AM/PM'
FORMAT_DATE_TIME3  = 'h:mm'
FORMAT_DATE_TIME4  = 'h:mm:ss'
FORMAT_DATE_TIME5  = 'mm:ss'
FORMAT_DATE_TIME6  = 'h:mm:ss'
FORMAT_DATE_TIME7  = 'i:s.S'
FORMAT_DATE_TIME8  = 'h:mm:ss;@'
FORMAT_DATE_XLSX14  = 'mm-dd-yy'
FORMAT_DATE_XLSX14_ACTUAL  = 'm/d/yyyy'
FORMAT_DATE_XLSX15  = 'd-mmm-yy'
FORMAT_DATE_XLSX16  = 'd-mmm'
FORMAT_DATE_XLSX17  = 'mmm-yy'
FORMAT_DATE_XLSX22  = 'm/d/yy h:mm'
FORMAT_DATE_XLSX22_ACTUAL  = 'm/d/yyyy h:mm'
FORMAT_DATE_YYYYMMDD  = 'yyyy-mm-dd'
FORMAT_DATE_YYYYMMDDSLASH  = 'yyyy/mm/dd;@'
FORMAT_GENERAL  = 'General'
FORMAT_NUMBER  = '0'
FORMAT_NUMBER_0  = '0.0'
FORMAT_NUMBER_00  = '0.00'
FORMAT_NUMBER_COMMA_SEPARATED1  = '#,##0.00'
FORMAT_NUMBER_COMMA_SEPARATED2  = '#,##0.00_-'
FORMAT_PERCENTAGE  = '0%'
FORMAT_PERCENTAGE_0  = '0.0%'
FORMAT_PERCENTAGE_00  = '0.00%'
FORMAT_SYSDATE_F800  = '[$-F800]'
FORMAT_SYSDATE_X  = '[$-x-sysdate]'
FORMAT_SYSTIME_F400  = '[$-F400]'
FORMAT_SYSTIME_X  = '[$-x-systime]'
FORMAT_TEXT  = '@'
SHORT_DATE_INDEX  = 14
TIME_OR_DATETIME_ARRAY  = [self::FORMAT_DATE_XLSX22, self::FORMAT_DATE_DATETIME, self::FORMAT_DATE_TIME1, self::FORMAT_DATE_TIME2, self::FORMAT_DATE_TIME3, self::FORMAT_DATE_TIME4, self::FORMAT_DATE_TIME5, self::FORMAT_DATE_TIME6, self::FORMAT_DATE_TIME7, self::FORMAT_DATE_TIME8]

Properties

$builtInFormatCode  : false|int
Built-in format Code.
$builtInFormats  : array<string|int, mixed>
Excel built-in number formats.
$dateTimeFormat  : string
$flippedBuiltInFormats  : array<string|int, mixed>
Excel built-in number formats (flipped, for faster lookups).
$formatCode  : string|null
Format Code.
$isSupervisor  : bool
Supervisor?
$longDateFormat  : string
$parent  : Spreadsheet|Supervisor
Parent. Only used for supervisor.
$parentPropertyName  : string|null
Parent property name.
$shortDateFormat  : string
$timeFormat  : string

Methods

__clone()  : mixed
Implement PHP __clone to create a deep clone, not just a shallow copy.
__construct()  : mixed
Create a new NumberFormat.
applyFromArray()  : $this
Apply styles from array.
bindParent()  : $this
Bind parent. Only used for supervisor.
builtInFormatCode()  : string
Get built-in format code.
builtInFormatCodeIndex()  : false|int
Get built-in format code index.
convertSystemFormats()  : string|null
exportArray()  : array<string|int, mixed>
Export style as array.
getActiveCell()  : string
Get the currently active cell coordinate in currently active sheet.
getActiveSheet()  : Worksheet
Get the currently active sheet. Only used for supervisor.
getBuiltInFormatCode()  : false|int
Get Built-In Format Code.
getDateTimeFormat()  : string
getFormatCode()  : string|null
Get Format Code.
getHashCode()  : string
Get hash code.
getIsSupervisor()  : bool
Is this a supervisor or a cell style component?
getLongDateFormat()  : string
getSelectedCells()  : string
Get the currently active cell coordinate in currently active sheet.
getSharedComponent()  : self
Get the shared style component for the currently active cell in currently active sheet.
getShortDateFormat()  : string
getStyleArray()  : array<string|int, mixed>
Build style array from subcomponents.
getTimeFormat()  : string
setBuiltInFormatCode()  : $this
Set Built-In Format Code.
setDateTimeFormat()  : void
setFormatCode()  : $this
Set Format Code.
setLongDateFormat()  : void
setShortDateFormat()  : void
setTimeFormat()  : void
toFormattedString()  : string
Convert a value in a pre-defined format to a PHP string.
exportArray1()  : array<string|int, mixed>
Abstract method to be implemented in anything which extends this class.
exportArray2()  : void
Populate array from exportArray1.
fillBuiltInFormatCodes()  : void
Fill built-in format codes.

Constants

DATE_TIME_OR_DATETIME_ARRAY

public mixed DATE_TIME_OR_DATETIME_ARRAY = [self::FORMAT_DATE_YYYYMMDD, self::FORMAT_DATE_DDMMYYYY, self::FORMAT_DATE_DMYSLASH, self::FORMAT_DATE_DMYMINUS, self::FORMAT_DATE_DMMINUS, self::FORMAT_DATE_MYMINUS, self::FORMAT_DATE_XLSX14, self::FORMAT_DATE_XLSX14_ACTUAL, self::FORMAT_DATE_XLSX15, self::FORMAT_DATE_XLSX16, self::FORMAT_DATE_XLSX17, self::FORMAT_DATE_XLSX22, self::FORMAT_DATE_XLSX22_ACTUAL, self::FORMAT_DATE_DATETIME, self::FORMAT_DATE_TIME1, self::FORMAT_DATE_TIME2, self::FORMAT_DATE_TIME3, self::FORMAT_DATE_TIME4, self::FORMAT_DATE_TIME5, self::FORMAT_DATE_TIME6, self::FORMAT_DATE_TIME7, self::FORMAT_DATE_TIME8, self::FORMAT_DATE_YYYYMMDDSLASH, self::FORMAT_DATE_LONG_DATE]

FORMAT_ACCOUNTING_EUR

public mixed FORMAT_ACCOUNTING_EUR = '_("€"* #,##0.00_);_("€"* \(#,##0.00\);_("€"* "-"??_);_(@_)'

FORMAT_ACCOUNTING_USD

public mixed FORMAT_ACCOUNTING_USD = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)'

FORMAT_CURRENCY_EUR

public mixed FORMAT_CURRENCY_EUR = '#,##0.00_-[$€]'

FORMAT_CURRENCY_EUR_INTEGER

public mixed FORMAT_CURRENCY_EUR_INTEGER = '#,##0_-[$€]'

FORMAT_CURRENCY_USD

public mixed FORMAT_CURRENCY_USD = '$#,##0.00_-'

FORMAT_CURRENCY_USD_INTEGER

public mixed FORMAT_CURRENCY_USD_INTEGER = '$#,##0_-'

FORMAT_DATE_DATETIME

public mixed FORMAT_DATE_DATETIME = 'd/m/yy h:mm'

FORMAT_DATE_DDMMYYYY

public mixed FORMAT_DATE_DDMMYYYY = 'dd/mm/yyyy'

FORMAT_DATE_DMMINUS

public mixed FORMAT_DATE_DMMINUS = 'd-m'

FORMAT_DATE_DMYMINUS

public mixed FORMAT_DATE_DMYMINUS = 'd-m-yy'

FORMAT_DATE_DMYSLASH

public mixed FORMAT_DATE_DMYSLASH = 'd/m/yy'

FORMAT_DATE_LONG_DATE

public mixed FORMAT_DATE_LONG_DATE = 'dddd, mmmm d, yyyy'

FORMAT_DATE_MYMINUS

public mixed FORMAT_DATE_MYMINUS = 'm-yy'

FORMAT_DATE_TIME1

public mixed FORMAT_DATE_TIME1 = 'h:mm AM/PM'

FORMAT_DATE_TIME2

public mixed FORMAT_DATE_TIME2 = 'h:mm:ss AM/PM'

FORMAT_DATE_TIME3

public mixed FORMAT_DATE_TIME3 = 'h:mm'

FORMAT_DATE_TIME4

public mixed FORMAT_DATE_TIME4 = 'h:mm:ss'

FORMAT_DATE_TIME5

public mixed FORMAT_DATE_TIME5 = 'mm:ss'

FORMAT_DATE_TIME6

public mixed FORMAT_DATE_TIME6 = 'h:mm:ss'

FORMAT_DATE_TIME7

public mixed FORMAT_DATE_TIME7 = 'i:s.S'

FORMAT_DATE_TIME8

public mixed FORMAT_DATE_TIME8 = 'h:mm:ss;@'

FORMAT_DATE_XLSX14

public mixed FORMAT_DATE_XLSX14 = 'mm-dd-yy'

FORMAT_DATE_XLSX14_ACTUAL

public mixed FORMAT_DATE_XLSX14_ACTUAL = 'm/d/yyyy'

FORMAT_DATE_XLSX15

public mixed FORMAT_DATE_XLSX15 = 'd-mmm-yy'

FORMAT_DATE_XLSX16

public mixed FORMAT_DATE_XLSX16 = 'd-mmm'

FORMAT_DATE_XLSX17

public mixed FORMAT_DATE_XLSX17 = 'mmm-yy'

FORMAT_DATE_XLSX22

public mixed FORMAT_DATE_XLSX22 = 'm/d/yy h:mm'

FORMAT_DATE_XLSX22_ACTUAL

public mixed FORMAT_DATE_XLSX22_ACTUAL = 'm/d/yyyy h:mm'

FORMAT_DATE_YYYYMMDD

public mixed FORMAT_DATE_YYYYMMDD = 'yyyy-mm-dd'

FORMAT_DATE_YYYYMMDDSLASH

public mixed FORMAT_DATE_YYYYMMDDSLASH = 'yyyy/mm/dd;@'

FORMAT_NUMBER_COMMA_SEPARATED1

public mixed FORMAT_NUMBER_COMMA_SEPARATED1 = '#,##0.00'

FORMAT_NUMBER_COMMA_SEPARATED2

public mixed FORMAT_NUMBER_COMMA_SEPARATED2 = '#,##0.00_-'

FORMAT_PERCENTAGE_0

public mixed FORMAT_PERCENTAGE_0 = '0.0%'

FORMAT_PERCENTAGE_00

public mixed FORMAT_PERCENTAGE_00 = '0.00%'

FORMAT_SYSDATE_F800

public mixed FORMAT_SYSDATE_F800 = '[$-F800]'

FORMAT_SYSDATE_X

public mixed FORMAT_SYSDATE_X = '[$-x-sysdate]'

FORMAT_SYSTIME_F400

public mixed FORMAT_SYSTIME_F400 = '[$-F400]'

FORMAT_SYSTIME_X

public mixed FORMAT_SYSTIME_X = '[$-x-systime]'

TIME_OR_DATETIME_ARRAY

public mixed TIME_OR_DATETIME_ARRAY = [self::FORMAT_DATE_XLSX22, self::FORMAT_DATE_DATETIME, self::FORMAT_DATE_TIME1, self::FORMAT_DATE_TIME2, self::FORMAT_DATE_TIME3, self::FORMAT_DATE_TIME4, self::FORMAT_DATE_TIME5, self::FORMAT_DATE_TIME6, self::FORMAT_DATE_TIME7, self::FORMAT_DATE_TIME8]

Properties

$builtInFormatCode

Built-in format Code.

protected false|int $builtInFormatCode = 0

$builtInFormats

Excel built-in number formats.

protected static array<string|int, mixed> $builtInFormats

$dateTimeFormat

protected static string $dateTimeFormat = self::FORMAT_DATE_XLSX22_ACTUAL

$flippedBuiltInFormats

Excel built-in number formats (flipped, for faster lookups).

protected static array<string|int, mixed> $flippedBuiltInFormats

$formatCode

Format Code.

protected string|null $formatCode = self::FORMAT_GENERAL

$isSupervisor

Supervisor?

protected bool $isSupervisor

$longDateFormat

protected static string $longDateFormat = self::FORMAT_DATE_LONG_DATE

$parentPropertyName

Parent property name.

protected string|null $parentPropertyName = null

$shortDateFormat

protected static string $shortDateFormat = self::FORMAT_DATE_XLSX14_ACTUAL

$timeFormat

protected static string $timeFormat = self::FORMAT_DATE_TIME2

Methods

__clone()

Implement PHP __clone to create a deep clone, not just a shallow copy.

public __clone() : mixed

__construct()

Create a new NumberFormat.

public __construct([bool $isSupervisor = false ][, bool $isConditional = false ]) : mixed
Parameters
$isSupervisor : bool = false

Flag indicating if this is a supervisor or not Leave this value at default unless you understand exactly what its ramifications are

$isConditional : bool = false

Flag indicating if this is a conditional style or not Leave this value at default unless you understand exactly what its ramifications are

applyFromArray()

Apply styles from array.

public applyFromArray(array<string|int, mixed> $styleArray) : $this
$spreadsheet->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray( [ 'formatCode' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE ] );
Parameters
$styleArray : array<string|int, mixed>

Array containing style information

Return values
$this

bindParent()

Bind parent. Only used for supervisor.

public bindParent(Spreadsheet|self $parent[, string|null $parentPropertyName = null ]) : $this
Parameters
$parent : Spreadsheet|self
$parentPropertyName : string|null = null
Return values
$this

builtInFormatCode()

Get built-in format code.

public static builtInFormatCode(int $index) : string
Parameters
$index : int
Return values
string

builtInFormatCodeIndex()

Get built-in format code index.

public static builtInFormatCodeIndex(string $formatCodeIndex) : false|int
Parameters
$formatCodeIndex : string
Return values
false|int

convertSystemFormats()

public static convertSystemFormats(string|null $formatCode) : string|null
Parameters
$formatCode : string|null
Return values
string|null

exportArray()

Export style as array.

public final exportArray() : array<string|int, mixed>

Available to anything which extends this class: Alignment, Border, Borders, Color, Fill, Font, NumberFormat, Protection, and Style.

Return values
array<string|int, mixed>

getActiveCell()

Get the currently active cell coordinate in currently active sheet.

public getActiveCell() : string

Only used for supervisor.

Return values
string

E.g. 'A1'

getBuiltInFormatCode()

Get Built-In Format Code.

public getBuiltInFormatCode() : false|int
Return values
false|int

getDateTimeFormat()

public static getDateTimeFormat() : string
Return values
string

getFormatCode()

Get Format Code.

public getFormatCode([bool $extended = false ]) : string|null
Parameters
$extended : bool = false
Return values
string|null

getHashCode()

Get hash code.

public getHashCode() : string
Return values
string

Hash code

getIsSupervisor()

Is this a supervisor or a cell style component?

public getIsSupervisor() : bool
Return values
bool

getLongDateFormat()

public static getLongDateFormat() : string
Return values
string

getSelectedCells()

Get the currently active cell coordinate in currently active sheet.

public getSelectedCells() : string

Only used for supervisor.

Return values
string

E.g. 'A1'

getSharedComponent()

Get the shared style component for the currently active cell in currently active sheet.

public getSharedComponent() : self

Only used for style supervisor.

Return values
self

getShortDateFormat()

public static getShortDateFormat() : string
Return values
string

getStyleArray()

Build style array from subcomponents.

public getStyleArray(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>
Return values
array<string|int, mixed>

getTimeFormat()

public static getTimeFormat() : string
Return values
string

setBuiltInFormatCode()

Set Built-In Format Code.

public setBuiltInFormatCode(int $formatCodeIndex) : $this
Parameters
$formatCodeIndex : int

Id of the built-in format code to use

Return values
$this

setDateTimeFormat()

public static setDateTimeFormat(string $dateTimeFormat) : void
Parameters
$dateTimeFormat : string

setFormatCode()

Set Format Code.

public setFormatCode(string $formatCode) : $this
Parameters
$formatCode : string

see self::FORMAT_*

Return values
$this

setLongDateFormat()

public static setLongDateFormat(string $longDateFormat) : void
Parameters
$longDateFormat : string

setShortDateFormat()

public static setShortDateFormat(string $shortDateFormat) : void
Parameters
$shortDateFormat : string

setTimeFormat()

public static setTimeFormat(string $timeFormat) : void
Parameters
$timeFormat : string

toFormattedString()

Convert a value in a pre-defined format to a PHP string.

public static toFormattedString(null|bool|float|int|RichText|string $value, string $format[, array<string|int, mixed>|null $callBack = null ]) : string
Parameters
$value : null|bool|float|int|RichText|string

Value to format

$format : string

Format code: see = self::FORMAT_* for predefined values; or can be any valid MS Excel custom format string

$callBack : array<string|int, mixed>|null = null

Callback function for additional formatting of string

Return values
string

Formatted string

exportArray1()

Abstract method to be implemented in anything which extends this class.

protected exportArray1() : array<string|int, mixed>

This method invokes exportArray2 with the names and values of all properties to be included in output array, returning that array to exportArray, then to caller.

Return values
array<string|int, mixed>

exportArray2()

Populate array from exportArray1.

protected final exportArray2(array<string|int, mixed> &$exportedArray, string $index, mixed $objOrValue) : void

This method is available to anything which extends this class. The parameter index is the key to be added to the array. The parameter objOrValue is either a primitive type, which is the value added to the array, or a Style object to be recursively added via exportArray.

Parameters
$exportedArray : array<string|int, mixed>
$index : string
$objOrValue : mixed

fillBuiltInFormatCodes()

Fill built-in format codes.

private static fillBuiltInFormatCodes() : void

        
On this page

Search results