123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace Util\PHPExcel\Cell;
- use Util\PHPExcel\RichText;
- use Util\PHPExcel\Shared\PHPExcelString;
- class DataType
- {
-
- const TYPE_STRING2 = 'str';
- const TYPE_STRING = 's';
- const TYPE_FORMULA = 'f';
- const TYPE_NUMERIC = 'n';
- const TYPE_BOOL = 'b';
- const TYPE_NULL = 'null';
- const TYPE_INLINE = 'inlineStr';
- const TYPE_ERROR = 'e';
-
- private static $errorCodes = array(
- '#NULL!' => 0,
- '#DIV/0!' => 1,
- '#VALUE!' => 2,
- '#REF!' => 3,
- '#NAME?' => 4,
- '#NUM!' => 5,
- '#N/A' => 6
- );
-
- public static function getErrorCodes()
- {
- return self::$errorCodes;
- }
-
- public static function dataTypeForValue($pValue = null)
- {
- return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
- }
-
- public static function checkString($pValue = null)
- {
- if ($pValue instanceof RichText) {
-
- return $pValue;
- }
-
- $pValue = PHPExcelString::Substring($pValue, 0, 32767);
-
- $pValue = str_replace(array("\r\n", "\r"), "\n", $pValue);
- return $pValue;
- }
-
- public static function checkErrorCode($pValue = null)
- {
- $pValue = (string) $pValue;
- if (!array_key_exists($pValue, self::$errorCodes)) {
- $pValue = '#NULL!';
- }
- return $pValue;
- }
- }
|