\PhpOffice\PhpSpreadsheet\StyleNumberFormat

Summary

Methods
Properties
Constants
__construct()
bindParent()
getIsSupervisor()
getActiveSheet()
getSelectedCells()
getActiveCell()
__clone()
getSharedComponent()
getStyleArray()
applyFromArray()
getFormatCode()
setFormatCode()
getBuiltInFormatCode()
setBuiltInFormatCode()
builtInFormatCode()
builtInFormatCodeIndex()
getHashCode()
toFormattedString()
No public properties found
FORMAT_GENERAL
FORMAT_TEXT
FORMAT_NUMBER
FORMAT_NUMBER_00
FORMAT_NUMBER_COMMA_SEPARATED1
FORMAT_NUMBER_COMMA_SEPARATED2
FORMAT_PERCENTAGE
FORMAT_PERCENTAGE_00
FORMAT_DATE_YYYYMMDD2
FORMAT_DATE_YYYYMMDD
FORMAT_DATE_DDMMYYYY
FORMAT_DATE_DMYSLASH
FORMAT_DATE_DMYMINUS
FORMAT_DATE_DMMINUS
FORMAT_DATE_MYMINUS
FORMAT_DATE_XLSX14
FORMAT_DATE_XLSX15
FORMAT_DATE_XLSX16
FORMAT_DATE_XLSX17
FORMAT_DATE_XLSX22
FORMAT_DATE_DATETIME
FORMAT_DATE_TIME1
FORMAT_DATE_TIME2
FORMAT_DATE_TIME3
FORMAT_DATE_TIME4
FORMAT_DATE_TIME5
FORMAT_DATE_TIME6
FORMAT_DATE_TIME7
FORMAT_DATE_TIME8
FORMAT_DATE_YYYYMMDDSLASH
FORMAT_CURRENCY_USD_SIMPLE
FORMAT_CURRENCY_USD
FORMAT_CURRENCY_EUR_SIMPLE
FORMAT_CURRENCY_EUR
FORMAT_ACCOUNTING_USD
FORMAT_ACCOUNTING_EUR
No protected methods found
$isSupervisor
$parent
$parentPropertyName
$builtInFormats
$flippedBuiltInFormats
$formatCode
$builtInFormatCode
N/A
fillBuiltInFormatCodes()
setLowercaseCallback()
escapeQuotesCallback()
formatAsDate()
formatAsPercentage()
formatAsFraction()
complexNumberFormatMask()
$dateFormatReplacements
$dateFormatReplacements24
$dateFormatReplacements12
N/A

Constants

FORMAT_GENERAL

FORMAT_GENERAL = 'General'

FORMAT_TEXT

FORMAT_TEXT = '@'

FORMAT_NUMBER

FORMAT_NUMBER = '0'

FORMAT_NUMBER_00

FORMAT_NUMBER_00 = '0.00'

FORMAT_NUMBER_COMMA_SEPARATED1

FORMAT_NUMBER_COMMA_SEPARATED1 = '#,##0.00'

FORMAT_NUMBER_COMMA_SEPARATED2

FORMAT_NUMBER_COMMA_SEPARATED2 = '#,##0.00_-'

FORMAT_PERCENTAGE

FORMAT_PERCENTAGE = '0%'

FORMAT_PERCENTAGE_00

FORMAT_PERCENTAGE_00 = '0.00%'

FORMAT_DATE_YYYYMMDD2

FORMAT_DATE_YYYYMMDD2 = 'yyyy-mm-dd'

FORMAT_DATE_YYYYMMDD

FORMAT_DATE_YYYYMMDD = 'yy-mm-dd'

FORMAT_DATE_DDMMYYYY

FORMAT_DATE_DDMMYYYY = 'dd/mm/yy'

FORMAT_DATE_DMYSLASH

FORMAT_DATE_DMYSLASH = 'd/m/yy'

FORMAT_DATE_DMYMINUS

FORMAT_DATE_DMYMINUS = 'd-m-yy'

FORMAT_DATE_DMMINUS

FORMAT_DATE_DMMINUS = 'd-m'

