class PHPExcel_Shared_String

PHPExcelSharedString

Copyright (c) 2006 - 2015 PHPExcel

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Constants

STRING_REGEXP_FRACTION

Methods

static boolean
getIsMbstringEnabled()

Get whether mbstring extension is available

static boolean
getIsIconvEnabled()

Get whether iconv extension is available

static 
buildCharacterSets()

No description

static string
ControlCharacterOOXML2PHP(string $value = '')

Convert from OpenXML escaped control character to PHP control character

static string
ControlCharacterPHP2OOXML(string $value = '')

Convert from PHP control character to OpenXML escaped control character

static string
SanitizeUTF8(string $value)

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

static boolean
IsUTF8(string $value = '')

Check if a string contains UTF8 data

static string
FormatNumber(mixed $value)

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.

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

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

static string
UTF8toBIFF8UnicodeLong(string $value)

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

static string
ConvertEncoding(string $value, string $to, string $from)

Convert string from one encoding to another. First try mbstring, then iconv, finally strlen

static string
utf16_decode($str, $bom_be = true)

Decode UTF-16 encoded strings.

static int
CountCharacters(string $value, string $enc = 'UTF-8')

Get character count. First try mbstring, then iconv, finally strlen

static string
Substring(string $pValue = '', int $pStart, int $pLength)

Get a substring of a UTF-8 encoded string. First try mbstring, then iconv, finally strlen

static string
StrToUpper(string $pValue = '')

Convert a UTF-8 encoded string to upper case

static string
StrToLower(string $pValue = '')

Convert a UTF-8 encoded string to lower case

static string
StrToTitle(string $pValue = '')

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

static 
mb_is_upper($char)

No description

static 
mb_str_split($string)

No description

static string
StrCaseReverse(string $pValue = '')

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

static boolean
convertToNumberIfFraction(string $operand)

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

static string
getDecimalSeparator()

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

static 
setDecimalSeparator(string $pValue = '.')

Set the decimal separator. Only used by PHPExcelStyleNumberFormat::toFormattedString() to format output by PHPExcelWriterHTML and PHPExcelWriterPDF

static string
getThousandsSeparator()

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

static 
setThousandsSeparator(string $pValue = ',')

Set the thousands separator. Only used by PHPExcelStyleNumberFormat::toFormattedString() to format output by PHPExcelWriterHTML and PHPExcelWriterPDF

static string
getCurrencyCode()

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

static 
setCurrencyCode(string $pValue = '$')

Set the currency code. Only used by PHPExcelStyleNumberFormat::toFormattedString() to format output by PHPExcelWriterHTML and PHPExcelWriterPDF

static string
SYLKtoUTF8(string $pValue = '')

Convert SYLK encoded string to UTF-8

static mixed
testStringAsNumeric(string $value)

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)

Details

at line 278
static boolean getIsMbstringEnabled()

Get whether mbstring extension is available

Return Value

boolean

at line 295
static boolean getIsIconvEnabled()

Get whether iconv extension is available

Return Value

boolean

at line 331
static buildCharacterSets()

at line 355
static string ControlCharacterOOXML2PHP(string $value = '')

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

Return Value

string

at line 374
static string ControlCharacterPHP2OOXML(string $value = '')

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

Return Value

string

at line 385
static string SanitizeUTF8(string $value)

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

Parameters

string $value

Return Value

string

at line 407
static boolean IsUTF8(string $value = '')

Check if a string contains UTF8 data

Parameters

string $value

Return Value

boolean

at line 419
static string FormatNumber(mixed $value)

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

Return Value

string

at line 438
static string UTF8toBIFF8UnicodeShort(string $value, mixed[] $arrcRuns = array())

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
mixed[] $arrcRuns Details of rich text runs in $value

Return Value

string

at line 472
static string UTF8toBIFF8UnicodeLong(string $value)

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

Return Value

string

at line 496
static string ConvertEncoding(string $value, string $to, string $from)

Convert string from one encoding to another. First try mbstring, then iconv, finally strlen

Parameters

string $value
string $to Encoding to convert to, e.g. 'UTF-8'
string $from Encoding to convert from, e.g. 'UTF-16LE'

Return Value

string

at line 530
static string utf16_decode($str, $bom_be = true)

Decode UTF-16 encoded strings.

Can handle both BOM'ed data and un-BOM'ed data. Assumes Big-Endian byte order if no BOM is available. This function was taken from http://php.net/manual/en/function.utf8-decode.php and $bom_be parameter added.

Parameters

$str
$bom_be

Return Value

string UTF-8 / ISO encoded data.

at line 565
static int CountCharacters(string $value, string $enc = 'UTF-8')

Get character count. First try mbstring, then iconv, finally strlen

Parameters

string $value
string $enc Encoding

Return Value

int Character count

at line 587
static string Substring(string $pValue = '', int $pStart, int $pLength)

Get a substring of a UTF-8 encoded string. First try mbstring, then iconv, finally strlen

Parameters

string $pValue UTF-8 encoded string
int $pStart Start offset
int $pLength Maximum number of characters in substring

Return Value

string

at line 607
static string StrToUpper(string $pValue = '')

Convert a UTF-8 encoded string to upper case

Parameters

string $pValue UTF-8 encoded string

Return Value

string

at line 621
static string StrToLower(string $pValue = '')

Convert a UTF-8 encoded string to lower case

Parameters

string $pValue UTF-8 encoded string

Return Value

string

at line 636
static string StrToTitle(string $pValue = '')

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

Return Value

string

at line 644
static mb_is_upper($char)

Parameters

$char

at line 649
static mb_str_split($string)

Parameters

$string

at line 663
static string StrCaseReverse(string $pValue = '')

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

Return Value

string

at line 686
static boolean convertToNumberIfFraction(string $operand)

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

Parameters

string $operand &$operand string value to test

Return Value

boolean

at line 703
static string getDecimalSeparator()

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

Return Value

string

at line 724
static setDecimalSeparator(string $pValue = '.')

Set the decimal separator. Only used by PHPExcelStyleNumberFormat::toFormattedString() to format output by PHPExcelWriterHTML and PHPExcelWriterPDF

Parameters

string $pValue Character for decimal separator

at line 735
static string getThousandsSeparator()

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

Return Value

string

at line 756
static setThousandsSeparator(string $pValue = ',')

Set the thousands separator. Only used by PHPExcelStyleNumberFormat::toFormattedString() to format output by PHPExcelWriterHTML and PHPExcelWriterPDF

Parameters

string $pValue Character for thousands separator

at line 767
static string getCurrencyCode()

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

Return Value

string

at line 788
static setCurrencyCode(string $pValue = '$')

Set the currency code. Only used by PHPExcelStyleNumberFormat::toFormattedString() to format output by PHPExcelWriterHTML and PHPExcelWriterPDF

Parameters

string $pValue Character for currency code

at line 799
static string SYLKtoUTF8(string $pValue = '')

Convert SYLK encoded string to UTF-8

Parameters

string $pValue

Return Value

string UTF-8 encoded string

at line 820
static mixed testStringAsNumeric(string $value)

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

Return Value

mixed string or only the leading numeric part of the string