Constants

STRING_REGEXP_FRACTION

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

Properties

$controlCharacters

$controlCharacters : array<mixed,string>

Control characters array.

Type

array<mixed,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 : boolean

Is iconv extension avalable?

Type

boolean

$iconvOptions

$iconvOptions : string

iconv options.

Type

string

Methods

getIsIconvEnabled()

getIsIconvEnabled() : boolean

Get whether iconv extension is available.

Returns

boolean

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) : boolean

Check if a string contains UTF8 data.

Parameters

string $value

Returns

boolean

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<mixed,mixed>  $arrcRuns = array()) : 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<mixed,mixed> $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') : integer

Get character count.

Parameters

string $value
string $enc

Encoding

Returns

integer —

Character count

substring()

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

Get a substring of a UTF-8 encoded string.

Parameters

string $pValue

UTF-8 encoded string

integer $pStart

Start offset

integer $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(  $char) 

Parameters

$char

mbStrSplit()

mbStrSplit(  $string) 

Parameters

$string

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(  $operand) : boolean

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

Parameters

$operand

Returns

boolean

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) 

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) 

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) 

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() 

Build control characters array.

buildSYLKCharacters()

buildSYLKCharacters() 

Build SYLK characters array.

buildCharacterSets()

buildCharacterSets()