FORMAT_DATE_MYMINUS

FORMAT_DATE_MYMINUS = 'm-yy'

FORMAT_DATE_XLSX14

FORMAT_DATE_XLSX14 = 'mm-dd-yy'

FORMAT_DATE_XLSX15

FORMAT_DATE_XLSX15 = 'd-mmm-yy'

FORMAT_DATE_XLSX16

FORMAT_DATE_XLSX16 = 'd-mmm'

FORMAT_DATE_XLSX17

FORMAT_DATE_XLSX17 = 'mmm-yy'

FORMAT_DATE_XLSX22

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

FORMAT_DATE_DATETIME

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

FORMAT_DATE_TIME1

FORMAT_DATE_TIME1 = 'h:mm AM/PM'

FORMAT_DATE_TIME2

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

FORMAT_DATE_TIME3

FORMAT_DATE_TIME3 = 'h:mm'

FORMAT_DATE_TIME4

FORMAT_DATE_TIME4 = 'h:mm:ss'

FORMAT_DATE_TIME5

FORMAT_DATE_TIME5 = 'mm:ss'

FORMAT_DATE_TIME6

FORMAT_DATE_TIME6 = 'h:mm:ss'

FORMAT_DATE_TIME7

FORMAT_DATE_TIME7 = 'i:s.S'

FORMAT_DATE_TIME8

FORMAT_DATE_TIME8 = 'h:mm:ss;@'

FORMAT_DATE_YYYYMMDDSLASH

FORMAT_DATE_YYYYMMDDSLASH = 'yy/mm/dd;@'

FORMAT_CURRENCY_USD_SIMPLE

FORMAT_CURRENCY_USD_SIMPLE = '"$"#,##0.00_-'

FORMAT_CURRENCY_USD

FORMAT_CURRENCY_USD = '$#,##0_-'

FORMAT_CURRENCY_EUR_SIMPLE

FORMAT_CURRENCY_EUR_SIMPLE = '#,##0.00_-"€"'

FORMAT_CURRENCY_EUR

FORMAT_CURRENCY_EUR = '#,##0_-"€"'

FORMAT_ACCOUNTING_USD

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

FORMAT_ACCOUNTING_EUR

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

Properties

$isSupervisor

$isSupervisor : bool

Supervisor?

Type

bool

$parent

$parent : \PhpOffice\PhpSpreadsheet\Spreadsheet|\PhpOffice\PhpSpreadsheet\Style\Style

Parent. Only used for supervisor.

Type

Style

$parentPropertyName

$parentPropertyName : null|string

Parent property name.

Type

null|string

$builtInFormats

$builtInFormats : array

Excel built-in number formats.

Type

array

$flippedBuiltInFormats

$flippedBuiltInFormats : array

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

Type

array

$formatCode

$formatCode : string

Format Code.

Type

string

$builtInFormatCode

$builtInFormatCode : string

Built-in format Code.

Type

string

$dateFormatReplacements

$dateFormatReplacements : array

Search/replace values to convert Excel date/time format masks to PHP format masks.

Type

array

$dateFormatReplacements24

$dateFormatReplacements24 : array

Search/replace values to convert Excel date/time format masks hours to PHP format masks (24 hr clock).

Type

array

$dateFormatReplacements12

$dateFormatReplacements12 : array

Search/replace values to convert Excel date/time format masks hours to PHP format masks (12 hr clock).

Type

array

Methods

__construct()

__construct(bool  $isSupervisor = false, bool  $isConditional = false) : mixed

Create a new NumberFormat.

Parameters

bool $isSupervisor

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

bool $isConditional

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

Returns

mixed —

bindParent()

bindParent(\PhpOffice\PhpSpreadsheet\Spreadsheet|\PhpOffice\PhpSpreadsheet\Style\Style  $parent, null|string  $parentPropertyName = null) : \PhpOffice\PhpSpreadsheet\Style\Supervisor

Bind parent. Only used for supervisor.

Parameters

\PhpOffice\PhpSpreadsheet\Spreadsheet|\PhpOffice\PhpSpreadsheet\Style\Style $parent
null|string $parentPropertyName

