Constants

STRING_REGEXP_FRACTION

STRING_REGEXP_FRACTION = '(-?)(\\d+)\\s+(\\d+\\/\\d+)'

Regular Expressions

Properties

$controlCharacters

$controlCharacters : string[]

Control characters array.

Type

string[]

$SYLKCharacters

$SYLKCharacters : array

SYLK Characters array.

Type

array

$decimalSeparator

$decimalSeparator : string

Decimal separator.

Type

string

$thousandsSeparator

$thousandsSeparator : string

Thousands separator.

Type

string

$currencyCode

$currencyCode : string

Currency code.

Type

string

$isIconvEnabled

$isIconvEnabled : bool

Is iconv extension avalable?

Type

bool

$iconvOptions

$iconvOptions : string

iconv options.

Type

string

Methods

getIsIconvEnabled()

getIsIconvEnabled() : bool

Get whether iconv extension is available.

Returns

bool —

controlCharacterOOXML2PHP()

controlCharacterOOXML2PHP(string  $value) : string

Convert from OpenXML escaped control character to PHP control character.

Excel 2007 team:

That's correct, control characters are stored directly in the shared-strings table. We do encode characters that cannot be represented in XML using the following escape sequence: xHHHH where H represents a hexadecimal character in the character's value... So you could end up with something like x0008 in a string (either in a cell value () element or in the shared string element.

Parameters

string $value

Value to unescape

Returns

string —

controlCharacterPHP2OOXML()

controlCharacterPHP2OOXML(string  $value) : string

Convert from PHP control character to OpenXML escaped control character.

Excel 2007 team:

That's correct, control characters are stored directly in the shared-strings table. We do encode characters that cannot be represented in XML using the following escape sequence: xHHHH where H represents a hexadecimal character in the character's value... So you could end up with something like x0008 in a string (either in a cell value () element or in the shared string element.

Parameters

string $value

Value to escape

Returns

string —

sanitizeUTF8()

sanitizeUTF8(string  $value) : string

Try to sanitize UTF8, stripping invalid byte sequences. Not perfect. Does not surrogate characters.

Parameters

string $value

Returns

string —

isUTF8()

isUTF8(string  $value) : bool

Check if a string contains UTF8 data.

Parameters

string $value

Returns

bool —

formatNumber()

formatNumber(mixed  $value) : string

Formats a numeric value as a string for output in various output writers forcing point as decimal separator in case locale is other than English.

Parameters

mixed $value

Returns

string —

UTF8toBIFF8UnicodeShort()

UTF8toBIFF8UnicodeShort(string  $value, array  $arrcRuns = []) : string

Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length) Writes the string using uncompressed notation, no rich text, no Asian phonetics If mbstring extension is not available, ASCII is assumed, and compressed notation is used although this will give wrong results for non-ASCII strings see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3.

Parameters

string $value

UTF-8 encoded string

array $arrcRuns

Details of rich text runs in $value

Returns

string —

UTF8toBIFF8UnicodeLong()

UTF8toBIFF8UnicodeLong(string  $value) : string

Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length) Writes the string using uncompressed notation, no rich text, no Asian phonetics If mbstring extension is not available, ASCII is assumed, and compressed notation is used although this will give wrong results for non-ASCII strings see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3.

Parameters

string $value

UTF-8 encoded string

Returns

string —

convertEncoding()

convertEncoding(string  $value, string  $to, string  $from) : string

Convert string from one encoding to another.

Parameters

string $value
string $to

Encoding to convert to, e.g. 'UTF-8'

string $from

Encoding to convert from, e.g. 'UTF-16LE'

Returns

string —

countCharacters()

countCharacters(string  $value, string  $enc = 'UTF-8') : int

Get character count.

Parameters

string $value
string $enc

Encoding

Returns

int —

Character count

substring()

substring(string  $pValue, int  $pStart, int  $pLength) : string

Get a substring of a UTF-8 encoded string.

Parameters

string $pValue

UTF-8 encoded string

int $pStart

Start offset

int $pLength

Maximum number of characters in substring

Returns

string —

strToUpper()

strToUpper(string  $pValue) : string

Convert a UTF-8 encoded string to upper case.

Parameters

string $pValue

UTF-8 encoded string

Returns

string —

strToLower()

strToLower(string  $pValue) : string

Convert a UTF-8 encoded string to lower case.

Parameters

string $pValue

UTF-8 encoded string

Returns

string —

strToTitle()

strToTitle(string  $pValue) : string

Convert a UTF-8 encoded string to title/proper case (uppercase every first character in each word, lower case all other characters).

Parameters

string $pValue

UTF-8 encoded string

Returns

string —

mbIsUpper()

mbIsUpper(mixed  $char) : mixed

Parameters

mixed $char

Returns

mixed —

mbStrSplit()

mbStrSplit(mixed  $string) : mixed

Parameters

mixed $string

Returns

mixed —

strCaseReverse()

strCaseReverse(string  $pValue) : string

Reverse the case of a string, so that all uppercase characters become lowercase and all lowercase characters become uppercase.

Parameters

string $pValue

UTF-8 encoded string

Returns

string —

convertToNumberIfFraction()

convertToNumberIfFraction(string  $operand) : bool

Identify whether a string contains a fractional numeric value, and convert it to a numeric if it is.

Parameters

string $operand

string value to test

Returns

bool —

getDecimalSeparator()

getDecimalSeparator() : string

Get the decimal separator. If it has not yet been set explicitly, try to obtain number formatting information from locale.

Returns

string —

setDecimalSeparator()

setDecimalSeparator(string  $pValue) : void

Set the decimal separator. Only used by NumberFormat::toFormattedString() to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf.

Parameters

string $pValue

Character for decimal separator

getThousandsSeparator()

getThousandsSeparator() : string

Get the thousands separator. If it has not yet been set explicitly, try to obtain number formatting information from locale.

Returns

string —

setThousandsSeparator()

setThousandsSeparator(string  $pValue) : void

Set the thousands separator. Only used by NumberFormat::toFormattedString() to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf.

Parameters

string $pValue

Character for thousands separator

getCurrencyCode()

getCurrencyCode() : string

Get the currency code. If it has not yet been set explicitly, try to obtain the symbol information from locale.

Returns

string —

setCurrencyCode()

setCurrencyCode(string  $pValue) : void

Set the currency code. Only used by NumberFormat::toFormattedString() to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf.

Parameters

string $pValue

Character for currency code

SYLKtoUTF8()

SYLKtoUTF8(string  $pValue) : string

Convert SYLK encoded string to UTF-8.

Parameters

string $pValue

Returns

string —

UTF-8 encoded string

testStringAsNumeric()

testStringAsNumeric(string  $value) : mixed

Retrieve any leading numeric part of a string, or return the full string if no leading numeric (handles basic integer or float, but not exponent or non decimal).

Parameters

string $value

Returns

mixed —

string or only the leading numeric part of the string

buildControlCharacters()

buildControlCharacters() : void

Build control characters array.

buildSYLKCharacters()

buildSYLKCharacters() : void

Build SYLK characters array.

buildCharacterSets()

buildCharacterSets() : void