diff --git a/Classes/PHPExcel/Reader/CSV.php b/Classes/PHPExcel/Reader/CSV.php index d4fefd5..c8c5fbb 100644 --- a/Classes/PHPExcel/Reader/CSV.php +++ b/Classes/PHPExcel/Reader/CSV.php @@ -95,7 +95,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R /** * Create a new PHPExcel_Reader_CSV */ - public function __construct() { + public function __construct() + { $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); } @@ -106,7 +107,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R */ protected function _isValidFormat() { - return TRUE; + return true; } /** @@ -175,7 +176,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R // Open file $this->_openFile($pFilename); if (!$this->_isValidFormat()) { - fclose ($this->_fileHandle); + fclose($this->_fileHandle); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } $fileHandle = $this->_fileHandle; @@ -193,7 +194,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R $worksheetInfo[0]['totalColumns'] = 0; // Loop through each line of the file in turn - while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) { + while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== false) { $worksheetInfo[0]['totalRows']++; $worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1); } @@ -239,7 +240,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R // Open file $this->_openFile($pFilename); if (!$this->_isValidFormat()) { - fclose ($this->_fileHandle); + fclose($this->_fileHandle); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); } $fileHandle = $this->_fileHandle; @@ -264,7 +265,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R } // Loop through each line of the file in turn - while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) { + while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== false) { $columnLetter = 'A'; foreach ($rowData as $rowDatum) { if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) { @@ -302,7 +303,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * * @return string */ - public function getDelimiter() { + public function getDelimiter() + { return $this->_delimiter; } @@ -312,7 +314,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * @param string $pValue Delimiter, defaults to , * @return PHPExcel_Reader_CSV */ - public function setDelimiter($pValue = ',') { + public function setDelimiter($pValue = ',') + { $this->_delimiter = $pValue; return $this; } @@ -322,7 +325,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * * @return string */ - public function getEnclosure() { + public function getEnclosure() + { return $this->_enclosure; } @@ -332,7 +336,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * @param string $pValue Enclosure, defaults to " * @return PHPExcel_Reader_CSV */ - public function setEnclosure($pValue = '"') { + public function setEnclosure($pValue = '"') + { if ($pValue == '') { $pValue = '"'; } @@ -345,7 +350,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * * @return integer */ - public function getSheetIndex() { + public function getSheetIndex() + { return $this->_sheetIndex; } @@ -355,7 +361,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * @param integer $pValue Sheet index * @return PHPExcel_Reader_CSV */ - public function setSheetIndex($pValue = 0) { + public function setSheetIndex($pValue = 0) + { $this->_sheetIndex = $pValue; return $this; } @@ -365,7 +372,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * * @param boolean $contiguous */ - public function setContiguous($contiguous = FALSE) + public function setContiguous($contiguous = false) { $this->_contiguous = (bool) $contiguous; if (!$contiguous) { @@ -380,8 +387,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R * * @return boolean */ - public function getContiguous() { + public function getContiguous(){ return $this->_contiguous; } - } diff --git a/Classes/PHPExcel/Reader/DefaultReadFilter.php b/Classes/PHPExcel/Reader/DefaultReadFilter.php index 7caf260..2e06dcb 100644 --- a/Classes/PHPExcel/Reader/DefaultReadFilter.php +++ b/Classes/PHPExcel/Reader/DefaultReadFilter.php @@ -52,7 +52,8 @@ class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter * @param $worksheetName Optional worksheet name * @return boolean */ - public function readCell($column, $row, $worksheetName = '') { + public function readCell($column, $row, $worksheetName = '') + { return true; } } diff --git a/Classes/PHPExcel/Reader/Excel2003XML.php b/Classes/PHPExcel/Reader/Excel2003XML.php index e66ee1f..29720aa 100644 --- a/Classes/PHPExcel/Reader/Excel2003XML.php +++ b/Classes/PHPExcel/Reader/Excel2003XML.php @@ -239,7 +239,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P return $this->loadIntoExisting($pFilename, $objPHPExcel); } - protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) + protected static function identifyFixedStyleValue($styleList, &$styleAttributeValue) { $styleAttributeValue = strtolower($styleAttributeValue); foreach ($styleList as $style) { @@ -251,18 +251,18 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P return false; } - /** - * pixel units to excel width units(units of 1/256th of a character width) - * @param pxs - * @return - */ - protected static function _pixel2WidthUnits($pxs) - { - $UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219); + /** + * pixel units to excel width units(units of 1/256th of a character width) + * @param pxs + * @return + */ + protected static function _pixel2WidthUnits($pxs) + { + $UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219); - $widthUnits = 256 * ($pxs / 7); - $widthUnits += $UNIT_OFFSET_MAP[($pxs % 7)]; - return $widthUnits; + $widthUnits = 256 * ($pxs / 7); + $widthUnits += $UNIT_OFFSET_MAP[($pxs % 7)]; + return $widthUnits; } /** @@ -337,39 +337,39 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P if (isset($xml->DocumentProperties[0])) { foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) { switch ($propertyName) { - case 'Title' : + case 'Title': $docProps->setTitle(self::_convertStringEncoding($propertyValue, $this->_charSet)); break; - case 'Subject' : + case 'Subject': $docProps->setSubject(self::_convertStringEncoding($propertyValue, $this->_charSet)); break; - case 'Author' : + case 'Author': $docProps->setCreator(self::_convertStringEncoding($propertyValue, $this->_charSet)); break; - case 'Created' : + case 'Created': $creationDate = strtotime($propertyValue); $docProps->setCreated($creationDate); break; - case 'LastAuthor' : + case 'LastAuthor': $docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue, $this->_charSet)); break; - case 'LastSaved' : + case 'LastSaved': $lastSaveDate = strtotime($propertyValue); $docProps->setModified($lastSaveDate); break; - case 'Company' : + case 'Company': $docProps->setCompany(self::_convertStringEncoding($propertyValue, $this->_charSet)); break; - case 'Category' : + case 'Category': $docProps->setCategory(self::_convertStringEncoding($propertyValue, $this->_charSet)); break; - case 'Manager' : + case 'Manager': $docProps->setManager(self::_convertStringEncoding($propertyValue, $this->_charSet)); break; - case 'Keywords' : + case 'Keywords': $docProps->setKeywords(self::_convertStringEncoding($propertyValue, $this->_charSet)); break; - case 'Description' : + case 'Description': $docProps->setDescription(self::_convertStringEncoding($propertyValue, $this->_charSet)); break; } @@ -378,26 +378,26 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P if (isset($xml->CustomDocumentProperties)) { foreach ($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) { $propertyAttributes = $propertyValue->attributes($namespaces['dt']); - $propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/','PHPExcel_Reader_Excel2003XML::_hex2str', $propertyName); + $propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/', 'PHPExcel_Reader_Excel2003XML::_hex2str', $propertyName); $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN; switch ((string) $propertyAttributes) { - case 'string' : + case 'string': $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; $propertyValue = trim($propertyValue); break; - case 'boolean' : + case 'boolean': $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; $propertyValue = (bool) $propertyValue; break; - case 'integer' : + case 'integer': $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_INTEGER; $propertyValue = intval($propertyValue); break; - case 'float' : + case 'float': $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; $propertyValue = floatval($propertyValue); break; - case 'dateTime.tz' : + case 'dateTime.tz': $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; $propertyValue = strtotime(trim($propertyValue)); break; @@ -419,46 +419,46 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P $styleAttributes = $styleData->attributes($namespaces['ss']); // echo $styleType.'
'; switch ($styleType) { - case 'Alignment' : + case 'Alignment': foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { // echo $styleAttributeKey.' = '.$styleAttributeValue.'
'; $styleAttributeValue = (string) $styleAttributeValue; switch ($styleAttributeKey) { - case 'Vertical' : + case 'Vertical': if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) { $this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue; } break; - case 'Horizontal' : + case 'Horizontal': if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) { $this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue; } break; - case 'WrapText' : + case 'WrapText': $this->_styles[$styleID]['alignment']['wrap'] = true; break; } } break; - case 'Borders' : + case 'Borders': foreach ($styleData->Border as $borderStyle) { $borderAttributes = $borderStyle->attributes($namespaces['ss']); $thisBorder = array(); foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) { // echo $borderStyleKey.' = '.$borderStyleValue.'
'; switch ($borderStyleKey) { - case 'LineStyle' : + case 'LineStyle': $thisBorder['style'] = PHPExcel_Style_Border::BORDER_MEDIUM; // $thisBorder['style'] = $borderStyleValue; break; - case 'Weight' : + case 'Weight': // $thisBorder['style'] = $borderStyleValue; break; - case 'Position' : + case 'Position': $borderPosition = strtolower($borderStyleValue); break; - case 'Color' : - $borderColour = substr($borderStyleValue,1); + case 'Color': + $borderColour = substr($borderStyleValue, 1); $thisBorder['color']['rgb'] = $borderColour; break; } @@ -470,27 +470,27 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P } } break; - case 'Font' : + case 'Font': foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { // echo $styleAttributeKey.' = '.$styleAttributeValue.'
'; $styleAttributeValue = (string) $styleAttributeValue; switch ($styleAttributeKey) { - case 'FontName' : + case 'FontName': $this->_styles[$styleID]['font']['name'] = $styleAttributeValue; break; - case 'Size' : + case 'Size': $this->_styles[$styleID]['font']['size'] = $styleAttributeValue; break; - case 'Color' : - $this->_styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue,1); + case 'Color': + $this->_styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue, 1); break; - case 'Bold' : + case 'Bold': $this->_styles[$styleID]['font']['bold'] = true; break; - case 'Italic' : + case 'Italic': $this->_styles[$styleID]['font']['italic'] = true; break; - case 'Underline' : + case 'Underline': if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) { $this->_styles[$styleID]['font']['underline'] = $styleAttributeValue; } @@ -498,22 +498,22 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P } } break; - case 'Interior' : + case 'Interior': foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { // echo $styleAttributeKey.' = '.$styleAttributeValue.'
'; switch ($styleAttributeKey) { - case 'Color' : - $this->_styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue,1); + case 'Color': + $this->_styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue, 1); break; } } break; - case 'NumberFormat' : + case 'NumberFormat': foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { // echo $styleAttributeKey.' = '.$styleAttributeValue.'
'; $styleAttributeValue = str_replace($fromFormats, $toFormats, $styleAttributeValue); switch ($styleAttributeValue) { - case 'Short Date' : + case 'Short Date': $styleAttributeValue = 'dd/mm/yyyy'; break; } @@ -522,7 +522,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P } } break; - case 'Protection' : + case 'Protection': foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { // echo $styleAttributeKey.' = '.$styleAttributeValue.'
'; } @@ -555,7 +555,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in // formula cells... during the load, all formulae should be correct, and we're simply bringing // the worksheet name in line with the formula, not the reverse - $objPHPExcel->getActiveSheet()->setTitle($worksheetName,false); + $objPHPExcel->getActiveSheet()->setTitle($worksheetName, false); } $columnID = 'A'; @@ -640,26 +640,26 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P const TYPE_INLINE = 'inlineStr'; const TYPE_ERROR = 'e'; */ - case 'String' : + case 'String': $cellValue = self::_convertStringEncoding($cellValue, $this->_charSet); $type = PHPExcel_Cell_DataType::TYPE_STRING; break; - case 'Number' : + case 'Number': $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $cellValue = (float) $cellValue; if (floor($cellValue) == $cellValue) { $cellValue = (integer) $cellValue; } break; - case 'Boolean' : + case 'Boolean': $type = PHPExcel_Cell_DataType::TYPE_BOOL; $cellValue = ($cellValue != 0); break; - case 'DateTime' : + case 'DateTime': $type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $cellValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellValue)); break; - case 'Error' : + case 'Error': $type = PHPExcel_Cell_DataType::TYPE_ERROR; break; } @@ -669,15 +669,15 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P // echo 'FORMULA
'; $type = PHPExcel_Cell_DataType::TYPE_FORMULA; $columnNumber = PHPExcel_Cell::columnIndexFromString($columnID); - if (substr($cellDataFormula,0,3) == 'of:') { - $cellDataFormula = substr($cellDataFormula,3); + if (substr($cellDataFormula, 0, 3) == 'of:') { + $cellDataFormula = substr($cellDataFormula, 3); // echo 'Before: ', $cellDataFormula,'
'; $temp = explode('"', $cellDataFormula); $key = false; foreach ($temp as &$value) { // Only replace in alternate array entries (i.e. non-quoted blocks) if ($key = !$key) { - $value = str_replace(array('[.','.',']'),'', $value); + $value = str_replace(array('[.', '.', ']'), '', $value); } } } else { @@ -688,7 +688,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P foreach ($temp as &$value) { // Only replace in alternate array entries (i.e. non-quoted blocks) if ($key = !$key) { - preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE); + preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences, PREG_SET_ORDER + PREG_OFFSET_CAPTURE); // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way // through the formula from left to right. Reversing means that we work right to left.through // the formula @@ -703,7 +703,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P } // Bracketed R references are relative to the current row if ($rowReference{0} == '[') { - $rowReference = $rowID + trim($rowReference,'[]'); + $rowReference = $rowID + trim($rowReference, '[]'); } $columnReference = $cellReference[4][0]; // Empty C reference is the current column @@ -712,10 +712,10 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P } // Bracketed C references are relative to the current column if ($columnReference{0} == '[') { - $columnReference = $columnNumber + trim($columnReference,'[]'); + $columnReference = $columnNumber + trim($columnReference, '[]'); } $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; - $value = substr_replace($value, $A1CellReference, $cellReference[0][1],strlen($cellReference[0][0])); + $value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0])); } } } @@ -749,7 +749,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P // echo $annotation,'
'; $annotation = strip_tags($node); // echo 'Annotation: ', $annotation,'
'; - $objPHPExcel->getActiveSheet()->getComment($columnID.$rowID)->setAuthor(self::_convertStringEncoding($author , $this->_charSet))->setText($this->_parseRichText($annotation) ); + $objPHPExcel->getActiveSheet()->getComment($columnID.$rowID)->setAuthor(self::_convertStringEncoding($author, $this->_charSet))->setText($this->_parseRichText($annotation)); } if (($cellIsSet) && (isset($cell_ss['StyleID']))) { diff --git a/Classes/PHPExcel/Reader/Excel2007.php b/Classes/PHPExcel/Reader/Excel2007.php index 9e62a85..f59d310 100644 --- a/Classes/PHPExcel/Reader/Excel2007.php +++ b/Classes/PHPExcel/Reader/Excel2007.php @@ -49,25 +49,24 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE * * @var PHPExcel_ReferenceHelper */ - private $_referenceHelper = NULL; + private $_referenceHelper = null; /** * PHPExcel_Reader_Excel2007_Theme instance * * @var PHPExcel_Reader_Excel2007_Theme */ - private static $_theme = NULL; - + private static $_theme = null; /** * Create a new PHPExcel_Reader_Excel2007 instance */ - public function __construct() { + public function __construct() + { $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance(); } - /** * Can the current PHPExcel_Reader_IReader read the file? * @@ -85,7 +84,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $zipClass = PHPExcel_Settings::getZipClass(); // Check if zip class exists -// if (!class_exists($zipClass, FALSE)) { +// if (!class_exists($zipClass, false)) { // throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled"); // } @@ -240,39 +239,39 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE return $worksheetInfo; } - - private static function _castToBool($c) { + private static function _castToBool($c) + { // echo 'Initial Cast to Boolean', PHP_EOL; - $value = isset($c->v) ? (string) $c->v : NULL; + $value = isset($c->v) ? (string) $c->v : null; if ($value == '0') { - return FALSE; + return false; } elseif ($value == '1') { - return TRUE; + return true; } else { return (bool)$c->v; } return $value; } // function _castToBool() - - private static function _castToError($c) { + private static function _castToError($c) + { // echo 'Initial Cast to Error', PHP_EOL; - return isset($c->v) ? (string) $c->v : NULL; + return isset($c->v) ? (string) $c->v : null; } // function _castToError() - - private static function _castToString($c) { + private static function _castToString($c) + { // echo 'Initial Cast to String, PHP_EOL; - return isset($c->v) ? (string) $c->v : NULL; + return isset($c->v) ? (string) $c->v : null; } // function _castToString() - - private function _castToFormula($c, $r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas, $castBaseType) { + private function _castToFormula($c, $r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas, $castBaseType) + { // echo 'Formula', PHP_EOL; // echo '$c->f is ', $c->f, PHP_EOL; - $cellDataType = 'f'; - $value = "={$c->f}"; - $calculatedValue = self::$castBaseType($c); + $cellDataType = 'f'; + $value = "={$c->f}"; + $calculatedValue = self::$castBaseType($c); // Shared formula? if (isset($c->f['t']) && strtolower((string)$c->f['t']) == 'shared') { @@ -287,9 +286,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // echo 'SETTING NEW SHARED FORMULA', PHP_EOL; // echo 'Master is ', $r, PHP_EOL; // echo 'Formula is ', $value, PHP_EOL; - $sharedFormulas[$instance] = array( 'master' => $r, - 'formula' => $value - ); + $sharedFormulas[$instance] = array('master' => $r, 'formula' => $value); // echo 'New Shared Formula Array:', PHP_EOL; // print_r($sharedFormulas); } else { @@ -303,11 +300,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $difference[0] = PHPExcel_Cell::columnIndexFromString($current[0]) - PHPExcel_Cell::columnIndexFromString($master[0]); $difference[1] = $current[1] - $master[1]; - $value = $this->_referenceHelper->updateFormulaReferences( $sharedFormulas[$instance]['formula'], - 'A1', - $difference[0], - $difference[1] - ); + $value = $this->_referenceHelper->updateFormulaReferences($sharedFormulas[$instance]['formula'], 'A1', $difference[0], $difference[1]); // echo 'Adjusted Formula is ', $value, PHP_EOL; } } @@ -317,16 +310,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE public function _getFromZipArchive($archive, $fileName = '') { // Root-relative paths - if (strpos($fileName, '//') !== false) - { + if (strpos($fileName, '//') !== false) { $fileName = substr($fileName, strpos($fileName, '//') + 1); } $fileName = PHPExcel_Shared_File::realpath($fileName); // Apache POI fixes $contents = $archive->getFromName($fileName); - if ($contents === false) - { + if ($contents === false) { $contents = $archive->getFromName(substr($fileName, 1)); } @@ -366,7 +357,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE foreach ($wbRels->Relationship as $rel) { switch ($rel["Type"]) { case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme": - $themeOrderArray = array('lt1','dk1','lt2','dk2'); + $themeOrderArray = array('lt1', 'dk1', 'lt2', 'dk2'); $themeOrderAdditional = count($themeOrderArray); $xmlTheme = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "xl/{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); @@ -419,19 +410,19 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docProps->setKeywords((string) self::array_item($xmlCore->xpath("cp:keywords"))); $docProps->setCategory((string) self::array_item($xmlCore->xpath("cp:category"))); } - break; - + break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties": $xmlCore = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlCore)) { $docProps = $excel->getProperties(); - if (isset($xmlCore->Company)) + if (isset($xmlCore->Company)) { $docProps->setCompany((string) $xmlCore->Company); - if (isset($xmlCore->Manager)) + } + if (isset($xmlCore->Manager)) { $docProps->setManager((string) $xmlCore->Manager); + } } - break; - + break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties": $xmlCore = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); if (is_object($xmlCore)) { @@ -449,14 +440,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } } - break; + break; //Ribbon case "http://schemas.microsoft.com/office/2006/relationships/ui/extensibility": $customUI = $rel['Target']; if (!is_null($customUI)) { $this->_readRibbon($excel, $customUI, $zip); } - break; + break; case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": $dir = dirname($rel["Target"]); $relsWorkbook = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); @@ -468,7 +459,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($xmlStrings) && isset($xmlStrings->si)) { foreach ($xmlStrings->si as $val) { if (isset($val->t)) { - $sharedStrings[] = PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $val->t ); + $sharedStrings[] = PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $val->t); } elseif (isset($val->r)) { $sharedStrings[] = $this->_parseRichText($val); } @@ -476,7 +467,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } $worksheets = array(); - $macros = $customUI = NULL; + $macros = $customUI = null; foreach ($relsWorkbook->Relationship as $ele) { switch ($ele['Type']) { case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet": @@ -496,8 +487,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $excel->setHasMacros(true); //short-circuit : not reading vbaProject.bin.rel to get Signature =>allways vbaProjectSignature.bin in 'xl' dir $Certificate = $this->_getFromZipArchive($zip, 'xl/vbaProjectSignature.bin'); - if ($Certificate !== false) + if ($Certificate !== false) { $excel->setMacrosCertificate($Certificate); + } } } $styles = array(); @@ -508,7 +500,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ($xmlStyles && $xmlStyles->numFmts[0]) { $numFmts = $xmlStyles->numFmts[0]; } - if (isset($numFmts) && ($numFmts !== NULL)) { + if (isset($numFmts) && ($numFmts !== null)) { $numFmts->registerXPathNamespace("sml", "http://schemas.openxmlformats.org/spreadsheetml/2006/main"); } if (!$this->_readDataOnly && $xmlStyles) { @@ -586,7 +578,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Conditional Styles if ($xmlStyles->dxfs) { foreach ($xmlStyles->dxfs->dxf as $dxf) { - $style = new PHPExcel_Style(FALSE, TRUE); + $style = new PHPExcel_Style(false, true); self::_readStyle($style, $dxf); $dxfs[] = $style; } @@ -624,7 +616,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $countSkippedSheets = 0; // keep track of number of skipped sheets $mapSheetId = array(); // mapping of sheet ids from old to new - $charts = $chartDetails = array(); if ($xmlWorkbook->sheets) { @@ -655,37 +646,31 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $sharedFormulas = array(); if (isset($eleSheet["state"]) && (string) $eleSheet["state"] != '') { - $docSheet->setSheetState( (string) $eleSheet["state"] ); + $docSheet->setSheetState((string) $eleSheet["state"]); } if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) { if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) { - $docSheet->getSheetView()->setZoomScale( intval($xmlSheet->sheetViews->sheetView['zoomScale']) ); + $docSheet->getSheetView()->setZoomScale(intval($xmlSheet->sheetViews->sheetView['zoomScale'])); } - if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) { - $docSheet->getSheetView()->setZoomScaleNormal( intval($xmlSheet->sheetViews->sheetView['zoomScaleNormal']) ); + $docSheet->getSheetView()->setZoomScaleNormal(intval($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])); } - if (isset($xmlSheet->sheetViews->sheetView['view'])) { $docSheet->getSheetView()->setView((string) $xmlSheet->sheetViews->sheetView['view']); } - if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) { $docSheet->setShowGridLines(self::boolean((string)$xmlSheet->sheetViews->sheetView['showGridLines'])); } - if (isset($xmlSheet->sheetViews->sheetView['showRowColHeaders'])) { $docSheet->setShowRowColHeaders(self::boolean((string)$xmlSheet->sheetViews->sheetView['showRowColHeaders'])); } - if (isset($xmlSheet->sheetViews->sheetView['rightToLeft'])) { $docSheet->setRightToLeft(self::boolean((string)$xmlSheet->sheetViews->sheetView['rightToLeft'])); } - if (isset($xmlSheet->sheetViews->sheetView->pane)) { if (isset($xmlSheet->sheetViews->sheetView->pane['topLeftCell'])) { - $docSheet->freezePane( (string)$xmlSheet->sheetViews->sheetView->pane['topLeftCell'] ); + $docSheet->freezePane((string)$xmlSheet->sheetViews->sheetView->pane['topLeftCell']); } else { $xSplit = 0; $ySplit = 0; @@ -710,12 +695,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docSheet->setSelectedCells($sqref); } } - } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) { if (isset($xmlSheet->sheetPr->tabColor['rgb'])) { - $docSheet->getTabColor()->setARGB( (string)$xmlSheet->sheetPr->tabColor['rgb'] ); + $docSheet->getTabColor()->setARGB((string)$xmlSheet->sheetPr->tabColor['rgb']); } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr['codeName'])) { @@ -724,25 +708,25 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) { if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) { - $docSheet->setShowSummaryRight(FALSE); + $docSheet->setShowSummaryRight(false); } else { - $docSheet->setShowSummaryRight(TRUE); + $docSheet->setShowSummaryRight(true); } if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryBelow'])) { - $docSheet->setShowSummaryBelow(FALSE); + $docSheet->setShowSummaryBelow(false); } else { - $docSheet->setShowSummaryBelow(TRUE); + $docSheet->setShowSummaryBelow(true); } } if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) { if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && !self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) { - $docSheet->getPageSetup()->setFitToPage(FALSE); + $docSheet->getPageSetup()->setFitToPage(false); } else { - $docSheet->getPageSetup()->setFitToPage(TRUE); + $docSheet->getPageSetup()->setFitToPage(true); } } @@ -750,10 +734,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($xmlSheet->sheetFormatPr['customHeight']) && self::boolean((string) $xmlSheet->sheetFormatPr['customHeight']) && isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) { - $docSheet->getDefaultRowDimension()->setRowHeight( (float)$xmlSheet->sheetFormatPr['defaultRowHeight'] ); + $docSheet->getDefaultRowDimension()->setRowHeight((float)$xmlSheet->sheetFormatPr['defaultRowHeight']); } if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) { - $docSheet->getDefaultColumnDimension()->setWidth( (float)$xmlSheet->sheetFormatPr['defaultColWidth'] ); + $docSheet->getDefaultColumnDimension()->setWidth((float)$xmlSheet->sheetFormatPr['defaultColWidth']); } if (isset($xmlSheet->sheetFormatPr['zeroHeight']) && ((string)$xmlSheet->sheetFormatPr['zeroHeight'] == '1')) { @@ -768,14 +752,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"])); } if (self::boolean($col["bestFit"])) { - //$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(TRUE); + //$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true); } if (self::boolean($col["hidden"])) { - // echo PHPExcel_Cell::stringFromColumnIndex($i),': HIDDEN COLUMN',PHP_EOL; - $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(FALSE); + // echo PHPExcel_Cell::stringFromColumnIndex($i), ': HIDDEN COLUMN',PHP_EOL; + $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false); } if (self::boolean($col["collapsed"])) { - $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(TRUE); + $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(true); } if ($col["outlineLevel"] > 0) { $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"])); @@ -791,18 +775,16 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) { if (self::boolean((string) $xmlSheet->printOptions['gridLinesSet'])) { - $docSheet->setShowGridlines(TRUE); + $docSheet->setShowGridlines(true); } - if (self::boolean((string) $xmlSheet->printOptions['gridLines'])) { - $docSheet->setPrintGridlines(TRUE); + $docSheet->setPrintGridlines(true); } - if (self::boolean((string) $xmlSheet->printOptions['horizontalCentered'])) { - $docSheet->getPageSetup()->setHorizontalCentered(TRUE); + $docSheet->getPageSetup()->setHorizontalCentered(true); } if (self::boolean((string) $xmlSheet->printOptions['verticalCentered'])) { - $docSheet->getPageSetup()->setVerticalCentered(TRUE); + $docSheet->getPageSetup()->setVerticalCentered(true); } } @@ -812,10 +794,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docSheet->getRowDimension(intval($row["r"]))->setRowHeight(floatval($row["ht"])); } if (self::boolean($row["hidden"]) && !$this->_readDataOnly) { - $docSheet->getRowDimension(intval($row["r"]))->setVisible(FALSE); + $docSheet->getRowDimension(intval($row["r"]))->setVisible(false); } if (self::boolean($row["collapsed"])) { - $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(TRUE); + $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(true); } if ($row["outlineLevel"] > 0) { $docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"])); @@ -831,7 +813,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $calculatedValue = null; // Read cell? - if ($this->getReadFilter() !== NULL) { + if ($this->getReadFilter() !== null) { $coordinates = PHPExcel_Cell::coordinateFromString($r); if (!$this->getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) { @@ -857,7 +839,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } else { $value = ''; } - break; case "b": // echo 'Boolean', PHP_EOL; @@ -865,7 +846,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $value = self::_castToBool($c); } else { // Formula - $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToBool'); + $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, '_castToBool'); if (isset($c->f['t'])) { $att = array(); $att = $c->f; @@ -877,7 +858,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE case "inlineStr": // echo 'Inline String', PHP_EOL; $value = $this->_parseRichText($c->is); - break; case "e": // echo 'Error', PHP_EOL; @@ -885,12 +865,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $value = self::_castToError($c); } else { // Formula - $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToError'); + $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, '_castToError'); // echo '$calculatedValue = ', $calculatedValue, PHP_EOL; } - break; - default: // echo 'Default', PHP_EOL; if (!isset($c->f)) { @@ -899,10 +877,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } else { // echo 'Treat as Formula', PHP_EOL; // Formula - $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToString'); + $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, '_castToString'); // echo '$calculatedValue = ', $calculatedValue, PHP_EOL; } - break; } // echo 'Value is ', $value, PHP_EOL; @@ -926,7 +903,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } else { $cell->setValue($value); } - if ($calculatedValue !== NULL) { + if ($calculatedValue !== null) { $cell->setCalculatedValue($calculatedValue); } @@ -997,7 +974,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { - $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], TRUE); + $docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], true); if ($xmlSheet->protectedRanges->protectedRange) { foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) { $docSheet->protectCells((string) $protectedRange["sqref"], (string) $protectedRange["password"], true); @@ -1019,7 +996,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $filters = $filterColumn->filters; if ((isset($filters["blank"])) && ($filters["blank"] == 1)) { $column->createRule()->setRule( - NULL, // Operator is undefined, but always treated as EQUAL + null, // Operator is undefined, but always treated as EQUAL '' ) ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); @@ -1028,7 +1005,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Entries can be either filter elements foreach ($filters->filter as $filterRule) { $column->createRule()->setRule( - NULL, // Operator is undefined, but always treated as EQUAL + null, // Operator is undefined, but always treated as EQUAL (string) $filterRule["val"] ) ->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); @@ -1036,7 +1013,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Or Date Group elements foreach ($filters->dateGroupItem as $dateGroupItem) { $column->createRule()->setRule( - NULL, // Operator is undefined, but always treated as EQUAL + null, // Operator is undefined, but always treated as EQUAL array( 'year' => (string) $dateGroupItem["year"], 'month' => (string) $dateGroupItem["month"], @@ -1073,7 +1050,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // We should only ever have one dynamic filter foreach ($filterColumn->dynamicFilter as $filterRule) { $column->createRule()->setRule( - NULL, // Operator is undefined, but always treated as EQUAL + null, // Operator is undefined, but always treated as EQUAL (string) $filterRule["val"], (string) $filterRule["type"] ) @@ -1112,7 +1089,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly) { foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) { $mergeRef = (string) $mergeCell["ref"]; - if (strpos($mergeRef,':') !== FALSE) { + if (strpos($mergeRef, ':') !== false) { $docSheet->mergeCells((string) $mergeCell["ref"]); } } @@ -1138,13 +1115,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docPageSetup->setPaperSize(intval($xmlSheet->pageSetup["paperSize"])); } if (isset($xmlSheet->pageSetup["scale"])) { - $docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]), FALSE); + $docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]), false); } if (isset($xmlSheet->pageSetup["fitToHeight"]) && intval($xmlSheet->pageSetup["fitToHeight"]) >= 0) { - $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]), FALSE); + $docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]), false); } if (isset($xmlSheet->pageSetup["fitToWidth"]) && intval($xmlSheet->pageSetup["fitToWidth"]) >= 0) { - $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]), FALSE); + $docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]), false); } if (isset($xmlSheet->pageSetup["firstPageNumber"]) && isset($xmlSheet->pageSetup["useFirstPageNumber"]) && self::boolean((string) $xmlSheet->pageSetup["useFirstPageNumber"])) { @@ -1157,27 +1134,27 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($xmlSheet->headerFooter["differentOddEven"]) && self::boolean((string)$xmlSheet->headerFooter["differentOddEven"])) { - $docHeaderFooter->setDifferentOddEven(TRUE); + $docHeaderFooter->setDifferentOddEven(true); } else { - $docHeaderFooter->setDifferentOddEven(FALSE); + $docHeaderFooter->setDifferentOddEven(false); } if (isset($xmlSheet->headerFooter["differentFirst"]) && self::boolean((string)$xmlSheet->headerFooter["differentFirst"])) { - $docHeaderFooter->setDifferentFirst(TRUE); + $docHeaderFooter->setDifferentFirst(true); } else { - $docHeaderFooter->setDifferentFirst(FALSE); + $docHeaderFooter->setDifferentFirst(false); } if (isset($xmlSheet->headerFooter["scaleWithDoc"]) && !self::boolean((string)$xmlSheet->headerFooter["scaleWithDoc"])) { - $docHeaderFooter->setScaleWithDocument(FALSE); + $docHeaderFooter->setScaleWithDocument(false); } else { - $docHeaderFooter->setScaleWithDocument(TRUE); + $docHeaderFooter->setScaleWithDocument(true); } if (isset($xmlSheet->headerFooter["alignWithMargins"]) && !self::boolean((string)$xmlSheet->headerFooter["alignWithMargins"])) { - $docHeaderFooter->setAlignWithMargins(FALSE); + $docHeaderFooter->setAlignWithMargins(false); } else { - $docHeaderFooter->setAlignWithMargins(TRUE); + $docHeaderFooter->setAlignWithMargins(true); } $docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader); @@ -1254,7 +1231,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'); foreach (PHPExcel_Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { - $cell = $docSheet->getCell( $cellReference ); + $cell = $docSheet->getCell($cellReference); if (isset($linkRel['id'])) { $hyperlinkUrl = $hyperlinks[ (string)$linkRel['id'] ]; if (isset($hyperlink['location'])) { @@ -1262,12 +1239,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } $cell->getHyperlink()->setUrl($hyperlinkUrl); } elseif (isset($hyperlink['location'])) { - $cell->getHyperlink()->setUrl( 'sheet://' . (string)$hyperlink['location'] ); + $cell->getHyperlink()->setUrl('sheet://' . (string)$hyperlink['location']); } // Tooltip if (isset($hyperlink['tooltip'])) { - $cell->getHyperlink()->setTooltip( (string)$hyperlink['tooltip'] ); + $cell->getHyperlink()->setTooltip((string)$hyperlink['tooltip']); } } } @@ -1308,8 +1285,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Loop through contents foreach ($commentsFile->commentList->comment as $comment) { if (!empty($comment['authorId'])) - $docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] ); - $docSheet->getComment( (string)$comment['ref'] )->setText( $this->_parseRichText($comment->text) ); + $docSheet->getComment((string)$comment['ref'])->setAuthor($authors[(string)$comment['authorId']]); + $docSheet->getComment((string)$comment['ref'])->setText($this->_parseRichText($comment->text)); } } @@ -1326,7 +1303,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (isset($shape['style'])) { $style = (string)$shape['style']; - $fillColor = strtoupper( substr( (string)$shape['fillcolor'], 1 ) ); + $fillColor = strtoupper(substr((string)$shape['fillcolor'], 1)); $column = null; $row = null; @@ -1334,31 +1311,44 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (is_array($clientData) && !empty($clientData)) { $clientData = $clientData[0]; - if ( isset($clientData['ObjectType']) && (string)$clientData['ObjectType'] == 'Note' ) { + if (isset($clientData['ObjectType']) && (string)$clientData['ObjectType'] == 'Note') { $temp = $clientData->xpath('.//x:Row'); - if (is_array($temp)) $row = $temp[0]; + if (is_array($temp)) { + $row = $temp[0]; + } $temp = $clientData->xpath('.//x:Column'); - if (is_array($temp)) $column = $temp[0]; + if (is_array($temp)) { + $column = $temp[0]; + } } } - if (($column !== NULL) && ($row !== NULL)) { + if (($column !== null) && ($row !== null)) { // Set comment properties $comment = $docSheet->getCommentByColumnAndRow((string) $column, $row + 1); - $comment->getFillColor()->setRGB( $fillColor ); + $comment->getFillColor()->setRGB($fillColor); // Parse style $styleArray = explode(';', str_replace(' ', '', $style)); foreach ($styleArray as $stylePair) { $stylePair = explode(':', $stylePair); - if ($stylePair[0] == 'margin-left') $comment->setMarginLeft($stylePair[1]); - if ($stylePair[0] == 'margin-top') $comment->setMarginTop($stylePair[1]); - if ($stylePair[0] == 'width') $comment->setWidth($stylePair[1]); - if ($stylePair[0] == 'height') $comment->setHeight($stylePair[1]); - if ($stylePair[0] == 'visibility') $comment->setVisible( $stylePair[1] == 'visible' ); - + if ($stylePair[0] == 'margin-left') { + $comment->setMarginLeft($stylePair[1]); + } + if ($stylePair[0] == 'margin-top') { + $comment->setMarginTop($stylePair[1]); + } + if ($stylePair[0] == 'width') { + $comment->setWidth($stylePair[1]); + } + if ($stylePair[0] == 'height') { + $comment->setHeight($stylePair[1]); + } + if ($stylePair[0] == 'visibility') { + $comment->setVisible($stylePair[1] == 'visible'); + } } } } @@ -1400,11 +1390,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $imageData = $imageData[$idx]; $imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office'); - $style = self::toCSSArray( (string)$shape['style'] ); + $style = self::toCSSArray((string)$shape['style']); $hfImages[ (string)$shape['id'] ] = new PHPExcel_Worksheet_HeaderFooterDrawing(); if (isset($imageData['title'])) { - $hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] ); + $hfImages[ (string)$shape['id'] ]->setName((string)$imageData['title']); } $hfImages[ (string)$shape['id'] ]->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $drawings[(string)$imageData['relid']], false); @@ -1446,9 +1436,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $images[(string) $ele["Id"]] = self::dir_add($fileDrawing, $ele["Target"]); } elseif ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart") { if ($this->_includeCharts) { - $charts[self::dir_add($fileDrawing, $ele["Target"])] = array('id' => (string) $ele["Id"], - 'sheet' => $docSheet->getTitle() - ); + $charts[self::dir_add($fileDrawing, $ele["Target"])] = array( + 'id' => (string) $ele["Id"], + 'sheet' => $docSheet->getTitle() + ); } } } @@ -1537,19 +1528,18 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $chartRef = $graphic->graphicData->children("http://schemas.openxmlformats.org/drawingml/2006/chart")->chart; $thisChart = (string) $chartRef->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"); - $chartDetails[$docSheet->getTitle().'!'.$thisChart] = - array( 'fromCoordinate' => $fromCoordinate, - 'fromOffsetX' => $fromOffsetX, - 'fromOffsetY' => $fromOffsetY, - 'toCoordinate' => $toCoordinate, - 'toOffsetX' => $toOffsetX, - 'toOffsetY' => $toOffsetY, - 'worksheetTitle' => $docSheet->getTitle() - ); + $chartDetails[$docSheet->getTitle().'!'.$thisChart] = array( + 'fromCoordinate' => $fromCoordinate, + 'fromOffsetX' => $fromOffsetX, + 'fromOffsetY' => $fromOffsetY, + 'toCoordinate' => $toCoordinate, + 'toOffsetX' => $toOffsetX, + 'toOffsetY' => $toOffsetY, + 'worksheetTitle' => $docSheet->getTitle() + ); } } } - } } } @@ -1560,14 +1550,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Extract range $extractedRange = (string)$definedName; $extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); - if (($spos = strpos($extractedRange,'!')) !== false) { + if (($spos = strpos($extractedRange, '!')) !== false) { $extractedRange = substr($extractedRange,0, $spos).str_replace('$', '', substr($extractedRange, $spos)); } else { $extractedRange = str_replace('$', '', $extractedRange); } // Valid range? - if (stripos((string)$definedName, '#REF!') !== FALSE || $extractedRange == '') { + if (stripos((string)$definedName, '#REF!') !== false || $extractedRange == '') { continue; } @@ -1575,7 +1565,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ((string)$definedName['localSheetId'] != '' && (string)$definedName['localSheetId'] == $sheetId) { // Switch on type switch ((string)$definedName['name']) { - case '_xlnm._FilterDatabase': if ((string)$definedName['hidden'] !== '1') { $extractedRange = explode(',', $extractedRange); @@ -1587,7 +1576,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } break; - case '_xlnm.Print_Titles': // Split $extractedRange $extractedRange = explode(',', $extractedRange); @@ -1607,14 +1595,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } break; - case '_xlnm.Print_Area': $rangeSets = explode(',', $extractedRange); // FIXME: what if sheetname contains comma? $newRangeSets = array(); foreach ($rangeSets as $rangeSet) { $range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark? $rangeSet = isset($range[1]) ? $range[1] : $range[0]; - if (strpos($rangeSet, ':') === FALSE) { + if (strpos($rangeSet, ':') === false) { $rangeSet = $rangeSet . ':' . $rangeSet; } $newRangeSets[] = str_replace('$', '', $rangeSet); @@ -1639,7 +1626,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Extract range $extractedRange = (string)$definedName; $extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); - if (($spos = strpos($extractedRange,'!')) !== false) { + if (($spos = strpos($extractedRange, '!')) !== false) { $extractedRange = substr($extractedRange,0, $spos).str_replace('$', '', substr($extractedRange, $spos)); } else { $extractedRange = str_replace('$', '', $extractedRange); @@ -1655,12 +1642,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // Local defined name // Switch on type switch ((string)$definedName['name']) { - case '_xlnm._FilterDatabase': case '_xlnm.Print_Titles': case '_xlnm.Print_Area': break; - default: if ($mapSheetId[(integer) $definedName['localSheetId']] !== null) { $range = explode('!', (string)$definedName); @@ -1670,7 +1655,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) { $extractedRange = str_replace('$', '', $range[1]); $scope = $docSheet->getParent()->getSheet($mapSheetId[(integer) $definedName['localSheetId']]); - $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope) ); + $excel->addNamedRange(new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope)); } } } @@ -1680,9 +1665,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE // "Global" definedNames $locatedSheet = null; $extractedSheetName = ''; - if (strpos( (string)$definedName, '!' ) !== false) { + if (strpos((string)$definedName, '!') !== false) { // Extract sheet name - $extractedSheetName = PHPExcel_Worksheet::extractSheetTitle( (string)$definedName, true ); + $extractedSheetName = PHPExcel_Worksheet::extractSheetTitle((string)$definedName, true); $extractedSheetName = $extractedSheetName[0]; // Locate sheet @@ -1693,8 +1678,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $extractedRange = isset($range[1]) ? $range[1] : $range[0]; } - if ($locatedSheet !== NULL) { - $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false) ); + if ($locatedSheet !== null) { + $excel->addNamedRange(new PHPExcel_NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false)); } } } @@ -1717,39 +1702,31 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } break; } - } - if (!$this->_readDataOnly) { $contentTypes = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "[Content_Types].xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); foreach ($contentTypes->Override as $contentType) { switch ($contentType["ContentType"]) { case "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": if ($this->_includeCharts) { - $chartEntryRef = ltrim($contentType['PartName'],'/'); + $chartEntryRef = ltrim($contentType['PartName'], '/'); $chartElements = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $chartEntryRef)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); - $objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml')); + $objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef, '.xml')); -// echo 'Chart ', $chartEntryRef,'
'; +// echo 'Chart ', $chartEntryRef, '
'; // var_dump($charts[$chartEntryRef]); // if (isset($charts[$chartEntryRef])) { $chartPositionRef = $charts[$chartEntryRef]['sheet'].'!'.$charts[$chartEntryRef]['id']; -// echo 'Position Ref ', $chartPositionRef,'
'; +// echo 'Position Ref ', $chartPositionRef, '
'; if (isset($chartDetails[$chartPositionRef])) { // var_dump($chartDetails[$chartPositionRef]); $excel->getSheetByName($charts[$chartEntryRef]['sheet'])->addChart($objChart); $objChart->setWorksheet($excel->getSheetByName($charts[$chartEntryRef]['sheet'])); - $objChart->setTopLeftPosition( $chartDetails[$chartPositionRef]['fromCoordinate'], - $chartDetails[$chartPositionRef]['fromOffsetX'], - $chartDetails[$chartPositionRef]['fromOffsetY'] - ); - $objChart->setBottomRightPosition( $chartDetails[$chartPositionRef]['toCoordinate'], - $chartDetails[$chartPositionRef]['toOffsetX'], - $chartDetails[$chartPositionRef]['toOffsetY'] - ); + $objChart->setTopLeftPosition($chartDetails[$chartPositionRef]['fromCoordinate'], $chartDetails[$chartPositionRef]['fromOffsetX'], $chartDetails[$chartPositionRef]['fromOffsetY']); + $objChart->setBottomRightPosition($chartDetails[$chartPositionRef]['toCoordinate'], $chartDetails[$chartPositionRef]['toOffsetX'], $chartDetails[$chartPositionRef]['toOffsetY']); } } } @@ -1762,14 +1739,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE return $excel; } - - private static function _readColor($color, $background=FALSE) { + private static function _readColor($color, $background = false) + { if (isset($color["rgb"])) { return (string)$color["rgb"]; } else if (isset($color["indexed"])) { return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB(); } else if (isset($color["theme"])) { - if (self::$_theme !== NULL) { + if (self::$_theme !== null) { $returnColour = self::$_theme->getColourByIndex((int)$color["theme"]); if (isset($color["tint"])) { $tintAdjust = (float) $color["tint"]; @@ -1785,8 +1762,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE return 'FF000000'; } - - private static function _readStyle($docStyle, $style) { + private static function _readStyle($docStyle, $style) + { // format code // if (isset($style->numFmt)) { // if (isset($style->numFmt['formatCode'])) { @@ -1837,8 +1814,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } $docStyle->getFill()->setRotation(floatval($gradientFill["degree"])); $gradientFill->registerXPathNamespace("sml", "http://schemas.openxmlformats.org/spreadsheetml/2006/main"); - $docStyle->getFill()->getStartColor()->setARGB(self::_readColor( self::array_item($gradientFill->xpath("sml:stop[@position=0]"))->color) ); - $docStyle->getFill()->getEndColor()->setARGB(self::_readColor( self::array_item($gradientFill->xpath("sml:stop[@position=1]"))->color) ); + $docStyle->getFill()->getStartColor()->setARGB(self::_readColor(self::array_item($gradientFill->xpath("sml:stop[@position=0]"))->color)); + $docStyle->getFill()->getEndColor()->setARGB(self::_readColor(self::array_item($gradientFill->xpath("sml:stop[@position=1]"))->color)); } elseif ($style->fill->patternFill) { $patternType = (string)$style->fill->patternFill["patternType"] != '' ? (string)$style->fill->patternFill["patternType"] : 'solid'; $docStyle->getFill()->setFillType($patternType); @@ -1888,8 +1865,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE $docStyle->getAlignment()->setTextRotation(intval($textRotation)); $docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment["wrapText"])); $docStyle->getAlignment()->setShrinkToFit(self::boolean((string) $style->alignment["shrinkToFit"])); - $docStyle->getAlignment()->setIndent( intval((string)$style->alignment["indent"]) > 0 ? intval((string)$style->alignment["indent"]) : 0 ); - $docStyle->getAlignment()->setReadorder( intval((string)$style->alignment["readingOrder"]) > 0 ? intval((string)$style->alignment["readingOrder"]) : 0 ); + $docStyle->getAlignment()->setIndent(intval((string)$style->alignment["indent"]) > 0 ? intval((string)$style->alignment["indent"]) : 0); + $docStyle->getAlignment()->setReadorder(intval((string)$style->alignment["readingOrder"]) > 0 ? intval((string)$style->alignment["readingOrder"]) : 0); } // protection @@ -1917,8 +1894,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } - - private static function _readBorder($docBorder, $eleBorder) { + private static function _readBorder($docBorder, $eleBorder) + { if (isset($eleBorder["style"])) { $docBorder->setBorderStyle((string) $eleBorder["style"]); } @@ -1927,66 +1904,59 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE } } - - private function _parseRichText($is = null) { + private function _parseRichText($is = null) + { $value = new PHPExcel_RichText(); if (isset($is->t)) { - $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) ); + $value->createText(PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $is->t)); } else { if (is_object($is->r)) { - foreach ($is->r as $run) { - if (!isset($run->rPr)) { - $objText = $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) ); + foreach ($is->r as $run) { + if (!isset($run->rPr)) { + $objText = $value->createText(PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $run->t)); - } else { - $objText = $value->createTextRun( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) ); + } else { + $objText = $value->createTextRun(PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $run->t)); - if (isset($run->rPr->rFont["val"])) { - $objText->getFont()->setName((string) $run->rPr->rFont["val"]); - } - - if (isset($run->rPr->sz["val"])) { - $objText->getFont()->setSize((string) $run->rPr->sz["val"]); - } - - if (isset($run->rPr->color)) { - $objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($run->rPr->color) ) ); - } - - if ((isset($run->rPr->b["val"]) && self::boolean((string) $run->rPr->b["val"])) || - (isset($run->rPr->b) && !isset($run->rPr->b["val"]))) { - $objText->getFont()->setBold(TRUE); - } - - if ((isset($run->rPr->i["val"]) && self::boolean((string) $run->rPr->i["val"])) || - (isset($run->rPr->i) && !isset($run->rPr->i["val"]))) { - $objText->getFont()->setItalic(TRUE); - } - - if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign["val"])) { - $vertAlign = strtolower((string)$run->rPr->vertAlign["val"]); - if ($vertAlign == 'superscript') { - $objText->getFont()->setSuperScript(TRUE); + if (isset($run->rPr->rFont["val"])) { + $objText->getFont()->setName((string) $run->rPr->rFont["val"]); } - if ($vertAlign == 'subscript') { - $objText->getFont()->setSubScript(TRUE); + if (isset($run->rPr->sz["val"])) { + $objText->getFont()->setSize((string) $run->rPr->sz["val"]); + } + if (isset($run->rPr->color)) { + $objText->getFont()->setColor(new PHPExcel_Style_Color(self::_readColor($run->rPr->color))); + } + if ((isset($run->rPr->b["val"]) && self::boolean((string) $run->rPr->b["val"])) || + (isset($run->rPr->b) && !isset($run->rPr->b["val"]))) { + $objText->getFont()->setBold(true); + } + if ((isset($run->rPr->i["val"]) && self::boolean((string) $run->rPr->i["val"])) || + (isset($run->rPr->i) && !isset($run->rPr->i["val"]))) { + $objText->getFont()->setItalic(true); + } + if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign["val"])) { + $vertAlign = strtolower((string)$run->rPr->vertAlign["val"]); + if ($vertAlign == 'superscript') { + $objText->getFont()->setSuperScript(true); + } + if ($vertAlign == 'subscript') { + $objText->getFont()->setSubScript(true); + } + } + if (isset($run->rPr->u) && !isset($run->rPr->u["val"])) { + $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); + } else if (isset($run->rPr->u) && isset($run->rPr->u["val"])) { + $objText->getFont()->setUnderline((string)$run->rPr->u["val"]); + } + if ((isset($run->rPr->strike["val"]) && self::boolean((string) $run->rPr->strike["val"])) || + (isset($run->rPr->strike) && !isset($run->rPr->strike["val"]))) { + $objText->getFont()->setStrikethrough(true); } - } - - if (isset($run->rPr->u) && !isset($run->rPr->u["val"])) { - $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); - } else if (isset($run->rPr->u) && isset($run->rPr->u["val"])) { - $objText->getFont()->setUnderline((string)$run->rPr->u["val"]); - } - - if ((isset($run->rPr->strike["val"]) && self::boolean((string) $run->rPr->strike["val"])) || - (isset($run->rPr->strike) && !isset($run->rPr->strike["val"]))) { - $objText->getFont()->setStrikethrough(TRUE); } } } - } } return $value; @@ -2022,25 +1992,26 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE if (count($customUIImagesNames) > 0 && count($customUIImagesBinaries) > 0) { $excel->setRibbonBinObjects($customUIImagesNames, $customUIImagesBinaries); } else { - $excel->setRibbonBinObjects(NULL); + $excel->setRibbonBinObjects(null); } } else { - $excel->setRibbonXMLData(NULL); - $excel->setRibbonBinObjects(NULL); + $excel->setRibbonXMLData(null); + $excel->setRibbonBinObjects(null); } } - private static function array_item($array, $key = 0) { + private static function array_item($array, $key = 0) + { return (isset($array[$key]) ? $array[$key] : null); } - - private static function dir_add($base, $add) { + private static function dir_add($base, $add) + { return preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add"); } - - private static function toCSSArray($style) { + private static function toCSSArray($style) + { $style = str_replace(array("\r","\n"), "", $style); $temp = explode(';', $style); @@ -2070,7 +2041,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE return $style; } - private static function boolean($value = NULL) + private static function boolean($value = null) { if (is_object($value)) { $value = (string) $value; diff --git a/Classes/PHPExcel/Reader/Excel5.php b/Classes/PHPExcel/Reader/Excel5.php index 9b27b96..15fa11b 100644 --- a/Classes/PHPExcel/Reader/Excel5.php +++ b/Classes/PHPExcel/Reader/Excel5.php @@ -78,94 +78,94 @@ if (!defined('PHPEXCEL_ROOT')) { class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader { // ParseXL definitions - const XLS_BIFF8 = 0x0600; - const XLS_BIFF7 = 0x0500; - const XLS_WorkbookGlobals = 0x0005; - const XLS_Worksheet = 0x0010; + const XLS_BIFF8 = 0x0600; + const XLS_BIFF7 = 0x0500; + const XLS_WorkbookGlobals = 0x0005; + const XLS_Worksheet = 0x0010; // record identifiers - const XLS_Type_FORMULA = 0x0006; - const XLS_Type_EOF = 0x000a; - const XLS_Type_PROTECT = 0x0012; + const XLS_Type_FORMULA = 0x0006; + const XLS_Type_EOF = 0x000a; + const XLS_Type_PROTECT = 0x0012; const XLS_Type_OBJECTPROTECT = 0x0063; - const XLS_Type_SCENPROTECT = 0x00dd; - const XLS_Type_PASSWORD = 0x0013; - const XLS_Type_HEADER = 0x0014; - const XLS_Type_FOOTER = 0x0015; - const XLS_Type_EXTERNSHEET = 0x0017; - const XLS_Type_DEFINEDNAME = 0x0018; - const XLS_Type_VERTICALPAGEBREAKS = 0x001a; - const XLS_Type_HORIZONTALPAGEBREAKS = 0x001b; - const XLS_Type_NOTE = 0x001c; + const XLS_Type_SCENPROTECT = 0x00dd; + const XLS_Type_PASSWORD = 0x0013; + const XLS_Type_HEADER = 0x0014; + const XLS_Type_FOOTER = 0x0015; + const XLS_Type_EXTERNSHEET = 0x0017; + const XLS_Type_DEFINEDNAME = 0x0018; + const XLS_Type_VERTICALPAGEBREAKS = 0x001a; + const XLS_Type_HORIZONTALPAGEBREAKS = 0x001b; + const XLS_Type_NOTE = 0x001c; const XLS_Type_SELECTION = 0x001d; - const XLS_Type_DATEMODE = 0x0022; - const XLS_Type_EXTERNNAME = 0x0023; - const XLS_Type_LEFTMARGIN = 0x0026; - const XLS_Type_RIGHTMARGIN = 0x0027; + const XLS_Type_DATEMODE = 0x0022; + const XLS_Type_EXTERNNAME = 0x0023; + const XLS_Type_LEFTMARGIN = 0x0026; + const XLS_Type_RIGHTMARGIN = 0x0027; const XLS_Type_TOPMARGIN = 0x0028; - const XLS_Type_BOTTOMMARGIN = 0x0029; - const XLS_Type_PRINTGRIDLINES = 0x002b; - const XLS_Type_FILEPASS = 0x002f; - const XLS_Type_FONT = 0x0031; - const XLS_Type_CONTINUE = 0x003c; - const XLS_Type_PANE = 0x0041; - const XLS_Type_CODEPAGE = 0x0042; - const XLS_Type_DEFCOLWIDTH = 0x0055; - const XLS_Type_OBJ = 0x005d; - const XLS_Type_COLINFO = 0x007d; - const XLS_Type_IMDATA = 0x007f; - const XLS_Type_SHEETPR = 0x0081; - const XLS_Type_HCENTER = 0x0083; - const XLS_Type_VCENTER = 0x0084; + const XLS_Type_BOTTOMMARGIN = 0x0029; + const XLS_Type_PRINTGRIDLINES = 0x002b; + const XLS_Type_FILEPASS = 0x002f; + const XLS_Type_FONT = 0x0031; + const XLS_Type_CONTINUE = 0x003c; + const XLS_Type_PANE = 0x0041; + const XLS_Type_CODEPAGE = 0x0042; + const XLS_Type_DEFCOLWIDTH = 0x0055; + const XLS_Type_OBJ = 0x005d; + const XLS_Type_COLINFO = 0x007d; + const XLS_Type_IMDATA = 0x007f; + const XLS_Type_SHEETPR = 0x0081; + const XLS_Type_HCENTER = 0x0083; + const XLS_Type_VCENTER = 0x0084; const XLS_Type_SHEET = 0x0085; - const XLS_Type_PALETTE = 0x0092; - const XLS_Type_SCL = 0x00a0; + const XLS_Type_PALETTE = 0x0092; + const XLS_Type_SCL = 0x00a0; const XLS_Type_PAGESETUP = 0x00a1; const XLS_Type_MULRK = 0x00bd; - const XLS_Type_MULBLANK = 0x00be; - const XLS_Type_DBCELL = 0x00d7; - const XLS_Type_XF = 0x00e0; - const XLS_Type_MERGEDCELLS = 0x00e5; - const XLS_Type_MSODRAWINGGROUP = 0x00eb; - const XLS_Type_MSODRAWING = 0x00ec; - const XLS_Type_SST = 0x00fc; - const XLS_Type_LABELSST = 0x00fd; - const XLS_Type_EXTSST = 0x00ff; - const XLS_Type_EXTERNALBOOK = 0x01ae; - const XLS_Type_DATAVALIDATIONS = 0x01b2; - const XLS_Type_TXO = 0x01b6; + const XLS_Type_MULBLANK = 0x00be; + const XLS_Type_DBCELL = 0x00d7; + const XLS_Type_XF = 0x00e0; + const XLS_Type_MERGEDCELLS = 0x00e5; + const XLS_Type_MSODRAWINGGROUP = 0x00eb; + const XLS_Type_MSODRAWING = 0x00ec; + const XLS_Type_SST = 0x00fc; + const XLS_Type_LABELSST = 0x00fd; + const XLS_Type_EXTSST = 0x00ff; + const XLS_Type_EXTERNALBOOK = 0x01ae; + const XLS_Type_DATAVALIDATIONS = 0x01b2; + const XLS_Type_TXO = 0x01b6; const XLS_Type_HYPERLINK = 0x01b8; - const XLS_Type_DATAVALIDATION = 0x01be; + const XLS_Type_DATAVALIDATION = 0x01be; const XLS_Type_DIMENSION = 0x0200; const XLS_Type_BLANK = 0x0201; - const XLS_Type_NUMBER = 0x0203; + const XLS_Type_NUMBER = 0x0203; const XLS_Type_LABEL = 0x0204; - const XLS_Type_BOOLERR = 0x0205; - const XLS_Type_STRING = 0x0207; - const XLS_Type_ROW = 0x0208; + const XLS_Type_BOOLERR = 0x0205; + const XLS_Type_STRING = 0x0207; + const XLS_Type_ROW = 0x0208; const XLS_Type_INDEX = 0x020b; const XLS_Type_ARRAY = 0x0221; const XLS_Type_DEFAULTROWHEIGHT = 0x0225; - const XLS_Type_WINDOW2 = 0x023e; - const XLS_Type_RK = 0x027e; + const XLS_Type_WINDOW2 = 0x023e; + const XLS_Type_RK = 0x027e; const XLS_Type_STYLE = 0x0293; - const XLS_Type_FORMAT = 0x041e; - const XLS_Type_SHAREDFMLA = 0x04bc; - const XLS_Type_BOF = 0x0809; - const XLS_Type_SHEETPROTECTION = 0x0867; - const XLS_Type_RANGEPROTECTION = 0x0868; - const XLS_Type_SHEETLAYOUT = 0x0862; + const XLS_Type_FORMAT = 0x041e; + const XLS_Type_SHAREDFMLA = 0x04bc; + const XLS_Type_BOF = 0x0809; + const XLS_Type_SHEETPROTECTION = 0x0867; + const XLS_Type_RANGEPROTECTION = 0x0868; + const XLS_Type_SHEETLAYOUT = 0x0862; const XLS_Type_XFEXT = 0x087d; - const XLS_Type_PAGELAYOUTVIEW = 0x088b; - const XLS_Type_UNKNOWN = 0xffff; + const XLS_Type_PAGELAYOUTVIEW = 0x088b; + const XLS_Type_UNKNOWN = 0xffff; // Encryption type - const MS_BIFF_CRYPTO_NONE = 0; - const MS_BIFF_CRYPTO_XOR = 1; - const MS_BIFF_CRYPTO_RC4 = 2; + const MS_BIFF_CRYPTO_NONE = 0; + const MS_BIFF_CRYPTO_XOR = 1; + const MS_BIFF_CRYPTO_RC4 = 2; // Size of stream blocks when using RC4 encryption - const REKEY_BLOCK = 0x400; + const REKEY_BLOCK = 0x400; /** * Summary Information stream data. @@ -389,7 +389,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce /** * The type of encryption in use * - * @var int + * @var int */ private $_encryption = 0; @@ -424,11 +424,11 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce /** * Create a new PHPExcel_Reader_Excel5 instance */ - public function __construct() { + public function __construct() + { $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); } - /** * Can the current PHPExcel_Reader_IReader read the file? * @@ -455,7 +455,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } } - /** * Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object * @@ -485,10 +484,18 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $code = self::_GetInt2d($this->_data, $this->_pos); switch ($code) { - case self::XLS_Type_BOF: $this->_readBof(); break; - case self::XLS_Type_SHEET: $this->_readSheet(); break; - case self::XLS_Type_EOF: $this->_readDefault(); break 2; - default: $this->_readDefault(); break; + case self::XLS_Type_BOF: + $this->_readBof(); + break; + case self::XLS_Type_SHEET: + $this->_readSheet(); + break; + case self::XLS_Type_EOF: + $this->_readDefault(); + break 2; + default: + $this->_readDefault(); + break; } } @@ -535,10 +542,18 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $code = self::_GetInt2d($this->_data, $this->_pos); switch ($code) { - case self::XLS_Type_BOF: $this->_readBof(); break; - case self::XLS_Type_SHEET: $this->_readSheet(); break; - case self::XLS_Type_EOF: $this->_readDefault(); break 2; - default: $this->_readDefault(); break; + case self::XLS_Type_BOF: + $this->_readBof(); + break; + case self::XLS_Type_SHEET: + $this->_readSheet(); + break; + case self::XLS_Type_EOF: + $this->_readDefault(); + break 2; + default: + $this->_readDefault(); + break; } } @@ -583,9 +598,15 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $tmpInfo['totalRows'] = max($tmpInfo['totalRows'], $rowIndex); $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex); break; - case self::XLS_Type_BOF: $this->_readBof(); break; - case self::XLS_Type_EOF: $this->_readDefault(); break 2; - default: $this->_readDefault(); break; + case self::XLS_Type_BOF: + $this->_readBof(); + break; + case self::XLS_Type_EOF: + $this->_readDefault(); + break 2; + default: + $this->_readDefault(); + break; } } @@ -629,45 +650,83 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $this->_dataSize = strlen($this->_data); // initialize - $this->_pos = 0; + $this->_pos = 0; $this->_codepage = 'CP1252'; - $this->_formats = array(); + $this->_formats = array(); $this->_objFonts = array(); - $this->_palette = array(); - $this->_sheets = array(); - $this->_externalBooks = array(); - $this->_ref = array(); - $this->_definedname = array(); - $this->_sst = array(); + $this->_palette = array(); + $this->_sheets = array(); + $this->_externalBooks = array(); + $this->_ref = array(); + $this->_definedname = array(); + $this->_sst = array(); $this->_drawingGroupData = ''; - $this->_xfIndex = ''; - $this->_mapCellXfIndex = array(); - $this->_mapCellStyleXfIndex = array(); + $this->_xfIndex = ''; + $this->_mapCellXfIndex = array(); + $this->_mapCellStyleXfIndex = array(); // Parse Workbook Global Substream while ($this->_pos < $this->_dataSize) { $code = self::_GetInt2d($this->_data, $this->_pos); switch ($code) { - case self::XLS_Type_BOF: $this->_readBof(); break; - case self::XLS_Type_FILEPASS: $this->_readFilepass(); break; - case self::XLS_Type_CODEPAGE: $this->_readCodepage(); break; - case self::XLS_Type_DATEMODE: $this->_readDateMode(); break; - case self::XLS_Type_FONT: $this->_readFont(); break; - case self::XLS_Type_FORMAT: $this->_readFormat(); break; - case self::XLS_Type_XF: $this->_readXf(); break; - case self::XLS_Type_XFEXT: $this->_readXfExt(); break; - case self::XLS_Type_STYLE: $this->_readStyle(); break; - case self::XLS_Type_PALETTE: $this->_readPalette(); break; - case self::XLS_Type_SHEET: $this->_readSheet(); break; - case self::XLS_Type_EXTERNALBOOK: $this->_readExternalBook(); break; - case self::XLS_Type_EXTERNNAME: $this->_readExternName(); break; - case self::XLS_Type_EXTERNSHEET: $this->_readExternSheet(); break; - case self::XLS_Type_DEFINEDNAME: $this->_readDefinedName(); break; - case self::XLS_Type_MSODRAWINGGROUP: $this->_readMsoDrawingGroup(); break; - case self::XLS_Type_SST: $this->_readSst(); break; - case self::XLS_Type_EOF: $this->_readDefault(); break 2; - default: $this->_readDefault(); break; + case self::XLS_Type_BOF: + $this->_readBof(); + break; + case self::XLS_Type_FILEPASS: + $this->_readFilepass(); + break; + case self::XLS_Type_CODEPAGE: + $this->_readCodepage(); + break; + case self::XLS_Type_DATEMODE: + $this->_readDateMode(); + break; + case self::XLS_Type_FONT: + $this->_readFont(); + break; + case self::XLS_Type_FORMAT: + $this->_readFormat(); + break; + case self::XLS_Type_XF: + $this->_readXf(); + break; + case self::XLS_Type_XFEXT: + $this->_readXfExt(); + break; + case self::XLS_Type_STYLE: + $this->_readStyle(); + break; + case self::XLS_Type_PALETTE: + $this->_readPalette(); + break; + case self::XLS_Type_SHEET: + $this->_readSheet(); + break; + case self::XLS_Type_EXTERNALBOOK: + $this->_readExternalBook(); + break; + case self::XLS_Type_EXTERNNAME: + $this->_readExternName(); + break; + case self::XLS_Type_EXTERNSHEET: + $this->_readExternSheet(); + break; + case self::XLS_Type_DEFINEDNAME: + $this->_readDefinedName(); + break; + case self::XLS_Type_MSODRAWINGGROUP: + $this->_readMsoDrawingGroup(); + break; + case self::XLS_Type_SST: + $this->_readSst(); + break; + case self::XLS_Type_EOF: + $this->_readDefault(); + break 2; + default: + $this->_readDefault(); + break; } } @@ -689,7 +748,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $startColor = self::_readColor($fill->startcolorIndex, $this->_palette, $this->_version); $fill->getStartColor()->setRGB($startColor['rgb']); } - if (isset($fill->endcolorIndex)) { $endColor = self::_readColor($fill->endcolorIndex, $this->_palette, $this->_version); $fill->getEndColor()->setRGB($endColor['rgb']); @@ -706,22 +764,18 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $borderTopColor = self::_readColor($top->colorIndex, $this->_palette, $this->_version); $top->getColor()->setRGB($borderTopColor['rgb']); } - if (isset($right->colorIndex)) { $borderRightColor = self::_readColor($right->colorIndex, $this->_palette, $this->_version); $right->getColor()->setRGB($borderRightColor['rgb']); } - if (isset($bottom->colorIndex)) { $borderBottomColor = self::_readColor($bottom->colorIndex, $this->_palette, $this->_version); $bottom->getColor()->setRGB($borderBottomColor['rgb']); } - if (isset($left->colorIndex)) { $borderLeftColor = self::_readColor($left->colorIndex, $this->_palette, $this->_version); $left->getColor()->setRGB($borderLeftColor['rgb']); } - if (isset($diagonal->colorIndex)) { $borderDiagonalColor = self::_readColor($diagonal->colorIndex, $this->_palette, $this->_version); $diagonal->getColor()->setRGB($borderDiagonalColor['rgb']); @@ -742,7 +796,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // Parse the individual sheets foreach ($this->_sheets as $sheet) { - if ($sheet['sheetType'] != 0x00) { // 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module continue; @@ -789,60 +842,166 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $code = self::_GetInt2d($this->_data, $this->_pos); switch ($code) { - case self::XLS_Type_BOF: $this->_readBof(); break; - case self::XLS_Type_PRINTGRIDLINES: $this->_readPrintGridlines(); break; - case self::XLS_Type_DEFAULTROWHEIGHT: $this->_readDefaultRowHeight(); break; - case self::XLS_Type_SHEETPR: $this->_readSheetPr(); break; - case self::XLS_Type_HORIZONTALPAGEBREAKS: $this->_readHorizontalPageBreaks(); break; - case self::XLS_Type_VERTICALPAGEBREAKS: $this->_readVerticalPageBreaks(); break; - case self::XLS_Type_HEADER: $this->_readHeader(); break; - case self::XLS_Type_FOOTER: $this->_readFooter(); break; - case self::XLS_Type_HCENTER: $this->_readHcenter(); break; - case self::XLS_Type_VCENTER: $this->_readVcenter(); break; - case self::XLS_Type_LEFTMARGIN: $this->_readLeftMargin(); break; - case self::XLS_Type_RIGHTMARGIN: $this->_readRightMargin(); break; - case self::XLS_Type_TOPMARGIN: $this->_readTopMargin(); break; - case self::XLS_Type_BOTTOMMARGIN: $this->_readBottomMargin(); break; - case self::XLS_Type_PAGESETUP: $this->_readPageSetup(); break; - case self::XLS_Type_PROTECT: $this->_readProtect(); break; - case self::XLS_Type_SCENPROTECT: $this->_readScenProtect(); break; - case self::XLS_Type_OBJECTPROTECT: $this->_readObjectProtect(); break; - case self::XLS_Type_PASSWORD: $this->_readPassword(); break; - case self::XLS_Type_DEFCOLWIDTH: $this->_readDefColWidth(); break; - case self::XLS_Type_COLINFO: $this->_readColInfo(); break; - case self::XLS_Type_DIMENSION: $this->_readDefault(); break; - case self::XLS_Type_ROW: $this->_readRow(); break; - case self::XLS_Type_DBCELL: $this->_readDefault(); break; - case self::XLS_Type_RK: $this->_readRk(); break; - case self::XLS_Type_LABELSST: $this->_readLabelSst(); break; - case self::XLS_Type_MULRK: $this->_readMulRk(); break; - case self::XLS_Type_NUMBER: $this->_readNumber(); break; - case self::XLS_Type_FORMULA: $this->_readFormula(); break; - case self::XLS_Type_SHAREDFMLA: $this->_readSharedFmla(); break; - case self::XLS_Type_BOOLERR: $this->_readBoolErr(); break; - case self::XLS_Type_MULBLANK: $this->_readMulBlank(); break; - case self::XLS_Type_LABEL: $this->_readLabel(); break; - case self::XLS_Type_BLANK: $this->_readBlank(); break; - case self::XLS_Type_MSODRAWING: $this->_readMsoDrawing(); break; - case self::XLS_Type_OBJ: $this->_readObj(); break; - case self::XLS_Type_WINDOW2: $this->_readWindow2(); break; - case self::XLS_Type_PAGELAYOUTVIEW: $this->_readPageLayoutView(); break; - case self::XLS_Type_SCL: $this->_readScl(); break; - case self::XLS_Type_PANE: $this->_readPane(); break; - case self::XLS_Type_SELECTION: $this->_readSelection(); break; - case self::XLS_Type_MERGEDCELLS: $this->_readMergedCells(); break; - case self::XLS_Type_HYPERLINK: $this->_readHyperLink(); break; - case self::XLS_Type_DATAVALIDATIONS: $this->_readDataValidations(); break; - case self::XLS_Type_DATAVALIDATION: $this->_readDataValidation(); break; - case self::XLS_Type_SHEETLAYOUT: $this->_readSheetLayout(); break; - case self::XLS_Type_SHEETPROTECTION: $this->_readSheetProtection(); break; - case self::XLS_Type_RANGEPROTECTION: $this->_readRangeProtection(); break; - case self::XLS_Type_NOTE: $this->_readNote(); break; + case self::XLS_Type_BOF: + $this->_readBof(); + break; + case self::XLS_Type_PRINTGRIDLINES: + $this->_readPrintGridlines(); + break; + case self::XLS_Type_DEFAULTROWHEIGHT: + $this->_readDefaultRowHeight(); + break; + case self::XLS_Type_SHEETPR: + $this->_readSheetPr(); + break; + case self::XLS_Type_HORIZONTALPAGEBREAKS: + $this->_readHorizontalPageBreaks(); + break; + case self::XLS_Type_VERTICALPAGEBREAKS: + $this->_readVerticalPageBreaks(); + break; + case self::XLS_Type_HEADER: + $this->_readHeader(); + break; + case self::XLS_Type_FOOTER: + $this->_readFooter(); + break; + case self::XLS_Type_HCENTER: + $this->_readHcenter(); + break; + case self::XLS_Type_VCENTER: + $this->_readVcenter(); + break; + case self::XLS_Type_LEFTMARGIN: + $this->_readLeftMargin(); + break; + case self::XLS_Type_RIGHTMARGIN: + $this->_readRightMargin(); + break; + case self::XLS_Type_TOPMARGIN: + $this->_readTopMargin(); + break; + case self::XLS_Type_BOTTOMMARGIN: + $this->_readBottomMargin(); + break; + case self::XLS_Type_PAGESETUP: + $this->_readPageSetup(); + break; + case self::XLS_Type_PROTECT: + $this->_readProtect(); + break; + case self::XLS_Type_SCENPROTECT: + $this->_readScenProtect(); + break; + case self::XLS_Type_OBJECTPROTECT: + $this->_readObjectProtect(); + break; + case self::XLS_Type_PASSWORD: + $this->_readPassword(); + break; + case self::XLS_Type_DEFCOLWIDTH: + $this->_readDefColWidth(); + break; + case self::XLS_Type_COLINFO: + $this->_readColInfo(); + break; + case self::XLS_Type_DIMENSION: + $this->_readDefault(); + break; + case self::XLS_Type_ROW: + $this->_readRow(); + break; + case self::XLS_Type_DBCELL: + $this->_readDefault(); + break; + case self::XLS_Type_RK: + $this->_readRk(); + break; + case self::XLS_Type_LABELSST: + $this->_readLabelSst(); + break; + case self::XLS_Type_MULRK: + $this->_readMulRk(); + break; + case self::XLS_Type_NUMBER: + $this->_readNumber(); + break; + case self::XLS_Type_FORMULA: + $this->_readFormula(); + break; + case self::XLS_Type_SHAREDFMLA: + $this->_readSharedFmla(); + break; + case self::XLS_Type_BOOLERR: + $this->_readBoolErr(); + break; + case self::XLS_Type_MULBLANK: + $this->_readMulBlank(); + break; + case self::XLS_Type_LABEL: + $this->_readLabel(); + break; + case self::XLS_Type_BLANK: + $this->_readBlank(); + break; + case self::XLS_Type_MSODRAWING: + $this->_readMsoDrawing(); + break; + case self::XLS_Type_OBJ: + $this->_readObj(); + break; + case self::XLS_Type_WINDOW2: + $this->_readWindow2(); + break; + case self::XLS_Type_PAGELAYOUTVIEW: + $this->_readPageLayoutView(); + break; + case self::XLS_Type_SCL: + $this->_readScl(); + break; + case self::XLS_Type_PANE: + $this->_readPane(); + break; + case self::XLS_Type_SELECTION: + $this->_readSelection(); + break; + case self::XLS_Type_MERGEDCELLS: + $this->_readMergedCells(); + break; + case self::XLS_Type_HYPERLINK: + $this->_readHyperLink(); + break; + case self::XLS_Type_DATAVALIDATIONS: + $this->_readDataValidations(); + break; + case self::XLS_Type_DATAVALIDATION: + $this->_readDataValidation(); + break; + case self::XLS_Type_SHEETLAYOUT: + $this->_readSheetLayout(); + break; + case self::XLS_Type_SHEETPROTECTION: + $this->_readSheetProtection(); + break; + case self::XLS_Type_RANGEPROTECTION: + $this->_readRangeProtection(); + break; + case self::XLS_Type_NOTE: + $this->_readNote(); + break; //case self::XLS_Type_IMDATA: $this->_readImData(); break; - case self::XLS_Type_TXO: $this->_readTextObject(); break; - case self::XLS_Type_CONTINUE: $this->_readContinue(); break; - case self::XLS_Type_EOF: $this->_readDefault(); break 2; - default: $this->_readDefault(); break; + case self::XLS_Type_TXO: + $this->_readTextObject(); + break; + case self::XLS_Type_CONTINUE: + $this->_readContinue(); + break; + case self::XLS_Type_EOF: + $this->_readDefault(); + break 2; + default: + $this->_readDefault(); + break; } } @@ -897,7 +1056,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // Note // echo 'Cell Annotation Object
'; // echo 'Object ID is ', $obj['idObjID'],'
'; -// if (isset($this->_cellNotes[$obj['idObjID']])) { $cellNote = $this->_cellNotes[$obj['idObjID']]; @@ -907,11 +1065,9 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } } break; - case 0x08: // echo 'Picture Object
'; // picture - // get index to BSE entry (1-based) $BSEindex = $spContainer->getOPT(0x0104); $BSECollection = $escherWorkbook->getDggContainer()->getBstoreContainer()->getBSECollection(); @@ -936,7 +1092,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG); $drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_JPEG); break; - case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG: $drawing->setRenderingFunction(PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG); $drawing->setMimeType(PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_PNG); @@ -946,13 +1101,10 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $drawing->setWorksheet($this->_phpSheet); $drawing->setCoordinates($spContainer->getStartCoordinates()); } - break; - default: // other object type break; - } } } @@ -982,9 +1134,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // var_dump($noteDetails); // echo '
'; $cellAddress = str_replace('$','', $noteDetails['cellRef']); - $this->_phpSheet->getComment( $cellAddress ) - ->setAuthor( $noteDetails['author'] ) - ->setText($this->_parseRichText($noteDetails['objTextData']['text']) ); + $this->_phpSheet->getComment($cellAddress)->setAuthor($noteDetails['author'])->setText($this->_parseRichText($noteDetails['objTextData']['text'])); } } } @@ -993,78 +1143,69 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce foreach ($this->_definedname as $definedName) { if ($definedName['isBuiltInName']) { switch ($definedName['name']) { + case pack('C', 0x06): + // print area + // in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2 + $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma? - case pack('C', 0x06): - // print area - // in general, formula looks like this: Foo!$C$7:$J$66,Bar!$A$1:$IV$2 - $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma? - - $extractedRanges = array(); - foreach ($ranges as $range) { - // $range should look like one of these - // Foo!$C$7:$J$66 - // Bar!$A$1:$IV$2 - - $explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark? - $sheetName = trim($explodes[0], "'"); - - if (count($explodes) == 2) { - if (strpos($explodes[1], ':') === FALSE) { - $explodes[1] = $explodes[1] . ':' . $explodes[1]; + $extractedRanges = array(); + foreach ($ranges as $range) { + // $range should look like one of these + // Foo!$C$7:$J$66 + // Bar!$A$1:$IV$2 + $explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark? + $sheetName = trim($explodes[0], "'"); + if (count($explodes) == 2) { + if (strpos($explodes[1], ':') === FALSE) { + $explodes[1] = $explodes[1] . ':' . $explodes[1]; + } + $extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66 } - $extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66 } - } - if ($docSheet = $this->_phpExcel->getSheetByName($sheetName)) { - $docSheet->getPageSetup()->setPrintArea(implode(',', $extractedRanges)); // C7:J66,A1:IV2 - } - break; + if ($docSheet = $this->_phpExcel->getSheetByName($sheetName)) { + $docSheet->getPageSetup()->setPrintArea(implode(',', $extractedRanges)); // C7:J66,A1:IV2 + } + break; + case pack('C', 0x07): + // print titles (repeating rows) + // Assuming BIFF8, there are 3 cases + // 1. repeating rows + // formula looks like this: Sheet!$A$1:$IV$2 + // rows 1-2 repeat + // 2. repeating columns + // formula looks like this: Sheet!$A$1:$B$65536 + // columns A-B repeat + // 3. both repeating rows and repeating columns + // formula looks like this: Sheet!$A$1:$B$65536,Sheet!$A$1:$IV$2 + $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma? + foreach ($ranges as $range) { + // $range should look like this one of these + // Sheet!$A$1:$B$65536 + // Sheet!$A$1:$IV$2 + $explodes = explode('!', $range); + if (count($explodes) == 2) { + if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) { - case pack('C', 0x07): - // print titles (repeating rows) - // Assuming BIFF8, there are 3 cases - // 1. repeating rows - // formula looks like this: Sheet!$A$1:$IV$2 - // rows 1-2 repeat - // 2. repeating columns - // formula looks like this: Sheet!$A$1:$B$65536 - // columns A-B repeat - // 3. both repeating rows and repeating columns - // formula looks like this: Sheet!$A$1:$B$65536,Sheet!$A$1:$IV$2 + $extractedRange = $explodes[1]; + $extractedRange = str_replace('$', '', $extractedRange); - $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma? + $coordinateStrings = explode(':', $extractedRange); + if (count($coordinateStrings) == 2) { + list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[0]); + list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[1]); - foreach ($ranges as $range) { - // $range should look like this one of these - // Sheet!$A$1:$B$65536 - // Sheet!$A$1:$IV$2 - - $explodes = explode('!', $range); - - if (count($explodes) == 2) { - if ($docSheet = $this->_phpExcel->getSheetByName($explodes[0])) { - - $extractedRange = $explodes[1]; - $extractedRange = str_replace('$', '', $extractedRange); - - $coordinateStrings = explode(':', $extractedRange); - if (count($coordinateStrings) == 2) { - list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[0]); - list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($coordinateStrings[1]); - - if ($firstColumn == 'A' and $lastColumn == 'IV') { - // then we have repeating rows - $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($firstRow, $lastRow)); - } elseif ($firstRow == 1 and $lastRow == 65536) { - // then we have repeating columns - $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($firstColumn, $lastColumn)); + if ($firstColumn == 'A' and $lastColumn == 'IV') { + // then we have repeating rows + $docSheet->getPageSetup()->setRowsToRepeatAtTop(array($firstRow, $lastRow)); + } elseif ($firstRow == 1 and $lastRow == 65536) { + // then we have repeating columns + $docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($firstColumn, $lastColumn)); + } } } } } - } - break; - + break; } } else { // Extract range @@ -1078,8 +1219,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $localOnly = ($definedName['scope'] == 0) ? false : true; - $scope = ($definedName['scope'] == 0) ? - null : $this->_phpExcel->getSheetByName($this->_sheets[$definedName['scope'] - 1]['name']); + $scope = ($definedName['scope'] == 0) ? null : $this->_phpExcel->getSheetByName($this->_sheets[$definedName['scope'] - 1]['name']); $this->_phpExcel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $docSheet, $extractedRange, $localOnly, $scope) ); } @@ -1114,7 +1254,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $recordData = ''; if ($this->_encryption == self::MS_BIFF_CRYPTO_RC4) { - $oldBlock = floor($this->_rc4Pos / self::REKEY_BLOCK); $block = floor($pos / self::REKEY_BLOCK); $endBlock = floor(($pos + $len) / self::REKEY_BLOCK); @@ -1144,7 +1283,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // Keep track of the position of this decryptor. // We'll try and re-use it later if we can to speed things up $this->_rc4Pos = $pos + $len; - } elseif ($this->_encryption == self::MS_BIFF_CRYPTO_XOR) { throw new PHPExcel_Reader_Exception('XOr encryption not supported'); } @@ -1160,18 +1298,14 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce { // OLE reader $ole = new PHPExcel_Shared_OLERead(); - // get excel data, $res = $ole->read($pFilename); // Get workbook data: workbook stream + sheet streams $this->_data = $ole->getStream($ole->wrkbook); - // Get summary information data $this->_summaryInformation = $ole->getStream($ole->summaryInformation); - // Get additional document summary information data $this->_documentSummaryInformation = $ole->getStream($ole->documentSummaryInformation); - // Get user-defined property data // $this->_userDefinedProperties = $ole->getUserDefinedProperties(); } @@ -1211,7 +1345,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // offset: ($secOffset+8); size: var // loop through property decarations and properties for ($i = 0; $i < $countProperties; ++$i) { - // offset: ($secOffset+8) + (8 * $i); size: 4; property ID $id = self::_GetInt4d($this->_summaryInformation, ($secOffset+8) + (8 * $i)); @@ -1229,27 +1362,22 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce case 0x02: // 2 byte signed integer $value = self::_GetInt2d($this->_summaryInformation, $secOffset + 4 + $offset); break; - case 0x03: // 4 byte signed integer $value = self::_GetInt4d($this->_summaryInformation, $secOffset + 4 + $offset); break; - case 0x13: // 4 byte unsigned integer // not needed yet, fix later if necessary break; - case 0x1E: // null-terminated string prepended by dword string length $byteLength = self::_GetInt4d($this->_summaryInformation, $secOffset + 4 + $offset); $value = substr($this->_summaryInformation, $secOffset + 8 + $offset, $byteLength); $value = PHPExcel_Shared_String::ConvertEncoding($value, 'UTF-8', $codePage); $value = rtrim($value); break; - case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) // PHP-time $value = PHPExcel_Shared_OLE::OLE2LocalDate(substr($this->_summaryInformation, $secOffset + 4 + $offset, 8)); break; - case 0x47: // Clipboard format // not needed yet, fix later if necessary break; @@ -1259,79 +1387,60 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce case 0x01: // Code Page $codePage = PHPExcel_Shared_CodePage::NumberToName($value); break; - case 0x02: // Title $this->_phpExcel->getProperties()->setTitle($value); break; - case 0x03: // Subject $this->_phpExcel->getProperties()->setSubject($value); break; - case 0x04: // Author (Creator) $this->_phpExcel->getProperties()->setCreator($value); break; - case 0x05: // Keywords $this->_phpExcel->getProperties()->setKeywords($value); break; - case 0x06: // Comments (Description) $this->_phpExcel->getProperties()->setDescription($value); break; - case 0x07: // Template // Not supported by PHPExcel break; - case 0x08: // Last Saved By (LastModifiedBy) $this->_phpExcel->getProperties()->setLastModifiedBy($value); break; - case 0x09: // Revision // Not supported by PHPExcel break; - case 0x0A: // Total Editing Time // Not supported by PHPExcel break; - case 0x0B: // Last Printed // Not supported by PHPExcel break; - case 0x0C: // Created Date/Time $this->_phpExcel->getProperties()->setCreated($value); break; - case 0x0D: // Modified Date/Time $this->_phpExcel->getProperties()->setModified($value); break; - case 0x0E: // Number of Pages // Not supported by PHPExcel break; - case 0x0F: // Number of Words // Not supported by PHPExcel break; - case 0x10: // Number of Characters // Not supported by PHPExcel break; - case 0x11: // Thumbnail // Not supported by PHPExcel break; - case 0x12: // Name of creating application // Not supported by PHPExcel break; - case 0x13: // Security // Not supported by PHPExcel break; - } } } @@ -1395,32 +1504,26 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce case 0x02: // 2 byte signed integer $value = self::_GetInt2d($this->_documentSummaryInformation, $secOffset + 4 + $offset); break; - case 0x03: // 4 byte signed integer $value = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + 4 + $offset); break; - case 0x0B: // Boolean $value = self::_GetInt2d($this->_documentSummaryInformation, $secOffset + 4 + $offset); $value = ($value == 0 ? false : true); break; - case 0x13: // 4 byte unsigned integer // not needed yet, fix later if necessary break; - case 0x1E: // null-terminated string prepended by dword string length $byteLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + 4 + $offset); $value = substr($this->_documentSummaryInformation, $secOffset + 8 + $offset, $byteLength); $value = PHPExcel_Shared_String::ConvertEncoding($value, 'UTF-8', $codePage); $value = rtrim($value); break; - case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) // PHP-Time $value = PHPExcel_Shared_OLE::OLE2LocalDate(substr($this->_documentSummaryInformation, $secOffset + 4 + $offset, 8)); break; - case 0x47: // Clipboard format // not needed yet, fix later if necessary break; @@ -1430,67 +1533,51 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce case 0x01: // Code Page $codePage = PHPExcel_Shared_CodePage::NumberToName($value); break; - case 0x02: // Category $this->_phpExcel->getProperties()->setCategory($value); break; - case 0x03: // Presentation Target // Not supported by PHPExcel break; - case 0x04: // Bytes // Not supported by PHPExcel break; - case 0x05: // Lines // Not supported by PHPExcel break; - case 0x06: // Paragraphs // Not supported by PHPExcel break; - case 0x07: // Slides // Not supported by PHPExcel break; - case 0x08: // Notes // Not supported by PHPExcel break; - case 0x09: // Hidden Slides // Not supported by PHPExcel break; - case 0x0A: // MM Clips // Not supported by PHPExcel break; - case 0x0B: // Scale Crop // Not supported by PHPExcel break; - case 0x0C: // Heading Pairs // Not supported by PHPExcel break; - case 0x0D: // Titles of Parts // Not supported by PHPExcel break; - case 0x0E: // Manager $this->_phpExcel->getProperties()->setManager($value); break; - case 0x0F: // Company $this->_phpExcel->getProperties()->setCompany($value); break; - case 0x10: // Links up-to-date // Not supported by PHPExcel break; - } } } @@ -1535,10 +1622,11 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // echo 'Note Object ID=', $noteObjID,'
'; // echo 'Note Author=', $noteAuthor,'
'; // - $this->_cellNotes[$noteObjID] = array('cellRef' => $cellAddress, - 'objectID' => $noteObjID, - 'author' => $noteAuthor - ); + $this->_cellNotes[$noteObjID] = array( + 'cellRef' => $cellAddress, + 'objectID' => $noteObjID, + 'author' => $noteAuthor + ); } else { $extension = false; if ($cellAddress == '$B$65536') { @@ -1564,9 +1652,8 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $comment->setText($this->_parseRichText($commentText.$noteText) ); } else { // Set comment for the cell - $this->_phpSheet->getComment( $cellAddress ) + $this->_phpSheet->getComment($cellAddress)->setText($this->_parseRichText($noteText)); // ->setAuthor( $author ) - ->setText($this->_parseRichText($noteText) ); } } @@ -1594,18 +1681,18 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // cchText: 2 bytes; length of the text (in the first continue record) // cbRuns: 2 bytes; length of the formatting (in the second continue record) // followed by the continuation records containing the actual text and formatting - $grbitOpts = self::_GetInt2d($recordData, 0); + $grbitOpts = self::_GetInt2d($recordData, 0); $rot = self::_GetInt2d($recordData, 2); $cchText = self::_GetInt2d($recordData, 10); - $cbRuns = self::_GetInt2d($recordData, 12); - $text = $this->_getSplicedRecordData(); + $cbRuns = self::_GetInt2d($recordData, 12); + $text = $this->_getSplicedRecordData(); $this->_textObjects[$this->textObjRef] = array( - 'text' => substr($text["recordData"], $text["spliceOffsets"][0]+1, $cchText), - 'format' => substr($text["recordData"], $text["spliceOffsets"][1], $cbRuns), - 'alignment' => $grbitOpts, - 'rotation' => $rot - ); + 'text' => substr($text["recordData"], $text["spliceOffsets"][0]+1, $cchText), + 'format' => substr($text["recordData"], $text["spliceOffsets"][1], $cbRuns), + 'alignment' => $grbitOpts, + 'rotation' => $rot + ); // echo '_readTextObject()
'; // var_dump($this->_textObjects[$this->textObjRef]); @@ -1635,12 +1722,10 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } $this->_version = $version; break; - case self::XLS_Worksheet: // do not use this version information for anything // it is unreliable (OpenOffice doc, 5.8), use only version information from the global stream break; - default: // substream, e.g. chart // just skip the entire substream @@ -1681,13 +1766,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // move stream pointer to next record $this->_pos += 4 + $length; - if (!$this->_verifyPassword( - 'VelvetSweatshop', - substr($recordData, 6, 16), - substr($recordData, 22, 16), - substr($recordData, 38, 16), - $this->_md5Ctxt - )) { + if (!$this->_verifyPassword('VelvetSweatshop', substr($recordData, 6, 16), substr($recordData, 22, 16), substr($recordData, 38, 16), $this->_md5Ctxt)) { throw new PHPExcel_Reader_Exception('Decryption password incorrect'); } @@ -1766,11 +1845,9 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce if ((64 - $offset) < 5) { $tocopy = 64 - $offset; } - for ($i = 0; $i <= $tocopy; $i++) { $pwarray[$offset + $i] = $mdContext1[$keyoffset + $i]; } - $offset += $tocopy; if ($offset == 64) { @@ -2045,13 +2122,11 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $xfTypeProt = self::_GetInt2d($recordData, 4); // bit 0; mask 0x01; 1 = cell is locked $isLocked = (0x01 & $xfTypeProt) >> 0; - $objStyle->getProtection()->setLocked($isLocked ? - PHPExcel_Style_Protection::PROTECTION_INHERIT : PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); + $objStyle->getProtection()->setLocked($isLocked ? PHPExcel_Style_Protection::PROTECTION_INHERIT : PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); // bit 1; mask 0x02; 1 = Formula is hidden $isHidden = (0x02 & $xfTypeProt) >> 1; - $objStyle->getProtection()->setHidden($isHidden ? - PHPExcel_Style_Protection::PROTECTION_PROTECTED : PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); + $objStyle->getProtection()->setHidden($isHidden ? PHPExcel_Style_Protection::PROTECTION_PROTECTED : PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); // bit 2; mask 0x04; 0 = Cell XF, 1 = Cell Style XF $isCellStyleXf = (0x04 & $xfTypeProt) >> 2; @@ -2111,101 +2186,99 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce if ($this->_version == self::XLS_BIFF8) { // offset: 7; size: 1; XF_ROTATION: Text rotation angle - $angle = ord($recordData{7}); - $rotation = 0; - if ($angle <= 90) { - $rotation = $angle; - } else if ($angle <= 180) { - $rotation = 90 - $angle; - } else if ($angle == 255) { - $rotation = -165; - } - $objStyle->getAlignment()->setTextRotation($rotation); + $angle = ord($recordData{7}); + $rotation = 0; + if ($angle <= 90) { + $rotation = $angle; + } else if ($angle <= 180) { + $rotation = 90 - $angle; + } else if ($angle == 255) { + $rotation = -165; + } + $objStyle->getAlignment()->setTextRotation($rotation); // offset: 8; size: 1; Indentation, shrink to cell size, and text direction - // bit: 3-0; mask: 0x0F; indent level - $indent = (0x0F & ord($recordData{8})) >> 0; - $objStyle->getAlignment()->setIndent($indent); + // bit: 3-0; mask: 0x0F; indent level + $indent = (0x0F & ord($recordData{8})) >> 0; + $objStyle->getAlignment()->setIndent($indent); - // bit: 4; mask: 0x10; 1 = shrink content to fit into cell - $shrinkToFit = (0x10 & ord($recordData{8})) >> 4; - switch ($shrinkToFit) { - case 0: - $objStyle->getAlignment()->setShrinkToFit(false); - break; - case 1: - $objStyle->getAlignment()->setShrinkToFit(true); - break; - } + // bit: 4; mask: 0x10; 1 = shrink content to fit into cell + $shrinkToFit = (0x10 & ord($recordData{8})) >> 4; + switch ($shrinkToFit) { + case 0: + $objStyle->getAlignment()->setShrinkToFit(false); + break; + case 1: + $objStyle->getAlignment()->setShrinkToFit(true); + break; + } // offset: 9; size: 1; Flags used for attribute groups // offset: 10; size: 4; Cell border lines and background area - // bit: 3-0; mask: 0x0000000F; left style - if ($bordersLeftStyle = self::_mapBorderStyle((0x0000000F & self::_GetInt4d($recordData, 10)) >> 0)) { - $objStyle->getBorders()->getLeft()->setBorderStyle($bordersLeftStyle); - } - // bit: 7-4; mask: 0x000000F0; right style - if ($bordersRightStyle = self::_mapBorderStyle((0x000000F0 & self::_GetInt4d($recordData, 10)) >> 4)) { - $objStyle->getBorders()->getRight()->setBorderStyle($bordersRightStyle); - } - // bit: 11-8; mask: 0x00000F00; top style - if ($bordersTopStyle = self::_mapBorderStyle((0x00000F00 & self::_GetInt4d($recordData, 10)) >> 8)) { - $objStyle->getBorders()->getTop()->setBorderStyle($bordersTopStyle); - } - // bit: 15-12; mask: 0x0000F000; bottom style - if ($bordersBottomStyle = self::_mapBorderStyle((0x0000F000 & self::_GetInt4d($recordData, 10)) >> 12)) { - $objStyle->getBorders()->getBottom()->setBorderStyle($bordersBottomStyle); - } - // bit: 22-16; mask: 0x007F0000; left color - $objStyle->getBorders()->getLeft()->colorIndex = (0x007F0000 & self::_GetInt4d($recordData, 10)) >> 16; + // bit: 3-0; mask: 0x0000000F; left style + if ($bordersLeftStyle = self::_mapBorderStyle((0x0000000F & self::_GetInt4d($recordData, 10)) >> 0)) { + $objStyle->getBorders()->getLeft()->setBorderStyle($bordersLeftStyle); + } + // bit: 7-4; mask: 0x000000F0; right style + if ($bordersRightStyle = self::_mapBorderStyle((0x000000F0 & self::_GetInt4d($recordData, 10)) >> 4)) { + $objStyle->getBorders()->getRight()->setBorderStyle($bordersRightStyle); + } + // bit: 11-8; mask: 0x00000F00; top style + if ($bordersTopStyle = self::_mapBorderStyle((0x00000F00 & self::_GetInt4d($recordData, 10)) >> 8)) { + $objStyle->getBorders()->getTop()->setBorderStyle($bordersTopStyle); + } + // bit: 15-12; mask: 0x0000F000; bottom style + if ($bordersBottomStyle = self::_mapBorderStyle((0x0000F000 & self::_GetInt4d($recordData, 10)) >> 12)) { + $objStyle->getBorders()->getBottom()->setBorderStyle($bordersBottomStyle); + } + // bit: 22-16; mask: 0x007F0000; left color + $objStyle->getBorders()->getLeft()->colorIndex = (0x007F0000 & self::_GetInt4d($recordData, 10)) >> 16; - // bit: 29-23; mask: 0x3F800000; right color - $objStyle->getBorders()->getRight()->colorIndex = (0x3F800000 & self::_GetInt4d($recordData, 10)) >> 23; + // bit: 29-23; mask: 0x3F800000; right color + $objStyle->getBorders()->getRight()->colorIndex = (0x3F800000 & self::_GetInt4d($recordData, 10)) >> 23; - // bit: 30; mask: 0x40000000; 1 = diagonal line from top left to right bottom - $diagonalDown = (0x40000000 & self::_GetInt4d($recordData, 10)) >> 30 ? - true : false; + // bit: 30; mask: 0x40000000; 1 = diagonal line from top left to right bottom + $diagonalDown = (0x40000000 & self::_GetInt4d($recordData, 10)) >> 30 ? true : false; - // bit: 31; mask: 0x80000000; 1 = diagonal line from bottom left to top right - $diagonalUp = (0x80000000 & self::_GetInt4d($recordData, 10)) >> 31 ? - true : false; + // bit: 31; mask: 0x80000000; 1 = diagonal line from bottom left to top right + $diagonalUp = (0x80000000 & self::_GetInt4d($recordData, 10)) >> 31 ? true : false; - if ($diagonalUp == false && $diagonalDown == false) { - $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_NONE); - } elseif ($diagonalUp == true && $diagonalDown == false) { - $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_UP); - } elseif ($diagonalUp == false && $diagonalDown == true) { - $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_DOWN); - } elseif ($diagonalUp == true && $diagonalDown == true) { - $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_BOTH); - } + if ($diagonalUp == false && $diagonalDown == false) { + $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_NONE); + } elseif ($diagonalUp == true && $diagonalDown == false) { + $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_UP); + } elseif ($diagonalUp == false && $diagonalDown == true) { + $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_DOWN); + } elseif ($diagonalUp == true && $diagonalDown == true) { + $objStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_BOTH); + } // offset: 14; size: 4; - // bit: 6-0; mask: 0x0000007F; top color - $objStyle->getBorders()->getTop()->colorIndex = (0x0000007F & self::_GetInt4d($recordData, 14)) >> 0; + // bit: 6-0; mask: 0x0000007F; top color + $objStyle->getBorders()->getTop()->colorIndex = (0x0000007F & self::_GetInt4d($recordData, 14)) >> 0; - // bit: 13-7; mask: 0x00003F80; bottom color - $objStyle->getBorders()->getBottom()->colorIndex = (0x00003F80 & self::_GetInt4d($recordData, 14)) >> 7; + // bit: 13-7; mask: 0x00003F80; bottom color + $objStyle->getBorders()->getBottom()->colorIndex = (0x00003F80 & self::_GetInt4d($recordData, 14)) >> 7; - // bit: 20-14; mask: 0x001FC000; diagonal color - $objStyle->getBorders()->getDiagonal()->colorIndex = (0x001FC000 & self::_GetInt4d($recordData, 14)) >> 14; + // bit: 20-14; mask: 0x001FC000; diagonal color + $objStyle->getBorders()->getDiagonal()->colorIndex = (0x001FC000 & self::_GetInt4d($recordData, 14)) >> 14; - // bit: 24-21; mask: 0x01E00000; diagonal style - if ($bordersDiagonalStyle = self::_mapBorderStyle((0x01E00000 & self::_GetInt4d($recordData, 14)) >> 21)) { - $objStyle->getBorders()->getDiagonal()->setBorderStyle($bordersDiagonalStyle); - } + // bit: 24-21; mask: 0x01E00000; diagonal style + if ($bordersDiagonalStyle = self::_mapBorderStyle((0x01E00000 & self::_GetInt4d($recordData, 14)) >> 21)) { + $objStyle->getBorders()->getDiagonal()->setBorderStyle($bordersDiagonalStyle); + } - // bit: 31-26; mask: 0xFC000000 fill pattern - if ($fillType = self::_mapFillPattern((0xFC000000 & self::_GetInt4d($recordData, 14)) >> 26)) { - $objStyle->getFill()->setFillType($fillType); - } + // bit: 31-26; mask: 0xFC000000 fill pattern + if ($fillType = self::_mapFillPattern((0xFC000000 & self::_GetInt4d($recordData, 14)) >> 26)) { + $objStyle->getFill()->setFillType($fillType); + } // offset: 18; size: 2; pattern and background colour - // bit: 6-0; mask: 0x007F; color index for pattern color - $objStyle->getFill()->startcolorIndex = (0x007F & self::_GetInt2d($recordData, 18)) >> 0; + // bit: 6-0; mask: 0x007F; color index for pattern color + $objStyle->getFill()->startcolorIndex = (0x007F & self::_GetInt2d($recordData, 18)) >> 0; - // bit: 13-7; mask: 0x3F80; color index for pattern background - $objStyle->getFill()->endcolorIndex = (0x3F80 & self::_GetInt2d($recordData, 18)) >> 7; + // bit: 13-7; mask: 0x3F80; color index for pattern background + $objStyle->getFill()->endcolorIndex = (0x3F80 & self::_GetInt2d($recordData, 18)) >> 7; } else { // BIFF5 @@ -2344,7 +2417,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } } break; - case 5: // fill end color $xclfType = self::_GetInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) @@ -2360,7 +2432,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } } break; - case 7: // border color top $xclfType = self::_GetInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) @@ -2376,7 +2447,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } } break; - case 8: // border color bottom $xclfType = self::_GetInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) @@ -2392,7 +2462,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } } break; - case 9: // border color left $xclfType = self::_GetInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) @@ -2408,7 +2477,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } } break; - case 10: // border color right $xclfType = self::_GetInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) @@ -2424,7 +2492,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } } break; - case 11: // border color diagonal $xclfType = self::_GetInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) @@ -2440,7 +2507,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } } break; - case 13: // font color $xclfType = self::_GetInt2d($extData, 0); // color type $xclrValue = substr($extData, 4, 4); // color value (value based on color type) @@ -2494,11 +2560,9 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce case 0x00: // currently, we are not using this for anything break; - default: break; } - } else { // user-defined; not supported by PHPExcel } @@ -2556,10 +2620,18 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // offset: 4; size: 1; sheet state switch (ord($recordData{4})) { - case 0x00: $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; break; - case 0x01: $sheetState = PHPExcel_Worksheet::SHEETSTATE_HIDDEN; break; - case 0x02: $sheetState = PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN; break; - default: $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; break; + case 0x00: + $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; + break; + case 0x01: + $sheetState = PHPExcel_Worksheet::SHEETSTATE_HIDDEN; + break; + case 0x02: + $sheetState = PHPExcel_Worksheet::SHEETSTATE_VERYHIDDEN; + break; + default: + $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; + break; } // offset: 5; size: 1; sheet type @@ -2622,7 +2694,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce 'encodedUrl' => $encodedUrlString['value'], 'externalSheetNames' => $externalSheetNames, ); - } elseif (substr($recordData, 2, 2) == pack('CC', 0x01, 0x04)) { // internal reference // offset: 0; size: 2; number of sheet in this document @@ -2736,8 +2807,8 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // offset: 0; size: 2; option flags $opts = self::_GetInt2d($recordData, 0); - // bit: 5; mask: 0x0020; 0 = user-defined name, 1 = built-in-name - $isBuiltInName = (0x0020 & $opts) >> 5; + // bit: 5; mask: 0x0020; 0 = user-defined name, 1 = built-in-name + $isBuiltInName = (0x0020 & $opts) >> 5; // offset: 2; size: 1; keyboard shortcut @@ -2868,7 +2939,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $retstr = substr($recordData, $pos, $len); $pos += $len; - } else { // character array is split between records @@ -2884,7 +2954,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // keep reading the characters while ($charsLeft > 0) { - // look up next limit position, in case the string span more than one continue record foreach ($spliceOffsets as $spliceOffset) { if ($pos < $spliceOffset) { @@ -2905,7 +2974,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $retstr .= substr($recordData, $pos, $len); $charsLeft -= $len; $isCompressed = true; - } elseif (!$isCompressed && ($option != 0)) { // 1st fragment uncompressed // this fragment uncompressed @@ -2913,7 +2981,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $retstr .= substr($recordData, $pos, $len); $charsLeft -= $len / 2; $isCompressed = false; - } elseif (!$isCompressed && ($option == 0)) { // 1st fragment uncompressed // this fragment compressed @@ -2923,7 +2990,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } $charsLeft -= $len; $isCompressed = false; - } else { // 1st fragment compressed // this fragment uncompressed @@ -3057,7 +3123,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $this->_pos += 4 + $length; if ($this->_version == self::XLS_BIFF8 && !$this->_readDataOnly) { - // offset: 0; size: 2; number of the following row index structures $nm = self::_GetInt2d($recordData, 0); @@ -3295,18 +3360,22 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // offset: 10; size: 2; option flags - // bit: 1; mask: 0x0002; 0=landscape, 1=portrait - $isPortrait = (0x0002 & self::_GetInt2d($recordData, 10)) >> 1; + // bit: 1; mask: 0x0002; 0=landscape, 1=portrait + $isPortrait = (0x0002 & self::_GetInt2d($recordData, 10)) >> 1; - // bit: 2; mask: 0x0004; 1= paper size, scaling factor, paper orient. not init - // when this bit is set, do not use flags for those properties - $isNotInit = (0x0004 & self::_GetInt2d($recordData, 10)) >> 2; + // bit: 2; mask: 0x0004; 1= paper size, scaling factor, paper orient. not init + // when this bit is set, do not use flags for those properties + $isNotInit = (0x0004 & self::_GetInt2d($recordData, 10)) >> 2; if (!$isNotInit) { $this->_phpSheet->getPageSetup()->setPaperSize($paperSize); switch ($isPortrait) { - case 0: $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); break; - case 1: $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); break; + case 0: + $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); + break; + case 1: + $this->_phpSheet->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); + break; } $this->_phpSheet->getPageSetup()->setScale($scale, false); @@ -3461,15 +3530,14 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $xfIndex = self::_GetInt2d($recordData, 6); // offset: 8; size: 2; option flags + // bit: 0; mask: 0x0001; 1= columns are hidden + $isHidden = (0x0001 & self::_GetInt2d($recordData, 8)) >> 0; - // bit: 0; mask: 0x0001; 1= columns are hidden - $isHidden = (0x0001 & self::_GetInt2d($recordData, 8)) >> 0; + // bit: 10-8; mask: 0x0700; outline level of the columns (0 = no outline) + $level = (0x0700 & self::_GetInt2d($recordData, 8)) >> 8; - // bit: 10-8; mask: 0x0700; outline level of the columns (0 = no outline) - $level = (0x0700 & self::_GetInt2d($recordData, 8)) >> 8; - - // bit: 12; mask: 0x1000; 1 = collapsed - $isCollapsed = (0x1000 & self::_GetInt2d($recordData, 8)) >> 12; + // bit: 12; mask: 0x1000; 1 = collapsed + $isCollapsed = (0x1000 & self::_GetInt2d($recordData, 8)) >> 12; // offset: 10; size: 2; not used @@ -3584,7 +3652,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $columnString = PHPExcel_Cell::stringFromColumnIndex($column); // Read cell? - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { // offset: 4; size: 2; index to XF record $xfIndex = self::_GetInt2d($recordData, 4); @@ -3629,7 +3697,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $columnString = PHPExcel_Cell::stringFromColumnIndex($column); // Read cell? - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) { // offset: 4; size: 2; index to XF record $xfIndex = self::_GetInt2d($recordData, 4); @@ -3716,8 +3784,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $columnString = PHPExcel_Cell::stringFromColumnIndex($colFirst + $i); // Read cell? - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { - + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) { // offset: var; size: 2; index to XF record $xfIndex = self::_GetInt2d($recordData, $offset); @@ -3762,7 +3829,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $columnString = PHPExcel_Cell::stringFromColumnIndex($column); // Read cell? - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) { // offset 4; size: 2; index to XF record $xfIndex = self::_GetInt2d($recordData, 4); @@ -3829,8 +3896,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } // Read cell? - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { - + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) { if ($isPartOfSharedFormula) { // formula is added to this cell after the sheet has been read $this->_sharedFormulaParts[$columnString . ($row + 1)] = $this->_baseCell; @@ -3842,10 +3908,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $xfIndex = self::_GetInt2d($recordData, 4); // offset: 6; size: 8; result of the formula - if ( (ord($recordData{6}) == 0) - && (ord($recordData{12}) == 255) - && (ord($recordData{13}) == 255) ) { - + if ((ord($recordData{6}) == 0) && (ord($recordData{12}) == 255) && (ord($recordData{13}) == 255)) { // String formula. Result follows in appended STRING record $dataType = PHPExcel_Cell_DataType::TYPE_STRING; @@ -3857,7 +3920,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // read STRING record $value = $this->_readString(); - } elseif ((ord($recordData{6}) == 1) && (ord($recordData{12}) == 255) && (ord($recordData{13}) == 255)) { @@ -3865,7 +3927,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // Boolean formula. Result is in +2; 0=false, 1=true $dataType = PHPExcel_Cell_DataType::TYPE_BOOL; $value = (bool) ord($recordData{8}); - } elseif ((ord($recordData{6}) == 2) && (ord($recordData{12}) == 255) && (ord($recordData{13}) == 255)) { @@ -3873,7 +3934,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // Error formula. Error code is in +2 $dataType = PHPExcel_Cell_DataType::TYPE_ERROR; $value = self::_mapErrorCode(ord($recordData{8})); - } elseif ((ord($recordData{6}) == 3) && (ord($recordData{12}) == 255) && (ord($recordData{13}) == 255)) { @@ -3881,13 +3941,10 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // Formula result is a null string $dataType = PHPExcel_Cell_DataType::TYPE_NULL; $value = ''; - } else { - // forumla result is a number, first 14 bytes like _NUMBER record $dataType = PHPExcel_Cell_DataType::TYPE_NUMERIC; $value = self::_extractNumber(substr($recordData, 6, 8)); - } $cell = $this->_phpSheet->getCell($columnString . ($row + 1)); @@ -3951,7 +4008,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // at this point we only store the shared formula for later use $this->_sharedFormulas[$this->_baseCell] = $formula; - } @@ -4006,7 +4062,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $columnString = PHPExcel_Cell::stringFromColumnIndex($column); // Read cell? - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) { // offset: 4; size: 2; index to XF record $xfIndex = self::_GetInt2d($recordData, 4); @@ -4024,7 +4080,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // add cell value $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_BOOL); break; - case 1: // error type $value = self::_mapErrorCode($boolErr); @@ -4150,7 +4205,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $columnString = PHPExcel_Cell::stringFromColumnIndex($col); // Read cell? - if (($this->getReadFilter() !== NULL) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) { + if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle())) { // offset: 4; size: 2; XF index $xfIndex = self::_GetInt2d($recordData, 4); @@ -4202,18 +4257,18 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // data: var; subrecord data // for now, we are just interested in the second subrecord containing the object type - $ftCmoType = self::_GetInt2d($recordData, 0); - $cbCmoSize = self::_GetInt2d($recordData, 2); - $otObjType = self::_GetInt2d($recordData, 4); + $ftCmoType = self::_GetInt2d($recordData, 0); + $cbCmoSize = self::_GetInt2d($recordData, 2); + $otObjType = self::_GetInt2d($recordData, 4); $idObjID = self::_GetInt2d($recordData, 6); - $grbitOpts = self::_GetInt2d($recordData, 6); + $grbitOpts = self::_GetInt2d($recordData, 6); $this->_objs[] = array( - 'ftCmoType' => $ftCmoType, - 'cbCmoSize' => $cbCmoSize, - 'otObjType' => $otObjType, - 'idObjID' => $idObjID, - 'grbitOpts' => $grbitOpts + 'ftCmoType' => $ftCmoType, + 'cbCmoSize' => $cbCmoSize, + 'otObjType' => $otObjType, + 'idObjID' => $idObjID, + 'grbitOpts' => $grbitOpts ); $this->textObjRef = $idObjID; @@ -4248,9 +4303,13 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // offset: 12; size: 2; cached magnification factor in normal view (in percent); 0 = Default (100%) // offset: 14; size: 4; not used $zoomscaleInPageBreakPreview = self::_GetInt2d($recordData, 10); - if ($zoomscaleInPageBreakPreview === 0) $zoomscaleInPageBreakPreview = 60; + if ($zoomscaleInPageBreakPreview === 0) { + $zoomscaleInPageBreakPreview = 60; + } $zoomscaleInNormalView = self::_GetInt2d($recordData, 12); - if ($zoomscaleInNormalView === 0) $zoomscaleInNormalView = 100; + if ($zoomscaleInNormalView === 0) { + $zoomscaleInNormalView = 100; + } } // bit: 1; mask: 0x0002; 0 = do not show gridlines, 1 = show gridlines @@ -4280,11 +4339,10 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce if ($this->_phpSheet->getSheetView()->getView() !== PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT) { //NOTE: this setting is inferior to page layout view(Excel2007-) - $view = $isPageBreakPreview? PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW : - PHPExcel_Worksheet_SheetView::SHEETVIEW_NORMAL; + $view = $isPageBreakPreview ? PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW : PHPExcel_Worksheet_SheetView::SHEETVIEW_NORMAL; $this->_phpSheet->getSheetView()->setView($view); if ($this->_version === self::XLS_BIFF8) { - $zoomScale = $isPageBreakPreview? $zoomscaleInPageBreakPreview : $zoomscaleInNormalView; + $zoomScale = $isPageBreakPreview ? $zoomscaleInPageBreakPreview : $zoomscaleInNormalView; $this->_phpSheet->getSheetView()->setZoomScale($zoomScale); $this->_phpSheet->getSheetView()->setZoomScaleNormal($zoomscaleInNormalView); } @@ -4433,7 +4491,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce private function _includeCellRangeFiltered($cellRangeAddress) { $includeCellRange = true; - if ($this->getReadFilter() !== NULL) { + if ($this->getReadFilter() !== null) { $includeCellRange = false; $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($cellRangeAddress); $rangeBoundaries[1][0]++; @@ -4503,24 +4561,23 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // offset: 24, size: 4; unknown value // offset: 28, size: 4; option flags + // bit: 0; mask: 0x00000001; 0 = no link or extant, 1 = file link or URL + $isFileLinkOrUrl = (0x00000001 & self::_GetInt2d($recordData, 28)) >> 0; - // bit: 0; mask: 0x00000001; 0 = no link or extant, 1 = file link or URL - $isFileLinkOrUrl = (0x00000001 & self::_GetInt2d($recordData, 28)) >> 0; + // bit: 1; mask: 0x00000002; 0 = relative path, 1 = absolute path or URL + $isAbsPathOrUrl = (0x00000001 & self::_GetInt2d($recordData, 28)) >> 1; - // bit: 1; mask: 0x00000002; 0 = relative path, 1 = absolute path or URL - $isAbsPathOrUrl = (0x00000001 & self::_GetInt2d($recordData, 28)) >> 1; + // bit: 2 (and 4); mask: 0x00000014; 0 = no description + $hasDesc = (0x00000014 & self::_GetInt2d($recordData, 28)) >> 2; - // bit: 2 (and 4); mask: 0x00000014; 0 = no description - $hasDesc = (0x00000014 & self::_GetInt2d($recordData, 28)) >> 2; + // bit: 3; mask: 0x00000008; 0 = no text, 1 = has text + $hasText = (0x00000008 & self::_GetInt2d($recordData, 28)) >> 3; - // bit: 3; mask: 0x00000008; 0 = no text, 1 = has text - $hasText = (0x00000008 & self::_GetInt2d($recordData, 28)) >> 3; + // bit: 7; mask: 0x00000080; 0 = no target frame, 1 = has target frame + $hasFrame = (0x00000080 & self::_GetInt2d($recordData, 28)) >> 7; - // bit: 7; mask: 0x00000080; 0 = no target frame, 1 = has target frame - $hasFrame = (0x00000080 & self::_GetInt2d($recordData, 28)) >> 7; - - // bit: 8; mask: 0x00000100; 0 = file link or URL, 1 = UNC path (inc. server name) - $isUNC = (0x00000100 & self::_GetInt2d($recordData, 28)) >> 8; + // bit: 8; mask: 0x00000100; 0 = file link or URL, 1 = UNC path (inc. server name) + $isUNC = (0x00000100 & self::_GetInt2d($recordData, 28)) >> 8; // offset within record data $offset = 32; @@ -4551,94 +4608,87 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce } switch ($hyperlinkType) { - case 'URL': - // section 5.58.2: Hyperlink containing a URL - // e.g. http://example.org/index.php + case 'URL': + // section 5.58.2: Hyperlink containing a URL + // e.g. http://example.org/index.php - // offset: var; size: 16; GUID of URL Moniker - $offset += 16; - // offset: var; size: 4; size (in bytes) of character array of the URL including trailing zero word - $us = self::_GetInt4d($recordData, $offset); - $offset += 4; - // offset: var; size: $us; character array of the URL, no Unicode string header, always 16-bit characters, zero-terminated - $url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false); - $nullOffset = strpos($url, 0x00); - if ($nullOffset) - $url = substr($url,0, $nullOffset); - $url .= $hasText ? '#' : ''; - $offset += $us; - break; - - case 'local': - // section 5.58.3: Hyperlink to local file - // examples: - // mydoc.txt - // ../../somedoc.xls#Sheet!A1 - - // offset: var; size: 16; GUI of File Moniker - $offset += 16; - - // offset: var; size: 2; directory up-level count. - $upLevelCount = self::_GetInt2d($recordData, $offset); - $offset += 2; - - // offset: var; size: 4; character count of the shortened file path and name, including trailing zero word - $sl = self::_GetInt4d($recordData, $offset); - $offset += 4; - - // offset: var; size: sl; character array of the shortened file path and name in 8.3-DOS-format (compressed Unicode string) - $shortenedFilePath = substr($recordData, $offset, $sl); - $shortenedFilePath = self::_encodeUTF16($shortenedFilePath, true); - $shortenedFilePath = substr($shortenedFilePath, 0, -1); // remove trailing zero - - $offset += $sl; - - // offset: var; size: 24; unknown sequence - $offset += 24; - - // extended file path - // offset: var; size: 4; size of the following file link field including string lenth mark - $sz = self::_GetInt4d($recordData, $offset); - $offset += 4; - - // only present if $sz > 0 - if ($sz > 0) { - // offset: var; size: 4; size of the character array of the extended file path and name - $xl = self::_GetInt4d($recordData, $offset); + // offset: var; size: 16; GUID of URL Moniker + $offset += 16; + // offset: var; size: 4; size (in bytes) of character array of the URL including trailing zero word + $us = self::_GetInt4d($recordData, $offset); $offset += 4; + // offset: var; size: $us; character array of the URL, no Unicode string header, always 16-bit characters, zero-terminated + $url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false); + $nullOffset = strpos($url, 0x00); + if ($nullOffset) + $url = substr($url,0, $nullOffset); + $url .= $hasText ? '#' : ''; + $offset += $us; + break; + case 'local': + // section 5.58.3: Hyperlink to local file + // examples: + // mydoc.txt + // ../../somedoc.xls#Sheet!A1 - // offset: var; size 2; unknown + // offset: var; size: 16; GUI of File Moniker + $offset += 16; + + // offset: var; size: 2; directory up-level count. + $upLevelCount = self::_GetInt2d($recordData, $offset); $offset += 2; - // offset: var; size $xl; character array of the extended file path and name. - $extendedFilePath = substr($recordData, $offset, $xl); - $extendedFilePath = self::_encodeUTF16($extendedFilePath, false); - $offset += $xl; - } + // offset: var; size: 4; character count of the shortened file path and name, including trailing zero word + $sl = self::_GetInt4d($recordData, $offset); + $offset += 4; - // construct the path - $url = str_repeat('..\\', $upLevelCount); - $url .= ($sz > 0) ? - $extendedFilePath : $shortenedFilePath; // use extended path if available - $url .= $hasText ? '#' : ''; + // offset: var; size: sl; character array of the shortened file path and name in 8.3-DOS-format (compressed Unicode string) + $shortenedFilePath = substr($recordData, $offset, $sl); + $shortenedFilePath = self::_encodeUTF16($shortenedFilePath, true); + $shortenedFilePath = substr($shortenedFilePath, 0, -1); // remove trailing zero - break; + $offset += $sl; + // offset: var; size: 24; unknown sequence + $offset += 24; - case 'UNC': - // section 5.58.4: Hyperlink to a File with UNC (Universal Naming Convention) Path - // todo: implement - return; + // extended file path + // offset: var; size: 4; size of the following file link field including string lenth mark + $sz = self::_GetInt4d($recordData, $offset); + $offset += 4; - case 'workbook': - // section 5.58.5: Hyperlink to the Current Workbook - // e.g. Sheet2!B1:C2, stored in text mark field - $url = 'sheet://'; - break; + // only present if $sz > 0 + if ($sz > 0) { + // offset: var; size: 4; size of the character array of the extended file path and name + $xl = self::_GetInt4d($recordData, $offset); + $offset += 4; - default: - return; + // offset: var; size 2; unknown + $offset += 2; + // offset: var; size $xl; character array of the extended file path and name. + $extendedFilePath = substr($recordData, $offset, $xl); + $extendedFilePath = self::_encodeUTF16($extendedFilePath, false); + $offset += $xl; + } + + // construct the path + $url = str_repeat('..\\', $upLevelCount); + $url .= ($sz > 0) ? $extendedFilePath : $shortenedFilePath; // use extended path if available + $url .= $hasText ? '#' : ''; + + break; + case 'UNC': + // section 5.58.4: Hyperlink to a File with UNC (Universal Naming Convention) Path + // todo: implement + return; + case 'workbook': + // section 5.58.5: Hyperlink to the Current Workbook + // e.g. Sheet2!B1:C2, stored in text mark field + $url = 'sheet://'; + break; + default: + return; } if ($hasText) { @@ -4692,22 +4742,44 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // bit: 0-3; mask: 0x0000000F; type $type = (0x0000000F & $options) >> 0; switch ($type) { - case 0x00: $type = PHPExcel_Cell_DataValidation::TYPE_NONE; break; - case 0x01: $type = PHPExcel_Cell_DataValidation::TYPE_WHOLE; break; - case 0x02: $type = PHPExcel_Cell_DataValidation::TYPE_DECIMAL; break; - case 0x03: $type = PHPExcel_Cell_DataValidation::TYPE_LIST; break; - case 0x04: $type = PHPExcel_Cell_DataValidation::TYPE_DATE; break; - case 0x05: $type = PHPExcel_Cell_DataValidation::TYPE_TIME; break; - case 0x06: $type = PHPExcel_Cell_DataValidation::TYPE_TEXTLENGTH; break; - case 0x07: $type = PHPExcel_Cell_DataValidation::TYPE_CUSTOM; break; + case 0x00: + $type = PHPExcel_Cell_DataValidation::TYPE_NONE; + break; + case 0x01: + $type = PHPExcel_Cell_DataValidation::TYPE_WHOLE; + break; + case 0x02: + $type = PHPExcel_Cell_DataValidation::TYPE_DECIMAL; + break; + case 0x03: + $type = PHPExcel_Cell_DataValidation::TYPE_LIST; + break; + case 0x04: + $type = PHPExcel_Cell_DataValidation::TYPE_DATE; + break; + case 0x05: + $type = PHPExcel_Cell_DataValidation::TYPE_TIME; + break; + case 0x06: + $type = PHPExcel_Cell_DataValidation::TYPE_TEXTLENGTH; + break; + case 0x07: + $type = PHPExcel_Cell_DataValidation::TYPE_CUSTOM; + break; } // bit: 4-6; mask: 0x00000070; error type $errorStyle = (0x00000070 & $options) >> 4; switch ($errorStyle) { - case 0x00: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; break; - case 0x01: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_WARNING; break; - case 0x02: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_INFORMATION; break; + case 0x00: + $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; + break; + case 0x01: + $errorStyle = PHPExcel_Cell_DataValidation::STYLE_WARNING; + break; + case 0x02: + $errorStyle = PHPExcel_Cell_DataValidation::STYLE_INFORMATION; + break; } // bit: 7; mask: 0x00000080; 1= formula is explicit (only applies to list) @@ -4729,39 +4801,51 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // bit: 20-23; mask: 0x00F00000; condition operator $operator = (0x00F00000 & $options) >> 20; switch ($operator) { - case 0x00: $operator = PHPExcel_Cell_DataValidation::OPERATOR_BETWEEN ; break; - case 0x01: $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTBETWEEN ; break; - case 0x02: $operator = PHPExcel_Cell_DataValidation::OPERATOR_EQUAL ; break; - case 0x03: $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTEQUAL ; break; - case 0x04: $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHAN ; break; - case 0x05: $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHAN ; break; - case 0x06: $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHANOREQUAL; break; - case 0x07: $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHANOREQUAL ; break; + case 0x00: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_BETWEEN; + break; + case 0x01: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTBETWEEN; + break; + case 0x02: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_EQUAL; + break; + case 0x03: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTEQUAL; + break; + case 0x04: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHAN; + break; + case 0x05: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHAN; + break; + case 0x06: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHANOREQUAL; + break; + case 0x07: + $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHANOREQUAL; + break; } // offset: 4; size: var; title of the prompt box $offset = 4; $string = self::_readUnicodeStringLong(substr($recordData, $offset)); - $promptTitle = $string['value'] !== chr(0) ? - $string['value'] : ''; + $promptTitle = $string['value'] !== chr(0) ? $string['value'] : ''; $offset += $string['size']; // offset: var; size: var; title of the error box $string = self::_readUnicodeStringLong(substr($recordData, $offset)); - $errorTitle = $string['value'] !== chr(0) ? - $string['value'] : ''; + $errorTitle = $string['value'] !== chr(0) ? $string['value'] : ''; $offset += $string['size']; // offset: var; size: var; text of the prompt box $string = self::_readUnicodeStringLong(substr($recordData, $offset)); - $prompt = $string['value'] !== chr(0) ? - $string['value'] : ''; + $prompt = $string['value'] !== chr(0) ? $string['value'] : ''; $offset += $string['size']; // offset: var; size: var; text of the error box $string = self::_readUnicodeStringLong(substr($recordData, $offset)); - $error = $string['value'] !== chr(0) ? - $string['value'] : ''; + $error = $string['value'] !== chr(0) ? $string['value'] : ''; $offset += $string['size']; // offset: var; size: 2; size of the formula data for the first condition @@ -4827,10 +4911,8 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $objValidation->setFormula2($formula2); } } - } - /** * Read SHEETLAYOUT record. Stores sheet tab color information. */ @@ -4861,7 +4943,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $color = self::_readColor($colorIndex, $this->_palette, $this->_version); $this->_phpSheet->getTabColor()->setRGB($color['rgb']); break; - case 0x28: // TODO: Investigate structure for .xls SHEETLAYOUT record as saved by MS Office Excel 2007 return; @@ -5059,55 +5140,52 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $iData = substr($recordData, 8); switch ($cf) { - case 0x09: // Windows bitmap format - // BITMAPCOREINFO - // 1. BITMAPCOREHEADER - // offset: 0; size: 4; bcSize, Specifies the number of bytes required by the structure - $bcSize = self::_GetInt4d($iData, 0); -// var_dump($bcSize); + case 0x09: // Windows bitmap format + // BITMAPCOREINFO + // 1. BITMAPCOREHEADER + // offset: 0; size: 4; bcSize, Specifies the number of bytes required by the structure + $bcSize = self::_GetInt4d($iData, 0); + // var_dump($bcSize); - // offset: 4; size: 2; bcWidth, specifies the width of the bitmap, in pixels - $bcWidth = self::_GetInt2d($iData, 4); -// var_dump($bcWidth); + // offset: 4; size: 2; bcWidth, specifies the width of the bitmap, in pixels + $bcWidth = self::_GetInt2d($iData, 4); + // var_dump($bcWidth); - // offset: 6; size: 2; bcHeight, specifies the height of the bitmap, in pixels. - $bcHeight = self::_GetInt2d($iData, 6); -// var_dump($bcHeight); - $ih = imagecreatetruecolor($bcWidth, $bcHeight); + // offset: 6; size: 2; bcHeight, specifies the height of the bitmap, in pixels. + $bcHeight = self::_GetInt2d($iData, 6); + // var_dump($bcHeight); + $ih = imagecreatetruecolor($bcWidth, $bcHeight); - // offset: 8; size: 2; bcPlanes, specifies the number of planes for the target device. This value must be 1 + // offset: 8; size: 2; bcPlanes, specifies the number of planes for the target device. This value must be 1 - // offset: 10; size: 2; bcBitCount specifies the number of bits-per-pixel. This value must be 1, 4, 8, or 24 - $bcBitCount = self::_GetInt2d($iData, 10); -// var_dump($bcBitCount); + // offset: 10; size: 2; bcBitCount specifies the number of bits-per-pixel. This value must be 1, 4, 8, or 24 + $bcBitCount = self::_GetInt2d($iData, 10); + // var_dump($bcBitCount); - $rgbString = substr($iData, 12); - $rgbTriples = array(); - while (strlen($rgbString) > 0) { - $rgbTriples[] = unpack('Cb/Cg/Cr', $rgbString); - $rgbString = substr($rgbString, 3); - } - $x = 0; - $y = 0; - foreach ($rgbTriples as $i => $rgbTriple) { - $color = imagecolorallocate($ih, $rgbTriple['r'], $rgbTriple['g'], $rgbTriple['b']); - imagesetpixel($ih, $x, $bcHeight - 1 - $y, $color); - $x = ($x + 1) % $bcWidth; - $y = $y + floor(($x + 1) / $bcWidth); - } - //imagepng($ih, 'image.png'); - - $drawing = new PHPExcel_Worksheet_Drawing(); - $drawing->setPath($filename); - $drawing->setWorksheet($this->_phpSheet); - - break; - - case 0x02: // Windows metafile or Macintosh PICT format - case 0x0e: // native format - default; - break; + $rgbString = substr($iData, 12); + $rgbTriples = array(); + while (strlen($rgbString) > 0) { + $rgbTriples[] = unpack('Cb/Cg/Cr', $rgbString); + $rgbString = substr($rgbString, 3); + } + $x = 0; + $y = 0; + foreach ($rgbTriples as $i => $rgbTriple) { + $color = imagecolorallocate($ih, $rgbTriple['r'], $rgbTriple['g'], $rgbTriple['b']); + imagesetpixel($ih, $x, $bcHeight - 1 - $y, $color); + $x = ($x + 1) % $bcWidth; + $y = $y + floor(($x + 1) / $bcWidth); + } + //imagepng($ih, 'image.png'); + $drawing = new PHPExcel_Worksheet_Drawing(); + $drawing->setPath($filename); + $drawing->setWorksheet($this->_phpSheet); + break; + case 0x02: // Windows metafile or Macintosh PICT format + case 0x0e: // native format + default; + break; } // _getSplicedRecordData() takes care of moving current position in data stream @@ -5160,7 +5238,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce // move stream pointer to next record $this->_pos += 4 + $length; - } @@ -5193,8 +5270,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $this->_pos += 4 + $length; $nextIdentifier = self::_GetInt2d($this->_data, $this->_pos); - } - while ($nextIdentifier == self::XLS_Type_CONTINUE); + } while ($nextIdentifier == self::XLS_Type_CONTINUE); $splicedData = array( 'recordData' => $data, @@ -5236,7 +5312,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce //echo 'the entire additional data: '; //Debug::dump($additionalData); //echo "\n----\n"; - } else { $additionalData = ''; } @@ -5298,132 +5373,132 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $space5 = isset($space5) ? $space5 : ''; // carriage returns before closing parenthesis switch ($token['name']) { - case 'tAdd': // addition - case 'tConcat': // addition - case 'tDiv': // division - case 'tEQ': // equality - case 'tGE': // greater than or equal - case 'tGT': // greater than - case 'tIsect': // intersection - case 'tLE': // less than or equal - case 'tList': // less than or equal - case 'tLT': // less than - case 'tMul': // multiplication - case 'tNE': // multiplication - case 'tPower': // power - case 'tRange': // range - case 'tSub': // subtraction - $op2 = array_pop($formulaStrings); - $op1 = array_pop($formulaStrings); - $formulaStrings[] = "$op1$space1$space0{$token['data']}$op2"; - unset($space0, $space1); - break; - case 'tUplus': // unary plus - case 'tUminus': // unary minus - $op = array_pop($formulaStrings); - $formulaStrings[] = "$space1$space0{$token['data']}$op"; - unset($space0, $space1); - break; - case 'tPercent': // percent sign - $op = array_pop($formulaStrings); - $formulaStrings[] = "$op$space1$space0{$token['data']}"; - unset($space0, $space1); - break; - case 'tAttrVolatile': // indicates volatile function - case 'tAttrIf': - case 'tAttrSkip': - case 'tAttrChoose': - // token is only important for Excel formula evaluator - // do nothing - break; - case 'tAttrSpace': // space / carriage return - // space will be used when next token arrives, do not alter formulaString stack - switch ($token['data']['spacetype']) { - case 'type0': - $space0 = str_repeat(' ', $token['data']['spacecount']); - break; - case 'type1': - $space1 = str_repeat("\n", $token['data']['spacecount']); - break; - case 'type2': - $space2 = str_repeat(' ', $token['data']['spacecount']); - break; - case 'type3': - $space3 = str_repeat("\n", $token['data']['spacecount']); - break; - case 'type4': - $space4 = str_repeat(' ', $token['data']['spacecount']); - break; - case 'type5': - $space5 = str_repeat("\n", $token['data']['spacecount']); - break; - } - break; - case 'tAttrSum': // SUM function with one parameter - $op = array_pop($formulaStrings); - $formulaStrings[] = "{$space1}{$space0}SUM($op)"; - unset($space0, $space1); - break; - case 'tFunc': // function with fixed number of arguments - case 'tFuncV': // function with variable number of arguments - if ($token['data']['function'] != '') { - // normal function - $ops = array(); // array of operators - for ($i = 0; $i < $token['data']['args']; ++$i) { - $ops[] = array_pop($formulaStrings); - } - $ops = array_reverse($ops); - $formulaStrings[] = "$space1$space0{$token['data']['function']}(" . implode(',', $ops) . ")"; + case 'tAdd': // addition + case 'tConcat': // addition + case 'tDiv': // division + case 'tEQ': // equality + case 'tGE': // greater than or equal + case 'tGT': // greater than + case 'tIsect': // intersection + case 'tLE': // less than or equal + case 'tList': // less than or equal + case 'tLT': // less than + case 'tMul': // multiplication + case 'tNE': // multiplication + case 'tPower': // power + case 'tRange': // range + case 'tSub': // subtraction + $op2 = array_pop($formulaStrings); + $op1 = array_pop($formulaStrings); + $formulaStrings[] = "$op1$space1$space0{$token['data']}$op2"; unset($space0, $space1); - } else { - // add-in function - $ops = array(); // array of operators - for ($i = 0; $i < $token['data']['args'] - 1; ++$i) { - $ops[] = array_pop($formulaStrings); - } - $ops = array_reverse($ops); - $function = array_pop($formulaStrings); - $formulaStrings[] = "$space1$space0$function(" . implode(',', $ops) . ")"; + break; + case 'tUplus': // unary plus + case 'tUminus': // unary minus + $op = array_pop($formulaStrings); + $formulaStrings[] = "$space1$space0{$token['data']}$op"; unset($space0, $space1); - } - break; - case 'tParen': // parenthesis - $expression = array_pop($formulaStrings); - $formulaStrings[] = "$space3$space2($expression$space5$space4)"; - unset($space2, $space3, $space4, $space5); - break; - case 'tArray': // array constant - $constantArray = self::_readBIFF8ConstantArray($additionalData); - $formulaStrings[] = $space1 . $space0 . $constantArray['value']; - $additionalData = substr($additionalData, $constantArray['size']); // bite of chunk of additional data - unset($space0, $space1); - break; - case 'tMemArea': - // bite off chunk of additional data - $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($additionalData); - $additionalData = substr($additionalData, $cellRangeAddressList['size']); - $formulaStrings[] = "$space1$space0{$token['data']}"; - unset($space0, $space1); - break; - case 'tArea': // cell range address - case 'tBool': // boolean - case 'tErr': // error code - case 'tInt': // integer - case 'tMemErr': - case 'tMemFunc': - case 'tMissArg': - case 'tName': - case 'tNameX': - case 'tNum': // number - case 'tRef': // single cell reference - case 'tRef3d': // 3d cell reference - case 'tArea3d': // 3d cell range reference - case 'tRefN': - case 'tAreaN': - case 'tStr': // string - $formulaStrings[] = "$space1$space0{$token['data']}"; - unset($space0, $space1); - break; + break; + case 'tPercent': // percent sign + $op = array_pop($formulaStrings); + $formulaStrings[] = "$op$space1$space0{$token['data']}"; + unset($space0, $space1); + break; + case 'tAttrVolatile': // indicates volatile function + case 'tAttrIf': + case 'tAttrSkip': + case 'tAttrChoose': + // token is only important for Excel formula evaluator + // do nothing + break; + case 'tAttrSpace': // space / carriage return + // space will be used when next token arrives, do not alter formulaString stack + switch ($token['data']['spacetype']) { + case 'type0': + $space0 = str_repeat(' ', $token['data']['spacecount']); + break; + case 'type1': + $space1 = str_repeat("\n", $token['data']['spacecount']); + break; + case 'type2': + $space2 = str_repeat(' ', $token['data']['spacecount']); + break; + case 'type3': + $space3 = str_repeat("\n", $token['data']['spacecount']); + break; + case 'type4': + $space4 = str_repeat(' ', $token['data']['spacecount']); + break; + case 'type5': + $space5 = str_repeat("\n", $token['data']['spacecount']); + break; + } + break; + case 'tAttrSum': // SUM function with one parameter + $op = array_pop($formulaStrings); + $formulaStrings[] = "{$space1}{$space0}SUM($op)"; + unset($space0, $space1); + break; + case 'tFunc': // function with fixed number of arguments + case 'tFuncV': // function with variable number of arguments + if ($token['data']['function'] != '') { + // normal function + $ops = array(); // array of operators + for ($i = 0; $i < $token['data']['args']; ++$i) { + $ops[] = array_pop($formulaStrings); + } + $ops = array_reverse($ops); + $formulaStrings[] = "$space1$space0{$token['data']['function']}(" . implode(',', $ops) . ")"; + unset($space0, $space1); + } else { + // add-in function + $ops = array(); // array of operators + for ($i = 0; $i < $token['data']['args'] - 1; ++$i) { + $ops[] = array_pop($formulaStrings); + } + $ops = array_reverse($ops); + $function = array_pop($formulaStrings); + $formulaStrings[] = "$space1$space0$function(" . implode(',', $ops) . ")"; + unset($space0, $space1); + } + break; + case 'tParen': // parenthesis + $expression = array_pop($formulaStrings); + $formulaStrings[] = "$space3$space2($expression$space5$space4)"; + unset($space2, $space3, $space4, $space5); + break; + case 'tArray': // array constant + $constantArray = self::_readBIFF8ConstantArray($additionalData); + $formulaStrings[] = $space1 . $space0 . $constantArray['value']; + $additionalData = substr($additionalData, $constantArray['size']); // bite of chunk of additional data + unset($space0, $space1); + break; + case 'tMemArea': + // bite off chunk of additional data + $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList($additionalData); + $additionalData = substr($additionalData, $cellRangeAddressList['size']); + $formulaStrings[] = "$space1$space0{$token['data']}"; + unset($space0, $space1); + break; + case 'tArea': // cell range address + case 'tBool': // boolean + case 'tErr': // error code + case 'tInt': // integer + case 'tMemErr': + case 'tMemFunc': + case 'tMissArg': + case 'tName': + case 'tNameX': + case 'tNum': // number + case 'tRef': // single cell reference + case 'tRef3d': // 3d cell reference + case 'tArea3d': // 3d cell range reference + case 'tRefN': + case 'tAreaN': + case 'tStr': // string + $formulaStrings[] = "$space1$space0{$token['data']}"; + unset($space0, $space1); + break; } } $formulaString = $formulaStrings[0]; @@ -5451,546 +5526,1268 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $name = false; // initialize token name switch ($id) { - case 0x03: $name = 'tAdd'; $size = 1; $data = '+'; break; - case 0x04: $name = 'tSub'; $size = 1; $data = '-'; break; - case 0x05: $name = 'tMul'; $size = 1; $data = '*'; break; - case 0x06: $name = 'tDiv'; $size = 1; $data = '/'; break; - case 0x07: $name = 'tPower'; $size = 1; $data = '^'; break; - case 0x08: $name = 'tConcat'; $size = 1; $data = '&'; break; - case 0x09: $name = 'tLT'; $size = 1; $data = '<'; break; - case 0x0A: $name = 'tLE'; $size = 1; $data = '<='; break; - case 0x0B: $name = 'tEQ'; $size = 1; $data = '='; break; - case 0x0C: $name = 'tGE'; $size = 1; $data = '>='; break; - case 0x0D: $name = 'tGT'; $size = 1; $data = '>'; break; - case 0x0E: $name = 'tNE'; $size = 1; $data = '<>'; break; - case 0x0F: $name = 'tIsect'; $size = 1; $data = ' '; break; - case 0x10: $name = 'tList'; $size = 1; $data = ','; break; - case 0x11: $name = 'tRange'; $size = 1; $data = ':'; break; - case 0x12: $name = 'tUplus'; $size = 1; $data = '+'; break; - case 0x13: $name = 'tUminus'; $size = 1; $data = '-'; break; - case 0x14: $name = 'tPercent'; $size = 1; $data = '%'; break; - case 0x15: // parenthesis - $name = 'tParen'; - $size = 1; - $data = null; - break; - case 0x16: // missing argument - $name = 'tMissArg'; - $size = 1; - $data = ''; - break; - case 0x17: // string - $name = 'tStr'; - // offset: 1; size: var; Unicode string, 8-bit string length - $string = self::_readUnicodeStringShort(substr($formulaData, 1)); - $size = 1 + $string['size']; - $data = self::_UTF8toExcelDoubleQuoted($string['value']); - break; - case 0x19: // Special attribute - // offset: 1; size: 1; attribute type flags: - switch (ord($formulaData[1])) { - case 0x01: - $name = 'tAttrVolatile'; - $size = 4; - $data = null; - break; - case 0x02: - $name = 'tAttrIf'; - $size = 4; - $data = null; + case 0x03: + $name = 'tAdd'; + $size = 1; + $data = '+'; break; case 0x04: - $name = 'tAttrChoose'; - // offset: 2; size: 2; number of choices in the CHOOSE function ($nc, number of parameters decreased by 1) - $nc = self::_GetInt2d($formulaData, 2); - // offset: 4; size: 2 * $nc - // offset: 4 + 2 * $nc; size: 2 - $size = 2 * $nc + 6; - $data = null; + $name = 'tSub'; + $size = 1; + $data = '-'; + break; + case 0x05: + $name = 'tMul'; + $size = 1; + $data = '*'; + break; + case 0x06: + $name = 'tDiv'; + $size = 1; + $data = '/'; + break; + case 0x07: + $name = 'tPower'; + $size = 1; + $data = '^'; break; case 0x08: - $name = 'tAttrSkip'; - $size = 4; - $data = null; + $name = 'tConcat'; + $size = 1; + $data = '&'; + break; + case 0x09: + $name = 'tLT'; + $size = 1; + $data = '<'; + break; + case 0x0A: + $name = 'tLE'; + $size = 1; + $data = '<='; + break; + case 0x0B: + $name = 'tEQ'; + $size = 1; + $data = '='; + break; + case 0x0C: + $name = 'tGE'; + $size = 1; + $data = '>='; + break; + case 0x0D: + $name = 'tGT'; + $size = 1; + $data = '>'; + break; + case 0x0E: + $name = 'tNE'; + $size = 1; + $data = '<>'; + break; + case 0x0F: + $name = 'tIsect'; + $size = 1; + $data = ' '; break; case 0x10: - $name = 'tAttrSum'; - $size = 4; + $name = 'tList'; + $size = 1; + $data = ','; + break; + case 0x11: + $name = 'tRange'; + $size = 1; + $data = ':'; + break; + case 0x12: + $name = 'tUplus'; + $size = 1; + $data = '+'; + break; + case 0x13: + $name = 'tUminus'; + $size = 1; + $data = '-'; + break; + case 0x14: + $name = 'tPercent'; + $size = 1; + $data = '%'; + break; + case 0x15: // parenthesis + $name = 'tParen'; + $size = 1; $data = null; break; - case 0x40: - case 0x41: - $name = 'tAttrSpace'; - $size = 4; - // offset: 2; size: 2; space type and position - switch (ord($formulaData[2])) { - case 0x00: - $spacetype = 'type0'; - break; - case 0x01: - $spacetype = 'type1'; - break; - case 0x02: - $spacetype = 'type2'; - break; - case 0x03: - $spacetype = 'type3'; - break; - case 0x04: - $spacetype = 'type4'; - break; - case 0x05: - $spacetype = 'type5'; - break; - default: - throw new PHPExcel_Reader_Exception('Unrecognized space type in tAttrSpace token'); - break; + case 0x16: // missing argument + $name = 'tMissArg'; + $size = 1; + $data = ''; + break; + case 0x17: // string + $name = 'tStr'; + // offset: 1; size: var; Unicode string, 8-bit string length + $string = self::_readUnicodeStringShort(substr($formulaData, 1)); + $size = 1 + $string['size']; + $data = self::_UTF8toExcelDoubleQuoted($string['value']); + break; + case 0x19: // Special attribute + // offset: 1; size: 1; attribute type flags: + switch (ord($formulaData[1])) { + case 0x01: + $name = 'tAttrVolatile'; + $size = 4; + $data = null; + break; + case 0x02: + $name = 'tAttrIf'; + $size = 4; + $data = null; + break; + case 0x04: + $name = 'tAttrChoose'; + // offset: 2; size: 2; number of choices in the CHOOSE function ($nc, number of parameters decreased by 1) + $nc = self::_GetInt2d($formulaData, 2); + // offset: 4; size: 2 * $nc + // offset: 4 + 2 * $nc; size: 2 + $size = 2 * $nc + 6; + $data = null; + break; + case 0x08: + $name = 'tAttrSkip'; + $size = 4; + $data = null; + break; + case 0x10: + $name = 'tAttrSum'; + $size = 4; + $data = null; + break; + case 0x40: + case 0x41: + $name = 'tAttrSpace'; + $size = 4; + // offset: 2; size: 2; space type and position + switch (ord($formulaData[2])) { + case 0x00: + $spacetype = 'type0'; + break; + case 0x01: + $spacetype = 'type1'; + break; + case 0x02: + $spacetype = 'type2'; + break; + case 0x03: + $spacetype = 'type3'; + break; + case 0x04: + $spacetype = 'type4'; + break; + case 0x05: + $spacetype = 'type5'; + break; + default: + throw new PHPExcel_Reader_Exception('Unrecognized space type in tAttrSpace token'); + break; + } + // offset: 3; size: 1; number of inserted spaces/carriage returns + $spacecount = ord($formulaData[3]); + + $data = array('spacetype' => $spacetype, 'spacecount' => $spacecount); + break; + default: + throw new PHPExcel_Reader_Exception('Unrecognized attribute flag in tAttr token'); + break; } - // offset: 3; size: 1; number of inserted spaces/carriage returns - $spacecount = ord($formulaData[3]); - - $data = array('spacetype' => $spacetype, 'spacecount' => $spacecount); break; + case 0x1C: // error code + // offset: 1; size: 1; error code + $name = 'tErr'; + $size = 2; + $data = self::_mapErrorCode(ord($formulaData[1])); + break; + case 0x1D: // boolean + // offset: 1; size: 1; 0 = false, 1 = true; + $name = 'tBool'; + $size = 2; + $data = ord($formulaData[1]) ? 'TRUE' : 'FALSE'; + break; + case 0x1E: // integer + // offset: 1; size: 2; unsigned 16-bit integer + $name = 'tInt'; + $size = 3; + $data = self::_GetInt2d($formulaData, 1); + break; + case 0x1F: // number + // offset: 1; size: 8; + $name = 'tNum'; + $size = 9; + $data = self::_extractNumber(substr($formulaData, 1)); + $data = str_replace(',', '.', (string)$data); // in case non-English locale + break; + case 0x20: // array constant + case 0x40: + case 0x60: + // offset: 1; size: 7; not used + $name = 'tArray'; + $size = 8; + $data = null; + break; + case 0x21: // function with fixed number of arguments + case 0x41: + case 0x61: + $name = 'tFunc'; + $size = 3; + // offset: 1; size: 2; index to built-in sheet function + switch (self::_GetInt2d($formulaData, 1)) { + case 2: + $function = 'ISNA'; + $args = 1; + break; + case 3: + $function = 'ISERROR'; + $args = 1; + break; + case 10: + $function = 'NA'; + $args = 0; + break; + case 15: + $function = 'SIN'; + $args = 1; + break; + case 16: + $function = 'COS'; + $args = 1; + break; + case 17: + $function = 'TAN'; + $args = 1; + break; + case 18: + $function = 'ATAN'; + $args = 1; + break; + case 19: + $function = 'PI'; + $args = 0; + break; + case 20: + $function = 'SQRT'; + $args = 1; + break; + case 21: + $function = 'EXP'; + $args = 1; + break; + case 22: + $function = 'LN'; + $args = 1; + break; + case 23: + $function = 'LOG10'; + $args = 1; + break; + case 24: + $function = 'ABS'; + $args = 1; + break; + case 25: + $function = 'INT'; + $args = 1; + break; + case 26: + $function = 'SIGN'; + $args = 1; + break; + case 27: + $function = 'ROUND'; + $args = 2; + break; + case 30: + $function = 'REPT'; + $args = 2; + break; + case 31: + $function = 'MID'; + $args = 3; + break; + case 32: + $function = 'LEN'; + $args = 1; + break; + case 33: + $function = 'VALUE'; + $args = 1; + break; + case 34: + $function = 'TRUE'; + $args = 0; + break; + case 35: + $function = 'FALSE'; + $args = 0; + break; + case 38: + $function = 'NOT'; + $args = 1; + break; + case 39: + $function = 'MOD'; + $args = 2; + break; + case 40: + $function = 'DCOUNT'; + $args = 3; + break; + case 41: + $function = 'DSUM'; + $args = 3; + break; + case 42: + $function = 'DAVERAGE'; + $args = 3; + break; + case 43: + $function = 'DMIN'; + $args = 3; + break; + case 44: + $function = 'DMAX'; + $args = 3; + break; + case 45: + $function = 'DSTDEV'; + $args = 3; + break; + case 48: + $function = 'TEXT'; + $args = 2; + break; + case 61: + $function = 'MIRR'; + $args = 3; + break; + case 63: + $function = 'RAND'; + $args = 0; + break; + case 65: + $function = 'DATE'; + $args = 3; + break; + case 66: + $function = 'TIME'; + $args = 3; + break; + case 67: + $function = 'DAY'; + $args = 1; + break; + case 68: + $function = 'MONTH'; + $args = 1; + break; + case 69: + $function = 'YEAR'; + $args = 1; + break; + case 71: + $function = 'HOUR'; + $args = 1; + break; + case 72: + $function = 'MINUTE'; + $args = 1; + break; + case 73: + $function = 'SECOND'; + $args = 1; + break; + case 74: + $function = 'NOW'; + $args = 0; + break; + case 75: + $function = 'AREAS'; + $args = 1; + break; + case 76: + $function = 'ROWS'; + $args = 1; + break; + case 77: + $function = 'COLUMNS'; + $args = 1; + break; + case 83: + $function = 'TRANSPOSE'; + $args = 1; + break; + case 86: + $function = 'TYPE'; + $args = 1; + break; + case 97: + $function = 'ATAN2'; + $args = 2; + break; + case 98: + $function = 'ASIN'; + $args = 1; + break; + case 99: + $function = 'ACOS'; + $args = 1; + break; + case 105: + $function = 'ISREF'; + $args = 1; + break; + case 111: + $function = 'CHAR'; + $args = 1; + break; + case 112: + $function = 'LOWER'; + $args = 1; + break; + case 113: + $function = 'UPPER'; + $args = 1; + break; + case 114: + $function = 'PROPER'; + $args = 1; + break; + case 117: + $function = 'EXACT'; + $args = 2; + break; + case 118: + $function = 'TRIM'; + $args = 1; + break; + case 119: + $function = 'REPLACE'; + $args = 4; + break; + case 121: + $function = 'CODE'; + $args = 1; + break; + case 126: + $function = 'ISERR'; + $args = 1; + break; + case 127: + $function = 'ISTEXT'; + $args = 1; + break; + case 128: + $function = 'ISNUMBER'; + $args = 1; + break; + case 129: + $function = 'ISBLANK'; + $args = 1; + break; + case 130: + $function = 'T'; + $args = 1; + break; + case 131: + $function = 'N'; + $args = 1; + break; + case 140: + $function = 'DATEVALUE'; + $args = 1; + break; + case 141: + $function = 'TIMEVALUE'; + $args = 1; + break; + case 142: + $function = 'SLN'; + $args = 3; + break; + case 143: + $function = 'SYD'; + $args = 4; + break; + case 162: + $function = 'CLEAN'; + $args = 1; + break; + case 163: + $function = 'MDETERM'; + $args = 1; + break; + case 164: + $function = 'MINVERSE'; + $args = 1; + break; + case 165: + $function = 'MMULT'; + $args = 2; + break; + case 184: + $function = 'FACT'; + $args = 1; + break; + case 189: + $function = 'DPRODUCT'; + $args = 3; + break; + case 190: + $function = 'ISNONTEXT'; + $args = 1; + break; + case 195: + $function = 'DSTDEVP'; + $args = 3; + break; + case 196: + $function = 'DVARP'; + $args = 3; + break; + case 198: + $function = 'ISLOGICAL'; + $args = 1; + break; + case 199: + $function = 'DCOUNTA'; + $args = 3; + break; + case 207: + $function = 'REPLACEB'; + $args = 4; + break; + case 210: + $function = 'MIDB'; + $args = 3; + break; + case 211: + $function = 'LENB'; + $args = 1; + break; + case 212: + $function = 'ROUNDUP'; + $args = 2; + break; + case 213: + $function = 'ROUNDDOWN'; + $args = 2; + break; + case 214: + $function = 'ASC'; + $args = 1; + break; + case 215: + $function = 'DBCS'; + $args = 1; + break; + case 221: + $function = 'TODAY'; + $args = 0; + break; + case 229: + $function = 'SINH'; + $args = 1; + break; + case 230: + $function = 'COSH'; + $args = 1; + break; + case 231: + $function = 'TANH'; + $args = 1; + break; + case 232: + $function = 'ASINH'; + $args = 1; + break; + case 233: + $function = 'ACOSH'; + $args = 1; + break; + case 234: + $function = 'ATANH'; + $args = 1; + break; + case 235: + $function = 'DGET'; + $args = 3; + break; + case 244: + $function = 'INFO'; + $args = 1; + break; + case 252: + $function = 'FREQUENCY'; + $args = 2; + break; + case 261: + $function = 'ERROR.TYPE'; + $args = 1; + break; + case 271: + $function = 'GAMMALN'; + $args = 1; + break; + case 273: + $function = 'BINOMDIST'; + $args = 4; + break; + case 274: + $function = 'CHIDIST'; + $args = 2; + break; + case 275: + $function = 'CHIINV'; + $args = 2; + break; + case 276: + $function = 'COMBIN'; + $args = 2; + break; + case 277: + $function = 'CONFIDENCE'; + $args = 3; + break; + case 278: + $function = 'CRITBINOM'; + $args = 3; + break; + case 279: + $function = 'EVEN'; + $args = 1; + break; + case 280: + $function = 'EXPONDIST'; + $args = 3; + break; + case 281: + $function = 'FDIST'; + $args = 3; + break; + case 282: + $function = 'FINV'; + $args = 3; + break; + case 283: + $function = 'FISHER'; + $args = 1; + break; + case 284: + $function = 'FISHERINV'; + $args = 1; + break; + case 285: + $function = 'FLOOR'; + $args = 2; + break; + case 286: + $function = 'GAMMADIST'; + $args = 4; + break; + case 287: + $function = 'GAMMAINV'; + $args = 3; + break; + case 288: + $function = 'CEILING'; + $args = 2; + break; + case 289: + $function = 'HYPGEOMDIST'; + $args = 4; + break; + case 290: + $function = 'LOGNORMDIST'; + $args = 3; + break; + case 291: + $function = 'LOGINV'; + $args = 3; + break; + case 292: + $function = 'NEGBINOMDIST'; + $args = 3; + break; + case 293: + $function = 'NORMDIST'; + $args = 4; + break; + case 294: + $function = 'NORMSDIST'; + $args = 1; + break; + case 295: + $function = 'NORMINV'; + $args = 3; + break; + case 296: + $function = 'NORMSINV'; + $args = 1; + break; + case 297: + $function = 'STANDARDIZE'; + $args = 3; + break; + case 298: + $function = 'ODD'; + $args = 1; + break; + case 299: + $function = 'PERMUT'; + $args = 2; + break; + case 300: + $function = 'POISSON'; + $args = 3; + break; + case 301: + $function = 'TDIST'; + $args = 3; + break; + case 302: + $function = 'WEIBULL'; + $args = 4; + break; + case 303: + $function = 'SUMXMY2'; + $args = 2; + break; + case 304: + $function = 'SUMX2MY2'; + $args = 2; + break; + case 305: + $function = 'SUMX2PY2'; + $args = 2; + break; + case 306: + $function = 'CHITEST'; + $args = 2; + break; + case 307: + $function = 'CORREL'; + $args = 2; + break; + case 308: + $function = 'COVAR'; + $args = 2; + break; + case 309: + $function = 'FORECAST'; + $args = 3; + break; + case 310: + $function = 'FTEST'; + $args = 2; + break; + case 311: + $function = 'INTERCEPT'; + $args = 2; + break; + case 312: + $function = 'PEARSON'; + $args = 2; + break; + case 313: + $function = 'RSQ'; + $args = 2; + break; + case 314: + $function = 'STEYX'; + $args = 2; + break; + case 315: + $function = 'SLOPE'; + $args = 2; + break; + case 316: + $function = 'TTEST'; + $args = 4; + break; + case 325: + $function = 'LARGE'; + $args = 2; + break; + case 326: + $function = 'SMALL'; + $args = 2; + break; + case 327: + $function = 'QUARTILE'; + $args = 2; + break; + case 328: + $function = 'PERCENTILE'; + $args = 2; + break; + case 331: + $function = 'TRIMMEAN'; + $args = 2; + break; + case 332: + $function = 'TINV'; + $args = 2; + break; + case 337: + $function = 'POWER'; + $args = 2; + break; + case 342: + $function = 'RADIANS'; + $args = 1; + break; + case 343: + $function = 'DEGREES'; + $args = 1; + break; + case 346: + $function = 'COUNTIF'; + $args = 2; + break; + case 347: + $function = 'COUNTBLANK'; + $args = 1; + break; + case 350: + $function = 'ISPMT'; + $args = 4; + break; + case 351: + $function = 'DATEDIF'; + $args = 3; + break; + case 352: + $function = 'DATESTRING'; + $args = 1; + break; + case 353: + $function = 'NUMBERSTRING'; + $args = 2; + break; + case 360: + $function = 'PHONETIC'; + $args = 1; + break; + case 368: + $function = 'BAHTTEXT'; + $args = 1; + break; + default: + throw new PHPExcel_Reader_Exception('Unrecognized function in formula'); + break; + } + $data = array('function' => $function, 'args' => $args); + break; + case 0x22: // function with variable number of arguments + case 0x42: + case 0x62: + $name = 'tFuncV'; + $size = 4; + // offset: 1; size: 1; number of arguments + $args = ord($formulaData[1]); + // offset: 2: size: 2; index to built-in sheet function + $index = self::_GetInt2d($formulaData, 2); + switch ($index) { + case 0: + $function = 'COUNT'; + break; + case 1: + $function = 'IF'; + break; + case 4: + $function = 'SUM'; + break; + case 5: + $function = 'AVERAGE'; + break; + case 6: + $function = 'MIN'; + break; + case 7: + $function = 'MAX'; + break; + case 8: + $function = 'ROW'; + break; + case 9: + $function = 'COLUMN'; + break; + case 11: + $function = 'NPV'; + break; + case 12: + $function = 'STDEV'; + break; + case 13: + $function = 'DOLLAR'; + break; + case 14: + $function = 'FIXED'; + break; + case 28: + $function = 'LOOKUP'; + break; + case 29: + $function = 'INDEX'; + break; + case 36: + $function = 'AND'; + break; + case 37: + $function = 'OR'; + break; + case 46: + $function = 'VAR'; + break; + case 49: + $function = 'LINEST'; + break; + case 50: + $function = 'TREND'; + break; + case 51: + $function = 'LOGEST'; + break; + case 52: + $function = 'GROWTH'; + break; + case 56: + $function = 'PV'; + break; + case 57: + $function = 'FV'; + break; + case 58: + $function = 'NPER'; + break; + case 59: + $function = 'PMT'; + break; + case 60: + $function = 'RATE'; + break; + case 62: + $function = 'IRR'; + break; + case 64: + $function = 'MATCH'; + break; + case 70: + $function = 'WEEKDAY'; + break; + case 78: + $function = 'OFFSET'; + break; + case 82: + $function = 'SEARCH'; + break; + case 100: + $function = 'CHOOSE'; + break; + case 101: + $function = 'HLOOKUP'; + break; + case 102: + $function = 'VLOOKUP'; + break; + case 109: + $function = 'LOG'; + break; + case 115: + $function = 'LEFT'; + break; + case 116: + $function = 'RIGHT'; + break; + case 120: + $function = 'SUBSTITUTE'; + break; + case 124: + $function = 'FIND'; + break; + case 125: + $function = 'CELL'; + break; + case 144: + $function = 'DDB'; + break; + case 148: + $function = 'INDIRECT'; + break; + case 167: + $function = 'IPMT'; + break; + case 168: + $function = 'PPMT'; + break; + case 169: + $function = 'COUNTA'; + break; + case 183: + $function = 'PRODUCT'; + break; + case 193: + $function = 'STDEVP'; + break; + case 194: + $function = 'VARP'; + break; + case 197: + $function = 'TRUNC'; + break; + case 204: + $function = 'USDOLLAR'; + break; + case 205: + $function = 'FINDB'; + break; + case 206: + $function = 'SEARCHB'; + break; + case 208: + $function = 'LEFTB'; + break; + case 209: + $function = 'RIGHTB'; + break; + case 216: + $function = 'RANK'; + break; + case 219: + $function = 'ADDRESS'; + break; + case 220: + $function = 'DAYS360'; + break; + case 222: + $function = 'VDB'; + break; + case 227: + $function = 'MEDIAN'; + break; + case 228: + $function = 'SUMPRODUCT'; + break; + case 247: + $function = 'DB'; + break; + case 255: + $function = ''; + break; + case 269: + $function = 'AVEDEV'; + break; + case 270: + $function = 'BETADIST'; + break; + case 272: + $function = 'BETAINV'; + break; + case 317: + $function = 'PROB'; + break; + case 318: + $function = 'DEVSQ'; + break; + case 319: + $function = 'GEOMEAN'; + break; + case 320: + $function = 'HARMEAN'; + break; + case 321: + $function = 'SUMSQ'; + break; + case 322: + $function = 'KURT'; + break; + case 323: + $function = 'SKEW'; + break; + case 324: + $function = 'ZTEST'; + break; + case 329: + $function = 'PERCENTRANK'; + break; + case 330: + $function = 'MODE'; + break; + case 336: + $function = 'CONCATENATE'; + break; + case 344: + $function = 'SUBTOTAL'; + break; + case 345: + $function = 'SUMIF'; + break; + case 354: + $function = 'ROMAN'; + break; + case 358: + $function = 'GETPIVOTDATA'; + break; + case 359: + $function = 'HYPERLINK'; + break; + case 361: + $function = 'AVERAGEA'; + break; + case 362: + $function = 'MAXA'; + break; + case 363: + $function = 'MINA'; + break; + case 364: + $function = 'STDEVPA'; + break; + case 365: + $function = 'VARPA'; + break; + case 366: + $function = 'STDEVA'; + break; + case 367: + $function = 'VARA'; + break; + default: + throw new PHPExcel_Reader_Exception('Unrecognized function in formula'); + break; + } + $data = array('function' => $function, 'args' => $args); + break; + case 0x23: // index to defined name + case 0x43: + case 0x63: + $name = 'tName'; + $size = 5; + // offset: 1; size: 2; one-based index to definedname record + $definedNameIndex = self::_GetInt2d($formulaData, 1) - 1; + // offset: 2; size: 2; not used + $data = $this->_definedname[$definedNameIndex]['name']; + break; + case 0x24: // single cell reference e.g. A5 + case 0x44: + case 0x64: + $name = 'tRef'; + $size = 5; + $data = $this->_readBIFF8CellAddress(substr($formulaData, 1, 4)); + break; + case 0x25: // cell range reference to cells in the same sheet (2d) + case 0x45: + case 0x65: + $name = 'tArea'; + $size = 9; + $data = $this->_readBIFF8CellRangeAddress(substr($formulaData, 1, 8)); + break; + case 0x26: // Constant reference sub-expression + case 0x46: + case 0x66: + $name = 'tMemArea'; + // offset: 1; size: 4; not used + // offset: 5; size: 2; size of the following subexpression + $subSize = self::_GetInt2d($formulaData, 5); + $size = 7 + $subSize; + $data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize)); + break; + case 0x27: // Deleted constant reference sub-expression + case 0x47: + case 0x67: + $name = 'tMemErr'; + // offset: 1; size: 4; not used + // offset: 5; size: 2; size of the following subexpression + $subSize = self::_GetInt2d($formulaData, 5); + $size = 7 + $subSize; + $data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize)); + break; + case 0x29: // Variable reference sub-expression + case 0x49: + case 0x69: + $name = 'tMemFunc'; + // offset: 1; size: 2; size of the following sub-expression + $subSize = self::_GetInt2d($formulaData, 1); + $size = 3 + $subSize; + $data = $this->_getFormulaFromData(substr($formulaData, 3, $subSize)); + break; + case 0x2C: // Relative 2d cell reference reference, used in shared formulas and some other places + case 0x4C: + case 0x6C: + $name = 'tRefN'; + $size = 5; + $data = $this->_readBIFF8CellAddressB(substr($formulaData, 1, 4), $baseCell); + break; + case 0x2D: // Relative 2d range reference + case 0x4D: + case 0x6D: + $name = 'tAreaN'; + $size = 9; + $data = $this->_readBIFF8CellRangeAddressB(substr($formulaData, 1, 8), $baseCell); + break; + case 0x39: // External name + case 0x59: + case 0x79: + $name = 'tNameX'; + $size = 7; + // offset: 1; size: 2; index to REF entry in EXTERNSHEET record + // offset: 3; size: 2; one-based index to DEFINEDNAME or EXTERNNAME record + $index = self::_GetInt2d($formulaData, 3); + // assume index is to EXTERNNAME record + $data = $this->_externalNames[$index - 1]['name']; + // offset: 5; size: 2; not used + break; + case 0x3A: // 3d reference to cell + case 0x5A: + case 0x7A: + $name = 'tRef3d'; + $size = 7; + + try { + // offset: 1; size: 2; index to REF entry + $sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1)); + // offset: 3; size: 4; cell address + $cellAddress = $this->_readBIFF8CellAddress(substr($formulaData, 3, 4)); + + $data = "$sheetRange!$cellAddress"; + } catch (PHPExcel_Exception $e) { + // deleted sheet reference + $data = '#REF!'; + } + break; + case 0x3B: // 3d reference to cell range + case 0x5B: + case 0x7B: + $name = 'tArea3d'; + $size = 11; + + try { + // offset: 1; size: 2; index to REF entry + $sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1)); + // offset: 3; size: 8; cell address + $cellRangeAddress = $this->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8)); + + $data = "$sheetRange!$cellRangeAddress"; + } catch (PHPExcel_Exception $e) { + // deleted sheet reference + $data = '#REF!'; + } + break; + // Unknown cases // don't know how to deal with default: - throw new PHPExcel_Reader_Exception('Unrecognized attribute flag in tAttr token'); + throw new PHPExcel_Reader_Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula'); break; - } - break; - case 0x1C: // error code - // offset: 1; size: 1; error code - $name = 'tErr'; - $size = 2; - $data = self::_mapErrorCode(ord($formulaData[1])); - break; - case 0x1D: // boolean - // offset: 1; size: 1; 0 = false, 1 = true; - $name = 'tBool'; - $size = 2; - $data = ord($formulaData[1]) ? 'TRUE' : 'FALSE'; - break; - case 0x1E: // integer - // offset: 1; size: 2; unsigned 16-bit integer - $name = 'tInt'; - $size = 3; - $data = self::_GetInt2d($formulaData, 1); - break; - case 0x1F: // number - // offset: 1; size: 8; - $name = 'tNum'; - $size = 9; - $data = self::_extractNumber(substr($formulaData, 1)); - $data = str_replace(',', '.', (string)$data); // in case non-English locale - break; - case 0x20: // array constant - case 0x40: - case 0x60: - // offset: 1; size: 7; not used - $name = 'tArray'; - $size = 8; - $data = null; - break; - case 0x21: // function with fixed number of arguments - case 0x41: - case 0x61: - $name = 'tFunc'; - $size = 3; - // offset: 1; size: 2; index to built-in sheet function - switch (self::_GetInt2d($formulaData, 1)) { - case 2: $function = 'ISNA'; $args = 1; break; - case 3: $function = 'ISERROR'; $args = 1; break; - case 10: $function = 'NA'; $args = 0; break; - case 15: $function = 'SIN'; $args = 1; break; - case 16: $function = 'COS'; $args = 1; break; - case 17: $function = 'TAN'; $args = 1; break; - case 18: $function = 'ATAN'; $args = 1; break; - case 19: $function = 'PI'; $args = 0; break; - case 20: $function = 'SQRT'; $args = 1; break; - case 21: $function = 'EXP'; $args = 1; break; - case 22: $function = 'LN'; $args = 1; break; - case 23: $function = 'LOG10'; $args = 1; break; - case 24: $function = 'ABS'; $args = 1; break; - case 25: $function = 'INT'; $args = 1; break; - case 26: $function = 'SIGN'; $args = 1; break; - case 27: $function = 'ROUND'; $args = 2; break; - case 30: $function = 'REPT'; $args = 2; break; - case 31: $function = 'MID'; $args = 3; break; - case 32: $function = 'LEN'; $args = 1; break; - case 33: $function = 'VALUE'; $args = 1; break; - case 34: $function = 'TRUE'; $args = 0; break; - case 35: $function = 'FALSE'; $args = 0; break; - case 38: $function = 'NOT'; $args = 1; break; - case 39: $function = 'MOD'; $args = 2; break; - case 40: $function = 'DCOUNT'; $args = 3; break; - case 41: $function = 'DSUM'; $args = 3; break; - case 42: $function = 'DAVERAGE'; $args = 3; break; - case 43: $function = 'DMIN'; $args = 3; break; - case 44: $function = 'DMAX'; $args = 3; break; - case 45: $function = 'DSTDEV'; $args = 3; break; - case 48: $function = 'TEXT'; $args = 2; break; - case 61: $function = 'MIRR'; $args = 3; break; - case 63: $function = 'RAND'; $args = 0; break; - case 65: $function = 'DATE'; $args = 3; break; - case 66: $function = 'TIME'; $args = 3; break; - case 67: $function = 'DAY'; $args = 1; break; - case 68: $function = 'MONTH'; $args = 1; break; - case 69: $function = 'YEAR'; $args = 1; break; - case 71: $function = 'HOUR'; $args = 1; break; - case 72: $function = 'MINUTE'; $args = 1; break; - case 73: $function = 'SECOND'; $args = 1; break; - case 74: $function = 'NOW'; $args = 0; break; - case 75: $function = 'AREAS'; $args = 1; break; - case 76: $function = 'ROWS'; $args = 1; break; - case 77: $function = 'COLUMNS'; $args = 1; break; - case 83: $function = 'TRANSPOSE'; $args = 1; break; - case 86: $function = 'TYPE'; $args = 1; break; - case 97: $function = 'ATAN2'; $args = 2; break; - case 98: $function = 'ASIN'; $args = 1; break; - case 99: $function = 'ACOS'; $args = 1; break; - case 105: $function = 'ISREF'; $args = 1; break; - case 111: $function = 'CHAR'; $args = 1; break; - case 112: $function = 'LOWER'; $args = 1; break; - case 113: $function = 'UPPER'; $args = 1; break; - case 114: $function = 'PROPER'; $args = 1; break; - case 117: $function = 'EXACT'; $args = 2; break; - case 118: $function = 'TRIM'; $args = 1; break; - case 119: $function = 'REPLACE'; $args = 4; break; - case 121: $function = 'CODE'; $args = 1; break; - case 126: $function = 'ISERR'; $args = 1; break; - case 127: $function = 'ISTEXT'; $args = 1; break; - case 128: $function = 'ISNUMBER'; $args = 1; break; - case 129: $function = 'ISBLANK'; $args = 1; break; - case 130: $function = 'T'; $args = 1; break; - case 131: $function = 'N'; $args = 1; break; - case 140: $function = 'DATEVALUE'; $args = 1; break; - case 141: $function = 'TIMEVALUE'; $args = 1; break; - case 142: $function = 'SLN'; $args = 3; break; - case 143: $function = 'SYD'; $args = 4; break; - case 162: $function = 'CLEAN'; $args = 1; break; - case 163: $function = 'MDETERM'; $args = 1; break; - case 164: $function = 'MINVERSE'; $args = 1; break; - case 165: $function = 'MMULT'; $args = 2; break; - case 184: $function = 'FACT'; $args = 1; break; - case 189: $function = 'DPRODUCT'; $args = 3; break; - case 190: $function = 'ISNONTEXT'; $args = 1; break; - case 195: $function = 'DSTDEVP'; $args = 3; break; - case 196: $function = 'DVARP'; $args = 3; break; - case 198: $function = 'ISLOGICAL'; $args = 1; break; - case 199: $function = 'DCOUNTA'; $args = 3; break; - case 207: $function = 'REPLACEB'; $args = 4; break; - case 210: $function = 'MIDB'; $args = 3; break; - case 211: $function = 'LENB'; $args = 1; break; - case 212: $function = 'ROUNDUP'; $args = 2; break; - case 213: $function = 'ROUNDDOWN'; $args = 2; break; - case 214: $function = 'ASC'; $args = 1; break; - case 215: $function = 'DBCS'; $args = 1; break; - case 221: $function = 'TODAY'; $args = 0; break; - case 229: $function = 'SINH'; $args = 1; break; - case 230: $function = 'COSH'; $args = 1; break; - case 231: $function = 'TANH'; $args = 1; break; - case 232: $function = 'ASINH'; $args = 1; break; - case 233: $function = 'ACOSH'; $args = 1; break; - case 234: $function = 'ATANH'; $args = 1; break; - case 235: $function = 'DGET'; $args = 3; break; - case 244: $function = 'INFO'; $args = 1; break; - case 252: $function = 'FREQUENCY'; $args = 2; break; - case 261: $function = 'ERROR.TYPE'; $args = 1; break; - case 271: $function = 'GAMMALN'; $args = 1; break; - case 273: $function = 'BINOMDIST'; $args = 4; break; - case 274: $function = 'CHIDIST'; $args = 2; break; - case 275: $function = 'CHIINV'; $args = 2; break; - case 276: $function = 'COMBIN'; $args = 2; break; - case 277: $function = 'CONFIDENCE'; $args = 3; break; - case 278: $function = 'CRITBINOM'; $args = 3; break; - case 279: $function = 'EVEN'; $args = 1; break; - case 280: $function = 'EXPONDIST'; $args = 3; break; - case 281: $function = 'FDIST'; $args = 3; break; - case 282: $function = 'FINV'; $args = 3; break; - case 283: $function = 'FISHER'; $args = 1; break; - case 284: $function = 'FISHERINV'; $args = 1; break; - case 285: $function = 'FLOOR'; $args = 2; break; - case 286: $function = 'GAMMADIST'; $args = 4; break; - case 287: $function = 'GAMMAINV'; $args = 3; break; - case 288: $function = 'CEILING'; $args = 2; break; - case 289: $function = 'HYPGEOMDIST'; $args = 4; break; - case 290: $function = 'LOGNORMDIST'; $args = 3; break; - case 291: $function = 'LOGINV'; $args = 3; break; - case 292: $function = 'NEGBINOMDIST'; $args = 3; break; - case 293: $function = 'NORMDIST'; $args = 4; break; - case 294: $function = 'NORMSDIST'; $args = 1; break; - case 295: $function = 'NORMINV'; $args = 3; break; - case 296: $function = 'NORMSINV'; $args = 1; break; - case 297: $function = 'STANDARDIZE'; $args = 3; break; - case 298: $function = 'ODD'; $args = 1; break; - case 299: $function = 'PERMUT'; $args = 2; break; - case 300: $function = 'POISSON'; $args = 3; break; - case 301: $function = 'TDIST'; $args = 3; break; - case 302: $function = 'WEIBULL'; $args = 4; break; - case 303: $function = 'SUMXMY2'; $args = 2; break; - case 304: $function = 'SUMX2MY2'; $args = 2; break; - case 305: $function = 'SUMX2PY2'; $args = 2; break; - case 306: $function = 'CHITEST'; $args = 2; break; - case 307: $function = 'CORREL'; $args = 2; break; - case 308: $function = 'COVAR'; $args = 2; break; - case 309: $function = 'FORECAST'; $args = 3; break; - case 310: $function = 'FTEST'; $args = 2; break; - case 311: $function = 'INTERCEPT'; $args = 2; break; - case 312: $function = 'PEARSON'; $args = 2; break; - case 313: $function = 'RSQ'; $args = 2; break; - case 314: $function = 'STEYX'; $args = 2; break; - case 315: $function = 'SLOPE'; $args = 2; break; - case 316: $function = 'TTEST'; $args = 4; break; - case 325: $function = 'LARGE'; $args = 2; break; - case 326: $function = 'SMALL'; $args = 2; break; - case 327: $function = 'QUARTILE'; $args = 2; break; - case 328: $function = 'PERCENTILE'; $args = 2; break; - case 331: $function = 'TRIMMEAN'; $args = 2; break; - case 332: $function = 'TINV'; $args = 2; break; - case 337: $function = 'POWER'; $args = 2; break; - case 342: $function = 'RADIANS'; $args = 1; break; - case 343: $function = 'DEGREES'; $args = 1; break; - case 346: $function = 'COUNTIF'; $args = 2; break; - case 347: $function = 'COUNTBLANK'; $args = 1; break; - case 350: $function = 'ISPMT'; $args = 4; break; - case 351: $function = 'DATEDIF'; $args = 3; break; - case 352: $function = 'DATESTRING'; $args = 1; break; - case 353: $function = 'NUMBERSTRING'; $args = 2; break; - case 360: $function = 'PHONETIC'; $args = 1; break; - case 368: $function = 'BAHTTEXT'; $args = 1; break; - default: - throw new PHPExcel_Reader_Exception('Unrecognized function in formula'); - break; - } - $data = array('function' => $function, 'args' => $args); - break; - case 0x22: // function with variable number of arguments - case 0x42: - case 0x62: - $name = 'tFuncV'; - $size = 4; - // offset: 1; size: 1; number of arguments - $args = ord($formulaData[1]); - // offset: 2: size: 2; index to built-in sheet function - $index = self::_GetInt2d($formulaData, 2); - switch ($index) { - case 0: $function = 'COUNT'; break; - case 1: $function = 'IF'; break; - case 4: $function = 'SUM'; break; - case 5: $function = 'AVERAGE'; break; - case 6: $function = 'MIN'; break; - case 7: $function = 'MAX'; break; - case 8: $function = 'ROW'; break; - case 9: $function = 'COLUMN'; break; - case 11: $function = 'NPV'; break; - case 12: $function = 'STDEV'; break; - case 13: $function = 'DOLLAR'; break; - case 14: $function = 'FIXED'; break; - case 28: $function = 'LOOKUP'; break; - case 29: $function = 'INDEX'; break; - case 36: $function = 'AND'; break; - case 37: $function = 'OR'; break; - case 46: $function = 'VAR'; break; - case 49: $function = 'LINEST'; break; - case 50: $function = 'TREND'; break; - case 51: $function = 'LOGEST'; break; - case 52: $function = 'GROWTH'; break; - case 56: $function = 'PV'; break; - case 57: $function = 'FV'; break; - case 58: $function = 'NPER'; break; - case 59: $function = 'PMT'; break; - case 60: $function = 'RATE'; break; - case 62: $function = 'IRR'; break; - case 64: $function = 'MATCH'; break; - case 70: $function = 'WEEKDAY'; break; - case 78: $function = 'OFFSET'; break; - case 82: $function = 'SEARCH'; break; - case 100: $function = 'CHOOSE'; break; - case 101: $function = 'HLOOKUP'; break; - case 102: $function = 'VLOOKUP'; break; - case 109: $function = 'LOG'; break; - case 115: $function = 'LEFT'; break; - case 116: $function = 'RIGHT'; break; - case 120: $function = 'SUBSTITUTE'; break; - case 124: $function = 'FIND'; break; - case 125: $function = 'CELL'; break; - case 144: $function = 'DDB'; break; - case 148: $function = 'INDIRECT'; break; - case 167: $function = 'IPMT'; break; - case 168: $function = 'PPMT'; break; - case 169: $function = 'COUNTA'; break; - case 183: $function = 'PRODUCT'; break; - case 193: $function = 'STDEVP'; break; - case 194: $function = 'VARP'; break; - case 197: $function = 'TRUNC'; break; - case 204: $function = 'USDOLLAR'; break; - case 205: $function = 'FINDB'; break; - case 206: $function = 'SEARCHB'; break; - case 208: $function = 'LEFTB'; break; - case 209: $function = 'RIGHTB'; break; - case 216: $function = 'RANK'; break; - case 219: $function = 'ADDRESS'; break; - case 220: $function = 'DAYS360'; break; - case 222: $function = 'VDB'; break; - case 227: $function = 'MEDIAN'; break; - case 228: $function = 'SUMPRODUCT'; break; - case 247: $function = 'DB'; break; - case 255: $function = ''; break; - case 269: $function = 'AVEDEV'; break; - case 270: $function = 'BETADIST'; break; - case 272: $function = 'BETAINV'; break; - case 317: $function = 'PROB'; break; - case 318: $function = 'DEVSQ'; break; - case 319: $function = 'GEOMEAN'; break; - case 320: $function = 'HARMEAN'; break; - case 321: $function = 'SUMSQ'; break; - case 322: $function = 'KURT'; break; - case 323: $function = 'SKEW'; break; - case 324: $function = 'ZTEST'; break; - case 329: $function = 'PERCENTRANK'; break; - case 330: $function = 'MODE'; break; - case 336: $function = 'CONCATENATE'; break; - case 344: $function = 'SUBTOTAL'; break; - case 345: $function = 'SUMIF'; break; - case 354: $function = 'ROMAN'; break; - case 358: $function = 'GETPIVOTDATA'; break; - case 359: $function = 'HYPERLINK'; break; - case 361: $function = 'AVERAGEA'; break; - case 362: $function = 'MAXA'; break; - case 363: $function = 'MINA'; break; - case 364: $function = 'STDEVPA'; break; - case 365: $function = 'VARPA'; break; - case 366: $function = 'STDEVA'; break; - case 367: $function = 'VARA'; break; - default: - throw new PHPExcel_Reader_Exception('Unrecognized function in formula'); - break; - } - $data = array('function' => $function, 'args' => $args); - break; - case 0x23: // index to defined name - case 0x43: - case 0x63: - $name = 'tName'; - $size = 5; - // offset: 1; size: 2; one-based index to definedname record - $definedNameIndex = self::_GetInt2d($formulaData, 1) - 1; - // offset: 2; size: 2; not used - $data = $this->_definedname[$definedNameIndex]['name']; - break; - case 0x24: // single cell reference e.g. A5 - case 0x44: - case 0x64: - $name = 'tRef'; - $size = 5; - $data = $this->_readBIFF8CellAddress(substr($formulaData, 1, 4)); - break; - case 0x25: // cell range reference to cells in the same sheet (2d) - case 0x45: - case 0x65: - $name = 'tArea'; - $size = 9; - $data = $this->_readBIFF8CellRangeAddress(substr($formulaData, 1, 8)); - break; - case 0x26: // Constant reference sub-expression - case 0x46: - case 0x66: - $name = 'tMemArea'; - // offset: 1; size: 4; not used - // offset: 5; size: 2; size of the following subexpression - $subSize = self::_GetInt2d($formulaData, 5); - $size = 7 + $subSize; - $data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize)); - break; - case 0x27: // Deleted constant reference sub-expression - case 0x47: - case 0x67: - $name = 'tMemErr'; - // offset: 1; size: 4; not used - // offset: 5; size: 2; size of the following subexpression - $subSize = self::_GetInt2d($formulaData, 5); - $size = 7 + $subSize; - $data = $this->_getFormulaFromData(substr($formulaData, 7, $subSize)); - break; - case 0x29: // Variable reference sub-expression - case 0x49: - case 0x69: - $name = 'tMemFunc'; - // offset: 1; size: 2; size of the following sub-expression - $subSize = self::_GetInt2d($formulaData, 1); - $size = 3 + $subSize; - $data = $this->_getFormulaFromData(substr($formulaData, 3, $subSize)); - break; - - case 0x2C: // Relative 2d cell reference reference, used in shared formulas and some other places - case 0x4C: - case 0x6C: - $name = 'tRefN'; - $size = 5; - $data = $this->_readBIFF8CellAddressB(substr($formulaData, 1, 4), $baseCell); - break; - - case 0x2D: // Relative 2d range reference - case 0x4D: - case 0x6D: - $name = 'tAreaN'; - $size = 9; - $data = $this->_readBIFF8CellRangeAddressB(substr($formulaData, 1, 8), $baseCell); - break; - - case 0x39: // External name - case 0x59: - case 0x79: - $name = 'tNameX'; - $size = 7; - // offset: 1; size: 2; index to REF entry in EXTERNSHEET record - // offset: 3; size: 2; one-based index to DEFINEDNAME or EXTERNNAME record - $index = self::_GetInt2d($formulaData, 3); - // assume index is to EXTERNNAME record - $data = $this->_externalNames[$index - 1]['name']; - // offset: 5; size: 2; not used - break; - - case 0x3A: // 3d reference to cell - case 0x5A: - case 0x7A: - $name = 'tRef3d'; - $size = 7; - - try { - // offset: 1; size: 2; index to REF entry - $sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1)); - // offset: 3; size: 4; cell address - $cellAddress = $this->_readBIFF8CellAddress(substr($formulaData, 3, 4)); - - $data = "$sheetRange!$cellAddress"; - } catch (PHPExcel_Exception $e) { - // deleted sheet reference - $data = '#REF!'; - } - - break; - case 0x3B: // 3d reference to cell range - case 0x5B: - case 0x7B: - $name = 'tArea3d'; - $size = 11; - - try { - // offset: 1; size: 2; index to REF entry - $sheetRange = $this->_readSheetRangeByRefIndex(self::_GetInt2d($formulaData, 1)); - // offset: 3; size: 8; cell address - $cellRangeAddress = $this->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8)); - - $data = "$sheetRange!$cellRangeAddress"; - } catch (PHPExcel_Exception $e) { - // deleted sheet reference - $data = '#REF!'; - } - - break; - // Unknown cases // don't know how to deal with - default: - throw new PHPExcel_Reader_Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula'); - break; } return array( @@ -6015,18 +6812,17 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $row = self::_GetInt2d($cellAddressStructure, 0) + 1; // offset: 2; size: 2; index to column or column offset + relative flags + // bit: 7-0; mask 0x00FF; column index + $column = PHPExcel_Cell::stringFromColumnIndex(0x00FF & self::_GetInt2d($cellAddressStructure, 2)); - // bit: 7-0; mask 0x00FF; column index - $column = PHPExcel_Cell::stringFromColumnIndex(0x00FF & self::_GetInt2d($cellAddressStructure, 2)); - - // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) - if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) { - $column = '$' . $column; - } - // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) - if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) { - $row = '$' . $row; - } + // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) + if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) { + $column = '$' . $column; + } + // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) + if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) { + $row = '$' . $row; + } return $column . $row; } @@ -6047,30 +6843,29 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $baseCol = PHPExcel_Cell::columnIndexFromString($baseCol) - 1; // offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767)) - $rowIndex = self::_GetInt2d($cellAddressStructure, 0); - $row = self::_GetInt2d($cellAddressStructure, 0) + 1; + $rowIndex = self::_GetInt2d($cellAddressStructure, 0); + $row = self::_GetInt2d($cellAddressStructure, 0) + 1; // offset: 2; size: 2; index to column or column offset + relative flags + // bit: 7-0; mask 0x00FF; column index + $colIndex = 0x00FF & self::_GetInt2d($cellAddressStructure, 2); - // bit: 7-0; mask 0x00FF; column index - $colIndex = 0x00FF & self::_GetInt2d($cellAddressStructure, 2); + // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) + if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) { + $column = PHPExcel_Cell::stringFromColumnIndex($colIndex); + $column = '$' . $column; + } else { + $colIndex = ($colIndex <= 127) ? $colIndex : $colIndex - 256; + $column = PHPExcel_Cell::stringFromColumnIndex($baseCol + $colIndex); + } - // bit: 14; mask 0x4000; (1 = relative column index, 0 = absolute column index) - if (!(0x4000 & self::_GetInt2d($cellAddressStructure, 2))) { - $column = PHPExcel_Cell::stringFromColumnIndex($colIndex); - $column = '$' . $column; - } else { - $colIndex = ($colIndex <= 127) ? $colIndex : $colIndex - 256; - $column = PHPExcel_Cell::stringFromColumnIndex($baseCol + $colIndex); - } - - // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) - if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) { - $row = '$' . $row; - } else { - $rowIndex = ($rowIndex <= 32767) ? $rowIndex : $rowIndex - 65536; - $row = $baseRow + $rowIndex; - } + // bit: 15; mask 0x8000; (1 = relative row index, 0 = absolute row index) + if (!(0x8000 & self::_GetInt2d($cellAddressStructure, 2))) { + $row = '$' . $row; + } else { + $rowIndex = ($rowIndex <= 32767) ? $rowIndex : $rowIndex - 65536; + $row = $baseRow + $rowIndex; + } return $column . $row; } @@ -6359,7 +7154,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce private function _readSheetRangeByRefIndex($index) { if (isset($this->_ref[$index])) { - $type = $this->_externalBooks[$this->_ref[$index]['externalBookIndex']]['type']; switch ($type) { @@ -6393,7 +7187,6 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce return $sheetRange; break; - default: // TODO: external sheet support throw new PHPExcel_Reader_Exception('Excel5 reader only supports internal sheets in fomulas'); @@ -6457,35 +7250,35 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $identifier = ord($valueData[0]); switch ($identifier) { - case 0x00: // empty constant (what is this?) - $value = ''; - $size = 9; - break; - case 0x01: // number - // offset: 1; size: 8; IEEE 754 floating-point value - $value = self::_extractNumber(substr($valueData, 1, 8)); - $size = 9; - break; - case 0x02: // string value - // offset: 1; size: var; Unicode string, 16-bit string length - $string = self::_readUnicodeStringLong(substr($valueData, 1)); - $value = '"' . $string['value'] . '"'; - $size = 1 + $string['size']; - break; - case 0x04: // boolean - // offset: 1; size: 1; 0 = FALSE, 1 = TRUE - if (ord($valueData[1])) { - $value = 'TRUE'; - } else { - $value = 'FALSE'; - } - $size = 9; - break; - case 0x10: // error code - // offset: 1; size: 1; error code - $value = self::_mapErrorCode(ord($valueData[1])); - $size = 9; - break; + case 0x00: // empty constant (what is this?) + $value = ''; + $size = 9; + break; + case 0x01: // number + // offset: 1; size: 8; IEEE 754 floating-point value + $value = self::_extractNumber(substr($valueData, 1, 8)); + $size = 9; + break; + case 0x02: // string value + // offset: 1; size: var; Unicode string, 16-bit string length + $string = self::_readUnicodeStringLong(substr($valueData, 1)); + $value = '"' . $string['value'] . '"'; + $size = 1 + $string['size']; + break; + case 0x04: // boolean + // offset: 1; size: 1; 0 = FALSE, 1 = TRUE + if (ord($valueData[1])) { + $value = 'TRUE'; + } else { + $value = 'FALSE'; + } + $size = 9; + break; + case 0x10: // error code + // offset: 1; size: 1; error code + $value = self::_mapErrorCode(ord($valueData[1])); + $size = 9; + break; } return array( 'value' => $value, @@ -6626,15 +7419,14 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce $value = ''; // offset: 0: size: 1; option flags + // bit: 0; mask: 0x01; character compression (0 = compressed 8-bit, 1 = uncompressed 16-bit) + $isCompressed = !((0x01 & ord($subData[0])) >> 0); - // bit: 0; mask: 0x01; character compression (0 = compressed 8-bit, 1 = uncompressed 16-bit) - $isCompressed = !((0x01 & ord($subData[0])) >> 0); + // bit: 2; mask: 0x04; Asian phonetic settings + $hasAsian = (0x04) & ord($subData[0]) >> 2; - // bit: 2; mask: 0x04; Asian phonetic settings - $hasAsian = (0x04) & ord($subData[0]) >> 2; - - // bit: 3; mask: 0x08; Rich-Text settings - $hasRichText = (0x08) & ord($subData[0]) >> 3; + // bit: 3; mask: 0x08; Rich-Text settings + $hasRichText = (0x08) & ord($subData[0]) >> 3; // offset: 1: size: var; character array // this offset assumes richtext and Asian phonetic settings are off which is generally wrong @@ -6839,21 +7631,36 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce private static function _mapBorderStyle($index) { switch ($index) { - case 0x00: return PHPExcel_Style_Border::BORDER_NONE; - case 0x01: return PHPExcel_Style_Border::BORDER_THIN; - case 0x02: return PHPExcel_Style_Border::BORDER_MEDIUM; - case 0x03: return PHPExcel_Style_Border::BORDER_DASHED; - case 0x04: return PHPExcel_Style_Border::BORDER_DOTTED; - case 0x05: return PHPExcel_Style_Border::BORDER_THICK; - case 0x06: return PHPExcel_Style_Border::BORDER_DOUBLE; - case 0x07: return PHPExcel_Style_Border::BORDER_HAIR; - case 0x08: return PHPExcel_Style_Border::BORDER_MEDIUMDASHED; - case 0x09: return PHPExcel_Style_Border::BORDER_DASHDOT; - case 0x0A: return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT; - case 0x0B: return PHPExcel_Style_Border::BORDER_DASHDOTDOT; - case 0x0C: return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; - case 0x0D: return PHPExcel_Style_Border::BORDER_SLANTDASHDOT; - default: return PHPExcel_Style_Border::BORDER_NONE; + case 0x00: + return PHPExcel_Style_Border::BORDER_NONE; + case 0x01: + return PHPExcel_Style_Border::BORDER_THIN; + case 0x02: + return PHPExcel_Style_Border::BORDER_MEDIUM; + case 0x03: + return PHPExcel_Style_Border::BORDER_DASHED; + case 0x04: + return PHPExcel_Style_Border::BORDER_DOTTED; + case 0x05: + return PHPExcel_Style_Border::BORDER_THICK; + case 0x06: + return PHPExcel_Style_Border::BORDER_DOUBLE; + case 0x07: + return PHPExcel_Style_Border::BORDER_HAIR; + case 0x08: + return PHPExcel_Style_Border::BORDER_MEDIUMDASHED; + case 0x09: + return PHPExcel_Style_Border::BORDER_DASHDOT; + case 0x0A: + return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT; + case 0x0B: + return PHPExcel_Style_Border::BORDER_DASHDOTDOT; + case 0x0C: + return PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; + case 0x0D: + return PHPExcel_Style_Border::BORDER_SLANTDASHDOT; + default: + return PHPExcel_Style_Border::BORDER_NONE; } } @@ -6868,26 +7675,46 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce private static function _mapFillPattern($index) { switch ($index) { - case 0x00: return PHPExcel_Style_Fill::FILL_NONE; - case 0x01: return PHPExcel_Style_Fill::FILL_SOLID; - case 0x02: return PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY; - case 0x03: return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY; - case 0x04: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY; - case 0x05: return PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL; - case 0x06: return PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL; - case 0x07: return PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN; - case 0x08: return PHPExcel_Style_Fill::FILL_PATTERN_DARKUP; - case 0x09: return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID; - case 0x0A: return PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS; - case 0x0B: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL; - case 0x0C: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL; - case 0x0D: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN; - case 0x0E: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP; - case 0x0F: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID; - case 0x10: return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS; - case 0x11: return PHPExcel_Style_Fill::FILL_PATTERN_GRAY125; - case 0x12: return PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625; - default: return PHPExcel_Style_Fill::FILL_NONE; + case 0x00: + return PHPExcel_Style_Fill::FILL_NONE; + case 0x01: + return PHPExcel_Style_Fill::FILL_SOLID; + case 0x02: + return PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY; + case 0x03: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY; + case 0x04: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY; + case 0x05: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL; + case 0x06: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL; + case 0x07: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN; + case 0x08: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKUP; + case 0x09: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID; + case 0x0A: + return PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS; + case 0x0B: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL; + case 0x0C: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL; + case 0x0D: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN; + case 0x0E: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP; + case 0x0F: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID; + case 0x10: + return PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS; + case 0x11: + return PHPExcel_Style_Fill::FILL_PATTERN_GRAY125; + case 0x12: + return PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625; + default: + return PHPExcel_Style_Fill::FILL_NONE; } } @@ -6901,14 +7728,29 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce private static function _mapErrorCode($subData) { switch ($subData) { - case 0x00: return '#NULL!'; break; - case 0x07: return '#DIV/0!'; break; - case 0x0F: return '#VALUE!'; break; - case 0x17: return '#REF!'; break; - case 0x1D: return '#NAME?'; break; - case 0x24: return '#NUM!'; break; - case 0x2A: return '#N/A'; break; - default: return false; + case 0x00: + return '#NULL!'; + break; + case 0x07: + return '#DIV/0!'; + break; + case 0x0F: + return '#VALUE!'; + break; + case 0x17: + return '#REF!'; + break; + case 0x1D: + return '#NAME?'; + break; + case 0x24: + return '#NUM!'; + break; + case 0x2A: + return '#N/A'; + break; + default: + return false; } } @@ -6922,17 +7764,28 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce private static function _mapBuiltInColor($color) { switch ($color) { - case 0x00: return array('rgb' => '000000'); - case 0x01: return array('rgb' => 'FFFFFF'); - case 0x02: return array('rgb' => 'FF0000'); - case 0x03: return array('rgb' => '00FF00'); - case 0x04: return array('rgb' => '0000FF'); - case 0x05: return array('rgb' => 'FFFF00'); - case 0x06: return array('rgb' => 'FF00FF'); - case 0x07: return array('rgb' => '00FFFF'); - case 0x40: return array('rgb' => '000000'); // system window text color - case 0x41: return array('rgb' => 'FFFFFF'); // system window background color - default: return array('rgb' => '000000'); + case 0x00: + return array('rgb' => '000000'); + case 0x01: + return array('rgb' => 'FFFFFF'); + case 0x02: + return array('rgb' => 'FF0000'); + case 0x03: + return array('rgb' => '00FF00'); + case 0x04: + return array('rgb' => '0000FF'); + case 0x05: + return array('rgb' => 'FFFF00'); + case 0x06: + return array('rgb' => 'FF00FF'); + case 0x07: + return array('rgb' => '00FFFF'); + case 0x40: + return array('rgb' => '000000'); // system window text color + case 0x41: + return array('rgb' => 'FFFFFF'); // system window background color + default: + return array('rgb' => '000000'); } } @@ -6946,63 +7799,120 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce private static function _mapColorBIFF5($subData) { switch ($subData) { - case 0x08: return array('rgb' => '000000'); - case 0x09: return array('rgb' => 'FFFFFF'); - case 0x0A: return array('rgb' => 'FF0000'); - case 0x0B: return array('rgb' => '00FF00'); - case 0x0C: return array('rgb' => '0000FF'); - case 0x0D: return array('rgb' => 'FFFF00'); - case 0x0E: return array('rgb' => 'FF00FF'); - case 0x0F: return array('rgb' => '00FFFF'); - case 0x10: return array('rgb' => '800000'); - case 0x11: return array('rgb' => '008000'); - case 0x12: return array('rgb' => '000080'); - case 0x13: return array('rgb' => '808000'); - case 0x14: return array('rgb' => '800080'); - case 0x15: return array('rgb' => '008080'); - case 0x16: return array('rgb' => 'C0C0C0'); - case 0x17: return array('rgb' => '808080'); - case 0x18: return array('rgb' => '8080FF'); - case 0x19: return array('rgb' => '802060'); - case 0x1A: return array('rgb' => 'FFFFC0'); - case 0x1B: return array('rgb' => 'A0E0F0'); - case 0x1C: return array('rgb' => '600080'); - case 0x1D: return array('rgb' => 'FF8080'); - case 0x1E: return array('rgb' => '0080C0'); - case 0x1F: return array('rgb' => 'C0C0FF'); - case 0x20: return array('rgb' => '000080'); - case 0x21: return array('rgb' => 'FF00FF'); - case 0x22: return array('rgb' => 'FFFF00'); - case 0x23: return array('rgb' => '00FFFF'); - case 0x24: return array('rgb' => '800080'); - case 0x25: return array('rgb' => '800000'); - case 0x26: return array('rgb' => '008080'); - case 0x27: return array('rgb' => '0000FF'); - case 0x28: return array('rgb' => '00CFFF'); - case 0x29: return array('rgb' => '69FFFF'); - case 0x2A: return array('rgb' => 'E0FFE0'); - case 0x2B: return array('rgb' => 'FFFF80'); - case 0x2C: return array('rgb' => 'A6CAF0'); - case 0x2D: return array('rgb' => 'DD9CB3'); - case 0x2E: return array('rgb' => 'B38FEE'); - case 0x2F: return array('rgb' => 'E3E3E3'); - case 0x30: return array('rgb' => '2A6FF9'); - case 0x31: return array('rgb' => '3FB8CD'); - case 0x32: return array('rgb' => '488436'); - case 0x33: return array('rgb' => '958C41'); - case 0x34: return array('rgb' => '8E5E42'); - case 0x35: return array('rgb' => 'A0627A'); - case 0x36: return array('rgb' => '624FAC'); - case 0x37: return array('rgb' => '969696'); - case 0x38: return array('rgb' => '1D2FBE'); - case 0x39: return array('rgb' => '286676'); - case 0x3A: return array('rgb' => '004500'); - case 0x3B: return array('rgb' => '453E01'); - case 0x3C: return array('rgb' => '6A2813'); - case 0x3D: return array('rgb' => '85396A'); - case 0x3E: return array('rgb' => '4A3285'); - case 0x3F: return array('rgb' => '424242'); - default: return array('rgb' => '000000'); + case 0x08: + return array('rgb' => '000000'); + case 0x09: + return array('rgb' => 'FFFFFF'); + case 0x0A: + return array('rgb' => 'FF0000'); + case 0x0B: + return array('rgb' => '00FF00'); + case 0x0C: + return array('rgb' => '0000FF'); + case 0x0D: + return array('rgb' => 'FFFF00'); + case 0x0E: + return array('rgb' => 'FF00FF'); + case 0x0F: + return array('rgb' => '00FFFF'); + case 0x10: + return array('rgb' => '800000'); + case 0x11: + return array('rgb' => '008000'); + case 0x12: + return array('rgb' => '000080'); + case 0x13: + return array('rgb' => '808000'); + case 0x14: + return array('rgb' => '800080'); + case 0x15: + return array('rgb' => '008080'); + case 0x16: + return array('rgb' => 'C0C0C0'); + case 0x17: + return array('rgb' => '808080'); + case 0x18: + return array('rgb' => '8080FF'); + case 0x19: + return array('rgb' => '802060'); + case 0x1A: + return array('rgb' => 'FFFFC0'); + case 0x1B: + return array('rgb' => 'A0E0F0'); + case 0x1C: + return array('rgb' => '600080'); + case 0x1D: + return array('rgb' => 'FF8080'); + case 0x1E: + return array('rgb' => '0080C0'); + case 0x1F: + return array('rgb' => 'C0C0FF'); + case 0x20: + return array('rgb' => '000080'); + case 0x21: + return array('rgb' => 'FF00FF'); + case 0x22: + return array('rgb' => 'FFFF00'); + case 0x23: + return array('rgb' => '00FFFF'); + case 0x24: + return array('rgb' => '800080'); + case 0x25: + return array('rgb' => '800000'); + case 0x26: + return array('rgb' => '008080'); + case 0x27: + return array('rgb' => '0000FF'); + case 0x28: + return array('rgb' => '00CFFF'); + case 0x29: + return array('rgb' => '69FFFF'); + case 0x2A: + return array('rgb' => 'E0FFE0'); + case 0x2B: + return array('rgb' => 'FFFF80'); + case 0x2C: + return array('rgb' => 'A6CAF0'); + case 0x2D: + return array('rgb' => 'DD9CB3'); + case 0x2E: + return array('rgb' => 'B38FEE'); + case 0x2F: + return array('rgb' => 'E3E3E3'); + case 0x30: + return array('rgb' => '2A6FF9'); + case 0x31: + return array('rgb' => '3FB8CD'); + case 0x32: + return array('rgb' => '488436'); + case 0x33: + return array('rgb' => '958C41'); + case 0x34: + return array('rgb' => '8E5E42'); + case 0x35: + return array('rgb' => 'A0627A'); + case 0x36: + return array('rgb' => '624FAC'); + case 0x37: + return array('rgb' => '969696'); + case 0x38: + return array('rgb' => '1D2FBE'); + case 0x39: + return array('rgb' => '286676'); + case 0x3A: + return array('rgb' => '004500'); + case 0x3B: + return array('rgb' => '453E01'); + case 0x3C: + return array('rgb' => '6A2813'); + case 0x3D: + return array('rgb' => '85396A'); + case 0x3E: + return array('rgb' => '4A3285'); + case 0x3F: + return array('rgb' => '424242'); + default: + return array('rgb' => '000000'); } } @@ -7016,63 +7926,120 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce private static function _mapColor($subData) { switch ($subData) { - case 0x08: return array('rgb' => '000000'); - case 0x09: return array('rgb' => 'FFFFFF'); - case 0x0A: return array('rgb' => 'FF0000'); - case 0x0B: return array('rgb' => '00FF00'); - case 0x0C: return array('rgb' => '0000FF'); - case 0x0D: return array('rgb' => 'FFFF00'); - case 0x0E: return array('rgb' => 'FF00FF'); - case 0x0F: return array('rgb' => '00FFFF'); - case 0x10: return array('rgb' => '800000'); - case 0x11: return array('rgb' => '008000'); - case 0x12: return array('rgb' => '000080'); - case 0x13: return array('rgb' => '808000'); - case 0x14: return array('rgb' => '800080'); - case 0x15: return array('rgb' => '008080'); - case 0x16: return array('rgb' => 'C0C0C0'); - case 0x17: return array('rgb' => '808080'); - case 0x18: return array('rgb' => '9999FF'); - case 0x19: return array('rgb' => '993366'); - case 0x1A: return array('rgb' => 'FFFFCC'); - case 0x1B: return array('rgb' => 'CCFFFF'); - case 0x1C: return array('rgb' => '660066'); - case 0x1D: return array('rgb' => 'FF8080'); - case 0x1E: return array('rgb' => '0066CC'); - case 0x1F: return array('rgb' => 'CCCCFF'); - case 0x20: return array('rgb' => '000080'); - case 0x21: return array('rgb' => 'FF00FF'); - case 0x22: return array('rgb' => 'FFFF00'); - case 0x23: return array('rgb' => '00FFFF'); - case 0x24: return array('rgb' => '800080'); - case 0x25: return array('rgb' => '800000'); - case 0x26: return array('rgb' => '008080'); - case 0x27: return array('rgb' => '0000FF'); - case 0x28: return array('rgb' => '00CCFF'); - case 0x29: return array('rgb' => 'CCFFFF'); - case 0x2A: return array('rgb' => 'CCFFCC'); - case 0x2B: return array('rgb' => 'FFFF99'); - case 0x2C: return array('rgb' => '99CCFF'); - case 0x2D: return array('rgb' => 'FF99CC'); - case 0x2E: return array('rgb' => 'CC99FF'); - case 0x2F: return array('rgb' => 'FFCC99'); - case 0x30: return array('rgb' => '3366FF'); - case 0x31: return array('rgb' => '33CCCC'); - case 0x32: return array('rgb' => '99CC00'); - case 0x33: return array('rgb' => 'FFCC00'); - case 0x34: return array('rgb' => 'FF9900'); - case 0x35: return array('rgb' => 'FF6600'); - case 0x36: return array('rgb' => '666699'); - case 0x37: return array('rgb' => '969696'); - case 0x38: return array('rgb' => '003366'); - case 0x39: return array('rgb' => '339966'); - case 0x3A: return array('rgb' => '003300'); - case 0x3B: return array('rgb' => '333300'); - case 0x3C: return array('rgb' => '993300'); - case 0x3D: return array('rgb' => '993366'); - case 0x3E: return array('rgb' => '333399'); - case 0x3F: return array('rgb' => '333333'); - default: return array('rgb' => '000000'); + case 0x08: + return array('rgb' => '000000'); + case 0x09: + return array('rgb' => 'FFFFFF'); + case 0x0A: + return array('rgb' => 'FF0000'); + case 0x0B: + return array('rgb' => '00FF00'); + case 0x0C: + return array('rgb' => '0000FF'); + case 0x0D: + return array('rgb' => 'FFFF00'); + case 0x0E: + return array('rgb' => 'FF00FF'); + case 0x0F: + return array('rgb' => '00FFFF'); + case 0x10: + return array('rgb' => '800000'); + case 0x11: + return array('rgb' => '008000'); + case 0x12: + return array('rgb' => '000080'); + case 0x13: + return array('rgb' => '808000'); + case 0x14: + return array('rgb' => '800080'); + case 0x15: + return array('rgb' => '008080'); + case 0x16: + return array('rgb' => 'C0C0C0'); + case 0x17: + return array('rgb' => '808080'); + case 0x18: + return array('rgb' => '9999FF'); + case 0x19: + return array('rgb' => '993366'); + case 0x1A: + return array('rgb' => 'FFFFCC'); + case 0x1B: + return array('rgb' => 'CCFFFF'); + case 0x1C: + return array('rgb' => '660066'); + case 0x1D: + return array('rgb' => 'FF8080'); + case 0x1E: + return array('rgb' => '0066CC'); + case 0x1F: + return array('rgb' => 'CCCCFF'); + case 0x20: + return array('rgb' => '000080'); + case 0x21: + return array('rgb' => 'FF00FF'); + case 0x22: + return array('rgb' => 'FFFF00'); + case 0x23: + return array('rgb' => '00FFFF'); + case 0x24: + return array('rgb' => '800080'); + case 0x25: + return array('rgb' => '800000'); + case 0x26: + return array('rgb' => '008080'); + case 0x27: + return array('rgb' => '0000FF'); + case 0x28: + return array('rgb' => '00CCFF'); + case 0x29: + return array('rgb' => 'CCFFFF'); + case 0x2A: + return array('rgb' => 'CCFFCC'); + case 0x2B: + return array('rgb' => 'FFFF99'); + case 0x2C: + return array('rgb' => '99CCFF'); + case 0x2D: + return array('rgb' => 'FF99CC'); + case 0x2E: + return array('rgb' => 'CC99FF'); + case 0x2F: + return array('rgb' => 'FFCC99'); + case 0x30: + return array('rgb' => '3366FF'); + case 0x31: + return array('rgb' => '33CCCC'); + case 0x32: + return array('rgb' => '99CC00'); + case 0x33: + return array('rgb' => 'FFCC00'); + case 0x34: + return array('rgb' => 'FF9900'); + case 0x35: + return array('rgb' => 'FF6600'); + case 0x36: + return array('rgb' => '666699'); + case 0x37: + return array('rgb' => '969696'); + case 0x38: + return array('rgb' => '003366'); + case 0x39: + return array('rgb' => '339966'); + case 0x3A: + return array('rgb' => '003300'); + case 0x3B: + return array('rgb' => '333300'); + case 0x3C: + return array('rgb' => '993300'); + case 0x3D: + return array('rgb' => '993366'); + case 0x3E: + return array('rgb' => '333399'); + case 0x3F: + return array('rgb' => '333333'); + default: + return array('rgb' => '000000'); } } @@ -7084,5 +8051,4 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce return $value; } - }