Returns

\PhpOffice\PhpSpreadsheet\Style\Supervisor —

getIsSupervisor()

getIsSupervisor() : bool

Is this a supervisor or a cell style component?

Returns

bool —

getActiveSheet()

getActiveSheet() : \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet

Get the currently active sheet. Only used for supervisor.

Returns

\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet —

getSelectedCells()

getSelectedCells() : string

Get the currently active cell coordinate in currently active sheet.

Only used for supervisor.

Returns

string —

E.g. 'A1'

getActiveCell()

getActiveCell() : string

Get the currently active cell coordinate in currently active sheet.

Only used for supervisor.

Returns

string —

E.g. 'A1'

__clone()

__clone() : mixed

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

Returns

mixed —

getSharedComponent()

getSharedComponent() : \PhpOffice\PhpSpreadsheet\Style\NumberFormat

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

Only used for style supervisor.

Returns

\PhpOffice\PhpSpreadsheet\Style\NumberFormat —

getStyleArray()

getStyleArray(array  $array) : array

Build style array from subcomponents.

Parameters

array $array

Returns

array —

applyFromArray()

applyFromArray(array  $pStyles) : \PhpOffice\PhpSpreadsheet\Style\NumberFormat

Apply styles from array.

$spreadsheet->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray( [ 'formatCode' => NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE ] );

Parameters

array $pStyles

Array containing style information

Throws

\PhpOffice\PhpSpreadsheet\Exception

Returns

\PhpOffice\PhpSpreadsheet\Style\NumberFormat —

getFormatCode()

getFormatCode() : string

Get Format Code.

Returns

string —

setFormatCode()

setFormatCode(string  $pValue) : \PhpOffice\PhpSpreadsheet\Style\NumberFormat

Set Format Code.

Parameters

string $pValue

see self::FORMAT_*

Returns

\PhpOffice\PhpSpreadsheet\Style\NumberFormat —

getBuiltInFormatCode()

getBuiltInFormatCode() : int

Get Built-In Format Code.

Returns

int —

setBuiltInFormatCode()

setBuiltInFormatCode(int  $pValue) : \PhpOffice\PhpSpreadsheet\Style\NumberFormat

Set Built-In Format Code.

Parameters

int $pValue

Returns

\PhpOffice\PhpSpreadsheet\Style\NumberFormat —

builtInFormatCode()

builtInFormatCode(int  $pIndex) : string

Get built-in format code.

Parameters

int $pIndex

Returns

string —

builtInFormatCodeIndex()

builtInFormatCodeIndex(string  $formatCode) : bool|int

Get built-in format code index.

Parameters

string $formatCode

Returns

bool|int —

getHashCode()

getHashCode() : string

Get hash code.

Returns

string —

Hash code

toFormattedString()

toFormattedString(mixed  $value, string  $format, array  $callBack = null) : string

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

Parameters

mixed $value

Value to format

string $format

Format code, see = self::FORMAT_*

array $callBack

Callback function for additional formatting of string

Returns

string —

Formatted string

fillBuiltInFormatCodes()

fillBuiltInFormatCodes() : mixed

Fill built-in format codes.

Returns

mixed —

setLowercaseCallback()

setLowercaseCallback(mixed  $matches) : mixed

Parameters

mixed $matches

Returns

mixed —

escapeQuotesCallback()

escapeQuotesCallback(mixed  $matches) : mixed

Parameters

mixed $matches

Returns

mixed —

formatAsDate()

formatAsDate(mixed  $value, mixed  $format) : mixed

Parameters

mixed $value
mixed $format

Returns

mixed —

formatAsPercentage()

formatAsPercentage(mixed  $value, mixed  $format) : mixed

Parameters

mixed $value
mixed $format

Returns

mixed —

formatAsFraction()

formatAsFraction(mixed  $value, mixed  $format) : mixed

Parameters

mixed $value
mixed $format

Returns

mixed —

complexNumberFormatMask()

complexNumberFormatMask(mixed  $number, mixed  $mask) : mixed

Parameters

mixed $number
mixed $mask

Returns

mixed —