From 5a5e920444ee96182d9f99735a7bcb9b51d82287 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Sat, 11 Dec 2010 22:00:16 +0000 Subject: [PATCH] Allow cell value type attribute of "str" in Excel2007 xlsx files as a synonym for type of "s" git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@65165 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Cell.php | 5 +++++ Classes/PHPExcel/Cell/DataType.php | 1 + Classes/PHPExcel/Writer/Excel2007/StringTable.php | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Classes/PHPExcel/Cell.php b/Classes/PHPExcel/Cell.php index 94fff477..454de210 100644 --- a/Classes/PHPExcel/Cell.php +++ b/Classes/PHPExcel/Cell.php @@ -232,6 +232,8 @@ class PHPExcel_Cell { // set the value according to data type switch ($pDataType) { + case PHPExcel_Cell_DataType::TYPE_STRING2: + $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; case PHPExcel_Cell_DataType::TYPE_STRING: case PHPExcel_Cell_DataType::TYPE_NULL: case PHPExcel_Cell_DataType::TYPE_INLINE: @@ -343,6 +345,9 @@ class PHPExcel_Cell */ public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING) { + if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) + $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; + $this->_dataType = $pDataType; return $this->notifyCacheController(); diff --git a/Classes/PHPExcel/Cell/DataType.php b/Classes/PHPExcel/Cell/DataType.php index 944dba9b..7ee47e26 100644 --- a/Classes/PHPExcel/Cell/DataType.php +++ b/Classes/PHPExcel/Cell/DataType.php @@ -36,6 +36,7 @@ class PHPExcel_Cell_DataType { /* Data types */ + const TYPE_STRING2 = 'str'; const TYPE_STRING = 's'; const TYPE_FORMULA = 'f'; const TYPE_NUMERIC = 'n'; diff --git a/Classes/PHPExcel/Writer/Excel2007/StringTable.php b/Classes/PHPExcel/Writer/Excel2007/StringTable.php index 05e9da53..859cb7ea 100644 --- a/Classes/PHPExcel/Writer/Excel2007/StringTable.php +++ b/Classes/PHPExcel/Writer/Excel2007/StringTable.php @@ -66,7 +66,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr !isset($aFlippedStringTable[$cell->getValue()]) && !is_null($cell->getValue()) && $cell->getValue() !== '' && - ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_NULL) + ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING2 || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_NULL) ) { $aStringTable[] = $cell->getValue(); $aFlippedStringTable[$cell->getValue()] = 1;