This commit is contained in:
MarkBaker 2015-05-17 10:23:26 +01:00
commit b531fd487e
5 changed files with 2794 additions and 1850 deletions

View File

@ -95,7 +95,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
/** /**
* Create a new PHPExcel_Reader_CSV * Create a new PHPExcel_Reader_CSV
*/ */
public function __construct() { public function __construct()
{
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
} }
@ -106,7 +107,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*/ */
protected function _isValidFormat() protected function _isValidFormat()
{ {
return TRUE; return true;
} }
/** /**
@ -175,7 +176,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
// Open file // Open file
$this->_openFile($pFilename); $this->_openFile($pFilename);
if (!$this->_isValidFormat()) { if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle); fclose($this->_fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
} }
$fileHandle = $this->_fileHandle; $fileHandle = $this->_fileHandle;
@ -193,7 +194,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
$worksheetInfo[0]['totalColumns'] = 0; $worksheetInfo[0]['totalColumns'] = 0;
// Loop through each line of the file in turn // 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]['totalRows']++;
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1); $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 // Open file
$this->_openFile($pFilename); $this->_openFile($pFilename);
if (!$this->_isValidFormat()) { if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle); fclose($this->_fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file."); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
} }
$fileHandle = $this->_fileHandle; $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 // 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'; $columnLetter = 'A';
foreach ($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) { if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
@ -302,7 +303,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* *
* @return string * @return string
*/ */
public function getDelimiter() { public function getDelimiter()
{
return $this->_delimiter; return $this->_delimiter;
} }
@ -312,7 +314,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @param string $pValue Delimiter, defaults to , * @param string $pValue Delimiter, defaults to ,
* @return PHPExcel_Reader_CSV * @return PHPExcel_Reader_CSV
*/ */
public function setDelimiter($pValue = ',') { public function setDelimiter($pValue = ',')
{
$this->_delimiter = $pValue; $this->_delimiter = $pValue;
return $this; return $this;
} }
@ -322,7 +325,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* *
* @return string * @return string
*/ */
public function getEnclosure() { public function getEnclosure()
{
return $this->_enclosure; return $this->_enclosure;
} }
@ -332,7 +336,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @param string $pValue Enclosure, defaults to " * @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Reader_CSV * @return PHPExcel_Reader_CSV
*/ */
public function setEnclosure($pValue = '"') { public function setEnclosure($pValue = '"')
{
if ($pValue == '') { if ($pValue == '') {
$pValue = '"'; $pValue = '"';
} }
@ -345,7 +350,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* *
* @return integer * @return integer
*/ */
public function getSheetIndex() { public function getSheetIndex()
{
return $this->_sheetIndex; return $this->_sheetIndex;
} }
@ -355,7 +361,8 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* @param integer $pValue Sheet index * @param integer $pValue Sheet index
* @return PHPExcel_Reader_CSV * @return PHPExcel_Reader_CSV
*/ */
public function setSheetIndex($pValue = 0) { public function setSheetIndex($pValue = 0)
{
$this->_sheetIndex = $pValue; $this->_sheetIndex = $pValue;
return $this; return $this;
} }
@ -365,7 +372,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* *
* @param boolean $contiguous * @param boolean $contiguous
*/ */
public function setContiguous($contiguous = FALSE) public function setContiguous($contiguous = false)
{ {
$this->_contiguous = (bool) $contiguous; $this->_contiguous = (bool) $contiguous;
if (!$contiguous) { if (!$contiguous) {
@ -380,8 +387,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* *
* @return boolean * @return boolean
*/ */
public function getContiguous() { public function getContiguous(){
return $this->_contiguous; return $this->_contiguous;
} }
} }

View File

@ -52,7 +52,8 @@ class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
* @param $worksheetName Optional worksheet name * @param $worksheetName Optional worksheet name
* @return boolean * @return boolean
*/ */
public function readCell($column, $row, $worksheetName = '') { public function readCell($column, $row, $worksheetName = '')
{
return true; return true;
} }
} }

View File

@ -239,7 +239,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return $this->loadIntoExisting($pFilename, $objPHPExcel); return $this->loadIntoExisting($pFilename, $objPHPExcel);
} }
protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) protected static function identifyFixedStyleValue($styleList, &$styleAttributeValue)
{ {
$styleAttributeValue = strtolower($styleAttributeValue); $styleAttributeValue = strtolower($styleAttributeValue);
foreach ($styleList as $style) { foreach ($styleList as $style) {
@ -337,39 +337,39 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
if (isset($xml->DocumentProperties[0])) { if (isset($xml->DocumentProperties[0])) {
foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) { foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
switch ($propertyName) { switch ($propertyName) {
case 'Title' : case 'Title':
$docProps->setTitle(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setTitle(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Subject' : case 'Subject':
$docProps->setSubject(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setSubject(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Author' : case 'Author':
$docProps->setCreator(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setCreator(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Created' : case 'Created':
$creationDate = strtotime($propertyValue); $creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
break; break;
case 'LastAuthor' : case 'LastAuthor':
$docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'LastSaved' : case 'LastSaved':
$lastSaveDate = strtotime($propertyValue); $lastSaveDate = strtotime($propertyValue);
$docProps->setModified($lastSaveDate); $docProps->setModified($lastSaveDate);
break; break;
case 'Company' : case 'Company':
$docProps->setCompany(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setCompany(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Category' : case 'Category':
$docProps->setCategory(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setCategory(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Manager' : case 'Manager':
$docProps->setManager(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setManager(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Keywords' : case 'Keywords':
$docProps->setKeywords(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setKeywords(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Description' : case 'Description':
$docProps->setDescription(self::_convertStringEncoding($propertyValue, $this->_charSet)); $docProps->setDescription(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
} }
@ -378,26 +378,26 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
if (isset($xml->CustomDocumentProperties)) { if (isset($xml->CustomDocumentProperties)) {
foreach ($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) { foreach ($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) {
$propertyAttributes = $propertyValue->attributes($namespaces['dt']); $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; $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN;
switch ((string) $propertyAttributes) { switch ((string) $propertyAttributes) {
case 'string' : case 'string':
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
$propertyValue = trim($propertyValue); $propertyValue = trim($propertyValue);
break; break;
case 'boolean' : case 'boolean':
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN; $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_BOOLEAN;
$propertyValue = (bool) $propertyValue; $propertyValue = (bool) $propertyValue;
break; break;
case 'integer' : case 'integer':
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_INTEGER; $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_INTEGER;
$propertyValue = intval($propertyValue); $propertyValue = intval($propertyValue);
break; break;
case 'float' : case 'float':
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT; $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_FLOAT;
$propertyValue = floatval($propertyValue); $propertyValue = floatval($propertyValue);
break; break;
case 'dateTime.tz' : case 'dateTime.tz':
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE; $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_DATE;
$propertyValue = strtotime(trim($propertyValue)); $propertyValue = strtotime(trim($propertyValue));
break; break;
@ -419,46 +419,46 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$styleAttributes = $styleData->attributes($namespaces['ss']); $styleAttributes = $styleData->attributes($namespaces['ss']);
// echo $styleType.'<br />'; // echo $styleType.'<br />';
switch ($styleType) { switch ($styleType) {
case 'Alignment' : case 'Alignment':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue; $styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'Vertical' : case 'Vertical':
if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) { if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue; $this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue;
} }
break; break;
case 'Horizontal' : case 'Horizontal':
if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) { if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue; $this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue;
} }
break; break;
case 'WrapText' : case 'WrapText':
$this->_styles[$styleID]['alignment']['wrap'] = true; $this->_styles[$styleID]['alignment']['wrap'] = true;
break; break;
} }
} }
break; break;
case 'Borders' : case 'Borders':
foreach ($styleData->Border as $borderStyle) { foreach ($styleData->Border as $borderStyle) {
$borderAttributes = $borderStyle->attributes($namespaces['ss']); $borderAttributes = $borderStyle->attributes($namespaces['ss']);
$thisBorder = array(); $thisBorder = array();
foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) { foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) {
// echo $borderStyleKey.' = '.$borderStyleValue.'<br />'; // echo $borderStyleKey.' = '.$borderStyleValue.'<br />';
switch ($borderStyleKey) { switch ($borderStyleKey) {
case 'LineStyle' : case 'LineStyle':
$thisBorder['style'] = PHPExcel_Style_Border::BORDER_MEDIUM; $thisBorder['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
// $thisBorder['style'] = $borderStyleValue; // $thisBorder['style'] = $borderStyleValue;
break; break;
case 'Weight' : case 'Weight':
// $thisBorder['style'] = $borderStyleValue; // $thisBorder['style'] = $borderStyleValue;
break; break;
case 'Position' : case 'Position':
$borderPosition = strtolower($borderStyleValue); $borderPosition = strtolower($borderStyleValue);
break; break;
case 'Color' : case 'Color':
$borderColour = substr($borderStyleValue,1); $borderColour = substr($borderStyleValue, 1);
$thisBorder['color']['rgb'] = $borderColour; $thisBorder['color']['rgb'] = $borderColour;
break; break;
} }
@ -470,27 +470,27 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
} }
break; break;
case 'Font' : case 'Font':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue; $styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'FontName' : case 'FontName':
$this->_styles[$styleID]['font']['name'] = $styleAttributeValue; $this->_styles[$styleID]['font']['name'] = $styleAttributeValue;
break; break;
case 'Size' : case 'Size':
$this->_styles[$styleID]['font']['size'] = $styleAttributeValue; $this->_styles[$styleID]['font']['size'] = $styleAttributeValue;
break; break;
case 'Color' : case 'Color':
$this->_styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue,1); $this->_styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue, 1);
break; break;
case 'Bold' : case 'Bold':
$this->_styles[$styleID]['font']['bold'] = true; $this->_styles[$styleID]['font']['bold'] = true;
break; break;
case 'Italic' : case 'Italic':
$this->_styles[$styleID]['font']['italic'] = true; $this->_styles[$styleID]['font']['italic'] = true;
break; break;
case 'Underline' : case 'Underline':
if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) { if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['font']['underline'] = $styleAttributeValue; $this->_styles[$styleID]['font']['underline'] = $styleAttributeValue;
} }
@ -498,22 +498,22 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
} }
break; break;
case 'Interior' : case 'Interior':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'Color' : case 'Color':
$this->_styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue,1); $this->_styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue, 1);
break; break;
} }
} }
break; break;
case 'NumberFormat' : case 'NumberFormat':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = str_replace($fromFormats, $toFormats, $styleAttributeValue); $styleAttributeValue = str_replace($fromFormats, $toFormats, $styleAttributeValue);
switch ($styleAttributeValue) { switch ($styleAttributeValue) {
case 'Short Date' : case 'Short Date':
$styleAttributeValue = 'dd/mm/yyyy'; $styleAttributeValue = 'dd/mm/yyyy';
break; break;
} }
@ -522,7 +522,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
} }
break; break;
case 'Protection' : case 'Protection':
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
} }
@ -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 // 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 // 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 // the worksheet name in line with the formula, not the reverse
$objPHPExcel->getActiveSheet()->setTitle($worksheetName,false); $objPHPExcel->getActiveSheet()->setTitle($worksheetName, false);
} }
$columnID = 'A'; $columnID = 'A';
@ -640,26 +640,26 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
const TYPE_INLINE = 'inlineStr'; const TYPE_INLINE = 'inlineStr';
const TYPE_ERROR = 'e'; const TYPE_ERROR = 'e';
*/ */
case 'String' : case 'String':
$cellValue = self::_convertStringEncoding($cellValue, $this->_charSet); $cellValue = self::_convertStringEncoding($cellValue, $this->_charSet);
$type = PHPExcel_Cell_DataType::TYPE_STRING; $type = PHPExcel_Cell_DataType::TYPE_STRING;
break; break;
case 'Number' : case 'Number':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$cellValue = (float) $cellValue; $cellValue = (float) $cellValue;
if (floor($cellValue) == $cellValue) { if (floor($cellValue) == $cellValue) {
$cellValue = (integer) $cellValue; $cellValue = (integer) $cellValue;
} }
break; break;
case 'Boolean' : case 'Boolean':
$type = PHPExcel_Cell_DataType::TYPE_BOOL; $type = PHPExcel_Cell_DataType::TYPE_BOOL;
$cellValue = ($cellValue != 0); $cellValue = ($cellValue != 0);
break; break;
case 'DateTime' : case 'DateTime':
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$cellValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellValue)); $cellValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellValue));
break; break;
case 'Error' : case 'Error':
$type = PHPExcel_Cell_DataType::TYPE_ERROR; $type = PHPExcel_Cell_DataType::TYPE_ERROR;
break; break;
} }
@ -669,15 +669,15 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// echo 'FORMULA<br />'; // echo 'FORMULA<br />';
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = PHPExcel_Cell_DataType::TYPE_FORMULA;
$columnNumber = PHPExcel_Cell::columnIndexFromString($columnID); $columnNumber = PHPExcel_Cell::columnIndexFromString($columnID);
if (substr($cellDataFormula,0,3) == 'of:') { if (substr($cellDataFormula, 0, 3) == 'of:') {
$cellDataFormula = substr($cellDataFormula,3); $cellDataFormula = substr($cellDataFormula, 3);
// echo 'Before: ', $cellDataFormula,'<br />'; // echo 'Before: ', $cellDataFormula,'<br />';
$temp = explode('"', $cellDataFormula); $temp = explode('"', $cellDataFormula);
$key = false; $key = false;
foreach ($temp as &$value) { foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks) // Only replace in alternate array entries (i.e. non-quoted blocks)
if ($key = !$key) { if ($key = !$key) {
$value = str_replace(array('[.','.',']'),'', $value); $value = str_replace(array('[.', '.', ']'), '', $value);
} }
} }
} else { } else {
@ -688,7 +688,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
foreach ($temp as &$value) { foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks) // Only replace in alternate array entries (i.e. non-quoted blocks)
if ($key = !$key) { 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 // 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 // through the formula from left to right. Reversing means that we work right to left.through
// the formula // 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 // Bracketed R references are relative to the current row
if ($rowReference{0} == '[') { if ($rowReference{0} == '[') {
$rowReference = $rowID + trim($rowReference,'[]'); $rowReference = $rowID + trim($rowReference, '[]');
} }
$columnReference = $cellReference[4][0]; $columnReference = $cellReference[4][0];
// Empty C reference is the current column // 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 // Bracketed C references are relative to the current column
if ($columnReference{0} == '[') { if ($columnReference{0} == '[') {
$columnReference = $columnNumber + trim($columnReference,'[]'); $columnReference = $columnNumber + trim($columnReference, '[]');
} }
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; $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,'<br />'; // echo $annotation,'<br />';
$annotation = strip_tags($node); $annotation = strip_tags($node);
// echo 'Annotation: ', $annotation,'<br />'; // echo 'Annotation: ', $annotation,'<br />';
$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']))) { if (($cellIsSet) && (isset($cell_ss['StyleID']))) {

View File

@ -49,25 +49,24 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
* *
* @var PHPExcel_ReferenceHelper * @var PHPExcel_ReferenceHelper
*/ */
private $_referenceHelper = NULL; private $_referenceHelper = null;
/** /**
* PHPExcel_Reader_Excel2007_Theme instance * PHPExcel_Reader_Excel2007_Theme instance
* *
* @var PHPExcel_Reader_Excel2007_Theme * @var PHPExcel_Reader_Excel2007_Theme
*/ */
private static $_theme = NULL; private static $_theme = null;
/** /**
* Create a new PHPExcel_Reader_Excel2007 instance * Create a new PHPExcel_Reader_Excel2007 instance
*/ */
public function __construct() { public function __construct()
{
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance(); $this->_referenceHelper = PHPExcel_ReferenceHelper::getInstance();
} }
/** /**
* Can the current PHPExcel_Reader_IReader read the file? * 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(); $zipClass = PHPExcel_Settings::getZipClass();
// Check if zip class exists // 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"); // throw new PHPExcel_Reader_Exception($zipClass . " library is not enabled");
// } // }
@ -240,34 +239,34 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
return $worksheetInfo; return $worksheetInfo;
} }
private static function _castToBool($c)
private static function _castToBool($c) { {
// echo 'Initial Cast to Boolean', PHP_EOL; // 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') { if ($value == '0') {
return FALSE; return false;
} elseif ($value == '1') { } elseif ($value == '1') {
return TRUE; return true;
} else { } else {
return (bool)$c->v; return (bool)$c->v;
} }
return $value; return $value;
} // function _castToBool() } // function _castToBool()
private static function _castToError($c)
private static function _castToError($c) { {
// echo 'Initial Cast to Error', PHP_EOL; // 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() } // function _castToError()
private static function _castToString($c)
private static function _castToString($c) { {
// echo 'Initial Cast to String, PHP_EOL; // 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() } // 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 'Formula', PHP_EOL;
// echo '$c->f is ', $c->f, PHP_EOL; // echo '$c->f is ', $c->f, PHP_EOL;
$cellDataType = 'f'; $cellDataType = 'f';
@ -287,9 +286,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// echo 'SETTING NEW SHARED FORMULA', PHP_EOL; // echo 'SETTING NEW SHARED FORMULA', PHP_EOL;
// echo 'Master is ', $r, PHP_EOL; // echo 'Master is ', $r, PHP_EOL;
// echo 'Formula is ', $value, PHP_EOL; // echo 'Formula is ', $value, PHP_EOL;
$sharedFormulas[$instance] = array( 'master' => $r, $sharedFormulas[$instance] = array('master' => $r, 'formula' => $value);
'formula' => $value
);
// echo 'New Shared Formula Array:', PHP_EOL; // echo 'New Shared Formula Array:', PHP_EOL;
// print_r($sharedFormulas); // print_r($sharedFormulas);
} else { } 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[0] = PHPExcel_Cell::columnIndexFromString($current[0]) - PHPExcel_Cell::columnIndexFromString($master[0]);
$difference[1] = $current[1] - $master[1]; $difference[1] = $current[1] - $master[1];
$value = $this->_referenceHelper->updateFormulaReferences( $sharedFormulas[$instance]['formula'], $value = $this->_referenceHelper->updateFormulaReferences($sharedFormulas[$instance]['formula'], 'A1', $difference[0], $difference[1]);
'A1',
$difference[0],
$difference[1]
);
// echo 'Adjusted Formula is ', $value, PHP_EOL; // 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 = '') public function _getFromZipArchive($archive, $fileName = '')
{ {
// Root-relative paths // Root-relative paths
if (strpos($fileName, '//') !== false) if (strpos($fileName, '//') !== false) {
{
$fileName = substr($fileName, strpos($fileName, '//') + 1); $fileName = substr($fileName, strpos($fileName, '//') + 1);
} }
$fileName = PHPExcel_Shared_File::realpath($fileName); $fileName = PHPExcel_Shared_File::realpath($fileName);
// Apache POI fixes // Apache POI fixes
$contents = $archive->getFromName($fileName); $contents = $archive->getFromName($fileName);
if ($contents === false) if ($contents === false) {
{
$contents = $archive->getFromName(substr($fileName, 1)); $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) { foreach ($wbRels->Relationship as $rel) {
switch ($rel["Type"]) { switch ($rel["Type"]) {
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme": case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme":
$themeOrderArray = array('lt1','dk1','lt2','dk2'); $themeOrderArray = array('lt1', 'dk1', 'lt2', 'dk2');
$themeOrderAdditional = count($themeOrderArray); $themeOrderAdditional = count($themeOrderArray);
$xmlTheme = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "xl/{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $xmlTheme = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "xl/{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
@ -420,18 +411,18 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$docProps->setCategory((string) self::array_item($xmlCore->xpath("cp:category"))); $docProps->setCategory((string) self::array_item($xmlCore->xpath("cp:category")));
} }
break; break;
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties": 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()); $xmlCore = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
if (is_object($xmlCore)) { if (is_object($xmlCore)) {
$docProps = $excel->getProperties(); $docProps = $excel->getProperties();
if (isset($xmlCore->Company)) if (isset($xmlCore->Company)) {
$docProps->setCompany((string) $xmlCore->Company); $docProps->setCompany((string) $xmlCore->Company);
if (isset($xmlCore->Manager)) }
if (isset($xmlCore->Manager)) {
$docProps->setManager((string) $xmlCore->Manager); $docProps->setManager((string) $xmlCore->Manager);
} }
}
break; break;
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties": 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()); $xmlCore = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
if (is_object($xmlCore)) { if (is_object($xmlCore)) {
@ -468,7 +459,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($xmlStrings) && isset($xmlStrings->si)) { if (isset($xmlStrings) && isset($xmlStrings->si)) {
foreach ($xmlStrings->si as $val) { foreach ($xmlStrings->si as $val) {
if (isset($val->t)) { if (isset($val->t)) {
$sharedStrings[] = PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $val->t ); $sharedStrings[] = PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $val->t);
} elseif (isset($val->r)) { } elseif (isset($val->r)) {
$sharedStrings[] = $this->_parseRichText($val); $sharedStrings[] = $this->_parseRichText($val);
} }
@ -476,7 +467,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
$worksheets = array(); $worksheets = array();
$macros = $customUI = NULL; $macros = $customUI = null;
foreach ($relsWorkbook->Relationship as $ele) { foreach ($relsWorkbook->Relationship as $ele) {
switch ($ele['Type']) { switch ($ele['Type']) {
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet": case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":
@ -496,10 +487,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$excel->setHasMacros(true); $excel->setHasMacros(true);
//short-circuit : not reading vbaProject.bin.rel to get Signature =>allways vbaProjectSignature.bin in 'xl' dir //short-circuit : not reading vbaProject.bin.rel to get Signature =>allways vbaProjectSignature.bin in 'xl' dir
$Certificate = $this->_getFromZipArchive($zip, 'xl/vbaProjectSignature.bin'); $Certificate = $this->_getFromZipArchive($zip, 'xl/vbaProjectSignature.bin');
if ($Certificate !== false) if ($Certificate !== false) {
$excel->setMacrosCertificate($Certificate); $excel->setMacrosCertificate($Certificate);
} }
} }
}
$styles = array(); $styles = array();
$cellStyles = array(); $cellStyles = array();
$xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']")); $xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']"));
@ -508,7 +500,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ($xmlStyles && $xmlStyles->numFmts[0]) { if ($xmlStyles && $xmlStyles->numFmts[0]) {
$numFmts = $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"); $numFmts->registerXPathNamespace("sml", "http://schemas.openxmlformats.org/spreadsheetml/2006/main");
} }
if (!$this->_readDataOnly && $xmlStyles) { if (!$this->_readDataOnly && $xmlStyles) {
@ -586,7 +578,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Conditional Styles // Conditional Styles
if ($xmlStyles->dxfs) { if ($xmlStyles->dxfs) {
foreach ($xmlStyles->dxfs->dxf as $dxf) { foreach ($xmlStyles->dxfs->dxf as $dxf) {
$style = new PHPExcel_Style(FALSE, TRUE); $style = new PHPExcel_Style(false, true);
self::_readStyle($style, $dxf); self::_readStyle($style, $dxf);
$dxfs[] = $style; $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 $countSkippedSheets = 0; // keep track of number of skipped sheets
$mapSheetId = array(); // mapping of sheet ids from old to new $mapSheetId = array(); // mapping of sheet ids from old to new
$charts = $chartDetails = array(); $charts = $chartDetails = array();
if ($xmlWorkbook->sheets) { if ($xmlWorkbook->sheets) {
@ -655,37 +646,31 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$sharedFormulas = array(); $sharedFormulas = array();
if (isset($eleSheet["state"]) && (string) $eleSheet["state"] != '') { 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) && isset($xmlSheet->sheetViews->sheetView)) {
if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) { 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'])) { 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'])) { if (isset($xmlSheet->sheetViews->sheetView['view'])) {
$docSheet->getSheetView()->setView((string) $xmlSheet->sheetViews->sheetView['view']); $docSheet->getSheetView()->setView((string) $xmlSheet->sheetViews->sheetView['view']);
} }
if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) { if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) {
$docSheet->setShowGridLines(self::boolean((string)$xmlSheet->sheetViews->sheetView['showGridLines'])); $docSheet->setShowGridLines(self::boolean((string)$xmlSheet->sheetViews->sheetView['showGridLines']));
} }
if (isset($xmlSheet->sheetViews->sheetView['showRowColHeaders'])) { if (isset($xmlSheet->sheetViews->sheetView['showRowColHeaders'])) {
$docSheet->setShowRowColHeaders(self::boolean((string)$xmlSheet->sheetViews->sheetView['showRowColHeaders'])); $docSheet->setShowRowColHeaders(self::boolean((string)$xmlSheet->sheetViews->sheetView['showRowColHeaders']));
} }
if (isset($xmlSheet->sheetViews->sheetView['rightToLeft'])) { if (isset($xmlSheet->sheetViews->sheetView['rightToLeft'])) {
$docSheet->setRightToLeft(self::boolean((string)$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)) {
if (isset($xmlSheet->sheetViews->sheetView->pane['topLeftCell'])) { if (isset($xmlSheet->sheetViews->sheetView->pane['topLeftCell'])) {
$docSheet->freezePane( (string)$xmlSheet->sheetViews->sheetView->pane['topLeftCell'] ); $docSheet->freezePane((string)$xmlSheet->sheetViews->sheetView->pane['topLeftCell']);
} else { } else {
$xSplit = 0; $xSplit = 0;
$ySplit = 0; $ySplit = 0;
@ -710,12 +695,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$docSheet->setSelectedCells($sqref); $docSheet->setSelectedCells($sqref);
} }
} }
} }
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) { if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) {
if (isset($xmlSheet->sheetPr->tabColor['rgb'])) { 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'])) { 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) && isset($xmlSheet->sheetPr->outlinePr)) {
if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) &&
!self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) { !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) {
$docSheet->setShowSummaryRight(FALSE); $docSheet->setShowSummaryRight(false);
} else { } else {
$docSheet->setShowSummaryRight(TRUE); $docSheet->setShowSummaryRight(true);
} }
if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) &&
!self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryBelow'])) { !self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryBelow'])) {
$docSheet->setShowSummaryBelow(FALSE); $docSheet->setShowSummaryBelow(false);
} else { } else {
$docSheet->setShowSummaryBelow(TRUE); $docSheet->setShowSummaryBelow(true);
} }
} }
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) { if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) {
if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) &&
!self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) { !self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) {
$docSheet->getPageSetup()->setFitToPage(FALSE); $docSheet->getPageSetup()->setFitToPage(false);
} else { } 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']) && if (isset($xmlSheet->sheetFormatPr['customHeight']) &&
self::boolean((string) $xmlSheet->sheetFormatPr['customHeight']) && self::boolean((string) $xmlSheet->sheetFormatPr['customHeight']) &&
isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) { isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) {
$docSheet->getDefaultRowDimension()->setRowHeight( (float)$xmlSheet->sheetFormatPr['defaultRowHeight'] ); $docSheet->getDefaultRowDimension()->setRowHeight((float)$xmlSheet->sheetFormatPr['defaultRowHeight']);
} }
if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) { if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) {
$docSheet->getDefaultColumnDimension()->setWidth( (float)$xmlSheet->sheetFormatPr['defaultColWidth'] ); $docSheet->getDefaultColumnDimension()->setWidth((float)$xmlSheet->sheetFormatPr['defaultColWidth']);
} }
if (isset($xmlSheet->sheetFormatPr['zeroHeight']) && if (isset($xmlSheet->sheetFormatPr['zeroHeight']) &&
((string)$xmlSheet->sheetFormatPr['zeroHeight'] == '1')) { ((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"])); $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"]));
} }
if (self::boolean($col["bestFit"])) { 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"])) { if (self::boolean($col["hidden"])) {
// echo PHPExcel_Cell::stringFromColumnIndex($i),': HIDDEN COLUMN',PHP_EOL; // echo PHPExcel_Cell::stringFromColumnIndex($i), ': HIDDEN COLUMN',PHP_EOL;
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(FALSE); $docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false);
} }
if (self::boolean($col["collapsed"])) { 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) { if ($col["outlineLevel"] > 0) {
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"])); $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 (isset($xmlSheet->printOptions) && !$this->_readDataOnly) {
if (self::boolean((string) $xmlSheet->printOptions['gridLinesSet'])) { if (self::boolean((string) $xmlSheet->printOptions['gridLinesSet'])) {
$docSheet->setShowGridlines(TRUE); $docSheet->setShowGridlines(true);
} }
if (self::boolean((string) $xmlSheet->printOptions['gridLines'])) { if (self::boolean((string) $xmlSheet->printOptions['gridLines'])) {
$docSheet->setPrintGridlines(TRUE); $docSheet->setPrintGridlines(true);
} }
if (self::boolean((string) $xmlSheet->printOptions['horizontalCentered'])) { if (self::boolean((string) $xmlSheet->printOptions['horizontalCentered'])) {
$docSheet->getPageSetup()->setHorizontalCentered(TRUE); $docSheet->getPageSetup()->setHorizontalCentered(true);
} }
if (self::boolean((string) $xmlSheet->printOptions['verticalCentered'])) { 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"])); $docSheet->getRowDimension(intval($row["r"]))->setRowHeight(floatval($row["ht"]));
} }
if (self::boolean($row["hidden"]) && !$this->_readDataOnly) { 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"])) { if (self::boolean($row["collapsed"])) {
$docSheet->getRowDimension(intval($row["r"]))->setCollapsed(TRUE); $docSheet->getRowDimension(intval($row["r"]))->setCollapsed(true);
} }
if ($row["outlineLevel"] > 0) { if ($row["outlineLevel"] > 0) {
$docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"])); $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; $calculatedValue = null;
// Read cell? // Read cell?
if ($this->getReadFilter() !== NULL) { if ($this->getReadFilter() !== null) {
$coordinates = PHPExcel_Cell::coordinateFromString($r); $coordinates = PHPExcel_Cell::coordinateFromString($r);
if (!$this->getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) { 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 { } else {
$value = ''; $value = '';
} }
break; break;
case "b": case "b":
// echo 'Boolean', PHP_EOL; // echo 'Boolean', PHP_EOL;
@ -865,7 +846,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$value = self::_castToBool($c); $value = self::_castToBool($c);
} else { } else {
// Formula // Formula
$this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToBool'); $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, '_castToBool');
if (isset($c->f['t'])) { if (isset($c->f['t'])) {
$att = array(); $att = array();
$att = $c->f; $att = $c->f;
@ -877,7 +858,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
case "inlineStr": case "inlineStr":
// echo 'Inline String', PHP_EOL; // echo 'Inline String', PHP_EOL;
$value = $this->_parseRichText($c->is); $value = $this->_parseRichText($c->is);
break; break;
case "e": case "e":
// echo 'Error', PHP_EOL; // echo 'Error', PHP_EOL;
@ -885,12 +865,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$value = self::_castToError($c); $value = self::_castToError($c);
} else { } else {
// Formula // Formula
$this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToError'); $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, '_castToError');
// echo '$calculatedValue = ', $calculatedValue, PHP_EOL; // echo '$calculatedValue = ', $calculatedValue, PHP_EOL;
} }
break; break;
default: default:
// echo 'Default', PHP_EOL; // echo 'Default', PHP_EOL;
if (!isset($c->f)) { if (!isset($c->f)) {
@ -899,10 +877,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} else { } else {
// echo 'Treat as Formula', PHP_EOL; // echo 'Treat as Formula', PHP_EOL;
// Formula // Formula
$this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToString'); $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas, '_castToString');
// echo '$calculatedValue = ', $calculatedValue, PHP_EOL; // echo '$calculatedValue = ', $calculatedValue, PHP_EOL;
} }
break; break;
} }
// echo 'Value is ', $value, PHP_EOL; // echo 'Value is ', $value, PHP_EOL;
@ -926,7 +903,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} else { } else {
$cell->setValue($value); $cell->setValue($value);
} }
if ($calculatedValue !== NULL) { if ($calculatedValue !== null) {
$cell->setCalculatedValue($calculatedValue); $cell->setCalculatedValue($calculatedValue);
} }
@ -997,7 +974,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { 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) { if ($xmlSheet->protectedRanges->protectedRange) {
foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) { foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) {
$docSheet->protectCells((string) $protectedRange["sqref"], (string) $protectedRange["password"], true); $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; $filters = $filterColumn->filters;
if ((isset($filters["blank"])) && ($filters["blank"] == 1)) { if ((isset($filters["blank"])) && ($filters["blank"] == 1)) {
$column->createRule()->setRule( $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); ->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 // Entries can be either filter elements
foreach ($filters->filter as $filterRule) { foreach ($filters->filter as $filterRule) {
$column->createRule()->setRule( $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["val"]
) )
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER); ->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 // Or Date Group elements
foreach ($filters->dateGroupItem as $dateGroupItem) { foreach ($filters->dateGroupItem as $dateGroupItem) {
$column->createRule()->setRule( $column->createRule()->setRule(
NULL, // Operator is undefined, but always treated as EQUAL null, // Operator is undefined, but always treated as EQUAL
array( array(
'year' => (string) $dateGroupItem["year"], 'year' => (string) $dateGroupItem["year"],
'month' => (string) $dateGroupItem["month"], '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 // We should only ever have one dynamic filter
foreach ($filterColumn->dynamicFilter as $filterRule) { foreach ($filterColumn->dynamicFilter as $filterRule) {
$column->createRule()->setRule( $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["val"],
(string) $filterRule["type"] (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) { if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly) {
foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) { foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) {
$mergeRef = (string) $mergeCell["ref"]; $mergeRef = (string) $mergeCell["ref"];
if (strpos($mergeRef,':') !== FALSE) { if (strpos($mergeRef, ':') !== false) {
$docSheet->mergeCells((string) $mergeCell["ref"]); $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"])); $docPageSetup->setPaperSize(intval($xmlSheet->pageSetup["paperSize"]));
} }
if (isset($xmlSheet->pageSetup["scale"])) { 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) { 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) { 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"]) && if (isset($xmlSheet->pageSetup["firstPageNumber"]) && isset($xmlSheet->pageSetup["useFirstPageNumber"]) &&
self::boolean((string) $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"]) && if (isset($xmlSheet->headerFooter["differentOddEven"]) &&
self::boolean((string)$xmlSheet->headerFooter["differentOddEven"])) { self::boolean((string)$xmlSheet->headerFooter["differentOddEven"])) {
$docHeaderFooter->setDifferentOddEven(TRUE); $docHeaderFooter->setDifferentOddEven(true);
} else { } else {
$docHeaderFooter->setDifferentOddEven(FALSE); $docHeaderFooter->setDifferentOddEven(false);
} }
if (isset($xmlSheet->headerFooter["differentFirst"]) && if (isset($xmlSheet->headerFooter["differentFirst"]) &&
self::boolean((string)$xmlSheet->headerFooter["differentFirst"])) { self::boolean((string)$xmlSheet->headerFooter["differentFirst"])) {
$docHeaderFooter->setDifferentFirst(TRUE); $docHeaderFooter->setDifferentFirst(true);
} else { } else {
$docHeaderFooter->setDifferentFirst(FALSE); $docHeaderFooter->setDifferentFirst(false);
} }
if (isset($xmlSheet->headerFooter["scaleWithDoc"]) && if (isset($xmlSheet->headerFooter["scaleWithDoc"]) &&
!self::boolean((string)$xmlSheet->headerFooter["scaleWithDoc"])) { !self::boolean((string)$xmlSheet->headerFooter["scaleWithDoc"])) {
$docHeaderFooter->setScaleWithDocument(FALSE); $docHeaderFooter->setScaleWithDocument(false);
} else { } else {
$docHeaderFooter->setScaleWithDocument(TRUE); $docHeaderFooter->setScaleWithDocument(true);
} }
if (isset($xmlSheet->headerFooter["alignWithMargins"]) && if (isset($xmlSheet->headerFooter["alignWithMargins"]) &&
!self::boolean((string)$xmlSheet->headerFooter["alignWithMargins"])) { !self::boolean((string)$xmlSheet->headerFooter["alignWithMargins"])) {
$docHeaderFooter->setAlignWithMargins(FALSE); $docHeaderFooter->setAlignWithMargins(false);
} else { } else {
$docHeaderFooter->setAlignWithMargins(TRUE); $docHeaderFooter->setAlignWithMargins(true);
} }
$docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader); $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'); $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships');
foreach (PHPExcel_Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { foreach (PHPExcel_Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) {
$cell = $docSheet->getCell( $cellReference ); $cell = $docSheet->getCell($cellReference);
if (isset($linkRel['id'])) { if (isset($linkRel['id'])) {
$hyperlinkUrl = $hyperlinks[ (string)$linkRel['id'] ]; $hyperlinkUrl = $hyperlinks[ (string)$linkRel['id'] ];
if (isset($hyperlink['location'])) { if (isset($hyperlink['location'])) {
@ -1262,12 +1239,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
$cell->getHyperlink()->setUrl($hyperlinkUrl); $cell->getHyperlink()->setUrl($hyperlinkUrl);
} elseif (isset($hyperlink['location'])) { } elseif (isset($hyperlink['location'])) {
$cell->getHyperlink()->setUrl( 'sheet://' . (string)$hyperlink['location'] ); $cell->getHyperlink()->setUrl('sheet://' . (string)$hyperlink['location']);
} }
// Tooltip // Tooltip
if (isset($hyperlink['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 // Loop through contents
foreach ($commentsFile->commentList->comment as $comment) { foreach ($commentsFile->commentList->comment as $comment) {
if (!empty($comment['authorId'])) if (!empty($comment['authorId']))
$docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$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'])->setText($this->_parseRichText($comment->text));
} }
} }
@ -1326,7 +1303,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($shape['style'])) { if (isset($shape['style'])) {
$style = (string)$shape['style']; $style = (string)$shape['style'];
$fillColor = strtoupper( substr( (string)$shape['fillcolor'], 1 ) ); $fillColor = strtoupper(substr((string)$shape['fillcolor'], 1));
$column = null; $column = null;
$row = null; $row = null;
@ -1334,31 +1311,44 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (is_array($clientData) && !empty($clientData)) { if (is_array($clientData) && !empty($clientData)) {
$clientData = $clientData[0]; $clientData = $clientData[0];
if ( isset($clientData['ObjectType']) && (string)$clientData['ObjectType'] == 'Note' ) { if (isset($clientData['ObjectType']) && (string)$clientData['ObjectType'] == 'Note') {
$temp = $clientData->xpath('.//x:Row'); $temp = $clientData->xpath('.//x:Row');
if (is_array($temp)) $row = $temp[0]; if (is_array($temp)) {
$row = $temp[0];
}
$temp = $clientData->xpath('.//x:Column'); $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 // Set comment properties
$comment = $docSheet->getCommentByColumnAndRow((string) $column, $row + 1); $comment = $docSheet->getCommentByColumnAndRow((string) $column, $row + 1);
$comment->getFillColor()->setRGB( $fillColor ); $comment->getFillColor()->setRGB($fillColor);
// Parse style // Parse style
$styleArray = explode(';', str_replace(' ', '', $style)); $styleArray = explode(';', str_replace(' ', '', $style));
foreach ($styleArray as $stylePair) { foreach ($styleArray as $stylePair) {
$stylePair = explode(':', $stylePair); $stylePair = explode(':', $stylePair);
if ($stylePair[0] == 'margin-left') $comment->setMarginLeft($stylePair[1]); if ($stylePair[0] == 'margin-left') {
if ($stylePair[0] == 'margin-top') $comment->setMarginTop($stylePair[1]); $comment->setMarginLeft($stylePair[1]);
if ($stylePair[0] == 'width') $comment->setWidth($stylePair[1]); }
if ($stylePair[0] == 'height') $comment->setHeight($stylePair[1]); if ($stylePair[0] == 'margin-top') {
if ($stylePair[0] == 'visibility') $comment->setVisible( $stylePair[1] == 'visible' ); $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[$idx];
$imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office'); $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(); $hfImages[ (string)$shape['id'] ] = new PHPExcel_Worksheet_HeaderFooterDrawing();
if (isset($imageData['title'])) { 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); $hfImages[ (string)$shape['id'] ]->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $drawings[(string)$imageData['relid']], false);
@ -1446,7 +1436,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$images[(string) $ele["Id"]] = self::dir_add($fileDrawing, $ele["Target"]); $images[(string) $ele["Id"]] = self::dir_add($fileDrawing, $ele["Target"]);
} elseif ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart") { } elseif ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart") {
if ($this->_includeCharts) { if ($this->_includeCharts) {
$charts[self::dir_add($fileDrawing, $ele["Target"])] = array('id' => (string) $ele["Id"], $charts[self::dir_add($fileDrawing, $ele["Target"])] = array(
'id' => (string) $ele["Id"],
'sheet' => $docSheet->getTitle() 'sheet' => $docSheet->getTitle()
); );
} }
@ -1537,8 +1528,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$chartRef = $graphic->graphicData->children("http://schemas.openxmlformats.org/drawingml/2006/chart")->chart; $chartRef = $graphic->graphicData->children("http://schemas.openxmlformats.org/drawingml/2006/chart")->chart;
$thisChart = (string) $chartRef->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"); $thisChart = (string) $chartRef->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships");
$chartDetails[$docSheet->getTitle().'!'.$thisChart] = $chartDetails[$docSheet->getTitle().'!'.$thisChart] = array(
array( 'fromCoordinate' => $fromCoordinate, 'fromCoordinate' => $fromCoordinate,
'fromOffsetX' => $fromOffsetX, 'fromOffsetX' => $fromOffsetX,
'fromOffsetY' => $fromOffsetY, 'fromOffsetY' => $fromOffsetY,
'toCoordinate' => $toCoordinate, 'toCoordinate' => $toCoordinate,
@ -1549,7 +1540,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
} }
} }
} }
} }
@ -1560,14 +1550,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Extract range // Extract range
$extractedRange = (string)$definedName; $extractedRange = (string)$definedName;
$extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); $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)); $extractedRange = substr($extractedRange,0, $spos).str_replace('$', '', substr($extractedRange, $spos));
} else { } else {
$extractedRange = str_replace('$', '', $extractedRange); $extractedRange = str_replace('$', '', $extractedRange);
} }
// Valid range? // Valid range?
if (stripos((string)$definedName, '#REF!') !== FALSE || $extractedRange == '') { if (stripos((string)$definedName, '#REF!') !== false || $extractedRange == '') {
continue; continue;
} }
@ -1575,7 +1565,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ((string)$definedName['localSheetId'] != '' && (string)$definedName['localSheetId'] == $sheetId) { if ((string)$definedName['localSheetId'] != '' && (string)$definedName['localSheetId'] == $sheetId) {
// Switch on type // Switch on type
switch ((string)$definedName['name']) { switch ((string)$definedName['name']) {
case '_xlnm._FilterDatabase': case '_xlnm._FilterDatabase':
if ((string)$definedName['hidden'] !== '1') { if ((string)$definedName['hidden'] !== '1') {
$extractedRange = explode(',', $extractedRange); $extractedRange = explode(',', $extractedRange);
@ -1587,7 +1576,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
break; break;
case '_xlnm.Print_Titles': case '_xlnm.Print_Titles':
// Split $extractedRange // Split $extractedRange
$extractedRange = explode(',', $extractedRange); $extractedRange = explode(',', $extractedRange);
@ -1607,14 +1595,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
break; break;
case '_xlnm.Print_Area': case '_xlnm.Print_Area':
$rangeSets = explode(',', $extractedRange); // FIXME: what if sheetname contains comma? $rangeSets = explode(',', $extractedRange); // FIXME: what if sheetname contains comma?
$newRangeSets = array(); $newRangeSets = array();
foreach ($rangeSets as $rangeSet) { foreach ($rangeSets as $rangeSet) {
$range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark? $range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark?
$rangeSet = isset($range[1]) ? $range[1] : $range[0]; $rangeSet = isset($range[1]) ? $range[1] : $range[0];
if (strpos($rangeSet, ':') === FALSE) { if (strpos($rangeSet, ':') === false) {
$rangeSet = $rangeSet . ':' . $rangeSet; $rangeSet = $rangeSet . ':' . $rangeSet;
} }
$newRangeSets[] = str_replace('$', '', $rangeSet); $newRangeSets[] = str_replace('$', '', $rangeSet);
@ -1639,7 +1626,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Extract range // Extract range
$extractedRange = (string)$definedName; $extractedRange = (string)$definedName;
$extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); $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)); $extractedRange = substr($extractedRange,0, $spos).str_replace('$', '', substr($extractedRange, $spos));
} else { } else {
$extractedRange = str_replace('$', '', $extractedRange); $extractedRange = str_replace('$', '', $extractedRange);
@ -1655,12 +1642,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Local defined name // Local defined name
// Switch on type // Switch on type
switch ((string)$definedName['name']) { switch ((string)$definedName['name']) {
case '_xlnm._FilterDatabase': case '_xlnm._FilterDatabase':
case '_xlnm.Print_Titles': case '_xlnm.Print_Titles':
case '_xlnm.Print_Area': case '_xlnm.Print_Area':
break; break;
default: default:
if ($mapSheetId[(integer) $definedName['localSheetId']] !== null) { if ($mapSheetId[(integer) $definedName['localSheetId']] !== null) {
$range = explode('!', (string)$definedName); $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])) { if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) {
$extractedRange = str_replace('$', '', $range[1]); $extractedRange = str_replace('$', '', $range[1]);
$scope = $docSheet->getParent()->getSheet($mapSheetId[(integer) $definedName['localSheetId']]); $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 // "Global" definedNames
$locatedSheet = null; $locatedSheet = null;
$extractedSheetName = ''; $extractedSheetName = '';
if (strpos( (string)$definedName, '!' ) !== false) { if (strpos((string)$definedName, '!') !== false) {
// Extract sheet name // Extract sheet name
$extractedSheetName = PHPExcel_Worksheet::extractSheetTitle( (string)$definedName, true ); $extractedSheetName = PHPExcel_Worksheet::extractSheetTitle((string)$definedName, true);
$extractedSheetName = $extractedSheetName[0]; $extractedSheetName = $extractedSheetName[0];
// Locate sheet // Locate sheet
@ -1693,8 +1678,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$extractedRange = isset($range[1]) ? $range[1] : $range[0]; $extractedRange = isset($range[1]) ? $range[1] : $range[0];
} }
if ($locatedSheet !== NULL) { if ($locatedSheet !== null) {
$excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false) ); $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; break;
} }
} }
if (!$this->_readDataOnly) { if (!$this->_readDataOnly) {
$contentTypes = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "[Content_Types].xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $contentTypes = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "[Content_Types].xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
foreach ($contentTypes->Override as $contentType) { foreach ($contentTypes->Override as $contentType) {
switch ($contentType["ContentType"]) { switch ($contentType["ContentType"]) {
case "application/vnd.openxmlformats-officedocument.drawingml.chart+xml": case "application/vnd.openxmlformats-officedocument.drawingml.chart+xml":
if ($this->_includeCharts) { 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()); $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,'<br />'; // echo 'Chart ', $chartEntryRef, '<br />';
// var_dump($charts[$chartEntryRef]); // var_dump($charts[$chartEntryRef]);
// //
if (isset($charts[$chartEntryRef])) { if (isset($charts[$chartEntryRef])) {
$chartPositionRef = $charts[$chartEntryRef]['sheet'].'!'.$charts[$chartEntryRef]['id']; $chartPositionRef = $charts[$chartEntryRef]['sheet'].'!'.$charts[$chartEntryRef]['id'];
// echo 'Position Ref ', $chartPositionRef,'<br />'; // echo 'Position Ref ', $chartPositionRef, '<br />';
if (isset($chartDetails[$chartPositionRef])) { if (isset($chartDetails[$chartPositionRef])) {
// var_dump($chartDetails[$chartPositionRef]); // var_dump($chartDetails[$chartPositionRef]);
$excel->getSheetByName($charts[$chartEntryRef]['sheet'])->addChart($objChart); $excel->getSheetByName($charts[$chartEntryRef]['sheet'])->addChart($objChart);
$objChart->setWorksheet($excel->getSheetByName($charts[$chartEntryRef]['sheet'])); $objChart->setWorksheet($excel->getSheetByName($charts[$chartEntryRef]['sheet']));
$objChart->setTopLeftPosition( $chartDetails[$chartPositionRef]['fromCoordinate'], $objChart->setTopLeftPosition($chartDetails[$chartPositionRef]['fromCoordinate'], $chartDetails[$chartPositionRef]['fromOffsetX'], $chartDetails[$chartPositionRef]['fromOffsetY']);
$chartDetails[$chartPositionRef]['fromOffsetX'], $objChart->setBottomRightPosition($chartDetails[$chartPositionRef]['toCoordinate'], $chartDetails[$chartPositionRef]['toOffsetX'], $chartDetails[$chartPositionRef]['toOffsetY']);
$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; return $excel;
} }
private static function _readColor($color, $background = false)
private static function _readColor($color, $background=FALSE) { {
if (isset($color["rgb"])) { if (isset($color["rgb"])) {
return (string)$color["rgb"]; return (string)$color["rgb"];
} else if (isset($color["indexed"])) { } else if (isset($color["indexed"])) {
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB(); return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB();
} else if (isset($color["theme"])) { } else if (isset($color["theme"])) {
if (self::$_theme !== NULL) { if (self::$_theme !== null) {
$returnColour = self::$_theme->getColourByIndex((int)$color["theme"]); $returnColour = self::$_theme->getColourByIndex((int)$color["theme"]);
if (isset($color["tint"])) { if (isset($color["tint"])) {
$tintAdjust = (float) $color["tint"]; $tintAdjust = (float) $color["tint"];
@ -1785,8 +1762,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
return 'FF000000'; return 'FF000000';
} }
private static function _readStyle($docStyle, $style)
private static function _readStyle($docStyle, $style) { {
// format code // format code
// if (isset($style->numFmt)) { // if (isset($style->numFmt)) {
// if (isset($style->numFmt['formatCode'])) { // 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"])); $docStyle->getFill()->setRotation(floatval($gradientFill["degree"]));
$gradientFill->registerXPathNamespace("sml", "http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $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()->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()->getEndColor()->setARGB(self::_readColor(self::array_item($gradientFill->xpath("sml:stop[@position=1]"))->color));
} elseif ($style->fill->patternFill) { } elseif ($style->fill->patternFill) {
$patternType = (string)$style->fill->patternFill["patternType"] != '' ? (string)$style->fill->patternFill["patternType"] : 'solid'; $patternType = (string)$style->fill->patternFill["patternType"] != '' ? (string)$style->fill->patternFill["patternType"] : 'solid';
$docStyle->getFill()->setFillType($patternType); $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()->setTextRotation(intval($textRotation));
$docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment["wrapText"])); $docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment["wrapText"]));
$docStyle->getAlignment()->setShrinkToFit(self::boolean((string) $style->alignment["shrinkToFit"])); $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()->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()->setReadorder(intval((string)$style->alignment["readingOrder"]) > 0 ? intval((string)$style->alignment["readingOrder"]) : 0);
} }
// protection // 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"])) { if (isset($eleBorder["style"])) {
$docBorder->setBorderStyle((string) $eleBorder["style"]); $docBorder->setBorderStyle((string) $eleBorder["style"]);
} }
@ -1927,62 +1904,55 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
private function _parseRichText($is = null)
private function _parseRichText($is = null) { {
$value = new PHPExcel_RichText(); $value = new PHPExcel_RichText();
if (isset($is->t)) { if (isset($is->t)) {
$value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) ); $value->createText(PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $is->t));
} else { } else {
if (is_object($is->r)) { if (is_object($is->r)) {
foreach ($is->r as $run) { foreach ($is->r as $run) {
if (!isset($run->rPr)) { if (!isset($run->rPr)) {
$objText = $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) ); $objText = $value->createText(PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $run->t));
} else { } else {
$objText = $value->createTextRun( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) ); $objText = $value->createTextRun(PHPExcel_Shared_String::ControlCharacterOOXML2PHP((string) $run->t));
if (isset($run->rPr->rFont["val"])) { if (isset($run->rPr->rFont["val"])) {
$objText->getFont()->setName((string) $run->rPr->rFont["val"]); $objText->getFont()->setName((string) $run->rPr->rFont["val"]);
} }
if (isset($run->rPr->sz["val"])) { if (isset($run->rPr->sz["val"])) {
$objText->getFont()->setSize((string) $run->rPr->sz["val"]); $objText->getFont()->setSize((string) $run->rPr->sz["val"]);
} }
if (isset($run->rPr->color)) { if (isset($run->rPr->color)) {
$objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($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"])) || if ((isset($run->rPr->b["val"]) && self::boolean((string) $run->rPr->b["val"])) ||
(isset($run->rPr->b) && !isset($run->rPr->b["val"]))) { (isset($run->rPr->b) && !isset($run->rPr->b["val"]))) {
$objText->getFont()->setBold(TRUE); $objText->getFont()->setBold(true);
} }
if ((isset($run->rPr->i["val"]) && self::boolean((string) $run->rPr->i["val"])) || if ((isset($run->rPr->i["val"]) && self::boolean((string) $run->rPr->i["val"])) ||
(isset($run->rPr->i) && !isset($run->rPr->i["val"]))) { (isset($run->rPr->i) && !isset($run->rPr->i["val"]))) {
$objText->getFont()->setItalic(TRUE); $objText->getFont()->setItalic(true);
} }
if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign["val"])) { if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign["val"])) {
$vertAlign = strtolower((string)$run->rPr->vertAlign["val"]); $vertAlign = strtolower((string)$run->rPr->vertAlign["val"]);
if ($vertAlign == 'superscript') { if ($vertAlign == 'superscript') {
$objText->getFont()->setSuperScript(TRUE); $objText->getFont()->setSuperScript(true);
} }
if ($vertAlign == 'subscript') { if ($vertAlign == 'subscript') {
$objText->getFont()->setSubScript(TRUE); $objText->getFont()->setSubScript(true);
} }
} }
if (isset($run->rPr->u) && !isset($run->rPr->u["val"])) { if (isset($run->rPr->u) && !isset($run->rPr->u["val"])) {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
} else if (isset($run->rPr->u) && isset($run->rPr->u["val"])) { } else if (isset($run->rPr->u) && isset($run->rPr->u["val"])) {
$objText->getFont()->setUnderline((string)$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"])) || if ((isset($run->rPr->strike["val"]) && self::boolean((string) $run->rPr->strike["val"])) ||
(isset($run->rPr->strike) && !isset($run->rPr->strike["val"]))) { (isset($run->rPr->strike) && !isset($run->rPr->strike["val"]))) {
$objText->getFont()->setStrikethrough(TRUE); $objText->getFont()->setStrikethrough(true);
} }
} }
} }
@ -2022,25 +1992,26 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (count($customUIImagesNames) > 0 && count($customUIImagesBinaries) > 0) { if (count($customUIImagesNames) > 0 && count($customUIImagesBinaries) > 0) {
$excel->setRibbonBinObjects($customUIImagesNames, $customUIImagesBinaries); $excel->setRibbonBinObjects($customUIImagesNames, $customUIImagesBinaries);
} else { } else {
$excel->setRibbonBinObjects(NULL); $excel->setRibbonBinObjects(null);
} }
} else { } else {
$excel->setRibbonXMLData(NULL); $excel->setRibbonXMLData(null);
$excel->setRibbonBinObjects(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); 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"); return preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add");
} }
private static function toCSSArray($style)
private static function toCSSArray($style) { {
$style = str_replace(array("\r","\n"), "", $style); $style = str_replace(array("\r","\n"), "", $style);
$temp = explode(';', $style); $temp = explode(';', $style);
@ -2070,7 +2041,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
return $style; return $style;
} }
private static function boolean($value = NULL) private static function boolean($value = null)
{ {
if (is_object($value)) { if (is_object($value)) {
$value = (string) $value; $value = (string) $value;

File diff suppressed because it is too large Load Diff