class NumberFormat extends Supervisor (View source)

Constants

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

Properties

protected bool $isSupervisor Supervisor? from Supervisor
protected Spreadsheet|Style $parent Parent. Only used for supervisor. from Supervisor
protected null|string $parentPropertyName Parent property name. from Supervisor
static protected array $builtInFormats Excel built-in number formats.
static protected array $flippedBuiltInFormats Excel built-in number formats (flipped, for faster lookups).
protected string $formatCode Format Code.
protected string $builtInFormatCode Built-in format Code.

Methods

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

Create a new NumberFormat.

bindParent(Spreadsheet|Style $parent, null|string $parentPropertyName = null)

Bind parent. Only used for supervisor.

bool
getIsSupervisor()

Is this a supervisor or a cell style component?

getActiveSheet()

Get the currently active sheet. Only used for supervisor.

string
getSelectedCells()

Get the currently active cell coordinate in currently active sheet.

string
getActiveCell()

Get the currently active cell coordinate in currently active sheet.

__clone()

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

getSharedComponent()

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

array
getStyleArray(array $array)

Build style array from subcomponents.

applyFromArray(array $pStyles)

Apply styles from array.

string
getFormatCode()

Get Format Code.

setFormatCode(string $pValue)

Set Format Code.

int
getBuiltInFormatCode()

Get Built-In Format Code.

setBuiltInFormatCode(int $pValue)

Set Built-In Format Code.

static string
builtInFormatCode(int $pIndex)

Get built-in format code.

static bool|int
builtInFormatCodeIndex(string $formatCode)

Get built-in format code index.

string
getHashCode()

Get hash code.

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

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

Details

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

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

Supervisor bindParent(Spreadsheet|Style $parent, null|string $parentPropertyName = null)

Bind parent. Only used for supervisor.

Parameters

Spreadsheet|Style $parent
null|string $parentPropertyName

Return Value

Supervisor

bool getIsSupervisor()

Is this a supervisor or a cell style component?

Return Value

bool

Worksheet getActiveSheet()

Get the currently active sheet. Only used for supervisor.

Return Value

Worksheet

string getSelectedCells()

Get the currently active cell coordinate in currently active sheet.

Only used for supervisor.

Return Value

string E.g. 'A1'

string getActiveCell()

Get the currently active cell coordinate in currently active sheet.

Only used for supervisor.

Return Value

string E.g. 'A1'

__clone()

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

NumberFormat getSharedComponent()

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

Only used for style supervisor.

Return Value

NumberFormat

array getStyleArray(array $array)

Build style array from subcomponents.

Parameters

array $array

Return Value

array

NumberFormat applyFromArray(array $pStyles)

Apply styles from array.

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

Parameters

array $pStyles Array containing style information

Return Value

NumberFormat

Exceptions

Exception

string getFormatCode()

Get Format Code.

Return Value

string

NumberFormat setFormatCode(string $pValue)

Set Format Code.

Parameters

string $pValue see self::FORMAT_*

Return Value

NumberFormat

int getBuiltInFormatCode()

Get Built-In Format Code.

Return Value

int

NumberFormat setBuiltInFormatCode(int $pValue)

Set Built-In Format Code.

Parameters

int $pValue

Return Value

NumberFormat

static string builtInFormatCode(int $pIndex)

Get built-in format code.

Parameters

int $pIndex

Return Value

string

static bool|int builtInFormatCodeIndex(string $formatCode)

Get built-in format code index.

Parameters

string $formatCode

Return Value

bool|int

string getHashCode()

Get hash code.

Return Value

string Hash code

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

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

Return Value

string Formatted string