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;
} }
/** /**
@ -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);
} }
@ -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) {
@ -383,5 +390,4 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
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

@ -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));
} }
@ -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)) {
@ -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) {
@ -662,27 +653,21 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
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']);
@ -710,7 +695,6 @@ 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)) {
@ -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);
} }
} }
@ -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;
@ -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;
@ -888,9 +868,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$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)) {
@ -902,7 +880,6 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$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);
@ -1336,14 +1313,18 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
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);
@ -1353,12 +1334,21 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
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');
}
} }
} }
} }
@ -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
} }
} }
} }
} }
} }
} }
@ -1567,7 +1557,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
// 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);
@ -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);
@ -1693,7 +1678,7 @@ 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,10 +1702,8 @@ 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) {
@ -1742,14 +1725,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$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'])) {
@ -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,8 +1904,8 @@ 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)) {
@ -1945,44 +1922,37 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
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