4
* PHPExcel_Cell_DataType
6
* Copyright (c) 2006 - 2015 PHPExcel
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2.1 of the License, or (at your option) any later version.
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
* @package PHPExcel_Cell
24
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
25
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
26
* @version ##VERSION##, ##DATE##
28
class PHPExcel_Cell_DataType
31
const TYPE_STRING2 = 'str';
32
const TYPE_STRING = 's';
33
const TYPE_FORMULA = 'f';
34
const TYPE_NUMERIC = 'n';
35
const TYPE_BOOL = 'b';
36
const TYPE_NULL = 'null';
37
const TYPE_INLINE = 'inlineStr';
38
const TYPE_ERROR = 'e';
45
private static $errorCodes = array(
56
* Get list of error codes
60
public static function getErrorCodes()
62
return self::$errorCodes;
68
* @deprecated Replaced by PHPExcel_Cell_IValueBinder infrastructure, will be removed in version 1.8.0
69
* @param mixed $pValue
72
public static function dataTypeForValue($pValue = null)
74
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
78
* Check a string that it satisfies Excel requirements
80
* @param mixed Value to sanitize to an Excel string
81
* @return mixed Sanitized value
83
public static function checkString($pValue = null)
85
if ($pValue instanceof PHPExcel_RichText) {
86
// TODO: Sanitize Rich-Text string (max. character count is 32,767)
90
// string must never be longer than 32,767 characters, truncate if necessary
91
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767);
93
// we require that newline is represented as "\n" in core, not as "\r\n" or "\r"
94
$pValue = str_replace(array("\r\n", "\r"), "\n", $pValue);
100
* Check a value that it is a valid error code
102
* @param mixed Value to sanitize to an Excel error code
103
* @return string Sanitized value
105
public static function checkErrorCode($pValue = null)
107
$pValue = (string) $pValue;
109
if (!array_key_exists($pValue, self::$errorCodes)) {