Merge branch 'psr2' into develop

This commit is contained in:
MarkBaker 2015-05-20 19:18:12 +01:00
commit 17c644bef6
34 changed files with 2382 additions and 2527 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Reader_Abstract
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Reader_Abstract
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{ {
/** /**
@ -42,7 +34,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @var boolean * @var boolean
*/ */
protected $_readDataOnly = false; protected $readDataOnly = false;
/** /**
* Read charts that are defined in the workbook? * Read charts that are defined in the workbook?
@ -50,7 +42,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @var boolean * @var boolean
*/ */
protected $_includeCharts = false; protected $includeCharts = false;
/** /**
* Restrict which sheets should be loaded? * Restrict which sheets should be loaded?
@ -58,16 +50,16 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @var array of string * @var array of string
*/ */
protected $_loadSheetsOnly = null; protected $loadSheetsOnly;
/** /**
* PHPExcel_Reader_IReadFilter instance * PHPExcel_Reader_IReadFilter instance
* *
* @var PHPExcel_Reader_IReadFilter * @var PHPExcel_Reader_IReadFilter
*/ */
protected $_readFilter = null; protected $readFilter;
protected $_fileHandle = null; protected $fileHandle = null;
/** /**
@ -79,7 +71,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/ */
public function getReadDataOnly() public function getReadDataOnly()
{ {
return $this->_readDataOnly; return $this->readDataOnly;
} }
/** /**
@ -93,7 +85,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/ */
public function setReadDataOnly($pValue = false) public function setReadDataOnly($pValue = false)
{ {
$this->_readDataOnly = $pValue; $this->readDataOnly = $pValue;
return $this; return $this;
} }
@ -107,7 +99,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/ */
public function getIncludeCharts() public function getIncludeCharts()
{ {
return $this->_includeCharts; return $this->includeCharts;
} }
/** /**
@ -122,7 +114,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/ */
public function setIncludeCharts($pValue = false) public function setIncludeCharts($pValue = false)
{ {
$this->_includeCharts = (boolean) $pValue; $this->includeCharts = (boolean) $pValue;
return $this; return $this;
} }
@ -135,7 +127,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/ */
public function getLoadSheetsOnly() public function getLoadSheetsOnly()
{ {
return $this->_loadSheetsOnly; return $this->loadSheetsOnly;
} }
/** /**
@ -153,7 +145,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
return $this->setLoadAllSheets(); return $this->setLoadAllSheets();
} }
$this->_loadSheetsOnly = is_array($value) ? $value : array($value); $this->loadSheetsOnly = is_array($value) ? $value : array($value);
return $this; return $this;
} }
@ -165,7 +157,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/ */
public function setLoadAllSheets() public function setLoadAllSheets()
{ {
$this->_loadSheetsOnly = null; $this->loadSheetsOnly = null;
return $this; return $this;
} }
@ -176,7 +168,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/ */
public function getReadFilter() public function getReadFilter()
{ {
return $this->_readFilter; return $this->readFilter;
} }
/** /**
@ -187,7 +179,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/ */
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue)
{ {
$this->_readFilter = $pValue; $this->readFilter = $pValue;
return $this; return $this;
} }
@ -198,7 +190,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* @throws PHPExcel_Reader_Exception * @throws PHPExcel_Reader_Exception
* @return resource * @return resource
*/ */
protected function _openFile($pFilename) protected function openFile($pFilename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename) || !is_readable($pFilename)) { if (!file_exists($pFilename) || !is_readable($pFilename)) {
@ -206,8 +198,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
} }
// Open file // Open file
$this->_fileHandle = fopen($pFilename, 'r'); $this->fileHandle = fopen($pFilename, 'r');
if ($this->_fileHandle === false) { if ($this->fileHandle === false) {
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading."); throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
} }
} }
@ -223,13 +215,13 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{ {
// Check if file exists // Check if file exists
try { try {
$this->_openFile($pFilename); $this->openFile($pFilename);
} catch (Exception $e) { } catch (Exception $e) {
return false; return false;
} }
$readable = $this->_isValidFormat(); $readable = $this->isValidFormat();
fclose($this->_fileHandle); fclose($this->fileHandle);
return $readable; return $readable;
} }

View File

@ -1,6 +1,16 @@
<?php <?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel * PHPExcel_Reader_CSV
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,24 +34,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_CSV
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{ {
/** /**
@ -97,7 +89,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*/ */
public function __construct() public function __construct()
{ {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
} }
/** /**
@ -105,7 +97,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* *
* @return boolean * @return boolean
*/ */
protected function _isValidFormat() protected function isValidFormat()
{ {
return true; return true;
} }
@ -135,30 +127,30 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
* Move filepointer past any BOM marker * Move filepointer past any BOM marker
* *
*/ */
protected function _skipBOM() protected function skipBOM()
{ {
rewind($this->_fileHandle); rewind($this->fileHandle);
switch ($this->inputEncoding) { switch ($this->inputEncoding) {
case 'UTF-8': case 'UTF-8':
fgets($this->_fileHandle, 4) == "\xEF\xBB\xBF" ? fgets($this->fileHandle, 4) == "\xEF\xBB\xBF" ?
fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0); fseek($this->fileHandle, 3) : fseek($this->fileHandle, 0);
break; break;
case 'UTF-16LE': case 'UTF-16LE':
fgets($this->_fileHandle, 3) == "\xFF\xFE" ? fgets($this->fileHandle, 3) == "\xFF\xFE" ?
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0); fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0);
break; break;
case 'UTF-16BE': case 'UTF-16BE':
fgets($this->_fileHandle, 3) == "\xFE\xFF" ? fgets($this->fileHandle, 3) == "\xFE\xFF" ?
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0); fseek($this->fileHandle, 2) : fseek($this->fileHandle, 0);
break; break;
case 'UTF-32LE': case 'UTF-32LE':
fgets($this->_fileHandle, 5) == "\xFF\xFE\x00\x00" ? fgets($this->fileHandle, 5) == "\xFF\xFE\x00\x00" ?
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0); fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0);
break; break;
case 'UTF-32BE': case 'UTF-32BE':
fgets($this->_fileHandle, 5) == "\x00\x00\xFE\xFF" ? fgets($this->fileHandle, 5) == "\x00\x00\xFE\xFF" ?
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0); fseek($this->fileHandle, 4) : fseek($this->fileHandle, 0);
break; break;
default: default:
break; break;
@ -174,15 +166,15 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
{ {
// 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;
// Skip BOM, if any // Skip BOM, if any
$this->_skipBOM(); $this->skipBOM();
$escapeEnclosures = array( "\\" . $this->enclosure, $this->enclosure . $this->enclosure ); $escapeEnclosures = array( "\\" . $this->enclosure, $this->enclosure . $this->enclosure );
@ -238,15 +230,15 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
ini_set('auto_detect_line_endings', true); ini_set('auto_detect_line_endings', true);
// 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;
// Skip BOM, if any // Skip BOM, if any
$this->_skipBOM(); $this->skipBOM();
// Create new PHPExcel object // Create new PHPExcel object
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) { while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
@ -268,7 +260,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
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)) {
// Unescape enclosures // Unescape enclosures
$rowDatum = str_replace($escapeEnclosures, $this->enclosure, $rowDatum); $rowDatum = str_replace($escapeEnclosures, $this->enclosure, $rowDatum);

View File

@ -1,6 +1,16 @@
<?php <?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel * PHPExcel_Reader_DefaultReadFilter
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,33 +34,15 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_DefaultReadFilter
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
{ {
/** /**
* Should this cell be read? * Should this cell be read?
* *
* @param $column String column index * @param $column Column address (as a string value like "A", or "IV")
* @param $row Row index * @param $row Row number
* @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 = '')
{ {

View File

@ -55,7 +55,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
*/ */
public function __construct() public function __construct()
{ {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
} }
@ -85,8 +85,8 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
); );
// Open file // Open file
$this->_openFile($pFilename); $this->openFile($pFilename);
$fileHandle = $this->_fileHandle; $fileHandle = $this->fileHandle;
// Read sample data (first 2 KB will do) // Read sample data (first 2 KB will do)
$data = fread($fileHandle, 2048); $data = fread($fileHandle, 2048);
@ -135,7 +135,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$xml_ss = $xml->children($namespaces['ss']); $xml_ss = $xml->children($namespaces['ss']);
foreach ($xml_ss->Worksheet as $worksheet) { foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']); $worksheet_ss = $worksheet->attributes($namespaces['ss']);
$worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'], $this->charSet); $worksheetNames[] = self::convertStringEncoding((string) $worksheet_ss['Name'], $this->charSet);
} }
return $worksheetNames; return $worksheetNames;
@ -247,7 +247,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
* @param pxs * @param pxs
* @return * @return
*/ */
protected static function _pixel2WidthUnits($pxs) protected static function pixel2WidthUnits($pxs)
{ {
$UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219); $UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219);
@ -261,7 +261,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
* @param widthUnits * @param widthUnits
* @return * @return
*/ */
protected static function _widthUnits2Pixel($widthUnits) protected static function widthUnits2Pixel($widthUnits)
{ {
$pixels = ($widthUnits / 256) * 7; $pixels = ($widthUnits / 256) * 7;
$offsetWidthUnits = $widthUnits % 256; $offsetWidthUnits = $widthUnits % 256;
@ -269,7 +269,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return $pixels; return $pixels;
} }
protected static function _hex2str($hex) protected static function hex2str($hex)
{ {
return chr(hexdec($hex[1])); return chr(hexdec($hex[1]));
} }
@ -329,39 +329,39 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
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;
} }
} }
@ -369,7 +369,7 @@ 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':
@ -531,8 +531,8 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
foreach ($xml_ss->Worksheet as $worksheet) { foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']); $worksheet_ss = $worksheet->attributes($namespaces['ss']);
if ((isset($this->_loadSheetsOnly)) && (isset($worksheet_ss['Name'])) && if ((isset($this->loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
(!in_array($worksheet_ss['Name'], $this->_loadSheetsOnly))) { (!in_array($worksheet_ss['Name'], $this->loadSheetsOnly))) {
continue; continue;
} }
@ -542,7 +542,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$objPHPExcel->createSheet(); $objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($worksheetID); $objPHPExcel->setActiveSheetIndex($worksheetID);
if (isset($worksheet_ss['Name'])) { if (isset($worksheet_ss['Name'])) {
$worksheetName = self::_convertStringEncoding((string) $worksheet_ss['Name'], $this->charSet); $worksheetName = self::convertStringEncoding((string) $worksheet_ss['Name'], $this->charSet);
// 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
@ -632,7 +632,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
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':
@ -740,7 +740,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']))) {
@ -785,7 +785,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
protected static function _convertStringEncoding($string, $charset) protected static function convertStringEncoding($string, $charset)
{ {
if ($charset != 'UTF-8') { if ($charset != 'UTF-8') {
return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $charset); return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $charset);
@ -794,11 +794,11 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
protected function _parseRichText($is = '') protected function parseRichText($is = '')
{ {
$value = new PHPExcel_RichText(); $value = new PHPExcel_RichText();
$value->createText(self::_convertStringEncoding($is, $this->charSet)); $value->createText(self::convertStringEncoding($is, $this->charSet));
return $value; return $value;
} }

View File

@ -55,7 +55,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
*/ */
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();
} }
@ -85,7 +85,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$zip = new $zipClass; $zip = new $zipClass;
if ($zip->open($pFilename) === true) { if ($zip->open($pFilename) === true) {
// check if it is an OOXML archive // check if it is an OOXML archive
$rels = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "_rels/.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $rels = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, "_rels/.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
if ($rels !== false) { if ($rels !== false) {
foreach ($rels->Relationship as $rel) { foreach ($rels->Relationship as $rel) {
switch ($rel["Type"]) { switch ($rel["Type"]) {
@ -127,13 +127,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// The files we're looking at here are small enough that simpleXML is more efficient than XMLReader // The files we're looking at here are small enough that simpleXML is more efficient than XMLReader
$rels = simplexml_load_string( $rels = simplexml_load_string(
$this->securityScan($this->_getFromZipArchive($zip, "_rels/.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()) $this->securityScan($this->getFromZipArchive($zip, "_rels/.rels"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions())
); //~ http://schemas.openxmlformats.org/package/2006/relationships"); ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
foreach ($rels->Relationship as $rel) { foreach ($rels->Relationship as $rel) {
switch ($rel["Type"]) { switch ($rel["Type"]) {
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
$xmlWorkbook = simplexml_load_string( $xmlWorkbook = simplexml_load_string(
$this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()) $this->securityScan($this->getFromZipArchive($zip, "{$rel['Target']}"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions())
); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); ); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
if ($xmlWorkbook->sheets) { if ($xmlWorkbook->sheets) {
@ -171,11 +171,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$zip = new $zipClass; $zip = new $zipClass;
$zip->open($pFilename); $zip->open($pFilename);
$rels = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "_rels/.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $rels = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, "_rels/.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships");
foreach ($rels->Relationship as $rel) { foreach ($rels->Relationship as $rel) {
if ($rel["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") { if ($rel["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") {
$dir = dirname($rel["Target"]); $dir = dirname($rel["Target"]);
$relsWorkbook = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorkbook = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships");
$worksheets = array(); $worksheets = array();
@ -185,7 +185,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
$xmlWorkbook = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $xmlWorkbook = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
if ($xmlWorkbook->sheets) { if ($xmlWorkbook->sheets) {
$dir = dirname($rel["Target"]); $dir = dirname($rel["Target"]);
foreach ($xmlWorkbook->sheets->sheet as $eleSheet) { foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
@ -197,7 +197,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
'totalColumns' => 0, 'totalColumns' => 0,
); );
$fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; $fileWorksheet = $worksheets[(string) self::getArrayItem($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$xml = new XMLReader(); $xml = new XMLReader();
$res = $xml->xml($this->securityScanFile('zip://'.PHPExcel_Shared_File::realpath($pFilename).'#'."$dir/$fileWorksheet"), null, PHPExcel_Settings::getLibXmlLoaderOptions()); $res = $xml->xml($this->securityScanFile('zip://'.PHPExcel_Shared_File::realpath($pFilename).'#'."$dir/$fileWorksheet"), null, PHPExcel_Settings::getLibXmlLoaderOptions());
@ -299,7 +299,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
public function _getFromZipArchive($archive, $fileName = '') private function getFromZipArchive($archive, $fileName = '')
{ {
// Root-relative paths // Root-relative paths
if (strpos($fileName, '//') !== false) { if (strpos($fileName, '//') !== false) {
@ -334,7 +334,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Initialisations // Initialisations
$excel = new PHPExcel; $excel = new PHPExcel;
$excel->removeSheetByIndex(0); $excel->removeSheetByIndex(0);
if (!$this->_readDataOnly) { if (!$this->readDataOnly) {
$excel->removeCellStyleXfByIndex(0); // remove the default style $excel->removeCellStyleXfByIndex(0); // remove the default style
$excel->removeCellXfByIndex(0); // remove the default style $excel->removeCellXfByIndex(0); // remove the default style
} }
@ -345,14 +345,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$zip->open($pFilename); $zip->open($pFilename);
// Read the theme first, because we need the colour scheme when reading the styles // Read the theme first, because we need the colour scheme when reading the styles
$wbRels = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "xl/_rels/workbook.xml.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $wbRels = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, "xl/_rels/workbook.xml.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships");
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());
if (is_object($xmlTheme)) { if (is_object($xmlTheme)) {
$xmlThemeName = $xmlTheme->attributes(); $xmlThemeName = $xmlTheme->attributes();
$xmlTheme = $xmlTheme->children("http://schemas.openxmlformats.org/drawingml/2006/main"); $xmlTheme = $xmlTheme->children("http://schemas.openxmlformats.org/drawingml/2006/main");
@ -382,29 +382,29 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
$rels = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "_rels/.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $rels = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, "_rels/.rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships");
foreach ($rels->Relationship as $rel) { foreach ($rels->Relationship as $rel) {
switch ($rel["Type"]) { switch ($rel["Type"]) {
case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties": case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-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)) {
$xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/"); $xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/");
$xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/"); $xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/");
$xmlCore->registerXPathNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"); $xmlCore->registerXPathNamespace("cp", "http://schemas.openxmlformats.org/package/2006/metadata/core-properties");
$docProps = $excel->getProperties(); $docProps = $excel->getProperties();
$docProps->setCreator((string) self::array_item($xmlCore->xpath("dc:creator"))); $docProps->setCreator((string) self::getArrayItem($xmlCore->xpath("dc:creator")));
$docProps->setLastModifiedBy((string) self::array_item($xmlCore->xpath("cp:lastModifiedBy"))); $docProps->setLastModifiedBy((string) self::getArrayItem($xmlCore->xpath("cp:lastModifiedBy")));
$docProps->setCreated(strtotime(self::array_item($xmlCore->xpath("dcterms:created")))); //! respect xsi:type $docProps->setCreated(strtotime(self::getArrayItem($xmlCore->xpath("dcterms:created")))); //! respect xsi:type
$docProps->setModified(strtotime(self::array_item($xmlCore->xpath("dcterms:modified")))); //! respect xsi:type $docProps->setModified(strtotime(self::getArrayItem($xmlCore->xpath("dcterms:modified")))); //! respect xsi:type
$docProps->setTitle((string) self::array_item($xmlCore->xpath("dc:title"))); $docProps->setTitle((string) self::getArrayItem($xmlCore->xpath("dc:title")));
$docProps->setDescription((string) self::array_item($xmlCore->xpath("dc:description"))); $docProps->setDescription((string) self::getArrayItem($xmlCore->xpath("dc:description")));
$docProps->setSubject((string) self::array_item($xmlCore->xpath("dc:subject"))); $docProps->setSubject((string) self::getArrayItem($xmlCore->xpath("dc:subject")));
$docProps->setKeywords((string) self::array_item($xmlCore->xpath("cp:keywords"))); $docProps->setKeywords((string) self::getArrayItem($xmlCore->xpath("cp:keywords")));
$docProps->setCategory((string) self::array_item($xmlCore->xpath("cp:category"))); $docProps->setCategory((string) self::getArrayItem($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)) {
@ -416,7 +416,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
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)) {
$docProps = $excel->getProperties(); $docProps = $excel->getProperties();
foreach ($xmlCore as $xmlProperty) { foreach ($xmlCore as $xmlProperty) {
@ -442,12 +442,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
break; break;
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument": case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
$dir = dirname($rel["Target"]); $dir = dirname($rel["Target"]);
$relsWorkbook = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorkbook = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, "$dir/_rels/" . basename($rel["Target"]) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorkbook->registerXPathNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships");
$sharedStrings = array(); $sharedStrings = array();
$xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']")); $xpath = self::getArrayItem($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']"));
$xmlStrings = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/$xpath[Target]")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $xmlStrings = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, "$dir/$xpath[Target]")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
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)) {
@ -473,12 +473,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
if (!is_null($macros)) { if (!is_null($macros)) {
$macrosCode = $this->_getFromZipArchive($zip, 'xl/vbaProject.bin');//vbaProject.bin always in 'xl' dir and always named vbaProject.bin $macrosCode = $this->getFromZipArchive($zip, 'xl/vbaProject.bin');//vbaProject.bin always in 'xl' dir and always named vbaProject.bin
if ($macrosCode !== false) { if ($macrosCode !== false) {
$excel->setMacrosCode($macrosCode); $excel->setMacrosCode($macrosCode);
$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);
} }
@ -486,8 +486,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
$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::getArrayItem($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']"));
$xmlStyles = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/$xpath[Target]")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $xmlStyles = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, "$dir/$xpath[Target]")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
$numFmts = null; $numFmts = null;
if ($xmlStyles && $xmlStyles->numFmts[0]) { if ($xmlStyles && $xmlStyles->numFmts[0]) {
$numFmts = $xmlStyles->numFmts[0]; $numFmts = $xmlStyles->numFmts[0];
@ -495,13 +495,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
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) {
foreach ($xmlStyles->cellXfs->xf as $xf) { foreach ($xmlStyles->cellXfs->xf as $xf) {
$numFmt = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; $numFmt = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
if ($xf["numFmtId"]) { if ($xf["numFmtId"]) {
if (isset($numFmts)) { if (isset($numFmts)) {
$tmpNumFmt = self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]")); $tmpNumFmt = self::getArrayItem($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]"));
if (isset($tmpNumFmt["formatCode"])) { if (isset($tmpNumFmt["formatCode"])) {
$numFmt = (string) $tmpNumFmt["formatCode"]; $numFmt = (string) $tmpNumFmt["formatCode"];
@ -539,7 +539,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
foreach ($xmlStyles->cellStyleXfs->xf as $xf) { foreach ($xmlStyles->cellStyleXfs->xf as $xf) {
$numFmt = PHPExcel_Style_NumberFormat::FORMAT_GENERAL; $numFmt = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
if ($numFmts && $xf["numFmtId"]) { if ($numFmts && $xf["numFmtId"]) {
$tmpNumFmt = self::array_item($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]")); $tmpNumFmt = self::getArrayItem($numFmts->xpath("sml:numFmt[@numFmtId=$xf[numFmtId]]"));
if (isset($tmpNumFmt["formatCode"])) { if (isset($tmpNumFmt["formatCode"])) {
$numFmt = (string) $tmpNumFmt["formatCode"]; $numFmt = (string) $tmpNumFmt["formatCode"];
} elseif ((int)$xf["numFmtId"] < 165) { } elseif ((int)$xf["numFmtId"] < 165) {
@ -566,7 +566,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
$dxfs = array(); $dxfs = array();
if (!$this->_readDataOnly && $xmlStyles) { if (!$this->readDataOnly && $xmlStyles) {
// Conditional Styles // Conditional Styles
if ($xmlStyles->dxfs) { if ($xmlStyles->dxfs) {
foreach ($xmlStyles->dxfs->dxf as $dxf) { foreach ($xmlStyles->dxfs->dxf as $dxf) {
@ -591,7 +591,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
$xmlWorkbook = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $xmlWorkbook = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, "{$rel['Target']}")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
// Set base date // Set base date
if ($xmlWorkbook->workbookPr) { if ($xmlWorkbook->workbookPr) {
@ -615,7 +615,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
++$oldSheetId; ++$oldSheetId;
// Check if sheet should be skipped // Check if sheet should be skipped
if (isset($this->_loadSheetsOnly) && !in_array((string) $eleSheet["name"], $this->_loadSheetsOnly)) { if (isset($this->loadSheetsOnly) && !in_array((string) $eleSheet["name"], $this->loadSheetsOnly)) {
++$countSkippedSheets; ++$countSkippedSheets;
$mapSheetId[$oldSheetId] = null; $mapSheetId[$oldSheetId] = null;
continue; continue;
@ -632,8 +632,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// and we're simply bringing the worksheet name in line with the formula, not the // and we're simply bringing the worksheet name in line with the formula, not the
// reverse // reverse
$docSheet->setTitle((string) $eleSheet["name"], false); $docSheet->setTitle((string) $eleSheet["name"], false);
$fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; $fileWorksheet = $worksheets[(string) self::getArrayItem($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$xmlSheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, "$dir/$fileWorksheet")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"); $xmlSheet = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, "$dir/$fileWorksheet")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
$sharedFormulas = array(); $sharedFormulas = array();
@ -737,10 +737,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
if (isset($xmlSheet->cols) && !$this->_readDataOnly) { if (isset($xmlSheet->cols) && !$this->readDataOnly) {
foreach ($xmlSheet->cols->col as $col) { foreach ($xmlSheet->cols->col as $col) {
for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) { for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) {
if ($col["style"] && !$this->_readDataOnly) { if ($col["style"] && !$this->readDataOnly) {
$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"])) {
@ -765,7 +765,7 @@ 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);
} }
@ -782,10 +782,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) { if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) {
foreach ($xmlSheet->sheetData->row as $row) { foreach ($xmlSheet->sheetData->row as $row) {
if ($row["ht"] && !$this->_readDataOnly) { if ($row["ht"] && !$this->readDataOnly) {
$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"])) {
@ -794,7 +794,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
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"]));
} }
if ($row["s"] && !$this->_readDataOnly) { if ($row["s"] && !$this->readDataOnly) {
$docSheet->getRowDimension(intval($row["r"]))->setXfIndex(intval($row["s"])); $docSheet->getRowDimension(intval($row["r"]))->setXfIndex(intval($row["s"]));
} }
@ -888,7 +888,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
// Rich text? // Rich text?
if ($value instanceof PHPExcel_RichText && $this->_readDataOnly) { if ($value instanceof PHPExcel_RichText && $this->readDataOnly) {
$value = $value->getPlainText(); $value = $value->getPlainText();
} }
@ -904,7 +904,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
// Style information? // Style information?
if ($c["s"] && !$this->_readDataOnly) { if ($c["s"] && !$this->readDataOnly) {
// no style index means 0, it seems // no style index means 0, it seems
$cell->setXfIndex(isset($styles[intval($c["s"])]) ? $cell->setXfIndex(isset($styles[intval($c["s"])]) ?
intval($c["s"]) : 0); intval($c["s"]) : 0);
@ -914,7 +914,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
$conditionals = array(); $conditionals = array();
if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) { if (!$this->readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) {
foreach ($xmlSheet->conditionalFormatting as $conditional) { foreach ($xmlSheet->conditionalFormatting as $conditional) {
foreach ($conditional->cfRule as $cfRule) { foreach ($conditional->cfRule as $cfRule) {
if (((string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_NONE || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CELLIS || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) && isset($dxfs[intval($cfRule["dxfId"])])) { if (((string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_NONE || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CELLIS || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT || (string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_EXPRESSION) && isset($dxfs[intval($cfRule["dxfId"])])) {
@ -955,14 +955,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
$aKeys = array("sheet", "objects", "scenarios", "formatCells", "formatColumns", "formatRows", "insertColumns", "insertRows", "insertHyperlinks", "deleteColumns", "deleteRows", "selectLockedCells", "sort", "autoFilter", "pivotTables", "selectUnlockedCells"); $aKeys = array("sheet", "objects", "scenarios", "formatCells", "formatColumns", "formatRows", "insertColumns", "insertRows", "insertHyperlinks", "deleteColumns", "deleteRows", "selectLockedCells", "sort", "autoFilter", "pivotTables", "selectUnlockedCells");
if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) { if (!$this->readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
foreach ($aKeys as $key) { foreach ($aKeys as $key) {
$method = "set" . ucfirst($key); $method = "set" . ucfirst($key);
$docSheet->getProtection()->$method(self::boolean((string) $xmlSheet->sheetProtection[$key])); $docSheet->getProtection()->$method(self::boolean((string) $xmlSheet->sheetProtection[$key]));
} }
} }
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) {
@ -971,7 +971,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) { if ($xmlSheet && $xmlSheet->autoFilter && !$this->readDataOnly) {
$autoFilterRange = (string) $xmlSheet->autoFilter["ref"]; $autoFilterRange = (string) $xmlSheet->autoFilter["ref"];
if (strpos($autoFilterRange, ':') !== false) { if (strpos($autoFilterRange, ':') !== false) {
$autoFilter = $docSheet->getAutoFilter(); $autoFilter = $docSheet->getAutoFilter();
@ -1071,7 +1071,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) {
@ -1080,7 +1080,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
if ($xmlSheet && $xmlSheet->pageMargins && !$this->_readDataOnly) { if ($xmlSheet && $xmlSheet->pageMargins && !$this->readDataOnly) {
$docPageMargins = $docSheet->getPageMargins(); $docPageMargins = $docSheet->getPageMargins();
$docPageMargins->setLeft(floatval($xmlSheet->pageMargins["left"])); $docPageMargins->setLeft(floatval($xmlSheet->pageMargins["left"]));
$docPageMargins->setRight(floatval($xmlSheet->pageMargins["right"])); $docPageMargins->setRight(floatval($xmlSheet->pageMargins["right"]));
@ -1090,7 +1090,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$docPageMargins->setFooter(floatval($xmlSheet->pageMargins["footer"])); $docPageMargins->setFooter(floatval($xmlSheet->pageMargins["footer"]));
} }
if ($xmlSheet && $xmlSheet->pageSetup && !$this->_readDataOnly) { if ($xmlSheet && $xmlSheet->pageSetup && !$this->readDataOnly) {
$docPageSetup = $docSheet->getPageSetup(); $docPageSetup = $docSheet->getPageSetup();
if (isset($xmlSheet->pageSetup["orientation"])) { if (isset($xmlSheet->pageSetup["orientation"])) {
@ -1114,7 +1114,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
if ($xmlSheet && $xmlSheet->headerFooter && !$this->_readDataOnly) { if ($xmlSheet && $xmlSheet->headerFooter && !$this->readDataOnly) {
$docHeaderFooter = $docSheet->getHeaderFooter(); $docHeaderFooter = $docSheet->getHeaderFooter();
if (isset($xmlSheet->headerFooter["differentOddEven"]) && if (isset($xmlSheet->headerFooter["differentOddEven"]) &&
@ -1150,14 +1150,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$docHeaderFooter->setFirstFooter((string) $xmlSheet->headerFooter->firstFooter); $docHeaderFooter->setFirstFooter((string) $xmlSheet->headerFooter->firstFooter);
} }
if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->_readDataOnly) { if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->readDataOnly) {
foreach ($xmlSheet->rowBreaks->brk as $brk) { foreach ($xmlSheet->rowBreaks->brk as $brk) {
if ($brk["man"]) { if ($brk["man"]) {
$docSheet->setBreak("A$brk[id]", PHPExcel_Worksheet::BREAK_ROW); $docSheet->setBreak("A$brk[id]", PHPExcel_Worksheet::BREAK_ROW);
} }
} }
} }
if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->_readDataOnly) { if ($xmlSheet && $xmlSheet->colBreaks && $xmlSheet->colBreaks->brk && !$this->readDataOnly) {
foreach ($xmlSheet->colBreaks->brk as $brk) { foreach ($xmlSheet->colBreaks->brk as $brk) {
if ($brk["man"]) { if ($brk["man"]) {
$docSheet->setBreak(PHPExcel_Cell::stringFromColumnIndex((string) $brk["id"]) . "1", PHPExcel_Worksheet::BREAK_COLUMN); $docSheet->setBreak(PHPExcel_Cell::stringFromColumnIndex((string) $brk["id"]) . "1", PHPExcel_Worksheet::BREAK_COLUMN);
@ -1165,7 +1165,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
if ($xmlSheet && $xmlSheet->dataValidations && !$this->_readDataOnly) { if ($xmlSheet && $xmlSheet->dataValidations && !$this->readDataOnly) {
foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) { foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) {
// Uppercase coordinate // Uppercase coordinate
$range = strtoupper($dataValidation["sqref"]); $range = strtoupper($dataValidation["sqref"]);
@ -1198,10 +1198,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Add hyperlinks // Add hyperlinks
$hyperlinks = array(); $hyperlinks = array();
if (!$this->_readDataOnly) { if (!$this->readDataOnly) {
// Locate hyperlink relations // Locate hyperlink relations
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorksheet = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships");
foreach ($relsWorksheet->Relationship as $ele) { foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") {
$hyperlinks[(string)$ele["Id"]] = (string)$ele["Target"]; $hyperlinks[(string)$ele["Id"]] = (string)$ele["Target"];
@ -1239,10 +1239,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Add comments // Add comments
$comments = array(); $comments = array();
$vmlComments = array(); $vmlComments = array();
if (!$this->_readDataOnly) { if (!$this->readDataOnly) {
// Locate comment relations // Locate comment relations
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorksheet = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships");
foreach ($relsWorksheet->Relationship as $ele) { foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") {
$comments[(string)$ele["Id"]] = (string)$ele["Target"]; $comments[(string)$ele["Id"]] = (string)$ele["Target"];
@ -1257,7 +1257,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
foreach ($comments as $relName => $relPath) { foreach ($comments as $relName => $relPath) {
// Load comments file // Load comments file
$relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); $relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath);
$commentsFile = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $relPath)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $commentsFile = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, $relPath)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
// Utility variables // Utility variables
$authors = array(); $authors = array();
@ -1280,7 +1280,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
foreach ($vmlComments as $relName => $relPath) { foreach ($vmlComments as $relName => $relPath) {
// Load VML comments file // Load VML comments file
$relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath); $relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath);
$vmlCommentsFile = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $relPath)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $vmlCommentsFile = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, $relPath)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
$shapes = $vmlCommentsFile->xpath('//v:shape'); $shapes = $vmlCommentsFile->xpath('//v:shape');
@ -1342,29 +1342,29 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
// Header/footer images // Header/footer images
if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->_readDataOnly) { if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->readDataOnly) {
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorksheet = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$vmlRelationship = ''; $vmlRelationship = '';
foreach ($relsWorksheet->Relationship as $ele) { foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") {
$vmlRelationship = self::dir_add("$dir/$fileWorksheet", $ele["Target"]); $vmlRelationship = self::dirAdd("$dir/$fileWorksheet", $ele["Target"]);
} }
} }
if ($vmlRelationship != '') { if ($vmlRelationship != '') {
// Fetch linked images // Fetch linked images
$relsVML = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsVML = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array(); $drawings = array();
foreach ($relsVML->Relationship as $ele) { foreach ($relsVML->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$drawings[(string) $ele["Id"]] = self::dir_add($vmlRelationship, $ele["Target"]); $drawings[(string) $ele["Id"]] = self::dirAdd($vmlRelationship, $ele["Target"]);
} }
} }
// Fetch VML document // Fetch VML document
$vmlDrawing = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $vmlRelationship)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $vmlDrawing = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, $vmlRelationship)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$vmlDrawing->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); $vmlDrawing->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
$hfImages = array(); $hfImages = array();
@ -1403,26 +1403,26 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// TODO: Autoshapes from twoCellAnchors! // TODO: Autoshapes from twoCellAnchors!
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) { if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsWorksheet = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$drawings = array(); $drawings = array();
foreach ($relsWorksheet->Relationship as $ele) { foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") {
$drawings[(string) $ele["Id"]] = self::dir_add("$dir/$fileWorksheet", $ele["Target"]); $drawings[(string) $ele["Id"]] = self::dirAdd("$dir/$fileWorksheet", $ele["Target"]);
} }
} }
if ($xmlSheet->drawing && !$this->_readDataOnly) { if ($xmlSheet->drawing && !$this->readDataOnly) {
foreach ($xmlSheet->drawing as $drawing) { foreach ($xmlSheet->drawing as $drawing) {
$fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")]; $fileDrawing = $drawings[(string) self::getArrayItem($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$relsDrawing = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships"); $relsDrawing = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$images = array(); $images = array();
if ($relsDrawing && $relsDrawing->Relationship) { if ($relsDrawing && $relsDrawing->Relationship) {
foreach ($relsDrawing->Relationship as $ele) { foreach ($relsDrawing->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") { if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
$images[(string) $ele["Id"]] = self::dir_add($fileDrawing, $ele["Target"]); $images[(string) $ele["Id"]] = self::dirAdd($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( $charts[self::dirAdd($fileDrawing, $ele["Target"])] = array(
'id' => (string) $ele["Id"], 'id' => (string) $ele["Id"],
'sheet' => $docSheet->getTitle() 'sheet' => $docSheet->getTitle()
); );
@ -1430,7 +1430,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
} }
$xmlDrawing = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $fileDrawing)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions())->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"); $xmlDrawing = simplexml_load_string($this->securityScan($this->getFromZipArchive($zip, $fileDrawing)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions())->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
if ($xmlDrawing->oneCellAnchor) { if ($xmlDrawing->oneCellAnchor) {
foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) { foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) {
@ -1439,27 +1439,27 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$xfrm = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm; $xfrm = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
$outerShdw = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw; $outerShdw = $oneCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
$objDrawing = new PHPExcel_Worksheet_Drawing; $objDrawing = new PHPExcel_Worksheet_Drawing;
$objDrawing->setName((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name")); $objDrawing->setName((string) self::getArrayItem($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
$objDrawing->setDescription((string) self::array_item($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr")); $objDrawing->setDescription((string) self::getArrayItem($oneCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));
$objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); $objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::getArrayItem($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
$objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1)); $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1));
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff)); $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff));
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff)); $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff));
$objDrawing->setResizeProportional(false); $objDrawing->setResizeProportional(false);
$objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx"))); $objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::getArrayItem($oneCellAnchor->ext->attributes(), "cx")));
$objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy"))); $objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::getArrayItem($oneCellAnchor->ext->attributes(), "cy")));
if ($xfrm) { if ($xfrm) {
$objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot"))); $objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::getArrayItem($xfrm->attributes(), "rot")));
} }
if ($outerShdw) { if ($outerShdw) {
$shadow = $objDrawing->getShadow(); $shadow = $objDrawing->getShadow();
$shadow->setVisible(true); $shadow->setVisible(true);
$shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "blurRad"))); $shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), "blurRad")));
$shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "dist"))); $shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), "dist")));
$shadow->setDirection(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($outerShdw->attributes(), "dir"))); $shadow->setDirection(PHPExcel_Shared_Drawing::angleToDegrees(self::getArrayItem($outerShdw->attributes(), "dir")));
$shadow->setAlignment((string) self::array_item($outerShdw->attributes(), "algn")); $shadow->setAlignment((string) self::getArrayItem($outerShdw->attributes(), "algn"));
$shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(), "val")); $shadow->getColor()->setRGB(self::getArrayItem($outerShdw->srgbClr->attributes(), "val"));
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000); $shadow->setAlpha(self::getArrayItem($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
} }
$objDrawing->setWorksheet($docSheet); $objDrawing->setWorksheet($docSheet);
} else { } else {
@ -1467,8 +1467,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$coordinates = PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1); $coordinates = PHPExcel_Cell::stringFromColumnIndex((string) $oneCellAnchor->from->col) . ($oneCellAnchor->from->row + 1);
$offsetX = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff); $offsetX = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->colOff);
$offsetY = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff); $offsetY = PHPExcel_Shared_Drawing::EMUToPixels($oneCellAnchor->from->rowOff);
$width = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cx")); $width = PHPExcel_Shared_Drawing::EMUToPixels(self::getArrayItem($oneCellAnchor->ext->attributes(), "cx"));
$height = PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($oneCellAnchor->ext->attributes(), "cy")); $height = PHPExcel_Shared_Drawing::EMUToPixels(self::getArrayItem($oneCellAnchor->ext->attributes(), "cy"));
} }
} }
} }
@ -1479,31 +1479,31 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$xfrm = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm; $xfrm = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->xfrm;
$outerShdw = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw; $outerShdw = $twoCellAnchor->pic->spPr->children("http://schemas.openxmlformats.org/drawingml/2006/main")->effectLst->outerShdw;
$objDrawing = new PHPExcel_Worksheet_Drawing; $objDrawing = new PHPExcel_Worksheet_Drawing;
$objDrawing->setName((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name")); $objDrawing->setName((string) self::getArrayItem($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "name"));
$objDrawing->setDescription((string) self::array_item($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr")); $objDrawing->setDescription((string) self::getArrayItem($twoCellAnchor->pic->nvPicPr->cNvPr->attributes(), "descr"));
$objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::array_item($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false); $objDrawing->setPath("zip://".PHPExcel_Shared_File::realpath($pFilename)."#" . $images[(string) self::getArrayItem($blip->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "embed")], false);
$objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1)); $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1));
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff)); $objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff));
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff)); $objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff));
$objDrawing->setResizeProportional(false); $objDrawing->setResizeProportional(false);
if ($xfrm) { if ($xfrm) {
$objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cx"))); $objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::getArrayItem($xfrm->ext->attributes(), "cx")));
$objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cy"))); $objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::getArrayItem($xfrm->ext->attributes(), "cy")));
$objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot"))); $objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::getArrayItem($xfrm->attributes(), "rot")));
} }
if ($outerShdw) { if ($outerShdw) {
$shadow = $objDrawing->getShadow(); $shadow = $objDrawing->getShadow();
$shadow->setVisible(true); $shadow->setVisible(true);
$shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "blurRad"))); $shadow->setBlurRadius(PHPExcel_Shared_Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), "blurRad")));
$shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::array_item($outerShdw->attributes(), "dist"))); $shadow->setDistance(PHPExcel_Shared_Drawing::EMUTopixels(self::getArrayItem($outerShdw->attributes(), "dist")));
$shadow->setDirection(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($outerShdw->attributes(), "dir"))); $shadow->setDirection(PHPExcel_Shared_Drawing::angleToDegrees(self::getArrayItem($outerShdw->attributes(), "dir")));
$shadow->setAlignment((string) self::array_item($outerShdw->attributes(), "algn")); $shadow->setAlignment((string) self::getArrayItem($outerShdw->attributes(), "algn"));
$shadow->getColor()->setRGB(self::array_item($outerShdw->srgbClr->attributes(), "val")); $shadow->getColor()->setRGB(self::getArrayItem($outerShdw->srgbClr->attributes(), "val"));
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000); $shadow->setAlpha(self::getArrayItem($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
} }
$objDrawing->setWorksheet($docSheet); $objDrawing->setWorksheet($docSheet);
} elseif (($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) { } elseif (($this->includeCharts) && ($twoCellAnchor->graphicFrame)) {
$fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1); $fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1);
$fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff); $fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff);
$fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff); $fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff);
@ -1671,7 +1671,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
if ((!$this->_readDataOnly) || (!empty($this->_loadSheetsOnly))) { if ((!$this->readDataOnly) || (!empty($this->loadSheetsOnly))) {
// active sheet index // active sheet index
$activeTab = intval($xmlWorkbook->bookViews->workbookView["activeTab"]); // refers to old sheet index $activeTab = intval($xmlWorkbook->bookViews->workbookView["activeTab"]); // refers to old sheet index
@ -1689,14 +1689,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
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 />';
@ -1799,8 +1799,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::getArrayItem($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::getArrayItem($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);
@ -1952,12 +1952,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$baseDir = dirname($customUITarget); $baseDir = dirname($customUITarget);
$nameCustomUI = basename($customUITarget); $nameCustomUI = basename($customUITarget);
// get the xml file (ribbon) // get the xml file (ribbon)
$localRibbon = $this->_getFromZipArchive($zip, $customUITarget); $localRibbon = $this->getFromZipArchive($zip, $customUITarget);
$customUIImagesNames = array(); $customUIImagesNames = array();
$customUIImagesBinaries = array(); $customUIImagesBinaries = array();
// something like customUI/_rels/customUI.xml.rels // something like customUI/_rels/customUI.xml.rels
$pathRels = $baseDir . '/_rels/' . $nameCustomUI . '.rels'; $pathRels = $baseDir . '/_rels/' . $nameCustomUI . '.rels';
$dataRels = $this->_getFromZipArchive($zip, $pathRels); $dataRels = $this->getFromZipArchive($zip, $pathRels);
if ($dataRels) { if ($dataRels) {
// exists and not empty if the ribbon have some pictures (other than internal MSO) // exists and not empty if the ribbon have some pictures (other than internal MSO)
$UIRels = simplexml_load_string($this->securityScan($dataRels), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $UIRels = simplexml_load_string($this->securityScan($dataRels), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
@ -1967,7 +1967,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ($ele["Type"] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image') { if ($ele["Type"] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image') {
// an image ? // an image ?
$customUIImagesNames[(string) $ele['Id']] = (string)$ele['Target']; $customUIImagesNames[(string) $ele['Id']] = (string)$ele['Target'];
$customUIImagesBinaries[(string)$ele['Target']] = $this->_getFromZipArchive($zip, $baseDir . '/' . (string) $ele['Target']); $customUIImagesBinaries[(string)$ele['Target']] = $this->getFromZipArchive($zip, $baseDir . '/' . (string) $ele['Target']);
} }
} }
} }
@ -1985,12 +1985,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
private static function array_item($array, $key = 0) private static function getArrayItem($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 dirAdd($base, $add)
{ {
return preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add"); return preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add");
} }

File diff suppressed because it is too large Load Diff

View File

@ -101,7 +101,7 @@ class PHPExcel_Reader_Excel5_Escher
// Parse Escher stream // Parse Escher stream
while ($this->pos < $this->dataSize) { while ($this->pos < $this->dataSize) {
// offset: 2; size: 2: Record Type // offset: 2; size: 2: Record Type
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos + 2); $fbt = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos + 2);
switch ($fbt) { switch ($fbt) {
case self::DGGCONTAINER: case self::DGGCONTAINER:
@ -173,15 +173,15 @@ class PHPExcel_Reader_Excel5_Escher
private function readDefault() private function readDefault()
{ {
// offset 0; size: 2; recVer and recInstance // offset 0; size: 2; recVer and recInstance
$verInstance = PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos); $verInstance = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos);
// offset: 2; size: 2: Record Type // offset: 2; size: 2: Record Type
$fbt = PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos + 2); $fbt = PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos + 2);
// bit: 0-3; mask: 0x000F; recVer // bit: 0-3; mask: 0x000F; recVer
$recVer = (0x000F & $verInstance) >> 0; $recVer = (0x000F & $verInstance) >> 0;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -193,7 +193,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function readDggContainer() private function readDggContainer()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -211,7 +211,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function readDgg() private function readDgg()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -223,7 +223,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function readBstoreContainer() private function readBstoreContainer()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -244,9 +244,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -268,16 +268,16 @@ class PHPExcel_Reader_Excel5_Escher
$rgbUid = substr($recordData, 2, 16); $rgbUid = substr($recordData, 2, 16);
// offset: 18; size: 2; tag // offset: 18; size: 2; tag
$tag = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 18); $tag = PHPExcel_Reader_Excel5::getInt2d($recordData, 18);
// offset: 20; size: 4; size of BLIP in bytes // offset: 20; size: 4; size of BLIP in bytes
$size = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 20); $size = PHPExcel_Reader_Excel5::getInt4d($recordData, 20);
// offset: 24; size: 4; number of references to this BLIP // offset: 24; size: 4; number of references to this BLIP
$cRef = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 24); $cRef = PHPExcel_Reader_Excel5::getInt4d($recordData, 24);
// offset: 28; size: 4; MSOFO file offset // offset: 28; size: 4; MSOFO file offset
$foDelay = PHPExcel_Reader_Excel5::_GetInt4d($recordData, 28); $foDelay = PHPExcel_Reader_Excel5::getInt4d($recordData, 28);
// offset: 32; size: 1; unused1 // offset: 32; size: 1; unused1
$unused1 = ord($recordData{32}); $unused1 = ord($recordData{32});
@ -310,9 +310,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -351,9 +351,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -392,9 +392,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -411,9 +411,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -425,7 +425,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function readSplitMenuColors() private function readSplitMenuColors()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -437,7 +437,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function readDgContainer() private function readDgContainer()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -455,7 +455,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function readDg() private function readDg()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -469,7 +469,7 @@ class PHPExcel_Reader_Excel5_Escher
{ {
// context is either context DgContainer or SpgrContainer // context is either context DgContainer or SpgrContainer
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -495,7 +495,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function readSpContainer() private function readSpContainer()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// add spContainer to spgrContainer // add spContainer to spgrContainer
@ -515,7 +515,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function readSpgr() private function readSpgr()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -530,9 +530,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -547,9 +547,9 @@ class PHPExcel_Reader_Excel5_Escher
// offset: 0; size: 2; recVer and recInstance // offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance // bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::_GetInt2d($this->data, $this->pos)) >> 4; $recInstance = (0xFFF0 & PHPExcel_Reader_Excel5::getInt2d($this->data, $this->pos)) >> 4;
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -561,35 +561,35 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function readClientAnchor() private function readClientAnchor()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
$this->pos += 8 + $length; $this->pos += 8 + $length;
// offset: 2; size: 2; upper-left corner column index (0-based) // offset: 2; size: 2; upper-left corner column index (0-based)
$c1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 2); $c1 = PHPExcel_Reader_Excel5::getInt2d($recordData, 2);
// offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width // offset: 4; size: 2; upper-left corner horizontal offset in 1/1024 of column width
$startOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 4); $startOffsetX = PHPExcel_Reader_Excel5::getInt2d($recordData, 4);
// offset: 6; size: 2; upper-left corner row index (0-based) // offset: 6; size: 2; upper-left corner row index (0-based)
$r1 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 6); $r1 = PHPExcel_Reader_Excel5::getInt2d($recordData, 6);
// offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height // offset: 8; size: 2; upper-left corner vertical offset in 1/256 of row height
$startOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 8); $startOffsetY = PHPExcel_Reader_Excel5::getInt2d($recordData, 8);
// offset: 10; size: 2; bottom-right corner column index (0-based) // offset: 10; size: 2; bottom-right corner column index (0-based)
$c2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 10); $c2 = PHPExcel_Reader_Excel5::getInt2d($recordData, 10);
// offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width // offset: 12; size: 2; bottom-right corner horizontal offset in 1/1024 of column width
$endOffsetX = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 12); $endOffsetX = PHPExcel_Reader_Excel5::getInt2d($recordData, 12);
// offset: 14; size: 2; bottom-right corner row index (0-based) // offset: 14; size: 2; bottom-right corner row index (0-based)
$r2 = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 14); $r2 = PHPExcel_Reader_Excel5::getInt2d($recordData, 14);
// offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height // offset: 16; size: 2; bottom-right corner vertical offset in 1/256 of row height
$endOffsetY = PHPExcel_Reader_Excel5::_GetInt2d($recordData, 16); $endOffsetY = PHPExcel_Reader_Excel5::getInt2d($recordData, 16);
// set the start coordinates // set the start coordinates
$this->object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1)); $this->object->setStartCoordinates(PHPExcel_Cell::stringFromColumnIndex($c1) . ($r1 + 1));
@ -615,7 +615,7 @@ class PHPExcel_Reader_Excel5_Escher
*/ */
private function readClientData() private function readClientData()
{ {
$length = PHPExcel_Reader_Excel5::_GetInt4d($this->data, $this->pos + 4); $length = PHPExcel_Reader_Excel5::getInt4d($this->data, $this->pos + 4);
$recordData = substr($this->data, $this->pos + 8, $length); $recordData = substr($this->data, $this->pos + 8, $length);
// move stream pointer to next record // move stream pointer to next record
@ -638,7 +638,7 @@ class PHPExcel_Reader_Excel5_Escher
$fopte = substr($data, 6 * $i, 6); $fopte = substr($data, 6 * $i, 6);
// offset: 0; size: 2; opid // offset: 0; size: 2; opid
$opid = PHPExcel_Reader_Excel5::_GetInt2d($fopte, 0); $opid = PHPExcel_Reader_Excel5::getInt2d($fopte, 0);
// bit: 0-13; mask: 0x3FFF; opid.opid // bit: 0-13; mask: 0x3FFF; opid.opid
$opidOpid = (0x3FFF & $opid) >> 0; $opidOpid = (0x3FFF & $opid) >> 0;
@ -650,7 +650,7 @@ class PHPExcel_Reader_Excel5_Escher
$opidFComplex = (0x8000 & $opid) >> 15; $opidFComplex = (0x8000 & $opid) >> 15;
// offset: 2; size: 4; the value for this property // offset: 2; size: 4; the value for this property
$op = PHPExcel_Reader_Excel5::_GetInt4d($fopte, 2); $op = PHPExcel_Reader_Excel5::getInt4d($fopte, 2);
if ($opidFComplex) { if ($opidFComplex) {
$complexData = substr($splicedComplexData, 0, $op); $complexData = substr($splicedComplexData, 0, $op);

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Reader_Exception
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Reader_Exception
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Exception extends PHPExcel_Exception class PHPExcel_Reader_Exception extends PHPExcel_Exception
{ {
/** /**

View File

@ -57,7 +57,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
*/ */
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();
} }
@ -173,7 +173,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $worksheetInfo; return $worksheetInfo;
} }
private function _gzfileGetContents($filename) private function gzfileGetContents($filename)
{ {
$file = @gzopen($filename, 'rb'); $file = @gzopen($filename, 'rb');
if ($file !== false) { if ($file !== false) {
@ -220,7 +220,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$timezoneObj = new DateTimeZone('Europe/London'); $timezoneObj = new DateTimeZone('Europe/London');
$GMT = new DateTimeZone('UTC'); $GMT = new DateTimeZone('UTC');
$gFileData = $this->_gzfileGetContents($pFilename); $gFileData = $this->gzfileGetContents($pFilename);
// echo '<pre>'; // echo '<pre>';
// echo htmlentities($gFileData,ENT_QUOTES,'UTF-8'); // echo htmlentities($gFileData,ENT_QUOTES,'UTF-8');
@ -340,7 +340,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
foreach ($gnmXML->Sheets->Sheet as $sheet) { foreach ($gnmXML->Sheets->Sheet as $sheet) {
$worksheetName = (string) $sheet->Name; $worksheetName = (string) $sheet->Name;
// echo '<b>Worksheet: ', $worksheetName,'</b><br />'; // echo '<b>Worksheet: ', $worksheetName,'</b><br />';
if ((isset($this->_loadSheetsOnly)) && (!in_array($worksheetName, $this->_loadSheetsOnly))) { if ((isset($this->loadSheetsOnly)) && (!in_array($worksheetName, $this->loadSheetsOnly))) {
continue; continue;
} }
@ -354,7 +354,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// name in line with the formula, not the reverse // name in line with the formula, not the reverse
$objPHPExcel->getActiveSheet()->setTitle($worksheetName, false); $objPHPExcel->getActiveSheet()->setTitle($worksheetName, false);
if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) { if ((!$this->readDataOnly) && (isset($sheet->PrintInformation))) {
if (isset($sheet->PrintInformation->Margins)) { if (isset($sheet->PrintInformation->Margins)) {
foreach ($sheet->PrintInformation->Margins->children('gnm', true) as $key => $margin) { foreach ($sheet->PrintInformation->Margins->children('gnm', true) as $key => $margin) {
$marginAttributes = $margin->attributes(); $marginAttributes = $margin->attributes();
@ -441,6 +441,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$cell = ($cell == 'TRUE') ? true: false; $cell = ($cell == 'TRUE') ? true: false;
break; break;
case '30': // Integer case '30': // Integer
// Excel 2007+ doesn't differentiate between integer and float, so set the value and dropthru to the next (numeric) case
$cell = intval($cell); $cell = intval($cell);
case '40': // Float case '40': // Float
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
@ -458,12 +459,12 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell, $type); $objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell, $type);
} }
if ((!$this->_readDataOnly) && (isset($sheet->Objects))) { if ((!$this->readDataOnly) && (isset($sheet->Objects))) {
foreach ($sheet->Objects->children('gnm', true) as $key => $comment) { foreach ($sheet->Objects->children('gnm', true) as $key => $comment) {
$commentAttributes = $comment->attributes(); $commentAttributes = $comment->attributes();
// Only comment objects are handled at the moment // Only comment objects are handled at the moment
if ($commentAttributes->Text) { if ($commentAttributes->Text) {
$objPHPExcel->getActiveSheet()->getComment((string)$commentAttributes->ObjectBound)->setAuthor((string)$commentAttributes->Author)->setText($this->_parseRichText((string)$commentAttributes->Text)); $objPHPExcel->getActiveSheet()->getComment((string)$commentAttributes->ObjectBound)->setAuthor((string)$commentAttributes->Author)->setText($this->parseRichText((string)$commentAttributes->Text));
} }
} }
} }
@ -487,13 +488,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// var_dump($styleAttributes); // var_dump($styleAttributes);
// echo '<br />'; // echo '<br />';
// We still set the number format mask for date/time values, even if _readDataOnly is true // We still set the number format mask for date/time values, even if readDataOnly is true
if ((!$this->_readDataOnly) || if ((!$this->readDataOnly) ||
(PHPExcel_Shared_Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) { (PHPExcel_Shared_Date::isDateTimeFormatCode((string) $styleAttributes['Format']))) {
$styleArray = array(); $styleArray = array();
$styleArray['numberformat']['code'] = (string) $styleAttributes['Format']; $styleArray['numberformat']['code'] = (string) $styleAttributes['Format'];
// If _readDataOnly is false, we set all formatting information // If readDataOnly is false, we set all formatting information
if (!$this->_readDataOnly) { if (!$this->readDataOnly) {
switch ($styleAttributes['HAlign']) { switch ($styleAttributes['HAlign']) {
case '1': case '1':
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
@ -535,13 +536,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false; $styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false;
$styleArray['alignment']['indent'] = (intval($styleAttributes["Indent"]) > 0) ? $styleAttributes["indent"] : 0; $styleArray['alignment']['indent'] = (intval($styleAttributes["Indent"]) > 0) ? $styleAttributes["indent"] : 0;
$RGB = self::_parseGnumericColour($styleAttributes["Fore"]); $RGB = self::parseGnumericColour($styleAttributes["Fore"]);
$styleArray['font']['color']['rgb'] = $RGB; $styleArray['font']['color']['rgb'] = $RGB;
$RGB = self::_parseGnumericColour($styleAttributes["Back"]); $RGB = self::parseGnumericColour($styleAttributes["Back"]);
$shade = $styleAttributes["Shade"]; $shade = $styleAttributes["Shade"];
if (($RGB != '000000') || ($shade != '0')) { if (($RGB != '000000') || ($shade != '0')) {
$styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB; $styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB;
$RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]); $RGB2 = self::parseGnumericColour($styleAttributes["PatternColor"]);
$styleArray['fill']['endcolor']['rgb'] = $RGB2; $styleArray['fill']['endcolor']['rgb'] = $RGB2;
switch ($shade) { switch ($shade) {
case '1': case '1':
@ -643,25 +644,25 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
if (isset($styleRegion->Style->StyleBorder)) { if (isset($styleRegion->Style->StyleBorder)) {
if (isset($styleRegion->Style->StyleBorder->Top)) { if (isset($styleRegion->Style->StyleBorder->Top)) {
$styleArray['borders']['top'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Top->attributes()); $styleArray['borders']['top'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Top->attributes());
} }
if (isset($styleRegion->Style->StyleBorder->Bottom)) { if (isset($styleRegion->Style->StyleBorder->Bottom)) {
$styleArray['borders']['bottom'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Bottom->attributes()); $styleArray['borders']['bottom'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Bottom->attributes());
} }
if (isset($styleRegion->Style->StyleBorder->Left)) { if (isset($styleRegion->Style->StyleBorder->Left)) {
$styleArray['borders']['left'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Left->attributes()); $styleArray['borders']['left'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Left->attributes());
} }
if (isset($styleRegion->Style->StyleBorder->Right)) { if (isset($styleRegion->Style->StyleBorder->Right)) {
$styleArray['borders']['right'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Right->attributes()); $styleArray['borders']['right'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Right->attributes());
} }
if ((isset($styleRegion->Style->StyleBorder->Diagonal)) && (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}))) { if ((isset($styleRegion->Style->StyleBorder->Diagonal)) && (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}))) {
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes()); $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_BOTH; $styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_BOTH;
} elseif (isset($styleRegion->Style->StyleBorder->Diagonal)) { } elseif (isset($styleRegion->Style->StyleBorder->Diagonal)) {
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes()); $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->Diagonal->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_UP; $styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_UP;
} elseif (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'})) { } elseif (isset($styleRegion->Style->StyleBorder->{'Rev-Diagonal'})) {
$styleArray['borders']['diagonal'] = self::_parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes()); $styleArray['borders']['diagonal'] = self::parseBorderAttributes($styleRegion->Style->StyleBorder->{'Rev-Diagonal'}->attributes());
$styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_DOWN; $styleArray['borders']['diagonaldirection'] = PHPExcel_Style_Borders::DIAGONAL_DOWN;
} }
} }
@ -677,7 +678,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
} }
if ((!$this->_readDataOnly) && (isset($sheet->Cols))) { if ((!$this->readDataOnly) && (isset($sheet->Cols))) {
// Column Widths // Column Widths
$columnAttributes = $sheet->Cols->attributes(); $columnAttributes = $sheet->Cols->attributes();
$defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4; $defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4;
@ -706,7 +707,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
} }
if ((!$this->_readDataOnly) && (isset($sheet->Rows))) { if ((!$this->readDataOnly) && (isset($sheet->Rows))) {
// Row Heights // Row Heights
$rowAttributes = $sheet->Rows->attributes(); $rowAttributes = $sheet->Rows->attributes();
$defaultHeight = $rowAttributes['DefaultSizePts']; $defaultHeight = $rowAttributes['DefaultSizePts'];
@ -770,13 +771,11 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
return $objPHPExcel; return $objPHPExcel;
} }
private static function _parseBorderAttributes($borderAttributes) private static function parseBorderAttributes($borderAttributes)
{ {
$styleArray = array(); $styleArray = array();
if (isset($borderAttributes["Color"])) { if (isset($borderAttributes["Color"])) {
$RGB = self::_parseGnumericColour($borderAttributes["Color"]); $styleArray['color']['rgb'] = self::parseGnumericColour($borderAttributes["Color"]);
$styleArray['color']['rgb'] = $RGB;
} }
switch ($borderAttributes["Style"]) { switch ($borderAttributes["Style"]) {
@ -789,6 +788,9 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
case '2': case '2':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUM; $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
break; break;
case '3':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_SLANTDASHDOT;
break;
case '4': case '4':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED; $styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHED;
break; break;
@ -801,6 +803,9 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
case '7': case '7':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED; $styleArray['style'] = PHPExcel_Style_Border::BORDER_DOTTED;
break; break;
case '8':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHED;
break;
case '9': case '9':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT; $styleArray['style'] = PHPExcel_Style_Border::BORDER_DASHDOT;
break; break;
@ -816,33 +821,24 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
case '13': case '13':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT; $styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT;
break; break;
case '3':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_SLANTDASHDOT;
break;
case '8':
$styleArray['style'] = PHPExcel_Style_Border::BORDER_MEDIUMDASHED;
break;
} }
return $styleArray; return $styleArray;
} }
private function _parseRichText($is = '') private function parseRichText($is = '')
{ {
$value = new PHPExcel_RichText(); $value = new PHPExcel_RichText();
$value->createText($is); $value->createText($is);
return $value; return $value;
} }
private static function _parseGnumericColour($gnmColour) private static function parseGnumericColour($gnmColour)
{ {
list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour); list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour);
$gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2); $gnmR = substr(str_pad($gnmR, 4, '0', STR_PAD_RIGHT), 0, 2);
$gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2); $gnmG = substr(str_pad($gnmG, 4, '0', STR_PAD_RIGHT), 0, 2);
$gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2); $gnmB = substr(str_pad($gnmB, 4, '0', STR_PAD_RIGHT), 0, 2);
$RGB = $gnmR.$gnmG.$gnmB; return $gnmR . $gnmG . $gnmB;
// echo 'Excel Colour: ', $RGB,'<br />';
return $RGB;
} }
} }

View File

@ -42,52 +42,71 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
* *
* @var string * @var string
*/ */
protected $_inputEncoding = 'ANSI'; protected $inputEncoding = 'ANSI';
/** /**
* Sheet index to read * Sheet index to read
* *
* @var int * @var int
*/ */
protected $_sheetIndex = 0; protected $sheetIndex = 0;
/** /**
* Formats * Formats
* *
* @var array * @var array
*/ */
protected $_formats = array( protected $formats = array(
'h1' => array('font' => array('bold' => true, 'h1' => array(
'font' => array(
'bold' => true,
'size' => 24, 'size' => 24,
), ),
), // Bold, 24pt ), // Bold, 24pt
'h2' => array('font' => array('bold' => true, 'h2' => array(
'font' => array(
'bold' => true,
'size' => 18, 'size' => 18,
), ),
), // Bold, 18pt ), // Bold, 18pt
'h3' => array('font' => array('bold' => true, 'h3' => array(
'font' => array(
'bold' => true,
'size' => 13.5, 'size' => 13.5,
), ),
), // Bold, 13.5pt ), // Bold, 13.5pt
'h4' => array('font' => array('bold' => true, 'h4' => array(
'font' => array(
'bold' => true,
'size' => 12, 'size' => 12,
), ),
), // Bold, 12pt ), // Bold, 12pt
'h5' => array('font' => array('bold' => true, 'h5' => array(
'font' => array(
'bold' => true,
'size' => 10, 'size' => 10,
), ),
), // Bold, 10pt ), // Bold, 10pt
'h6' => array('font' => array('bold' => true, 'h6' => array(
'font' => array(
'bold' => true,
'size' => 7.5, 'size' => 7.5,
), ),
), // Bold, 7.5pt ), // Bold, 7.5pt
'a' => array('font' => array('underline' => true, 'a' => array(
'color' => array('argb' => PHPExcel_Style_Color::COLOR_BLUE, 'font' => array(
'underline' => true,
'color' => array(
'argb' => PHPExcel_Style_Color::COLOR_BLUE,
), ),
), ),
), // Blue underlined ), // Blue underlined
'hr' => array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'hr' => array(
'color' => array(\PHPExcel_Style_Color::COLOR_BLACK, 'borders' => array(
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array(
PHPExcel_Style_Color::COLOR_BLACK,
), ),
), ),
), ),
@ -101,7 +120,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/ */
public function __construct() public function __construct()
{ {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
} }
/** /**
@ -109,10 +128,10 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
* *
* @return boolean * @return boolean
*/ */
protected function _isValidFormat() protected function isValidFormat()
{ {
// Reading 2048 bytes should be enough to validate that the format is HTML // Reading 2048 bytes should be enough to validate that the format is HTML
$data = fread($this->_fileHandle, 2048); $data = fread($this->fileHandle, 2048);
if ((strpos($data, '<') !== false) && if ((strpos($data, '<') !== false) &&
(strlen($data) !== strlen(strip_tags($data)))) { (strlen($data) !== strlen(strip_tags($data)))) {
return true; return true;
@ -144,7 +163,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/ */
public function setInputEncoding($pValue = 'ANSI') public function setInputEncoding($pValue = 'ANSI')
{ {
$this->_inputEncoding = $pValue; $this->inputEncoding = $pValue;
return $this; return $this;
} }
@ -156,7 +175,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/ */
public function getInputEncoding() public function getInputEncoding()
{ {
return $this->_inputEncoding; return $this->inputEncoding;
} }
// Data Array used for testing only, should write to PHPExcel object on completion of tests // Data Array used for testing only, should write to PHPExcel object on completion of tests
@ -164,7 +183,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
protected $_tableLevel = 0; protected $_tableLevel = 0;
protected $_nestedColumn = array('A'); protected $_nestedColumn = array('A');
protected function _setTableStartColumn($column) protected function setTableStartColumn($column)
{ {
if ($this->_tableLevel == 0) { if ($this->_tableLevel == 0) {
$column = 'A'; $column = 'A';
@ -175,19 +194,19 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
return $this->_nestedColumn[$this->_tableLevel]; return $this->_nestedColumn[$this->_tableLevel];
} }
protected function _getTableStartColumn() protected function getTableStartColumn()
{ {
return $this->_nestedColumn[$this->_tableLevel]; return $this->_nestedColumn[$this->_tableLevel];
} }
protected function _releaseTableStartColumn() protected function releaseTableStartColumn()
{ {
--$this->_tableLevel; --$this->_tableLevel;
return array_pop($this->_nestedColumn); return array_pop($this->_nestedColumn);
} }
protected function _flushCell($sheet, $column, $row, &$cellContent) protected function flushCell($sheet, $column, $row, &$cellContent)
{ {
if (is_string($cellContent)) { if (is_string($cellContent)) {
// Simple String content // Simple String content
@ -207,7 +226,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$cellContent = (string) ''; $cellContent = (string) '';
} }
protected function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null) protected function processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null)
{ {
foreach ($element->childNodes as $child) { foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) { if ($child instanceof DOMText) {
@ -238,10 +257,10 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
break; break;
} }
} }
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
break; break;
case 'title': case 'title':
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
$sheet->setTitle($cellContent); $sheet->setTitle($cellContent);
$cellContent = ''; $cellContent = '';
break; break;
@ -256,20 +275,20 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
if ($cellContent > '') { if ($cellContent > '') {
$cellContent .= ' '; $cellContent .= ' ';
} }
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
if ($cellContent > '') { if ($cellContent > '') {
$cellContent .= ' '; $cellContent .= ' ';
} }
// echo 'END OF STYLING, SPAN OR DIV<br />'; // echo 'END OF STYLING, SPAN OR DIV<br />';
break; break;
case 'hr': case 'hr':
$this->_flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
++$row; ++$row;
if (isset($this->_formats[$child->nodeName])) { if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]); $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
} else { } else {
$cellContent = '----------'; $cellContent = '----------';
$this->_flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
} }
++$row; ++$row;
case 'br': case 'br':
@ -278,7 +297,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$cellContent .= "\n"; $cellContent .= "\n";
} else { } else {
// Otherwise flush our existing content and move the row cursor on // Otherwise flush our existing content and move the row cursor on
$this->_flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
++$row; ++$row;
} }
// echo 'HARD LINE BREAK: ' , '<br />'; // echo 'HARD LINE BREAK: ' , '<br />';
@ -290,14 +309,14 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
case 'href': case 'href':
// echo 'Link to ' , $attributeValue , '<br />'; // echo 'Link to ' , $attributeValue , '<br />';
$sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue); $sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue);
if (isset($this->_formats[$child->nodeName])) { if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]); $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
} }
break; break;
} }
} }
$cellContent .= ' '; $cellContent .= ' ';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF HYPERLINK:' , '<br />'; // echo 'END OF HYPERLINK:' , '<br />';
break; break;
case 'h1': case 'h1':
@ -313,20 +332,20 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
// If we're inside a table, replace with a \n // If we're inside a table, replace with a \n
$cellContent .= "\n"; $cellContent .= "\n";
// echo 'LIST ENTRY: ' , '<br />'; // echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />'; // echo 'END OF LIST ENTRY:' , '<br />';
} else { } else {
if ($cellContent > '') { if ($cellContent > '') {
$this->_flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
$row++; $row++;
} }
// echo 'START OF PARAGRAPH: ' , '<br />'; // echo 'START OF PARAGRAPH: ' , '<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF PARAGRAPH:' , '<br />'; // echo 'END OF PARAGRAPH:' , '<br />';
$this->_flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
if (isset($this->_formats[$child->nodeName])) { if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]); $sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
} }
$row++; $row++;
@ -338,30 +357,30 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
// If we're inside a table, replace with a \n // If we're inside a table, replace with a \n
$cellContent .= "\n"; $cellContent .= "\n";
// echo 'LIST ENTRY: ' , '<br />'; // echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />'; // echo 'END OF LIST ENTRY:' , '<br />';
} else { } else {
if ($cellContent > '') { if ($cellContent > '') {
$this->_flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
} }
++$row; ++$row;
// echo 'LIST ENTRY: ' , '<br />'; // echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />'; // echo 'END OF LIST ENTRY:' , '<br />';
$this->_flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
$column = 'A'; $column = 'A';
} }
break; break;
case 'table': case 'table':
$this->_flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
$column = $this->_setTableStartColumn($column); $column = $this->setTableStartColumn($column);
// echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />'; // echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
if ($this->_tableLevel > 1) { if ($this->_tableLevel > 1) {
--$row; --$row;
} }
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />'; // echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
$column = $this->_releaseTableStartColumn(); $column = $this->releaseTableStartColumn();
if ($this->_tableLevel > 1) { if ($this->_tableLevel > 1) {
++$column; ++$column;
} else { } else {
@ -370,27 +389,27 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
break; break;
case 'thead': case 'thead':
case 'tbody': case 'tbody':
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
break; break;
case 'tr': case 'tr':
$column = $this->_getTableStartColumn(); $column = $this->getTableStartColumn();
$cellContent = ''; $cellContent = '';
// echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />'; // echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
++$row; ++$row;
// echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />'; // echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />';
break; break;
case 'th': case 'th':
case 'td': case 'td':
// echo 'START OF TABLE ' , $this->_tableLevel , ' CELL<br />'; // echo 'START OF TABLE ' , $this->_tableLevel , ' CELL<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE ' , $this->_tableLevel , ' CELL<br />'; // echo 'END OF TABLE ' , $this->_tableLevel , ' CELL<br />';
while (isset($this->rowspan[$column . $row])) { while (isset($this->rowspan[$column . $row])) {
++$column; ++$column;
} }
$this->_flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
// if (isset($attributeArray['style']) && !empty($attributeArray['style'])) { // if (isset($attributeArray['style']) && !empty($attributeArray['style'])) {
// $styleAry = $this->getPhpExcelStyleArray($attributeArray['style']); // $styleAry = $this->getPhpExcelStyleArray($attributeArray['style']);
@ -435,10 +454,10 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$column = 'A'; $column = 'A';
$content = ''; $content = '';
$this->_tableLevel = 0; $this->_tableLevel = 0;
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
break; break;
default: default:
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
} }
} }
} }
@ -455,19 +474,19 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{ {
// Open file to validate // Open file to validate
$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 HTML file."); throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
} }
// Close after validating // Close after validating
fclose($this->_fileHandle); fclose($this->fileHandle);
// Create new PHPExcel // Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) { while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
$objPHPExcel->createSheet(); $objPHPExcel->createSheet();
} }
$objPHPExcel->setActiveSheetIndex($this->_sheetIndex); $objPHPExcel->setActiveSheetIndex($this->sheetIndex);
// Create a new DOM object // Create a new DOM object
$dom = new domDocument; $dom = new domDocument;
@ -483,7 +502,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$row = 0; $row = 0;
$column = 'A'; $column = 'A';
$content = ''; $content = '';
$this->_processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content); $this->processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
// Return // Return
return $objPHPExcel; return $objPHPExcel;
@ -496,7 +515,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/ */
public function getSheetIndex() public function getSheetIndex()
{ {
return $this->_sheetIndex; return $this->sheetIndex;
} }
/** /**
@ -507,7 +526,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/ */
public function setSheetIndex($pValue = 0) public function setSheetIndex($pValue = 0)
{ {
$this->_sheetIndex = $pValue; $this->sheetIndex = $pValue;
return $this; return $this;
} }

View File

@ -30,10 +30,10 @@ interface PHPExcel_Reader_IReadFilter
/** /**
* Should this cell be read? * Should this cell be read?
* *
* @param $column String column index * @param $column Column address (as a string value like "A", or "IV")
* @param $row Row index * @param $row Row number
* @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 = '');
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Reader_IReader
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Reader_IReader
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_Reader_IReader interface PHPExcel_Reader_IReader
{ {
/** /**

View File

@ -48,7 +48,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
*/ */
public function __construct() public function __construct()
{ {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
} }
/** /**
@ -438,8 +438,8 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']); $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
// print_r($worksheetDataAttributes); // print_r($worksheetDataAttributes);
// echo '<br />'; // echo '<br />';
if ((isset($this->_loadSheetsOnly)) && (isset($worksheetDataAttributes['name'])) && if ((isset($this->loadSheetsOnly)) && (isset($worksheetDataAttributes['name'])) &&
(!in_array($worksheetDataAttributes['name'], $this->_loadSheetsOnly))) { (!in_array($worksheetDataAttributes['name'], $this->loadSheetsOnly))) {
continue; continue;
} }
@ -657,7 +657,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// Merged cells // Merged cells
if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) { if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) {
if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->_readDataOnly)) { if (($type !== PHPExcel_Cell_DataType::TYPE_NULL) || (!$this->readDataOnly)) {
$columnTo = $columnID; $columnTo = $columnID;
if (isset($cellDataTableAttributes['number-columns-spanned'])) { if (isset($cellDataTableAttributes['number-columns-spanned'])) {
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2); $columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);

View File

@ -1,6 +1,16 @@
<?php <?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel * PHPExcel_Reader_SYLK
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,24 +34,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_SYLK
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{ {
/** /**
@ -77,7 +69,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
*/ */
public function __construct() public function __construct()
{ {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
} }
/** /**
@ -85,10 +77,10 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
* *
* @return boolean * @return boolean
*/ */
protected function _isValidFormat() protected function isValidFormat()
{ {
// Read sample data (first 2 KB will do) // Read sample data (first 2 KB will do)
$data = fread($this->_fileHandle, 2048); $data = fread($this->fileHandle, 2048);
// Count delimiters in file // Count delimiters in file
$delimiterCount = substr_count($data, ';'); $delimiterCount = substr_count($data, ';');
@ -135,12 +127,12 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
public function listWorksheetInfo($pFilename) public function listWorksheetInfo($pFilename)
{ {
// 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;
rewind($fileHandle); rewind($fileHandle);
$worksheetInfo = array(); $worksheetInfo = array();
@ -222,12 +214,12 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel) public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{ {
// 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;
rewind($fileHandle); rewind($fileHandle);
// Create new PHPExcel // Create new PHPExcel

View File

@ -39,154 +39,105 @@ class PHPExcel_Shared_CodePage
{ {
switch ($codePage) { switch ($codePage) {
case 367: case 367:
return 'ASCII'; return 'ASCII'; // ASCII
break; // ASCII
case 437: case 437:
return 'CP437'; return 'CP437'; // OEM US
break; // OEM US
case 720: case 720:
throw new PHPExcel_Exception('Code page 720 not supported.'); throw new PHPExcel_Exception('Code page 720 not supported.'); // OEM Arabic
break; // OEM Arabic
case 737: case 737:
return 'CP737'; return 'CP737'; // OEM Greek
break; // OEM Greek
case 775: case 775:
return 'CP775'; return 'CP775'; // OEM Baltic
break; // OEM Baltic
case 850: case 850:
return 'CP850'; return 'CP850'; // OEM Latin I
break; // OEM Latin I
case 852: case 852:
return 'CP852'; return 'CP852'; // OEM Latin II (Central European)
break; // OEM Latin II (Central European)
case 855: case 855:
return 'CP855'; return 'CP855'; // OEM Cyrillic
break; // OEM Cyrillic
case 857: case 857:
return 'CP857'; return 'CP857'; // OEM Turkish
break; // OEM Turkish
case 858: case 858:
return 'CP858'; return 'CP858'; // OEM Multilingual Latin I with Euro
break; // OEM Multilingual Latin I with Euro
case 860: case 860:
return 'CP860'; return 'CP860'; // OEM Portugese
break; // OEM Portugese
case 861: case 861:
return 'CP861'; return 'CP861'; // OEM Icelandic
break; // OEM Icelandic
case 862: case 862:
return 'CP862'; return 'CP862'; // OEM Hebrew
break; // OEM Hebrew
case 863: case 863:
return 'CP863'; return 'CP863'; // OEM Canadian (French)
break; // OEM Canadian (French)
case 864: case 864:
return 'CP864'; return 'CP864'; // OEM Arabic
break; // OEM Arabic
case 865: case 865:
return 'CP865'; return 'CP865'; // OEM Nordic
break; // OEM Nordic
case 866: case 866:
return 'CP866'; return 'CP866'; // OEM Cyrillic (Russian)
break; // OEM Cyrillic (Russian)
case 869: case 869:
return 'CP869'; return 'CP869'; // OEM Greek (Modern)
break; // OEM Greek (Modern)
case 874: case 874:
return 'CP874'; return 'CP874'; // ANSI Thai
break; // ANSI Thai
case 932: case 932:
return 'CP932'; return 'CP932'; // ANSI Japanese Shift-JIS
break; // ANSI Japanese Shift-JIS
case 936: case 936:
return 'CP936'; return 'CP936'; // ANSI Chinese Simplified GBK
break; // ANSI Chinese Simplified GBK
case 949: case 949:
return 'CP949'; return 'CP949'; // ANSI Korean (Wansung)
break; // ANSI Korean (Wansung)
case 950: case 950:
return 'CP950'; return 'CP950'; // ANSI Chinese Traditional BIG5
break; // ANSI Chinese Traditional BIG5
case 1200: case 1200:
return 'UTF-16LE'; return 'UTF-16LE'; // UTF-16 (BIFF8)
break; // UTF-16 (BIFF8)
case 1250: case 1250:
return 'CP1250'; return 'CP1250'; // ANSI Latin II (Central European)
break; // ANSI Latin II (Central European)
case 1251: case 1251:
return 'CP1251'; return 'CP1251'; // ANSI Cyrillic
break; // ANSI Cyrillic
case 0: case 0:
// CodePage is not always correctly set when the xls file was saved by Apple's Numbers program // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
case 1252: case 1252:
return 'CP1252'; return 'CP1252'; // ANSI Latin I (BIFF4-BIFF7)
break; // ANSI Latin I (BIFF4-BIFF7)
case 1253: case 1253:
return 'CP1253'; return 'CP1253'; // ANSI Greek
break; // ANSI Greek
case 1254: case 1254:
return 'CP1254'; return 'CP1254'; // ANSI Turkish
break; // ANSI Turkish
case 1255: case 1255:
return 'CP1255'; return 'CP1255'; // ANSI Hebrew
break; // ANSI Hebrew
case 1256: case 1256:
return 'CP1256'; return 'CP1256'; // ANSI Arabic
break; // ANSI Arabic
case 1257: case 1257:
return 'CP1257'; return 'CP1257'; // ANSI Baltic
break; // ANSI Baltic
case 1258: case 1258:
return 'CP1258'; return 'CP1258'; // ANSI Vietnamese
break; // ANSI Vietnamese
case 1361: case 1361:
return 'CP1361'; return 'CP1361'; // ANSI Korean (Johab)
break; // ANSI Korean (Johab)
case 10000: case 10000:
return 'MAC'; return 'MAC'; // Apple Roman
break; // Apple Roman
case 10001: case 10001:
return 'CP932'; return 'CP932'; // Macintosh Japanese
break; // Macintosh Japanese
case 10002: case 10002:
return 'CP950'; return 'CP950'; // Macintosh Chinese Traditional
break; // Macintosh Chinese Traditional
case 10003: case 10003:
return 'CP1361'; return 'CP1361'; // Macintosh Korean
break; // Macintosh Korean
case 10006: case 10006:
return 'MACGREEK'; return 'MACGREEK'; // Macintosh Greek
break; // Macintosh Greek
case 10007: case 10007:
return 'MACCYRILLIC'; return 'MACCYRILLIC'; // Macintosh Cyrillic
break; // Macintosh Cyrillic
case 10008: case 10008:
return 'CP936'; return 'CP936'; // Macintosh - Simplified Chinese (GB 2312)
break; // Macintosh - Simplified Chinese (GB 2312)
case 10029: case 10029:
return 'MACCENTRALEUROPE'; return 'MACCENTRALEUROPE'; // Macintosh Central Europe
break; // Macintosh Central Europe
case 10079: case 10079:
return 'MACICELAND'; return 'MACICELAND'; // Macintosh Icelandic
break; // Macintosh Icelandic
case 10081: case 10081:
return 'MACTURKISH'; return 'MACTURKISH'; // Macintosh Turkish
break; // Macintosh Turkish
case 21010: case 21010:
return 'UTF-16LE'; return 'UTF-16LE'; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
break; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
case 32768: case 32768:
return 'MAC'; return 'MAC'; // Apple Roman
break; // Apple Roman
case 32769: case 32769:
throw new PHPExcel_Exception('Code page 32769 not supported.'); throw new PHPExcel_Exception('Code page 32769 not supported.'); // ANSI Latin I (BIFF2-BIFF3)
break; // ANSI Latin I (BIFF2-BIFF3)
case 65000: case 65000:
return 'UTF-7'; return 'UTF-7'; // Unicode (UTF-7)
break; // Unicode (UTF-7)
case 65001: case 65001:
return 'UTF-8'; return 'UTF-8'; // Unicode (UTF-8)
break; // Unicode (UTF-8)
} }
throw new PHPExcel_Exception('Unknown codepage: ' . $codePage); throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
} }

View File

@ -94,19 +94,19 @@ class PHPExcel_Shared_OLERead
$this->data = file_get_contents($sFileName); $this->data = file_get_contents($sFileName);
// Total number of sectors used for the SAT // Total number of sectors used for the SAT
$this->numBigBlockDepotBlocks = self::_GetInt4d($this->data, self::NUM_BIG_BLOCK_DEPOT_BLOCKS_POS); $this->numBigBlockDepotBlocks = self::getInt4d($this->data, self::NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
// SecID of the first sector of the directory stream // SecID of the first sector of the directory stream
$this->rootStartBlock = self::_GetInt4d($this->data, self::ROOT_START_BLOCK_POS); $this->rootStartBlock = self::getInt4d($this->data, self::ROOT_START_BLOCK_POS);
// SecID of the first sector of the SSAT (or -2 if not extant) // SecID of the first sector of the SSAT (or -2 if not extant)
$this->sbdStartBlock = self::_GetInt4d($this->data, self::SMALL_BLOCK_DEPOT_BLOCK_POS); $this->sbdStartBlock = self::getInt4d($this->data, self::SMALL_BLOCK_DEPOT_BLOCK_POS);
// SecID of the first sector of the MSAT (or -2 if no additional sectors are used) // SecID of the first sector of the MSAT (or -2 if no additional sectors are used)
$this->extensionBlock = self::_GetInt4d($this->data, self::EXTENSION_BLOCK_POS); $this->extensionBlock = self::getInt4d($this->data, self::EXTENSION_BLOCK_POS);
// Total number of sectors used by MSAT // Total number of sectors used by MSAT
$this->numExtensionBlocks = self::_GetInt4d($this->data, self::NUM_EXTENSION_BLOCK_POS); $this->numExtensionBlocks = self::getInt4d($this->data, self::NUM_EXTENSION_BLOCK_POS);
$bigBlockDepotBlocks = array(); $bigBlockDepotBlocks = array();
$pos = self::BIG_BLOCK_DEPOT_BLOCKS_POS; $pos = self::BIG_BLOCK_DEPOT_BLOCKS_POS;
@ -118,7 +118,7 @@ class PHPExcel_Shared_OLERead
} }
for ($i = 0; $i < $bbdBlocks; ++$i) { for ($i = 0; $i < $bbdBlocks; ++$i) {
$bigBlockDepotBlocks[$i] = self::_GetInt4d($this->data, $pos); $bigBlockDepotBlocks[$i] = self::getInt4d($this->data, $pos);
$pos += 4; $pos += 4;
} }
@ -127,13 +127,13 @@ class PHPExcel_Shared_OLERead
$blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, self::BIG_BLOCK_SIZE / 4 - 1); $blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, self::BIG_BLOCK_SIZE / 4 - 1);
for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; ++$i) { for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; ++$i) {
$bigBlockDepotBlocks[$i] = self::_GetInt4d($this->data, $pos); $bigBlockDepotBlocks[$i] = self::getInt4d($this->data, $pos);
$pos += 4; $pos += 4;
} }
$bbdBlocks += $blocksToRead; $bbdBlocks += $blocksToRead;
if ($bbdBlocks < $this->numBigBlockDepotBlocks) { if ($bbdBlocks < $this->numBigBlockDepotBlocks) {
$this->extensionBlock = self::_GetInt4d($this->data, $pos); $this->extensionBlock = self::getInt4d($this->data, $pos);
} }
} }
@ -156,14 +156,14 @@ class PHPExcel_Shared_OLERead
$this->smallBlockChain .= substr($this->data, $pos, 4*$bbs); $this->smallBlockChain .= substr($this->data, $pos, 4*$bbs);
$pos += 4*$bbs; $pos += 4*$bbs;
$sbdBlock = self::_GetInt4d($this->bigBlockChain, $sbdBlock*4); $sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock*4);
} }
// read the directory stream // read the directory stream
$block = $this->rootStartBlock; $block = $this->rootStartBlock;
$this->entry = $this->_readData($block); $this->entry = $this->_readData($block);
$this->_readPropertySets(); $this->readPropertySets();
} }
/** /**
@ -188,7 +188,7 @@ class PHPExcel_Shared_OLERead
$pos = $block * self::SMALL_BLOCK_SIZE; $pos = $block * self::SMALL_BLOCK_SIZE;
$streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE); $streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);
$block = self::_GetInt4d($this->smallBlockChain, $block*4); $block = self::getInt4d($this->smallBlockChain, $block*4);
} }
return $streamData; return $streamData;
@ -207,7 +207,7 @@ class PHPExcel_Shared_OLERead
while ($block != -2) { while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE; $pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); $streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
$block = self::_GetInt4d($this->bigBlockChain, $block*4); $block = self::getInt4d($this->bigBlockChain, $block*4);
} }
return $streamData; return $streamData;
@ -228,7 +228,7 @@ class PHPExcel_Shared_OLERead
while ($block != -2) { while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE; $pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); $data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
$block = self::_GetInt4d($this->bigBlockChain, $block*4); $block = self::getInt4d($this->bigBlockChain, $block*4);
} }
return $data; return $data;
} }
@ -236,7 +236,7 @@ class PHPExcel_Shared_OLERead
/** /**
* Read entries in the directory stream. * Read entries in the directory stream.
*/ */
private function _readPropertySets() private function readPropertySets()
{ {
$offset = 0; $offset = 0;
@ -254,9 +254,9 @@ class PHPExcel_Shared_OLERead
// sectorID of first sector or short sector, if this entry refers to a stream (the case with workbook) // sectorID of first sector or short sector, if this entry refers to a stream (the case with workbook)
// sectorID of first sector of the short-stream container stream, if this entry is root entry // sectorID of first sector of the short-stream container stream, if this entry is root entry
$startBlock = self::_GetInt4d($d, self::START_BLOCK_POS); $startBlock = self::getInt4d($d, self::START_BLOCK_POS);
$size = self::_GetInt4d($d, self::SIZE_POS); $size = self::getInt4d($d, self::SIZE_POS);
$name = str_replace("\x00", "", substr($d, 0, $nameSize)); $name = str_replace("\x00", "", substr($d, 0, $nameSize));
@ -301,7 +301,7 @@ class PHPExcel_Shared_OLERead
* @param int $pos * @param int $pos
* @return int * @return int
*/ */
private static function _GetInt4d($data, $pos) private static function getInt4d($data, $pos)
{ {
// FIX: represent numbers correctly on 64-bit system // FIX: represent numbers correctly on 64-bit system
// http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334 // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_AutoFilter
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_AutoFilter
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_AutoFilter class PHPExcel_Worksheet_AutoFilter
{ {
/** /**
@ -40,7 +32,7 @@ class PHPExcel_Worksheet_AutoFilter
* *
* @var PHPExcel_Worksheet * @var PHPExcel_Worksheet
*/ */
private $_workSheet = null; private $workSheet;
/** /**
@ -48,7 +40,7 @@ class PHPExcel_Worksheet_AutoFilter
* *
* @var string * @var string
*/ */
private $_range = ''; private $range = '';
/** /**
@ -56,7 +48,7 @@ class PHPExcel_Worksheet_AutoFilter
* *
* @var array of PHPExcel_Worksheet_AutoFilter_Column * @var array of PHPExcel_Worksheet_AutoFilter_Column
*/ */
private $_columns = array(); private $columns = array();
/** /**
@ -67,8 +59,8 @@ class PHPExcel_Worksheet_AutoFilter
*/ */
public function __construct($pRange = '', PHPExcel_Worksheet $pSheet = null) public function __construct($pRange = '', PHPExcel_Worksheet $pSheet = null)
{ {
$this->_range = $pRange; $this->range = $pRange;
$this->_workSheet = $pSheet; $this->workSheet = $pSheet;
} }
/** /**
@ -78,7 +70,7 @@ class PHPExcel_Worksheet_AutoFilter
*/ */
public function getParent() public function getParent()
{ {
return $this->_workSheet; return $this->workSheet;
} }
/** /**
@ -89,7 +81,7 @@ class PHPExcel_Worksheet_AutoFilter
*/ */
public function setParent(PHPExcel_Worksheet $pSheet = null) public function setParent(PHPExcel_Worksheet $pSheet = null)
{ {
$this->_workSheet = $pSheet; $this->workSheet = $pSheet;
return $this; return $this;
} }
@ -101,7 +93,7 @@ class PHPExcel_Worksheet_AutoFilter
*/ */
public function getRange() public function getRange()
{ {
return $this->_range; return $this->range;
} }
/** /**
@ -120,23 +112,23 @@ class PHPExcel_Worksheet_AutoFilter
} }
if (strpos($pRange, ':') !== false) { if (strpos($pRange, ':') !== false) {
$this->_range = $pRange; $this->range = $pRange;
} elseif (empty($pRange)) { } elseif (empty($pRange)) {
$this->_range = ''; $this->range = '';
} else { } else {
throw new PHPExcel_Exception('Autofilter must be set on a range of cells.'); throw new PHPExcel_Exception('Autofilter must be set on a range of cells.');
} }
if (empty($pRange)) { if (empty($pRange)) {
// Discard all column rules // Discard all column rules
$this->_columns = array(); $this->columns = array();
} else { } else {
// Discard any column rules that are no longer valid within this range // Discard any column rules that are no longer valid within this range
list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->range);
foreach ($this->_columns as $key => $value) { foreach ($this->columns as $key => $value) {
$colIndex = PHPExcel_Cell::columnIndexFromString($key); $colIndex = PHPExcel_Cell::columnIndexFromString($key);
if (($rangeStart[0] > $colIndex) || ($rangeEnd[0] < $colIndex)) { if (($rangeStart[0] > $colIndex) || ($rangeEnd[0] < $colIndex)) {
unset($this->_columns[$key]); unset($this->columns[$key]);
} }
} }
} }
@ -152,7 +144,7 @@ class PHPExcel_Worksheet_AutoFilter
*/ */
public function getColumns() public function getColumns()
{ {
return $this->_columns; return $this->columns;
} }
/** /**
@ -164,12 +156,12 @@ class PHPExcel_Worksheet_AutoFilter
*/ */
public function testColumnInRange($column) public function testColumnInRange($column)
{ {
if (empty($this->_range)) { if (empty($this->range)) {
throw new PHPExcel_Exception("No autofilter range is defined."); throw new PHPExcel_Exception("No autofilter range is defined.");
} }
$columnIndex = PHPExcel_Cell::columnIndexFromString($column); $columnIndex = PHPExcel_Cell::columnIndexFromString($column);
list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->range);
if (($rangeStart[0] > $columnIndex) || ($rangeEnd[0] < $columnIndex)) { if (($rangeStart[0] > $columnIndex) || ($rangeEnd[0] < $columnIndex)) {
throw new PHPExcel_Exception("Column is outside of current autofilter range."); throw new PHPExcel_Exception("Column is outside of current autofilter range.");
} }
@ -200,11 +192,11 @@ class PHPExcel_Worksheet_AutoFilter
{ {
$this->testColumnInRange($pColumn); $this->testColumnInRange($pColumn);
if (!isset($this->_columns[$pColumn])) { if (!isset($this->columns[$pColumn])) {
$this->_columns[$pColumn] = new PHPExcel_Worksheet_AutoFilter_Column($pColumn, $this); $this->columns[$pColumn] = new PHPExcel_Worksheet_AutoFilter_Column($pColumn, $this);
} }
return $this->_columns[$pColumn]; return $this->columns[$pColumn];
} }
/** /**
@ -216,7 +208,7 @@ class PHPExcel_Worksheet_AutoFilter
*/ */
public function getColumnByOffset($pColumnOffset = 0) public function getColumnByOffset($pColumnOffset = 0)
{ {
list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->range);
$pColumn = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $pColumnOffset - 1); $pColumn = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $pColumnOffset - 1);
return $this->getColumn($pColumn); return $this->getColumn($pColumn);
@ -242,12 +234,12 @@ class PHPExcel_Worksheet_AutoFilter
$this->testColumnInRange($column); $this->testColumnInRange($column);
if (is_string($pColumn)) { if (is_string($pColumn)) {
$this->_columns[$pColumn] = new PHPExcel_Worksheet_AutoFilter_Column($pColumn, $this); $this->columns[$pColumn] = new PHPExcel_Worksheet_AutoFilter_Column($pColumn, $this);
} elseif (is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) { } elseif (is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) {
$pColumn->setParent($this); $pColumn->setParent($this);
$this->_columns[$column] = $pColumn; $this->columns[$column] = $pColumn;
} }
ksort($this->_columns); ksort($this->columns);
return $this; return $this;
} }
@ -263,8 +255,8 @@ class PHPExcel_Worksheet_AutoFilter
{ {
$this->testColumnInRange($pColumn); $this->testColumnInRange($pColumn);
if (isset($this->_columns[$pColumn])) { if (isset($this->columns[$pColumn])) {
unset($this->_columns[$pColumn]); unset($this->columns[$pColumn]);
} }
return $this; return $this;
@ -286,14 +278,14 @@ class PHPExcel_Worksheet_AutoFilter
$fromColumn = strtoupper($fromColumn); $fromColumn = strtoupper($fromColumn);
$toColumn = strtoupper($toColumn); $toColumn = strtoupper($toColumn);
if (($fromColumn !== null) && (isset($this->_columns[$fromColumn])) && ($toColumn !== null)) { if (($fromColumn !== null) && (isset($this->columns[$fromColumn])) && ($toColumn !== null)) {
$this->_columns[$fromColumn]->setParent(); $this->columns[$fromColumn]->setParent();
$this->_columns[$fromColumn]->setColumnIndex($toColumn); $this->columns[$fromColumn]->setColumnIndex($toColumn);
$this->_columns[$toColumn] = $this->_columns[$fromColumn]; $this->columns[$toColumn] = $this->columns[$fromColumn];
$this->_columns[$toColumn]->setParent($this); $this->columns[$toColumn]->setParent($this);
unset($this->_columns[$fromColumn]); unset($this->columns[$fromColumn]);
ksort($this->_columns); ksort($this->columns);
} }
return $this; return $this;
@ -307,7 +299,7 @@ class PHPExcel_Worksheet_AutoFilter
* @param mixed[] $dataSet * @param mixed[] $dataSet
* @return boolean * @return boolean
*/ */
private static function _filterTestInSimpleDataSet($cellValue, $dataSet) private static function filterTestInSimpleDataSet($cellValue, $dataSet)
{ {
$dataSetValues = $dataSet['filterValues']; $dataSetValues = $dataSet['filterValues'];
$blanks = $dataSet['blanks']; $blanks = $dataSet['blanks'];
@ -324,7 +316,7 @@ class PHPExcel_Worksheet_AutoFilter
* @param mixed[] $dataSet * @param mixed[] $dataSet
* @return boolean * @return boolean
*/ */
private static function _filterTestInDateGroupSet($cellValue, $dataSet) private static function filterTestInDateGroupSet($cellValue, $dataSet)
{ {
$dateSet = $dataSet['filterValues']; $dateSet = $dataSet['filterValues'];
$blanks = $dataSet['blanks']; $blanks = $dataSet['blanks'];
@ -364,7 +356,7 @@ class PHPExcel_Worksheet_AutoFilter
* @param mixed[] $ruleSet * @param mixed[] $ruleSet
* @return boolean * @return boolean
*/ */
private static function _filterTestInCustomDataSet($cellValue, $ruleSet) private static function filterTestInCustomDataSet($cellValue, $ruleSet)
{ {
$dataSet = $ruleSet['filterRules']; $dataSet = $ruleSet['filterRules'];
$join = $ruleSet['join']; $join = $ruleSet['join'];
@ -442,7 +434,7 @@ class PHPExcel_Worksheet_AutoFilter
* @param mixed[] $monthSet * @param mixed[] $monthSet
* @return boolean * @return boolean
*/ */
private static function _filterTestInPeriodDateSet($cellValue, $monthSet) private static function filterTestInPeriodDateSet($cellValue, $monthSet)
{ {
// Blank cells are always ignored, so return a FALSE // Blank cells are always ignored, so return a FALSE
if (($cellValue == '') || ($cellValue === null)) { if (($cellValue == '') || ($cellValue === null)) {
@ -464,8 +456,8 @@ class PHPExcel_Worksheet_AutoFilter
* *
* @var array * @var array
*/ */
private static $_fromReplace = array('\*', '\?', '~~', '~.*', '~.?'); private static $fromReplace = array('\*', '\?', '~~', '~.*', '~.?');
private static $_toReplace = array('.*', '.', '~', '\*', '\?'); private static $toReplace = array('.*', '.', '~', '\*', '\?');
/** /**
@ -475,7 +467,7 @@ class PHPExcel_Worksheet_AutoFilter
* @param PHPExcel_Worksheet_AutoFilter_Column &$filterColumn * @param PHPExcel_Worksheet_AutoFilter_Column &$filterColumn
* @return mixed[] * @return mixed[]
*/ */
private function _dynamicFilterDateRange($dynamicRuleType, &$filterColumn) private function dynamicFilterDateRange($dynamicRuleType, &$filterColumn)
{ {
$rDateType = PHPExcel_Calculation_Functions::getReturnDateType(); $rDateType = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC); PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC);
@ -574,13 +566,13 @@ class PHPExcel_Worksheet_AutoFilter
$ruleValues[] = array('operator' => PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN, 'value' => $maxVal); $ruleValues[] = array('operator' => PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN, 'value' => $maxVal);
PHPExcel_Calculation_Functions::setReturnDateType($rDateType); PHPExcel_Calculation_Functions::setReturnDateType($rDateType);
return array('method' => '_filterTestInCustomDataSet', 'arguments' => array('filterRules' => $ruleValues, 'join' => PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND)); return array('method' => 'filterTestInCustomDataSet', 'arguments' => array('filterRules' => $ruleValues, 'join' => PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND));
} }
private function _calculateTopTenValue($columnID, $startRow, $endRow, $ruleType, $ruleValue) private function calculateTopTenValue($columnID, $startRow, $endRow, $ruleType, $ruleValue)
{ {
$range = $columnID.$startRow.':'.$columnID.$endRow; $range = $columnID.$startRow.':'.$columnID.$endRow;
$dataValues = PHPExcel_Calculation_Functions::flattenArray($this->_workSheet->rangeToArray($range, null, true, false)); $dataValues = PHPExcel_Calculation_Functions::flattenArray($this->workSheet->rangeToArray($range, null, true, false));
$dataValues = array_filter($dataValues); $dataValues = array_filter($dataValues);
if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) { if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) {
@ -600,14 +592,14 @@ class PHPExcel_Worksheet_AutoFilter
*/ */
public function showHideRows() public function showHideRows()
{ {
list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->range);
// The heading row should always be visible // The heading row should always be visible
// echo 'AutoFilter Heading Row ', $rangeStart[1],' is always SHOWN',PHP_EOL; // echo 'AutoFilter Heading Row ', $rangeStart[1],' is always SHOWN',PHP_EOL;
$this->_workSheet->getRowDimension($rangeStart[1])->setVisible(true); $this->workSheet->getRowDimension($rangeStart[1])->setVisible(true);
$columnFilterTests = array(); $columnFilterTests = array();
foreach ($this->_columns as $columnID => $filterColumn) { foreach ($this->columns as $columnID => $filterColumn) {
$rules = $filterColumn->getRules(); $rules = $filterColumn->getRules();
switch ($filterColumn->getFilterType()) { switch ($filterColumn->getFilterType()) {
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER: case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER:
@ -626,7 +618,7 @@ class PHPExcel_Worksheet_AutoFilter
if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER) { if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER) {
// Filter on absolute values // Filter on absolute values
$columnFilterTests[$columnID] = array( $columnFilterTests[$columnID] = array(
'method' => '_filterTestInSimpleDataSet', 'method' => 'filterTestInSimpleDataSet',
'arguments' => array('filterValues' => $ruleDataSet, 'blanks' => $blanks) 'arguments' => array('filterValues' => $ruleDataSet, 'blanks' => $blanks)
); );
} else { } else {
@ -672,7 +664,7 @@ class PHPExcel_Worksheet_AutoFilter
$arguments['time'] = array_filter($arguments['time']); $arguments['time'] = array_filter($arguments['time']);
$arguments['dateTime'] = array_filter($arguments['dateTime']); $arguments['dateTime'] = array_filter($arguments['dateTime']);
$columnFilterTests[$columnID] = array( $columnFilterTests[$columnID] = array(
'method' => '_filterTestInDateGroupSet', 'method' => 'filterTestInDateGroupSet',
'arguments' => array('filterValues' => $arguments, 'blanks' => $blanks) 'arguments' => array('filterValues' => $arguments, 'blanks' => $blanks)
); );
} }
@ -687,7 +679,7 @@ class PHPExcel_Worksheet_AutoFilter
if (!is_numeric($ruleValue)) { if (!is_numeric($ruleValue)) {
// Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards // Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards
$ruleValue = preg_quote($ruleValue); $ruleValue = preg_quote($ruleValue);
$ruleValue = str_replace(self::$_fromReplace, self::$_toReplace, $ruleValue); $ruleValue = str_replace(self::$fromReplace, self::$toReplace, $ruleValue);
if (trim($ruleValue) == '') { if (trim($ruleValue) == '') {
$customRuleForBlanks = true; $customRuleForBlanks = true;
$ruleValue = trim($ruleValue); $ruleValue = trim($ruleValue);
@ -697,7 +689,7 @@ class PHPExcel_Worksheet_AutoFilter
} }
$join = $filterColumn->getJoin(); $join = $filterColumn->getJoin();
$columnFilterTests[$columnID] = array( $columnFilterTests[$columnID] = array(
'method' => '_filterTestInCustomDataSet', 'method' => 'filterTestInCustomDataSet',
'arguments' => array('filterRules' => $ruleValues, 'join' => $join, 'customRuleForBlanks' => $customRuleForBlanks) 'arguments' => array('filterRules' => $ruleValues, 'join' => $join, 'customRuleForBlanks' => $customRuleForBlanks)
); );
break; break;
@ -711,7 +703,7 @@ class PHPExcel_Worksheet_AutoFilter
// Number (Average) based // Number (Average) based
// Calculate the average // Calculate the average
$averageFormula = '=AVERAGE('.$columnID.($rangeStart[1]+1).':'.$columnID.$rangeEnd[1].')'; $averageFormula = '=AVERAGE('.$columnID.($rangeStart[1]+1).':'.$columnID.$rangeEnd[1].')';
$average = PHPExcel_Calculation::getInstance()->calculateFormula($averageFormula, null, $this->_workSheet->getCell('A1')); $average = PHPExcel_Calculation::getInstance()->calculateFormula($averageFormula, null, $this->workSheet->getCell('A1'));
// Set above/below rule based on greaterThan or LessTan // Set above/below rule based on greaterThan or LessTan
$operator = ($dynamicRuleType === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) $operator = ($dynamicRuleType === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE)
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN
@ -720,7 +712,7 @@ class PHPExcel_Worksheet_AutoFilter
'value' => $average 'value' => $average
); );
$columnFilterTests[$columnID] = array( $columnFilterTests[$columnID] = array(
'method' => '_filterTestInCustomDataSet', 'method' => 'filterTestInCustomDataSet',
'arguments' => array('filterRules' => $ruleValues, 'join' => PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR) 'arguments' => array('filterRules' => $ruleValues, 'join' => PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR)
); );
} else { } else {
@ -737,13 +729,13 @@ class PHPExcel_Worksheet_AutoFilter
$ruleValues = range($periodStart, $periodEnd); $ruleValues = range($periodStart, $periodEnd);
} }
$columnFilterTests[$columnID] = array( $columnFilterTests[$columnID] = array(
'method' => '_filterTestInPeriodDateSet', 'method' => 'filterTestInPeriodDateSet',
'arguments' => $ruleValues 'arguments' => $ruleValues
); );
$filterColumn->setAttributes(array()); $filterColumn->setAttributes(array());
} else { } else {
// Date Range // Date Range
$columnFilterTests[$columnID] = $this->_dynamicFilterDateRange($dynamicRuleType, $filterColumn); $columnFilterTests[$columnID] = $this->dynamicFilterDateRange($dynamicRuleType, $filterColumn);
break; break;
} }
} }
@ -768,14 +760,14 @@ class PHPExcel_Worksheet_AutoFilter
$ruleValue = 500; $ruleValue = 500;
} }
$maxVal = $this->_calculateTopTenValue($columnID, $rangeStart[1]+1, $rangeEnd[1], $toptenRuleType, $ruleValue); $maxVal = $this->calculateTopTenValue($columnID, $rangeStart[1]+1, $rangeEnd[1], $toptenRuleType, $ruleValue);
$operator = ($toptenRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) $operator = ($toptenRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP)
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL
: PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL; : PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL;
$ruleValues[] = array('operator' => $operator, 'value' => $maxVal); $ruleValues[] = array('operator' => $operator, 'value' => $maxVal);
$columnFilterTests[$columnID] = array( $columnFilterTests[$columnID] = array(
'method' => '_filterTestInCustomDataSet', 'method' => 'filterTestInCustomDataSet',
'arguments' => array('filterRules' => $ruleValues, 'join' => PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR) 'arguments' => array('filterRules' => $ruleValues, 'join' => PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR)
); );
$filterColumn->setAttributes(array('maxVal' => $maxVal)); $filterColumn->setAttributes(array('maxVal' => $maxVal));
@ -792,7 +784,7 @@ class PHPExcel_Worksheet_AutoFilter
$result = true; $result = true;
foreach ($columnFilterTests as $columnID => $columnFilterTest) { foreach ($columnFilterTests as $columnID => $columnFilterTest) {
// echo 'Testing cell ', $columnID.$row,PHP_EOL; // echo 'Testing cell ', $columnID.$row,PHP_EOL;
$cellValue = $this->_workSheet->getCell($columnID.$row)->getCalculatedValue(); $cellValue = $this->workSheet->getCell($columnID.$row)->getCalculatedValue();
// echo 'Value is ', $cellValue,PHP_EOL; // echo 'Value is ', $cellValue,PHP_EOL;
// Execute the filter test // Execute the filter test
$result = $result && $result = $result &&
@ -808,7 +800,7 @@ class PHPExcel_Worksheet_AutoFilter
} }
// Set show/hide for the row based on the result of the autoFilter result // Set show/hide for the row based on the result of the autoFilter result
// echo (($result) ? 'SHOW' : 'HIDE'),PHP_EOL; // echo (($result) ? 'SHOW' : 'HIDE'),PHP_EOL;
$this->_workSheet->getRowDimension($row)->setVisible($result); $this->workSheet->getRowDimension($row)->setVisible($result);
} }
return $this; return $this;
@ -823,13 +815,13 @@ class PHPExcel_Worksheet_AutoFilter
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {
if ($key == '_workSheet') { if ($key == 'workSheet') {
// Detach from worksheet // Detach from worksheet
$this->{$key} = null; $this->{$key} = null;
} else { } else {
$this->{$key} = clone $value; $this->{$key} = clone $value;
} }
} elseif ((is_array($value)) && ($key == '_columns')) { } elseif ((is_array($value)) && ($key == 'columns')) {
// The columns array of PHPExcel_Worksheet_AutoFilter objects // The columns array of PHPExcel_Worksheet_AutoFilter objects
$this->{$key} = array(); $this->{$key} = array();
foreach ($value as $k => $v) { foreach ($value as $k => $v) {
@ -849,6 +841,6 @@ class PHPExcel_Worksheet_AutoFilter
*/ */
public function __toString() public function __toString()
{ {
return (string) $this->_range; return (string) $this->range;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_AutoFilter_Column
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,32 +25,23 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_AutoFilter_Column
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_AutoFilter_Column class PHPExcel_Worksheet_AutoFilter_Column
{ {
const AUTOFILTER_FILTERTYPE_FILTER = 'filters'; const AUTOFILTER_FILTERTYPE_FILTER = 'filters';
const AUTOFILTER_FILTERTYPE_CUSTOMFILTER = 'customFilters'; const AUTOFILTER_FILTERTYPE_CUSTOMFILTER = 'customFilters';
// Supports no more than 2 rules, with an And/Or join criteria // Supports no more than 2 rules, with an And/Or join criteria
// if more than 1 rule is defined // if more than 1 rule is defined
const AUTOFILTER_FILTERTYPE_DYNAMICFILTER = 'dynamicFilter'; const AUTOFILTER_FILTERTYPE_DYNAMICFILTER = 'dynamicFilter';
// Even though the filter rule is constant, the filtered data can vary // Even though the filter rule is constant, the filtered data can vary
// e.g. filtered by date = TODAY // e.g. filtered by date = TODAY
const AUTOFILTER_FILTERTYPE_TOPTENFILTER = 'top10'; const AUTOFILTER_FILTERTYPE_TOPTENFILTER = 'top10';
/** /**
* Types of autofilter rules * Types of autofilter rules
* *
* @var string[] * @var string[]
*/ */
private static $_filterTypes = array( private static $filterTypes = array(
// Currently we're not handling // Currently we're not handling
// colorFilter // colorFilter
// extLst // extLst
@ -61,15 +53,15 @@ class PHPExcel_Worksheet_AutoFilter_Column
); );
/* Multiple Rule Connections */ /* Multiple Rule Connections */
const AUTOFILTER_COLUMN_JOIN_AND = 'and'; const AUTOFILTER_COLUMN_JOIN_AND = 'and';
const AUTOFILTER_COLUMN_JOIN_OR = 'or'; const AUTOFILTER_COLUMN_JOIN_OR = 'or';
/** /**
* Join options for autofilter rules * Join options for autofilter rules
* *
* @var string[] * @var string[]
*/ */
private static $_ruleJoins = array( private static $ruleJoins = array(
self::AUTOFILTER_COLUMN_JOIN_AND, self::AUTOFILTER_COLUMN_JOIN_AND,
self::AUTOFILTER_COLUMN_JOIN_OR, self::AUTOFILTER_COLUMN_JOIN_OR,
); );
@ -79,7 +71,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @var PHPExcel_Worksheet_AutoFilter * @var PHPExcel_Worksheet_AutoFilter
*/ */
private $_parent = null; private $parent;
/** /**
@ -87,7 +79,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @var string * @var string
*/ */
private $_columnIndex = ''; private $columnIndex = '';
/** /**
@ -95,7 +87,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @var string * @var string
*/ */
private $_filterType = self::AUTOFILTER_FILTERTYPE_FILTER; private $filterType = self::AUTOFILTER_FILTERTYPE_FILTER;
/** /**
@ -103,7 +95,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @var string * @var string
*/ */
private $_join = self::AUTOFILTER_COLUMN_JOIN_OR; private $join = self::AUTOFILTER_COLUMN_JOIN_OR;
/** /**
@ -111,7 +103,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @var array of PHPExcel_Worksheet_AutoFilter_Column_Rule * @var array of PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
private $_ruleset = array(); private $ruleset = array();
/** /**
@ -119,7 +111,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
* *
* @var array of mixed * @var array of mixed
*/ */
private $_attributes = array(); private $attributes = array();
/** /**
@ -130,8 +122,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function __construct($pColumn, PHPExcel_Worksheet_AutoFilter $pParent = null) public function __construct($pColumn, PHPExcel_Worksheet_AutoFilter $pParent = null)
{ {
$this->_columnIndex = $pColumn; $this->columnIndex = $pColumn;
$this->_parent = $pParent; $this->parent = $pParent;
} }
/** /**
@ -141,7 +133,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function getColumnIndex() public function getColumnIndex()
{ {
return $this->_columnIndex; return $this->columnIndex;
} }
/** /**
@ -155,11 +147,11 @@ class PHPExcel_Worksheet_AutoFilter_Column
{ {
// Uppercase coordinate // Uppercase coordinate
$pColumn = strtoupper($pColumn); $pColumn = strtoupper($pColumn);
if ($this->_parent !== null) { if ($this->parent !== null) {
$this->_parent->testColumnInRange($pColumn); $this->parent->testColumnInRange($pColumn);
} }
$this->_columnIndex = $pColumn; $this->columnIndex = $pColumn;
return $this; return $this;
} }
@ -171,7 +163,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function getParent() public function getParent()
{ {
return $this->_parent; return $this->parent;
} }
/** /**
@ -182,7 +174,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function setParent(PHPExcel_Worksheet_AutoFilter $pParent = null) public function setParent(PHPExcel_Worksheet_AutoFilter $pParent = null)
{ {
$this->_parent = $pParent; $this->parent = $pParent;
return $this; return $this;
} }
@ -194,7 +186,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function getFilterType() public function getFilterType()
{ {
return $this->_filterType; return $this->filterType;
} }
/** /**
@ -206,11 +198,11 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function setFilterType($pFilterType = self::AUTOFILTER_FILTERTYPE_FILTER) public function setFilterType($pFilterType = self::AUTOFILTER_FILTERTYPE_FILTER)
{ {
if (!in_array($pFilterType, self::$_filterTypes)) { if (!in_array($pFilterType, self::$filterTypes)) {
throw new PHPExcel_Exception('Invalid filter type for column AutoFilter.'); throw new PHPExcel_Exception('Invalid filter type for column AutoFilter.');
} }
$this->_filterType = $pFilterType; $this->filterType = $pFilterType;
return $this; return $this;
} }
@ -222,7 +214,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function getJoin() public function getJoin()
{ {
return $this->_join; return $this->join;
} }
/** /**
@ -236,11 +228,11 @@ class PHPExcel_Worksheet_AutoFilter_Column
{ {
// Lowercase And/Or // Lowercase And/Or
$pJoin = strtolower($pJoin); $pJoin = strtolower($pJoin);
if (!in_array($pJoin, self::$_ruleJoins)) { if (!in_array($pJoin, self::$ruleJoins)) {
throw new PHPExcel_Exception('Invalid rule connection for column AutoFilter.'); throw new PHPExcel_Exception('Invalid rule connection for column AutoFilter.');
} }
$this->_join = $pJoin; $this->join = $pJoin;
return $this; return $this;
} }
@ -254,7 +246,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function setAttributes($pAttributes = array()) public function setAttributes($pAttributes = array())
{ {
$this->_attributes = $pAttributes; $this->attributes = $pAttributes;
return $this; return $this;
} }
@ -269,7 +261,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function setAttribute($pName, $pValue) public function setAttribute($pName, $pValue)
{ {
$this->_attributes[$pName] = $pValue; $this->attributes[$pName] = $pValue;
return $this; return $this;
} }
@ -281,7 +273,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function getAttributes() public function getAttributes()
{ {
return $this->_attributes; return $this->attributes;
} }
/** /**
@ -292,8 +284,8 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function getAttribute($pName) public function getAttribute($pName)
{ {
if (isset($this->_attributes[$pName])) { if (isset($this->attributes[$pName])) {
return $this->_attributes[$pName]; return $this->attributes[$pName];
} }
return null; return null;
} }
@ -306,7 +298,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function getRules() public function getRules()
{ {
return $this->_ruleset; return $this->ruleset;
} }
/** /**
@ -317,10 +309,10 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function getRule($pIndex) public function getRule($pIndex)
{ {
if (!isset($this->_ruleset[$pIndex])) { if (!isset($this->ruleset[$pIndex])) {
$this->_ruleset[$pIndex] = new PHPExcel_Worksheet_AutoFilter_Column_Rule($this); $this->ruleset[$pIndex] = new PHPExcel_Worksheet_AutoFilter_Column_Rule($this);
} }
return $this->_ruleset[$pIndex]; return $this->ruleset[$pIndex];
} }
/** /**
@ -330,9 +322,9 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function createRule() public function createRule()
{ {
$this->_ruleset[] = new PHPExcel_Worksheet_AutoFilter_Column_Rule($this); $this->ruleset[] = new PHPExcel_Worksheet_AutoFilter_Column_Rule($this);
return end($this->_ruleset); return end($this->ruleset);
} }
/** /**
@ -345,7 +337,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
public function addRule(PHPExcel_Worksheet_AutoFilter_Column_Rule $pRule, $returnRule = true) public function addRule(PHPExcel_Worksheet_AutoFilter_Column_Rule $pRule, $returnRule = true)
{ {
$pRule->setParent($this); $pRule->setParent($this);
$this->_ruleset[] = $pRule; $this->ruleset[] = $pRule;
return ($returnRule) ? $pRule : $this; return ($returnRule) ? $pRule : $this;
} }
@ -359,10 +351,10 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function deleteRule($pIndex) public function deleteRule($pIndex)
{ {
if (isset($this->_ruleset[$pIndex])) { if (isset($this->ruleset[$pIndex])) {
unset($this->_ruleset[$pIndex]); unset($this->ruleset[$pIndex]);
// If we've just deleted down to a single rule, then reset And/Or joining to Or // If we've just deleted down to a single rule, then reset And/Or joining to Or
if (count($this->_ruleset) <= 1) { if (count($this->ruleset) <= 1) {
$this->setJoin(self::AUTOFILTER_COLUMN_JOIN_OR); $this->setJoin(self::AUTOFILTER_COLUMN_JOIN_OR);
} }
} }
@ -377,7 +369,7 @@ class PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function clearRules() public function clearRules()
{ {
$this->_ruleset = array(); $this->ruleset = array();
$this->setJoin(self::AUTOFILTER_COLUMN_JOIN_OR); $this->setJoin(self::AUTOFILTER_COLUMN_JOIN_OR);
return $this; return $this;
@ -391,13 +383,13 @@ class PHPExcel_Worksheet_AutoFilter_Column
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {
if ($key == '_parent') { if ($key == 'parent') {
// Detach from autofilter parent // Detach from autofilter parent
$this->$key = null; $this->$key = null;
} else { } else {
$this->$key = clone $value; $this->$key = clone $value;
} }
} elseif ((is_array($value)) && ($key == '_ruleset')) { } elseif ((is_array($value)) && ($key == 'ruleset')) {
// The columns array of PHPExcel_Worksheet_AutoFilter objects // The columns array of PHPExcel_Worksheet_AutoFilter objects
$this->$key = array(); $this->$key = array();
foreach ($value as $k => $v) { foreach ($value as $k => $v) {

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_AutoFilter_Column_Rule
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,24 +25,15 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_AutoFilter_Column_Rule
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_AutoFilter_Column_Rule class PHPExcel_Worksheet_AutoFilter_Column_Rule
{ {
const AUTOFILTER_RULETYPE_FILTER = 'filter'; const AUTOFILTER_RULETYPE_FILTER = 'filter';
const AUTOFILTER_RULETYPE_DATEGROUP = 'dateGroupItem'; const AUTOFILTER_RULETYPE_DATEGROUP = 'dateGroupItem';
const AUTOFILTER_RULETYPE_CUSTOMFILTER = 'customFilter'; const AUTOFILTER_RULETYPE_CUSTOMFILTER = 'customFilter';
const AUTOFILTER_RULETYPE_DYNAMICFILTER = 'dynamicFilter'; const AUTOFILTER_RULETYPE_DYNAMICFILTER = 'dynamicFilter';
const AUTOFILTER_RULETYPE_TOPTENFILTER = 'top10Filter'; const AUTOFILTER_RULETYPE_TOPTENFILTER = 'top10Filter';
private static $_ruleTypes = array( private static $ruleTypes = array(
// Currently we're not handling // Currently we're not handling
// colorFilter // colorFilter
// extLst // extLst
@ -53,14 +45,14 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
self::AUTOFILTER_RULETYPE_TOPTENFILTER, self::AUTOFILTER_RULETYPE_TOPTENFILTER,
); );
const AUTOFILTER_RULETYPE_DATEGROUP_YEAR = 'year'; const AUTOFILTER_RULETYPE_DATEGROUP_YEAR = 'year';
const AUTOFILTER_RULETYPE_DATEGROUP_MONTH = 'month'; const AUTOFILTER_RULETYPE_DATEGROUP_MONTH = 'month';
const AUTOFILTER_RULETYPE_DATEGROUP_DAY = 'day'; const AUTOFILTER_RULETYPE_DATEGROUP_DAY = 'day';
const AUTOFILTER_RULETYPE_DATEGROUP_HOUR = 'hour'; const AUTOFILTER_RULETYPE_DATEGROUP_HOUR = 'hour';
const AUTOFILTER_RULETYPE_DATEGROUP_MINUTE = 'minute'; const AUTOFILTER_RULETYPE_DATEGROUP_MINUTE = 'minute';
const AUTOFILTER_RULETYPE_DATEGROUP_SECOND = 'second'; const AUTOFILTER_RULETYPE_DATEGROUP_SECOND = 'second';
private static $_dateTimeGroups = array( private static $dateTimeGroups = array(
self::AUTOFILTER_RULETYPE_DATEGROUP_YEAR, self::AUTOFILTER_RULETYPE_DATEGROUP_YEAR,
self::AUTOFILTER_RULETYPE_DATEGROUP_MONTH, self::AUTOFILTER_RULETYPE_DATEGROUP_MONTH,
self::AUTOFILTER_RULETYPE_DATEGROUP_DAY, self::AUTOFILTER_RULETYPE_DATEGROUP_DAY,
@ -69,54 +61,54 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
self::AUTOFILTER_RULETYPE_DATEGROUP_SECOND, self::AUTOFILTER_RULETYPE_DATEGROUP_SECOND,
); );
const AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY = 'yesterday'; const AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY = 'yesterday';
const AUTOFILTER_RULETYPE_DYNAMIC_TODAY = 'today'; const AUTOFILTER_RULETYPE_DYNAMIC_TODAY = 'today';
const AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW = 'tomorrow'; const AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW = 'tomorrow';
const AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE = 'yearToDate'; const AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE = 'yearToDate';
const AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR = 'thisYear'; const AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR = 'thisYear';
const AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER = 'thisQuarter'; const AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER = 'thisQuarter';
const AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH = 'thisMonth'; const AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH = 'thisMonth';
const AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK = 'thisWeek'; const AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK = 'thisWeek';
const AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR = 'lastYear'; const AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR = 'lastYear';
const AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER = 'lastQuarter'; const AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER = 'lastQuarter';
const AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH = 'lastMonth'; const AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH = 'lastMonth';
const AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK = 'lastWeek'; const AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK = 'lastWeek';
const AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR = 'nextYear'; const AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR = 'nextYear';
const AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER = 'nextQuarter'; const AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER = 'nextQuarter';
const AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH = 'nextMonth'; const AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH = 'nextMonth';
const AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK = 'nextWeek'; const AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK = 'nextWeek';
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_1 = 'M1'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_1 = 'M1';
const AUTOFILTER_RULETYPE_DYNAMIC_JANUARY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_1; const AUTOFILTER_RULETYPE_DYNAMIC_JANUARY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_1;
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_2 = 'M2'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_2 = 'M2';
const AUTOFILTER_RULETYPE_DYNAMIC_FEBRUARY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_2; const AUTOFILTER_RULETYPE_DYNAMIC_FEBRUARY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_2;
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_3 = 'M3'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_3 = 'M3';
const AUTOFILTER_RULETYPE_DYNAMIC_MARCH = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_3; const AUTOFILTER_RULETYPE_DYNAMIC_MARCH = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_3;
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_4 = 'M4'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_4 = 'M4';
const AUTOFILTER_RULETYPE_DYNAMIC_APRIL = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_4; const AUTOFILTER_RULETYPE_DYNAMIC_APRIL = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_4;
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_5 = 'M5'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_5 = 'M5';
const AUTOFILTER_RULETYPE_DYNAMIC_MAY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_5; const AUTOFILTER_RULETYPE_DYNAMIC_MAY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_5;
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_6 = 'M6'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_6 = 'M6';
const AUTOFILTER_RULETYPE_DYNAMIC_JUNE = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_6; const AUTOFILTER_RULETYPE_DYNAMIC_JUNE = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_6;
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_7 = 'M7'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_7 = 'M7';
const AUTOFILTER_RULETYPE_DYNAMIC_JULY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_7; const AUTOFILTER_RULETYPE_DYNAMIC_JULY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_7;
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_8 = 'M8'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_8 = 'M8';
const AUTOFILTER_RULETYPE_DYNAMIC_AUGUST = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_8; const AUTOFILTER_RULETYPE_DYNAMIC_AUGUST = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_8;
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_9 = 'M9'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_9 = 'M9';
const AUTOFILTER_RULETYPE_DYNAMIC_SEPTEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_9; const AUTOFILTER_RULETYPE_DYNAMIC_SEPTEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_9;
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_10 = 'M10'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_10 = 'M10';
const AUTOFILTER_RULETYPE_DYNAMIC_OCTOBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_10; const AUTOFILTER_RULETYPE_DYNAMIC_OCTOBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_10;
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_11 = 'M11'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_11 = 'M11';
const AUTOFILTER_RULETYPE_DYNAMIC_NOVEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_11; const AUTOFILTER_RULETYPE_DYNAMIC_NOVEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_11;
const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_12 = 'M12'; const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_12 = 'M12';
const AUTOFILTER_RULETYPE_DYNAMIC_DECEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_12; const AUTOFILTER_RULETYPE_DYNAMIC_DECEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_12;
const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_1 = 'Q1'; const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_1 = 'Q1';
const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_2 = 'Q2'; const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_2 = 'Q2';
const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_3 = 'Q3'; const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_3 = 'Q3';
const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_4 = 'Q4'; const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_4 = 'Q4';
const AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE = 'aboveAverage'; const AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE = 'aboveAverage';
const AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE = 'belowAverage'; const AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE = 'belowAverage';
private static $_dynamicTypes = array( private static $dynamicTypes = array(
self::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY, self::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY,
self::AUTOFILTER_RULETYPE_DYNAMIC_TODAY, self::AUTOFILTER_RULETYPE_DYNAMIC_TODAY,
self::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW, self::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW,
@ -162,14 +154,14 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* <xsd:enumeration value="greaterThanOrEqual"/> * <xsd:enumeration value="greaterThanOrEqual"/>
* <xsd:enumeration value="greaterThan"/> * <xsd:enumeration value="greaterThan"/>
*/ */
const AUTOFILTER_COLUMN_RULE_EQUAL = 'equal'; const AUTOFILTER_COLUMN_RULE_EQUAL = 'equal';
const AUTOFILTER_COLUMN_RULE_NOTEQUAL = 'notEqual'; const AUTOFILTER_COLUMN_RULE_NOTEQUAL = 'notEqual';
const AUTOFILTER_COLUMN_RULE_GREATERTHAN = 'greaterThan'; const AUTOFILTER_COLUMN_RULE_GREATERTHAN = 'greaterThan';
const AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL = 'greaterThanOrEqual'; const AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL = 'greaterThanOrEqual';
const AUTOFILTER_COLUMN_RULE_LESSTHAN = 'lessThan'; const AUTOFILTER_COLUMN_RULE_LESSTHAN = 'lessThan';
const AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL = 'lessThanOrEqual'; const AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL = 'lessThanOrEqual';
private static $_operators = array( private static $operators = array(
self::AUTOFILTER_COLUMN_RULE_EQUAL, self::AUTOFILTER_COLUMN_RULE_EQUAL,
self::AUTOFILTER_COLUMN_RULE_NOTEQUAL, self::AUTOFILTER_COLUMN_RULE_NOTEQUAL,
self::AUTOFILTER_COLUMN_RULE_GREATERTHAN, self::AUTOFILTER_COLUMN_RULE_GREATERTHAN,
@ -178,18 +170,18 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
self::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL, self::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL,
); );
const AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE = 'byValue'; const AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE = 'byValue';
const AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT = 'byPercent'; const AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT = 'byPercent';
private static $_topTenValue = array( private static $topTenValue = array(
self::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE, self::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE,
self::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT, self::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT,
); );
const AUTOFILTER_COLUMN_RULE_TOPTEN_TOP = 'top'; const AUTOFILTER_COLUMN_RULE_TOPTEN_TOP = 'top';
const AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM = 'bottom'; const AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM = 'bottom';
private static $_topTenType = array( private static $topTenType = array(
self::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP, self::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP,
self::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM, self::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM,
); );
@ -234,7 +226,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* *
* @var PHPExcel_Worksheet_AutoFilter_Column * @var PHPExcel_Worksheet_AutoFilter_Column
*/ */
private $_parent = null; private $parent = null;
/** /**
@ -242,7 +234,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* *
* @var string * @var string
*/ */
private $_ruleType = self::AUTOFILTER_RULETYPE_FILTER; private $ruleType = self::AUTOFILTER_RULETYPE_FILTER;
/** /**
@ -250,21 +242,21 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
* *
* @var string * @var string
*/ */
private $_value = ''; private $value = '';
/** /**
* Autofilter Rule Operator * Autofilter Rule Operator
* *
* @var string * @var string
*/ */
private $_operator = self::AUTOFILTER_COLUMN_RULE_EQUAL; private $operator = self::AUTOFILTER_COLUMN_RULE_EQUAL;
/** /**
* DateTimeGrouping Group Value * DateTimeGrouping Group Value
* *
* @var string * @var string
*/ */
private $_grouping = ''; private $grouping = '';
/** /**
@ -274,7 +266,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function __construct(PHPExcel_Worksheet_AutoFilter_Column $pParent = null) public function __construct(PHPExcel_Worksheet_AutoFilter_Column $pParent = null)
{ {
$this->_parent = $pParent; $this->parent = $pParent;
} }
/** /**
@ -284,7 +276,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function getRuleType() public function getRuleType()
{ {
return $this->_ruleType; return $this->ruleType;
} }
/** /**
@ -296,11 +288,11 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function setRuleType($pRuleType = self::AUTOFILTER_RULETYPE_FILTER) public function setRuleType($pRuleType = self::AUTOFILTER_RULETYPE_FILTER)
{ {
if (!in_array($pRuleType, self::$_ruleTypes)) { if (!in_array($pRuleType, self::$ruleTypes)) {
throw new PHPExcel_Exception('Invalid rule type for column AutoFilter Rule.'); throw new PHPExcel_Exception('Invalid rule type for column AutoFilter Rule.');
} }
$this->_ruleType = $pRuleType; $this->ruleType = $pRuleType;
return $this; return $this;
} }
@ -312,7 +304,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function getValue() public function getValue()
{ {
return $this->_value; return $this->value;
} }
/** /**
@ -328,21 +320,21 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
$grouping = -1; $grouping = -1;
foreach ($pValue as $key => $value) { foreach ($pValue as $key => $value) {
// Validate array entries // Validate array entries
if (!in_array($key, self::$_dateTimeGroups)) { if (!in_array($key, self::$dateTimeGroups)) {
// Remove any invalid entries from the value array // Remove any invalid entries from the value array
unset($pValue[$key]); unset($pValue[$key]);
} else { } else {
// Work out what the dateTime grouping will be // Work out what the dateTime grouping will be
$grouping = max($grouping, array_search($key, self::$_dateTimeGroups)); $grouping = max($grouping, array_search($key, self::$dateTimeGroups));
} }
} }
if (count($pValue) == 0) { if (count($pValue) == 0) {
throw new PHPExcel_Exception('Invalid rule value for column AutoFilter Rule.'); throw new PHPExcel_Exception('Invalid rule value for column AutoFilter Rule.');
} }
// Set the dateTime grouping that we've anticipated // Set the dateTime grouping that we've anticipated
$this->setGrouping(self::$_dateTimeGroups[$grouping]); $this->setGrouping(self::$dateTimeGroups[$grouping]);
} }
$this->_value = $pValue; $this->value = $pValue;
return $this; return $this;
} }
@ -354,7 +346,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function getOperator() public function getOperator()
{ {
return $this->_operator; return $this->operator;
} }
/** /**
@ -369,11 +361,11 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
if (empty($pOperator)) { if (empty($pOperator)) {
$pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL; $pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL;
} }
if ((!in_array($pOperator, self::$_operators)) && if ((!in_array($pOperator, self::$operators)) &&
(!in_array($pOperator, self::$_topTenValue))) { (!in_array($pOperator, self::$topTenValue))) {
throw new PHPExcel_Exception('Invalid operator for column AutoFilter Rule.'); throw new PHPExcel_Exception('Invalid operator for column AutoFilter Rule.');
} }
$this->_operator = $pOperator; $this->operator = $pOperator;
return $this; return $this;
} }
@ -385,7 +377,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function getGrouping() public function getGrouping()
{ {
return $this->_grouping; return $this->grouping;
} }
/** /**
@ -398,12 +390,12 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
public function setGrouping($pGrouping = null) public function setGrouping($pGrouping = null)
{ {
if (($pGrouping !== null) && if (($pGrouping !== null) &&
(!in_array($pGrouping, self::$_dateTimeGroups)) && (!in_array($pGrouping, self::$dateTimeGroups)) &&
(!in_array($pGrouping, self::$_dynamicTypes)) && (!in_array($pGrouping, self::$dynamicTypes)) &&
(!in_array($pGrouping, self::$_topTenType))) { (!in_array($pGrouping, self::$topTenType))) {
throw new PHPExcel_Exception('Invalid rule type for column AutoFilter Rule.'); throw new PHPExcel_Exception('Invalid rule type for column AutoFilter Rule.');
} }
$this->_grouping = $pGrouping; $this->grouping = $pGrouping;
return $this; return $this;
} }
@ -438,7 +430,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function getParent() public function getParent()
{ {
return $this->_parent; return $this->parent;
} }
/** /**
@ -449,7 +441,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
*/ */
public function setParent(PHPExcel_Worksheet_AutoFilter_Column $pParent = null) public function setParent(PHPExcel_Worksheet_AutoFilter_Column $pParent = null)
{ {
$this->_parent = $pParent; $this->parent = $pParent;
return $this; return $this;
} }
@ -462,7 +454,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {
if ($key == '_parent') { if ($key == 'parent') {
// Detach from autofilter column parent // Detach from autofilter column parent
$this->$key = null; $this->$key = null;
} else { } else {

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_BaseDrawing
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_BaseDrawing
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
{ {
/** /**
@ -40,14 +32,14 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* *
* @var int * @var int
*/ */
private static $_imageCounter = 0; private static $imageCounter = 0;
/** /**
* Image index * Image index
* *
* @var int * @var int
*/ */
private $_imageIndex = 0; private $imageIndex = 0;
/** /**
* Name * Name
@ -145,8 +137,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_shadow = new PHPExcel_Worksheet_Drawing_Shadow(); $this->_shadow = new PHPExcel_Worksheet_Drawing_Shadow();
// Set image index // Set image index
self::$_imageCounter++; self::$imageCounter++;
$this->_imageIndex = self::$_imageCounter; $this->imageIndex = self::$imageCounter;
} }
/** /**
@ -156,7 +148,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getImageIndex() public function getImageIndex()
{ {
return $this->_imageIndex; return $this->imageIndex;
} }
/** /**
@ -483,7 +475,19 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/ */
public function getHashCode() public function getHashCode()
{ {
return md5($this->_name.$this->_description.$this->_worksheet->getHashCode().$this->_coordinates.$this->_offsetX.$this->_offsetY.$this->_width.$this->_height.$this->_rotation.$this->_shadow->getHashCode().__CLASS__); return md5(
$this->_name .
$this->_description .
$this->_worksheet->getHashCode() .
$this->_coordinates .
$this->_offsetX .
$this->_offsetY .
$this->_width .
$this->_height .
$this->_rotation .
$this->_shadow->getHashCode() .
__CLASS__
);
} }
/** /**

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_Drawing
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_Drawing
*
* @category PHPExcel
* @package PHPExcel_Worksheet_Drawing
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
{ {
/** /**
@ -40,7 +32,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
* *
* @var string * @var string
*/ */
private $_path; private $path;
/** /**
* Create a new PHPExcel_Worksheet_Drawing * Create a new PHPExcel_Worksheet_Drawing
@ -48,7 +40,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
public function __construct() public function __construct()
{ {
// Initialise values // Initialise values
$this->_path = ''; $this->path = '';
// Initialize parent // Initialize parent
parent::__construct(); parent::__construct();
@ -61,7 +53,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
*/ */
public function getFilename() public function getFilename()
{ {
return basename($this->_path); return basename($this->path);
} }
/** /**
@ -83,7 +75,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
*/ */
public function getExtension() public function getExtension()
{ {
$exploded = explode(".", basename($this->_path)); $exploded = explode(".", basename($this->path));
return $exploded[count($exploded) - 1]; return $exploded[count($exploded) - 1];
} }
@ -94,7 +86,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
*/ */
public function getPath() public function getPath()
{ {
return $this->_path; return $this->path;
} }
/** /**
@ -109,7 +101,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
{ {
if ($pVerifyFile) { if ($pVerifyFile) {
if (file_exists($pValue)) { if (file_exists($pValue)) {
$this->_path = $pValue; $this->path = $pValue;
if ($this->_width == 0 && $this->_height == 0) { if ($this->_width == 0 && $this->_height == 0) {
// Get width/height // Get width/height
@ -119,7 +111,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
throw new PHPExcel_Exception("File $pValue not found!"); throw new PHPExcel_Exception("File $pValue not found!");
} }
} else { } else {
$this->_path = $pValue; $this->path = $pValue;
} }
return $this; return $this;
} }
@ -132,9 +124,9 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
public function getHashCode() public function getHashCode()
{ {
return md5( return md5(
$this->_path $this->path .
. parent::getHashCode() parent::getHashCode() .
. __CLASS__ __CLASS__
); );
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_Drawing_Shadow
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,33 +25,24 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_Drawing_Shadow
*
* @category PHPExcel
* @package PHPExcel_Worksheet_Drawing
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
{ {
/* Shadow alignment */ /* Shadow alignment */
const SHADOW_BOTTOM = 'b'; const SHADOW_BOTTOM = 'b';
const SHADOW_BOTTOM_LEFT = 'bl'; const SHADOW_BOTTOM_LEFT = 'bl';
const SHADOW_BOTTOM_RIGHT = 'br'; const SHADOW_BOTTOM_RIGHT = 'br';
const SHADOW_CENTER = 'ctr'; const SHADOW_CENTER = 'ctr';
const SHADOW_LEFT = 'l'; const SHADOW_LEFT = 'l';
const SHADOW_TOP = 't'; const SHADOW_TOP = 't';
const SHADOW_TOP_LEFT = 'tl'; const SHADOW_TOP_LEFT = 'tl';
const SHADOW_TOP_RIGHT = 'tr'; const SHADOW_TOP_RIGHT = 'tr';
/** /**
* Visible * Visible
* *
* @var boolean * @var boolean
*/ */
private $_visible; private $visible;
/** /**
* Blur radius * Blur radius
@ -59,7 +51,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
* *
* @var int * @var int
*/ */
private $_blurRadius; private $blurRadius;
/** /**
* Shadow distance * Shadow distance
@ -68,35 +60,35 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
* *
* @var int * @var int
*/ */
private $_distance; private $distance;
/** /**
* Shadow direction (in degrees) * Shadow direction (in degrees)
* *
* @var int * @var int
*/ */
private $_direction; private $direction;
/** /**
* Shadow alignment * Shadow alignment
* *
* @var int * @var int
*/ */
private $_alignment; private $alignment;
/** /**
* Color * Color
* *
* @var PHPExcel_Style_Color * @var PHPExcel_Style_Color
*/ */
private $_color; private $color;
/** /**
* Alpha * Alpha
* *
* @var int * @var int
*/ */
private $_alpha; private $alpha;
/** /**
* Create a new PHPExcel_Worksheet_Drawing_Shadow * Create a new PHPExcel_Worksheet_Drawing_Shadow
@ -104,13 +96,13 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function __construct() public function __construct()
{ {
// Initialise values // Initialise values
$this->_visible = false; $this->visible = false;
$this->_blurRadius = 6; $this->blurRadius = 6;
$this->_distance = 2; $this->distance = 2;
$this->_direction = 0; $this->direction = 0;
$this->_alignment = PHPExcel_Worksheet_Drawing_Shadow::SHADOW_BOTTOM_RIGHT; $this->alignment = PHPExcel_Worksheet_Drawing_Shadow::SHADOW_BOTTOM_RIGHT;
$this->_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK); $this->color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK);
$this->_alpha = 50; $this->alpha = 50;
} }
/** /**
@ -120,7 +112,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function getVisible() public function getVisible()
{ {
return $this->_visible; return $this->visible;
} }
/** /**
@ -131,7 +123,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function setVisible($pValue = false) public function setVisible($pValue = false)
{ {
$this->_visible = $pValue; $this->visible = $pValue;
return $this; return $this;
} }
@ -142,7 +134,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function getBlurRadius() public function getBlurRadius()
{ {
return $this->_blurRadius; return $this->blurRadius;
} }
/** /**
@ -153,7 +145,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function setBlurRadius($pValue = 6) public function setBlurRadius($pValue = 6)
{ {
$this->_blurRadius = $pValue; $this->blurRadius = $pValue;
return $this; return $this;
} }
@ -164,7 +156,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function getDistance() public function getDistance()
{ {
return $this->_distance; return $this->distance;
} }
/** /**
@ -175,7 +167,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function setDistance($pValue = 2) public function setDistance($pValue = 2)
{ {
$this->_distance = $pValue; $this->distance = $pValue;
return $this; return $this;
} }
@ -186,7 +178,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function getDirection() public function getDirection()
{ {
return $this->_direction; return $this->direction;
} }
/** /**
@ -197,7 +189,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function setDirection($pValue = 0) public function setDirection($pValue = 0)
{ {
$this->_direction = $pValue; $this->direction = $pValue;
return $this; return $this;
} }
@ -208,7 +200,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function getAlignment() public function getAlignment()
{ {
return $this->_alignment; return $this->alignment;
} }
/** /**
@ -219,7 +211,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function setAlignment($pValue = 0) public function setAlignment($pValue = 0)
{ {
$this->_alignment = $pValue; $this->alignment = $pValue;
return $this; return $this;
} }
@ -230,7 +222,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function getColor() public function getColor()
{ {
return $this->_color; return $this->color;
} }
/** /**
@ -242,7 +234,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function setColor(PHPExcel_Style_Color $pValue = null) public function setColor(PHPExcel_Style_Color $pValue = null)
{ {
$this->_color = $pValue; $this->color = $pValue;
return $this; return $this;
} }
@ -253,7 +245,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function getAlpha() public function getAlpha()
{ {
return $this->_alpha; return $this->alpha;
} }
/** /**
@ -264,7 +256,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
*/ */
public function setAlpha($pValue = 0) public function setAlpha($pValue = 0)
{ {
$this->_alpha = $pValue; $this->alpha = $pValue;
return $this; return $this;
} }
@ -276,14 +268,14 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getHashCode() public function getHashCode()
{ {
return md5( return md5(
($this->_visible ? 't' : 'f') ($this->visible ? 't' : 'f') .
. $this->_blurRadius $this->blurRadius .
. $this->_distance $this->distance .
. $this->_direction $this->direction .
. $this->_alignment $this->alignment .
. $this->_color->getHashCode() $this->color->getHashCode() .
. $this->_alpha $this->alpha .
. __CLASS__ __CLASS__
); );
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_HeaderFooter
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -23,11 +23,6 @@
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_HeaderFooter
* *
* <code> * <code>
* Header/Footer Formatting Syntax taken from Office Open XML Part 4 - Markup Language Reference, page 1970: * Header/Footer Formatting Syntax taken from Office Open XML Part 4 - Markup Language Reference, page 1970:
@ -89,96 +84,93 @@
* &H - code for "shadow style" * &H - code for "shadow style"
* </code> * </code>
* *
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Worksheet_HeaderFooter class PHPExcel_Worksheet_HeaderFooter
{ {
/* Header/footer image location */ /* Header/footer image location */
const IMAGE_HEADER_LEFT = 'LH'; const IMAGE_HEADER_LEFT = 'LH';
const IMAGE_HEADER_CENTER = 'CH'; const IMAGE_HEADER_CENTER = 'CH';
const IMAGE_HEADER_RIGHT = 'RH'; const IMAGE_HEADER_RIGHT = 'RH';
const IMAGE_FOOTER_LEFT = 'LF'; const IMAGE_FOOTER_LEFT = 'LF';
const IMAGE_FOOTER_CENTER = 'CF'; const IMAGE_FOOTER_CENTER = 'CF';
const IMAGE_FOOTER_RIGHT = 'RF'; const IMAGE_FOOTER_RIGHT = 'RF';
/** /**
* OddHeader * OddHeader
* *
* @var string * @var string
*/ */
private $_oddHeader = ''; private $oddHeader = '';
/** /**
* OddFooter * OddFooter
* *
* @var string * @var string
*/ */
private $_oddFooter = ''; private $oddFooter = '';
/** /**
* EvenHeader * EvenHeader
* *
* @var string * @var string
*/ */
private $_evenHeader = ''; private $evenHeader = '';
/** /**
* EvenFooter * EvenFooter
* *
* @var string * @var string
*/ */
private $_evenFooter = ''; private $evenFooter = '';
/** /**
* FirstHeader * FirstHeader
* *
* @var string * @var string
*/ */
private $_firstHeader = ''; private $firstHeader = '';
/** /**
* FirstFooter * FirstFooter
* *
* @var string * @var string
*/ */
private $_firstFooter = ''; private $firstFooter = '';
/** /**
* Different header for Odd/Even, defaults to false * Different header for Odd/Even, defaults to false
* *
* @var boolean * @var boolean
*/ */
private $_differentOddEven = false; private $differentOddEven = false;
/** /**
* Different header for first page, defaults to false * Different header for first page, defaults to false
* *
* @var boolean * @var boolean
*/ */
private $_differentFirst = false; private $differentFirst = false;
/** /**
* Scale with document, defaults to true * Scale with document, defaults to true
* *
* @var boolean * @var boolean
*/ */
private $_scaleWithDocument = true; private $scaleWithDocument = true;
/** /**
* Align with margins, defaults to true * Align with margins, defaults to true
* *
* @var boolean * @var boolean
*/ */
private $_alignWithMargins = true; private $alignWithMargins = true;
/** /**
* Header/footer images * Header/footer images
* *
* @var PHPExcel_Worksheet_HeaderFooterDrawing[] * @var PHPExcel_Worksheet_HeaderFooterDrawing[]
*/ */
private $_headerFooterImages = array(); private $headerFooterImages = array();
/** /**
* Create a new PHPExcel_Worksheet_HeaderFooter * Create a new PHPExcel_Worksheet_HeaderFooter
@ -194,7 +186,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function getOddHeader() public function getOddHeader()
{ {
return $this->_oddHeader; return $this->oddHeader;
} }
/** /**
@ -205,7 +197,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function setOddHeader($pValue) public function setOddHeader($pValue)
{ {
$this->_oddHeader = $pValue; $this->oddHeader = $pValue;
return $this; return $this;
} }
@ -216,7 +208,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function getOddFooter() public function getOddFooter()
{ {
return $this->_oddFooter; return $this->oddFooter;
} }
/** /**
@ -227,7 +219,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function setOddFooter($pValue) public function setOddFooter($pValue)
{ {
$this->_oddFooter = $pValue; $this->oddFooter = $pValue;
return $this; return $this;
} }
@ -238,7 +230,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function getEvenHeader() public function getEvenHeader()
{ {
return $this->_evenHeader; return $this->evenHeader;
} }
/** /**
@ -249,7 +241,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function setEvenHeader($pValue) public function setEvenHeader($pValue)
{ {
$this->_evenHeader = $pValue; $this->evenHeader = $pValue;
return $this; return $this;
} }
@ -260,7 +252,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function getEvenFooter() public function getEvenFooter()
{ {
return $this->_evenFooter; return $this->evenFooter;
} }
/** /**
@ -271,7 +263,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function setEvenFooter($pValue) public function setEvenFooter($pValue)
{ {
$this->_evenFooter = $pValue; $this->evenFooter = $pValue;
return $this; return $this;
} }
@ -282,7 +274,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function getFirstHeader() public function getFirstHeader()
{ {
return $this->_firstHeader; return $this->firstHeader;
} }
/** /**
@ -293,7 +285,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function setFirstHeader($pValue) public function setFirstHeader($pValue)
{ {
$this->_firstHeader = $pValue; $this->firstHeader = $pValue;
return $this; return $this;
} }
@ -304,7 +296,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function getFirstFooter() public function getFirstFooter()
{ {
return $this->_firstFooter; return $this->firstFooter;
} }
/** /**
@ -315,7 +307,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function setFirstFooter($pValue) public function setFirstFooter($pValue)
{ {
$this->_firstFooter = $pValue; $this->firstFooter = $pValue;
return $this; return $this;
} }
@ -326,7 +318,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function getDifferentOddEven() public function getDifferentOddEven()
{ {
return $this->_differentOddEven; return $this->differentOddEven;
} }
/** /**
@ -337,7 +329,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function setDifferentOddEven($pValue = false) public function setDifferentOddEven($pValue = false)
{ {
$this->_differentOddEven = $pValue; $this->differentOddEven = $pValue;
return $this; return $this;
} }
@ -348,7 +340,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function getDifferentFirst() public function getDifferentFirst()
{ {
return $this->_differentFirst; return $this->differentFirst;
} }
/** /**
@ -359,7 +351,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function setDifferentFirst($pValue = false) public function setDifferentFirst($pValue = false)
{ {
$this->_differentFirst = $pValue; $this->differentFirst = $pValue;
return $this; return $this;
} }
@ -370,7 +362,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function getScaleWithDocument() public function getScaleWithDocument()
{ {
return $this->_scaleWithDocument; return $this->scaleWithDocument;
} }
/** /**
@ -381,7 +373,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function setScaleWithDocument($pValue = true) public function setScaleWithDocument($pValue = true)
{ {
$this->_scaleWithDocument = $pValue; $this->scaleWithDocument = $pValue;
return $this; return $this;
} }
@ -392,7 +384,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function getAlignWithMargins() public function getAlignWithMargins()
{ {
return $this->_alignWithMargins; return $this->alignWithMargins;
} }
/** /**
@ -403,7 +395,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function setAlignWithMargins($pValue = true) public function setAlignWithMargins($pValue = true)
{ {
$this->_alignWithMargins = $pValue; $this->alignWithMargins = $pValue;
return $this; return $this;
} }
@ -417,7 +409,7 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function addImage(PHPExcel_Worksheet_HeaderFooterDrawing $image = null, $location = self::IMAGE_HEADER_LEFT) public function addImage(PHPExcel_Worksheet_HeaderFooterDrawing $image = null, $location = self::IMAGE_HEADER_LEFT)
{ {
$this->_headerFooterImages[$location] = $image; $this->headerFooterImages[$location] = $image;
return $this; return $this;
} }
@ -430,8 +422,8 @@ class PHPExcel_Worksheet_HeaderFooter
*/ */
public function removeImage($location = self::IMAGE_HEADER_LEFT) public function removeImage($location = self::IMAGE_HEADER_LEFT)
{ {
if (isset($this->_headerFooterImages[$location])) { if (isset($this->headerFooterImages[$location])) {
unset($this->_headerFooterImages[$location]); unset($this->headerFooterImages[$location]);
} }
return $this; return $this;
} }
@ -449,7 +441,7 @@ class PHPExcel_Worksheet_HeaderFooter
throw new PHPExcel_Exception('Invalid parameter!'); throw new PHPExcel_Exception('Invalid parameter!');
} }
$this->_headerFooterImages = $images; $this->headerFooterImages = $images;
return $this; return $this;
} }
@ -462,27 +454,27 @@ class PHPExcel_Worksheet_HeaderFooter
{ {
// Sort array // Sort array
$images = array(); $images = array();
if (isset($this->_headerFooterImages[self::IMAGE_HEADER_LEFT])) { if (isset($this->headerFooterImages[self::IMAGE_HEADER_LEFT])) {
$images[self::IMAGE_HEADER_LEFT] = $this->_headerFooterImages[self::IMAGE_HEADER_LEFT]; $images[self::IMAGE_HEADER_LEFT] = $this->headerFooterImages[self::IMAGE_HEADER_LEFT];
} }
if (isset($this->_headerFooterImages[self::IMAGE_HEADER_CENTER])) { if (isset($this->headerFooterImages[self::IMAGE_HEADER_CENTER])) {
$images[self::IMAGE_HEADER_CENTER] = $this->_headerFooterImages[self::IMAGE_HEADER_CENTER]; $images[self::IMAGE_HEADER_CENTER] = $this->headerFooterImages[self::IMAGE_HEADER_CENTER];
} }
if (isset($this->_headerFooterImages[self::IMAGE_HEADER_RIGHT])) { if (isset($this->headerFooterImages[self::IMAGE_HEADER_RIGHT])) {
$images[self::IMAGE_HEADER_RIGHT] = $this->_headerFooterImages[self::IMAGE_HEADER_RIGHT]; $images[self::IMAGE_HEADER_RIGHT] = $this->headerFooterImages[self::IMAGE_HEADER_RIGHT];
} }
if (isset($this->_headerFooterImages[self::IMAGE_FOOTER_LEFT])) { if (isset($this->headerFooterImages[self::IMAGE_FOOTER_LEFT])) {
$images[self::IMAGE_FOOTER_LEFT] = $this->_headerFooterImages[self::IMAGE_FOOTER_LEFT]; $images[self::IMAGE_FOOTER_LEFT] = $this->headerFooterImages[self::IMAGE_FOOTER_LEFT];
} }
if (isset($this->_headerFooterImages[self::IMAGE_FOOTER_CENTER])) { if (isset($this->headerFooterImages[self::IMAGE_FOOTER_CENTER])) {
$images[self::IMAGE_FOOTER_CENTER] = $this->_headerFooterImages[self::IMAGE_FOOTER_CENTER]; $images[self::IMAGE_FOOTER_CENTER] = $this->headerFooterImages[self::IMAGE_FOOTER_CENTER];
} }
if (isset($this->_headerFooterImages[self::IMAGE_FOOTER_RIGHT])) { if (isset($this->headerFooterImages[self::IMAGE_FOOTER_RIGHT])) {
$images[self::IMAGE_FOOTER_RIGHT] = $this->_headerFooterImages[self::IMAGE_FOOTER_RIGHT]; $images[self::IMAGE_FOOTER_RIGHT] = $this->headerFooterImages[self::IMAGE_FOOTER_RIGHT];
} }
$this->_headerFooterImages = $images; $this->headerFooterImages = $images;
return $this->_headerFooterImages; return $this->headerFooterImages;
} }
/** /**

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_HeaderFooterDrawing
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_HeaderFooterDrawing
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing implements PHPExcel_IComparable class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing implements PHPExcel_IComparable
{ {
/** /**
@ -40,49 +32,49 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* *
* @var string * @var string
*/ */
private $_path; private $path;
/** /**
* Name * Name
* *
* @var string * @var string
*/ */
protected $_name; protected $name;
/** /**
* Offset X * Offset X
* *
* @var int * @var int
*/ */
protected $_offsetX; protected $offsetX;
/** /**
* Offset Y * Offset Y
* *
* @var int * @var int
*/ */
protected $_offsetY; protected $offsetY;
/** /**
* Width * Width
* *
* @var int * @var int
*/ */
protected $_width; protected $width;
/** /**
* Height * Height
* *
* @var int * @var int
*/ */
protected $_height; protected $height;
/** /**
* Proportional resize * Proportional resize
* *
* @var boolean * @var boolean
*/ */
protected $_resizeProportional; protected $resizeProportional;
/** /**
* Create a new PHPExcel_Worksheet_HeaderFooterDrawing * Create a new PHPExcel_Worksheet_HeaderFooterDrawing
@ -90,13 +82,13 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function __construct() public function __construct()
{ {
// Initialise values // Initialise values
$this->_path = ''; $this->path = '';
$this->_name = ''; $this->name = '';
$this->_offsetX = 0; $this->offsetX = 0;
$this->_offsetY = 0; $this->offsetY = 0;
$this->_width = 0; $this->width = 0;
$this->_height = 0; $this->height = 0;
$this->_resizeProportional = true; $this->resizeProportional = true;
} }
/** /**
@ -106,7 +98,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function getName() public function getName()
{ {
return $this->_name; return $this->name;
} }
/** /**
@ -117,7 +109,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function setName($pValue = '') public function setName($pValue = '')
{ {
$this->_name = $pValue; $this->name = $pValue;
return $this; return $this;
} }
@ -128,7 +120,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function getOffsetX() public function getOffsetX()
{ {
return $this->_offsetX; return $this->offsetX;
} }
/** /**
@ -139,7 +131,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function setOffsetX($pValue = 0) public function setOffsetX($pValue = 0)
{ {
$this->_offsetX = $pValue; $this->offsetX = $pValue;
return $this; return $this;
} }
@ -150,7 +142,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function getOffsetY() public function getOffsetY()
{ {
return $this->_offsetY; return $this->offsetY;
} }
/** /**
@ -161,7 +153,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function setOffsetY($pValue = 0) public function setOffsetY($pValue = 0)
{ {
$this->_offsetY = $pValue; $this->offsetY = $pValue;
return $this; return $this;
} }
@ -172,7 +164,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function getWidth() public function getWidth()
{ {
return $this->_width; return $this->width;
} }
/** /**
@ -184,13 +176,13 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function setWidth($pValue = 0) public function setWidth($pValue = 0)
{ {
// Resize proportional? // Resize proportional?
if ($this->_resizeProportional && $pValue != 0) { if ($this->resizeProportional && $pValue != 0) {
$ratio = $this->_width / $this->_height; $ratio = $this->width / $this->height;
$this->_height = round($ratio * $pValue); $this->height = round($ratio * $pValue);
} }
// Set width // Set width
$this->_width = $pValue; $this->width = $pValue;
return $this; return $this;
} }
@ -202,7 +194,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function getHeight() public function getHeight()
{ {
return $this->_height; return $this->height;
} }
/** /**
@ -214,13 +206,13 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function setHeight($pValue = 0) public function setHeight($pValue = 0)
{ {
// Resize proportional? // Resize proportional?
if ($this->_resizeProportional && $pValue != 0) { if ($this->resizeProportional && $pValue != 0) {
$ratio = $this->_width / $this->_height; $ratio = $this->width / $this->height;
$this->_width = round($ratio * $pValue); $this->width = round($ratio * $pValue);
} }
// Set height // Set height
$this->_height = $pValue; $this->height = $pValue;
return $this; return $this;
} }
@ -240,15 +232,15 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function setWidthAndHeight($width = 0, $height = 0) public function setWidthAndHeight($width = 0, $height = 0)
{ {
$xratio = $width / $this->_width; $xratio = $width / $this->width;
$yratio = $height / $this->_height; $yratio = $height / $this->height;
if ($this->_resizeProportional && !($width == 0 || $height == 0)) { if ($this->resizeProportional && !($width == 0 || $height == 0)) {
if (($xratio * $this->_height) < $height) { if (($xratio * $this->height) < $height) {
$this->_height = ceil($xratio * $this->_height); $this->height = ceil($xratio * $this->height);
$this->_width = $width; $this->width = $width;
} else { } else {
$this->_width = ceil($yratio * $this->_width); $this->width = ceil($yratio * $this->width);
$this->_height = $height; $this->height = $height;
} }
} }
return $this; return $this;
@ -261,7 +253,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function getResizeProportional() public function getResizeProportional()
{ {
return $this->_resizeProportional; return $this->resizeProportional;
} }
/** /**
@ -272,7 +264,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function setResizeProportional($pValue = true) public function setResizeProportional($pValue = true)
{ {
$this->_resizeProportional = $pValue; $this->resizeProportional = $pValue;
return $this; return $this;
} }
@ -283,7 +275,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function getFilename() public function getFilename()
{ {
return basename($this->_path); return basename($this->path);
} }
/** /**
@ -293,7 +285,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function getExtension() public function getExtension()
{ {
$parts = explode(".", basename($this->_path)); $parts = explode(".", basename($this->path));
return end($parts); return end($parts);
} }
@ -304,7 +296,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
*/ */
public function getPath() public function getPath()
{ {
return $this->_path; return $this->path;
} }
/** /**
@ -319,17 +311,17 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
{ {
if ($pVerifyFile) { if ($pVerifyFile) {
if (file_exists($pValue)) { if (file_exists($pValue)) {
$this->_path = $pValue; $this->path = $pValue;
if ($this->_width == 0 && $this->_height == 0) { if ($this->width == 0 && $this->height == 0) {
// Get width/height // Get width/height
list($this->_width, $this->_height) = getimagesize($pValue); list($this->width, $this->height) = getimagesize($pValue);
} }
} else { } else {
throw new PHPExcel_Exception("File $pValue not found!"); throw new PHPExcel_Exception("File $pValue not found!");
} }
} else { } else {
$this->_path = $pValue; $this->path = $pValue;
} }
return $this; return $this;
} }
@ -342,13 +334,13 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function getHashCode() public function getHashCode()
{ {
return md5( return md5(
$this->_path $this->path .
. $this->_name $this->name .
. $this->_offsetX $this->offsetX .
. $this->_offsetY $this->offsetY .
. $this->_width $this->width .
. $this->_height $this->height .
. __CLASS__ __CLASS__
); );
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Worksheet_MemoryDrawing
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,56 +25,47 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Worksheet_MemoryDrawing
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
{ {
/* Rendering functions */ /* Rendering functions */
const RENDERING_DEFAULT = 'imagepng'; const RENDERING_DEFAULT = 'imagepng';
const RENDERING_PNG = 'imagepng'; const RENDERING_PNG = 'imagepng';
const RENDERING_GIF = 'imagegif'; const RENDERING_GIF = 'imagegif';
const RENDERING_JPEG = 'imagejpeg'; const RENDERING_JPEG = 'imagejpeg';
/* MIME types */ /* MIME types */
const MIMETYPE_DEFAULT = 'image/png'; const MIMETYPE_DEFAULT = 'image/png';
const MIMETYPE_PNG = 'image/png'; const MIMETYPE_PNG = 'image/png';
const MIMETYPE_GIF = 'image/gif'; const MIMETYPE_GIF = 'image/gif';
const MIMETYPE_JPEG = 'image/jpeg'; const MIMETYPE_JPEG = 'image/jpeg';
/** /**
* Image resource * Image resource
* *
* @var resource * @var resource
*/ */
private $_imageResource; private $imageResource;
/** /**
* Rendering function * Rendering function
* *
* @var string * @var string
*/ */
private $_renderingFunction; private $renderingFunction;
/** /**
* Mime type * Mime type
* *
* @var string * @var string
*/ */
private $_mimeType; private $mimeType;
/** /**
* Unique name * Unique name
* *
* @var string * @var string
*/ */
private $_uniqueName; private $uniqueName;
/** /**
* Create a new PHPExcel_Worksheet_MemoryDrawing * Create a new PHPExcel_Worksheet_MemoryDrawing
@ -81,10 +73,10 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
public function __construct() public function __construct()
{ {
// Initialise values // Initialise values
$this->_imageResource = null; $this->imageResource = null;
$this->_renderingFunction = self::RENDERING_DEFAULT; $this->renderingFunction = self::RENDERING_DEFAULT;
$this->_mimeType = self::MIMETYPE_DEFAULT; $this->mimeType = self::MIMETYPE_DEFAULT;
$this->_uniqueName = md5(rand(0, 9999). time() . rand(0, 9999)); $this->uniqueName = md5(rand(0, 9999). time() . rand(0, 9999));
// Initialize parent // Initialize parent
parent::__construct(); parent::__construct();
@ -97,7 +89,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
*/ */
public function getImageResource() public function getImageResource()
{ {
return $this->_imageResource; return $this->imageResource;
} }
/** /**
@ -108,12 +100,12 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
*/ */
public function setImageResource($value = null) public function setImageResource($value = null)
{ {
$this->_imageResource = $value; $this->imageResource = $value;
if (!is_null($this->_imageResource)) { if (!is_null($this->imageResource)) {
// Get width/height // Get width/height
$this->_width = imagesx($this->_imageResource); $this->_width = imagesx($this->imageResource);
$this->_height = imagesy($this->_imageResource); $this->_height = imagesy($this->imageResource);
} }
return $this; return $this;
} }
@ -125,7 +117,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
*/ */
public function getRenderingFunction() public function getRenderingFunction()
{ {
return $this->_renderingFunction; return $this->renderingFunction;
} }
/** /**
@ -136,7 +128,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
*/ */
public function setRenderingFunction($value = PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT) public function setRenderingFunction($value = PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT)
{ {
$this->_renderingFunction = $value; $this->renderingFunction = $value;
return $this; return $this;
} }
@ -147,7 +139,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
*/ */
public function getMimeType() public function getMimeType()
{ {
return $this->_mimeType; return $this->mimeType;
} }
/** /**
@ -158,7 +150,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
*/ */
public function setMimeType($value = PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT) public function setMimeType($value = PHPExcel_Worksheet_MemoryDrawing::MIMETYPE_DEFAULT)
{ {
$this->_mimeType = $value; $this->mimeType = $value;
return $this; return $this;
} }
@ -169,11 +161,11 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
*/ */
public function getIndexedFilename() public function getIndexedFilename()
{ {
$extension = strtolower($this->getMimeType()); $extension = strtolower($this->getMimeType());
$extension = explode('/', $extension); $extension = explode('/', $extension);
$extension = $extension[1]; $extension = $extension[1];
return $this->_uniqueName . $this->getImageIndex() . '.' . $extension; return $this->uniqueName . $this->getImageIndex() . '.' . $extension;
} }
/** /**
@ -184,11 +176,11 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
public function getHashCode() public function getHashCode()
{ {
return md5( return md5(
$this->_renderingFunction $this->renderingFunction .
. $this->_mimeType $this->mimeType .
. $this->_uniqueName $this->uniqueName .
. parent::getHashCode() parent::getHashCode() .
. __CLASS__ __CLASS__
); );
} }

View File

@ -189,14 +189,14 @@ class PHPExcel_Worksheet_PageSetup
* *
* @var int * @var int
*/ */
private $_paperSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER; private $paperSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER;
/** /**
* Orientation * Orientation
* *
* @var string * @var string
*/ */
private $_orientation = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT; private $orientation = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT;
/** /**
* Scale (Print Scale) * Scale (Print Scale)
@ -206,7 +206,7 @@ class PHPExcel_Worksheet_PageSetup
* *
* @var int? * @var int?
*/ */
private $_scale = 100; private $scale = 100;
/** /**
* Fit To Page * Fit To Page
@ -214,7 +214,7 @@ class PHPExcel_Worksheet_PageSetup
* *
* @var boolean * @var boolean
*/ */
private $_fitToPage = false; private $fitToPage = false;
/** /**
* Fit To Height * Fit To Height
@ -222,7 +222,7 @@ class PHPExcel_Worksheet_PageSetup
* *
* @var int? * @var int?
*/ */
private $_fitToHeight = 1; private $fitToHeight = 1;
/** /**
* Fit To Width * Fit To Width
@ -230,49 +230,49 @@ class PHPExcel_Worksheet_PageSetup
* *
* @var int? * @var int?
*/ */
private $_fitToWidth = 1; private $fitToWidth = 1;
/** /**
* Columns to repeat at left * Columns to repeat at left
* *
* @var array Containing start column and end column, empty array if option unset * @var array Containing start column and end column, empty array if option unset
*/ */
private $_columnsToRepeatAtLeft = array('', ''); private $columnsToRepeatAtLeft = array('', '');
/** /**
* Rows to repeat at top * Rows to repeat at top
* *
* @var array Containing start row number and end row number, empty array if option unset * @var array Containing start row number and end row number, empty array if option unset
*/ */
private $_rowsToRepeatAtTop = array(0, 0); private $rowsToRepeatAtTop = array(0, 0);
/** /**
* Center page horizontally * Center page horizontally
* *
* @var boolean * @var boolean
*/ */
private $_horizontalCentered = false; private $horizontalCentered = false;
/** /**
* Center page vertically * Center page vertically
* *
* @var boolean * @var boolean
*/ */
private $_verticalCentered = false; private $verticalCentered = false;
/** /**
* Print area * Print area
* *
* @var string * @var string
*/ */
private $_printArea = null; private $printArea = null;
/** /**
* First page number * First page number
* *
* @var int * @var int
*/ */
private $_firstPageNumber = null; private $firstPageNumber = null;
/** /**
* Create a new PHPExcel_Worksheet_PageSetup * Create a new PHPExcel_Worksheet_PageSetup
@ -288,7 +288,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function getPaperSize() public function getPaperSize()
{ {
return $this->_paperSize; return $this->paperSize;
} }
/** /**
@ -299,7 +299,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function setPaperSize($pValue = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER) public function setPaperSize($pValue = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER)
{ {
$this->_paperSize = $pValue; $this->paperSize = $pValue;
return $this; return $this;
} }
@ -310,7 +310,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function getOrientation() public function getOrientation()
{ {
return $this->_orientation; return $this->orientation;
} }
/** /**
@ -321,7 +321,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function setOrientation($pValue = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT) public function setOrientation($pValue = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT)
{ {
$this->_orientation = $pValue; $this->orientation = $pValue;
return $this; return $this;
} }
@ -332,7 +332,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function getScale() public function getScale()
{ {
return $this->_scale; return $this->scale;
} }
/** /**
@ -351,9 +351,9 @@ class PHPExcel_Worksheet_PageSetup
// Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface, // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
// but it is apparently still able to handle any scale >= 0, where 0 results in 100 // but it is apparently still able to handle any scale >= 0, where 0 results in 100
if (($pValue >= 0) || is_null($pValue)) { if (($pValue >= 0) || is_null($pValue)) {
$this->_scale = $pValue; $this->scale = $pValue;
if ($pUpdate) { if ($pUpdate) {
$this->_fitToPage = false; $this->fitToPage = false;
} }
} else { } else {
throw new PHPExcel_Exception("Scale must not be negative"); throw new PHPExcel_Exception("Scale must not be negative");
@ -368,7 +368,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function getFitToPage() public function getFitToPage()
{ {
return $this->_fitToPage; return $this->fitToPage;
} }
/** /**
@ -379,7 +379,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function setFitToPage($pValue = true) public function setFitToPage($pValue = true)
{ {
$this->_fitToPage = $pValue; $this->fitToPage = $pValue;
return $this; return $this;
} }
@ -390,7 +390,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function getFitToHeight() public function getFitToHeight()
{ {
return $this->_fitToHeight; return $this->fitToHeight;
} }
/** /**
@ -402,9 +402,9 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function setFitToHeight($pValue = 1, $pUpdate = true) public function setFitToHeight($pValue = 1, $pUpdate = true)
{ {
$this->_fitToHeight = $pValue; $this->fitToHeight = $pValue;
if ($pUpdate) { if ($pUpdate) {
$this->_fitToPage = true; $this->fitToPage = true;
} }
return $this; return $this;
} }
@ -416,7 +416,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function getFitToWidth() public function getFitToWidth()
{ {
return $this->_fitToWidth; return $this->fitToWidth;
} }
/** /**
@ -428,9 +428,9 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function setFitToWidth($pValue = 1, $pUpdate = true) public function setFitToWidth($pValue = 1, $pUpdate = true)
{ {
$this->_fitToWidth = $pValue; $this->fitToWidth = $pValue;
if ($pUpdate) { if ($pUpdate) {
$this->_fitToPage = true; $this->fitToPage = true;
} }
return $this; return $this;
} }
@ -442,8 +442,8 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function isColumnsToRepeatAtLeftSet() public function isColumnsToRepeatAtLeftSet()
{ {
if (is_array($this->_columnsToRepeatAtLeft)) { if (is_array($this->columnsToRepeatAtLeft)) {
if ($this->_columnsToRepeatAtLeft[0] != '' && $this->_columnsToRepeatAtLeft[1] != '') { if ($this->columnsToRepeatAtLeft[0] != '' && $this->columnsToRepeatAtLeft[1] != '') {
return true; return true;
} }
} }
@ -458,7 +458,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function getColumnsToRepeatAtLeft() public function getColumnsToRepeatAtLeft()
{ {
return $this->_columnsToRepeatAtLeft; return $this->columnsToRepeatAtLeft;
} }
/** /**
@ -470,7 +470,7 @@ class PHPExcel_Worksheet_PageSetup
public function setColumnsToRepeatAtLeft($pValue = null) public function setColumnsToRepeatAtLeft($pValue = null)
{ {
if (is_array($pValue)) { if (is_array($pValue)) {
$this->_columnsToRepeatAtLeft = $pValue; $this->columnsToRepeatAtLeft = $pValue;
} }
return $this; return $this;
} }
@ -484,7 +484,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function setColumnsToRepeatAtLeftByStartAndEnd($pStart = 'A', $pEnd = 'A') public function setColumnsToRepeatAtLeftByStartAndEnd($pStart = 'A', $pEnd = 'A')
{ {
$this->_columnsToRepeatAtLeft = array($pStart, $pEnd); $this->columnsToRepeatAtLeft = array($pStart, $pEnd);
return $this; return $this;
} }
@ -495,8 +495,8 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function isRowsToRepeatAtTopSet() public function isRowsToRepeatAtTopSet()
{ {
if (is_array($this->_rowsToRepeatAtTop)) { if (is_array($this->rowsToRepeatAtTop)) {
if ($this->_rowsToRepeatAtTop[0] != 0 && $this->_rowsToRepeatAtTop[1] != 0) { if ($this->rowsToRepeatAtTop[0] != 0 && $this->rowsToRepeatAtTop[1] != 0) {
return true; return true;
} }
} }
@ -511,7 +511,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function getRowsToRepeatAtTop() public function getRowsToRepeatAtTop()
{ {
return $this->_rowsToRepeatAtTop; return $this->rowsToRepeatAtTop;
} }
/** /**
@ -523,7 +523,7 @@ class PHPExcel_Worksheet_PageSetup
public function setRowsToRepeatAtTop($pValue = null) public function setRowsToRepeatAtTop($pValue = null)
{ {
if (is_array($pValue)) { if (is_array($pValue)) {
$this->_rowsToRepeatAtTop = $pValue; $this->rowsToRepeatAtTop = $pValue;
} }
return $this; return $this;
} }
@ -537,7 +537,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function setRowsToRepeatAtTopByStartAndEnd($pStart = 1, $pEnd = 1) public function setRowsToRepeatAtTopByStartAndEnd($pStart = 1, $pEnd = 1)
{ {
$this->_rowsToRepeatAtTop = array($pStart, $pEnd); $this->rowsToRepeatAtTop = array($pStart, $pEnd);
return $this; return $this;
} }
@ -548,7 +548,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function getHorizontalCentered() public function getHorizontalCentered()
{ {
return $this->_horizontalCentered; return $this->horizontalCentered;
} }
/** /**
@ -559,7 +559,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function setHorizontalCentered($value = false) public function setHorizontalCentered($value = false)
{ {
$this->_horizontalCentered = $value; $this->horizontalCentered = $value;
return $this; return $this;
} }
@ -570,7 +570,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function getVerticalCentered() public function getVerticalCentered()
{ {
return $this->_verticalCentered; return $this->verticalCentered;
} }
/** /**
@ -581,7 +581,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function setVerticalCentered($value = false) public function setVerticalCentered($value = false)
{ {
$this->_verticalCentered = $value; $this->verticalCentered = $value;
return $this; return $this;
} }
@ -598,9 +598,9 @@ class PHPExcel_Worksheet_PageSetup
public function getPrintArea($index = 0) public function getPrintArea($index = 0)
{ {
if ($index == 0) { if ($index == 0) {
return $this->_printArea; return $this->printArea;
} }
$printAreas = explode(',', $this->_printArea); $printAreas = explode(',', $this->printArea);
if (isset($printAreas[$index-1])) { if (isset($printAreas[$index-1])) {
return $printAreas[$index-1]; return $printAreas[$index-1];
} }
@ -619,9 +619,9 @@ class PHPExcel_Worksheet_PageSetup
public function isPrintAreaSet($index = 0) public function isPrintAreaSet($index = 0)
{ {
if ($index == 0) { if ($index == 0) {
return !is_null($this->_printArea); return !is_null($this->printArea);
} }
$printAreas = explode(',', $this->_printArea); $printAreas = explode(',', $this->printArea);
return isset($printAreas[$index-1]); return isset($printAreas[$index-1]);
} }
@ -637,12 +637,12 @@ class PHPExcel_Worksheet_PageSetup
public function clearPrintArea($index = 0) public function clearPrintArea($index = 0)
{ {
if ($index == 0) { if ($index == 0) {
$this->_printArea = null; $this->printArea = null;
} else { } else {
$printAreas = explode(',', $this->_printArea); $printAreas = explode(',', $this->printArea);
if (isset($printAreas[$index-1])) { if (isset($printAreas[$index-1])) {
unset($printAreas[$index-1]); unset($printAreas[$index-1]);
$this->_printArea = implode(',', $printAreas); $this->printArea = implode(',', $printAreas);
} }
} }
@ -682,9 +682,9 @@ class PHPExcel_Worksheet_PageSetup
if ($method == self::SETPRINTRANGE_OVERWRITE) { if ($method == self::SETPRINTRANGE_OVERWRITE) {
if ($index == 0) { if ($index == 0) {
$this->_printArea = $value; $this->printArea = $value;
} else { } else {
$printAreas = explode(',', $this->_printArea); $printAreas = explode(',', $this->printArea);
if ($index < 0) { if ($index < 0) {
$index = count($printAreas) - abs($index) + 1; $index = count($printAreas) - abs($index) + 1;
} }
@ -692,13 +692,13 @@ class PHPExcel_Worksheet_PageSetup
throw new PHPExcel_Exception('Invalid index for setting print range.'); throw new PHPExcel_Exception('Invalid index for setting print range.');
} }
$printAreas[$index-1] = $value; $printAreas[$index-1] = $value;
$this->_printArea = implode(',', $printAreas); $this->printArea = implode(',', $printAreas);
} }
} elseif ($method == self::SETPRINTRANGE_INSERT) { } elseif ($method == self::SETPRINTRANGE_INSERT) {
if ($index == 0) { if ($index == 0) {
$this->_printArea .= ($this->_printArea == '') ? $value : ','.$value; $this->printArea .= ($this->printArea == '') ? $value : ','.$value;
} else { } else {
$printAreas = explode(',', $this->_printArea); $printAreas = explode(',', $this->printArea);
if ($index < 0) { if ($index < 0) {
$index = abs($index) - 1; $index = abs($index) - 1;
} }
@ -706,7 +706,7 @@ class PHPExcel_Worksheet_PageSetup
throw new PHPExcel_Exception('Invalid index for setting print range.'); throw new PHPExcel_Exception('Invalid index for setting print range.');
} }
$printAreas = array_merge(array_slice($printAreas, 0, $index), array($value), array_slice($printAreas, $index)); $printAreas = array_merge(array_slice($printAreas, 0, $index), array($value), array_slice($printAreas, $index));
$this->_printArea = implode(',', $printAreas); $this->printArea = implode(',', $printAreas);
} }
} else { } else {
throw new PHPExcel_Exception('Invalid method for setting print range.'); throw new PHPExcel_Exception('Invalid method for setting print range.');
@ -758,7 +758,11 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE)
{ {
return $this->setPrintArea(PHPExcel_Cell::stringFromColumnIndex($column1) . $row1 . ':' . PHPExcel_Cell::stringFromColumnIndex($column2) . $row2, $index, $method); return $this->setPrintArea(
PHPExcel_Cell::stringFromColumnIndex($column1) . $row1 . ':' . PHPExcel_Cell::stringFromColumnIndex($column2) . $row2,
$index,
$method
);
} }
/** /**
@ -779,7 +783,11 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = -1) public function addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = -1)
{ {
return $this->setPrintArea(PHPExcel_Cell::stringFromColumnIndex($column1) . $row1 . ':' . PHPExcel_Cell::stringFromColumnIndex($column2) . $row2, $index, self::SETPRINTRANGE_INSERT); return $this->setPrintArea(
PHPExcel_Cell::stringFromColumnIndex($column1) . $row1 . ':' . PHPExcel_Cell::stringFromColumnIndex($column2) . $row2,
$index,
self::SETPRINTRANGE_INSERT
);
} }
/** /**
@ -789,7 +797,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function getFirstPageNumber() public function getFirstPageNumber()
{ {
return $this->_firstPageNumber; return $this->firstPageNumber;
} }
/** /**
@ -800,7 +808,7 @@ class PHPExcel_Worksheet_PageSetup
*/ */
public function setFirstPageNumber($value = null) public function setFirstPageNumber($value = null)
{ {
$this->_firstPageNumber = $value; $this->firstPageNumber = $value;
return $this; return $this;
} }

View File

@ -33,7 +33,7 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
* *
* @var boolean * @var boolean
*/ */
protected $_includeCharts = false; protected $includeCharts = false;
/** /**
* Pre-calculate formulas * Pre-calculate formulas
@ -67,7 +67,7 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
*/ */
public function getIncludeCharts() public function getIncludeCharts()
{ {
return $this->_includeCharts; return $this->includeCharts;
} }
/** /**
@ -80,7 +80,7 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
*/ */
public function setIncludeCharts($pValue = false) public function setIncludeCharts($pValue = false)
{ {
$this->_includeCharts = (boolean) $pValue; $this->includeCharts = (boolean) $pValue;
return $this; return $this;
} }

View File

@ -236,7 +236,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
} }
// Add [Content_Types].xml to ZIP file // Add [Content_Types].xml to ZIP file
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_spreadSheet, $this->_includeCharts)); $objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_spreadSheet, $this->includeCharts));
//if hasMacros, add the vbaProject.bin file, Certificate file(if exists) //if hasMacros, add the vbaProject.bin file, Certificate file(if exists)
if ($this->_spreadSheet->hasMacros()) { if ($this->_spreadSheet->hasMacros()) {
@ -292,8 +292,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
$chartCount = 0; $chartCount = 0;
// Add worksheets // Add worksheets
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) { for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
$objZip->addFromString('xl/worksheets/sheet' . ($i + 1) . '.xml', $this->getWriterPart('Worksheet')->writeWorksheet($this->_spreadSheet->getSheet($i), $this->_stringTable, $this->_includeCharts)); $objZip->addFromString('xl/worksheets/sheet' . ($i + 1) . '.xml', $this->getWriterPart('Worksheet')->writeWorksheet($this->_spreadSheet->getSheet($i), $this->_stringTable, $this->includeCharts));
if ($this->_includeCharts) { if ($this->includeCharts) {
$charts = $this->_spreadSheet->getSheet($i)->getChartCollection(); $charts = $this->_spreadSheet->getSheet($i)->getChartCollection();
if (count($charts) > 0) { if (count($charts) > 0) {
foreach ($charts as $chart) { foreach ($charts as $chart) {
@ -308,21 +308,21 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
// Add worksheet relationships (drawings, ...) // Add worksheet relationships (drawings, ...)
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) { for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
// Add relationships // Add relationships
$objZip->addFromString('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->_spreadSheet->getSheet($i), ($i + 1), $this->_includeCharts)); $objZip->addFromString('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->_spreadSheet->getSheet($i), ($i + 1), $this->includeCharts));
$drawings = $this->_spreadSheet->getSheet($i)->getDrawingCollection(); $drawings = $this->_spreadSheet->getSheet($i)->getDrawingCollection();
$drawingCount = count($drawings); $drawingCount = count($drawings);
if ($this->_includeCharts) { if ($this->includeCharts) {
$chartCount = $this->_spreadSheet->getSheet($i)->getChartCount(); $chartCount = $this->_spreadSheet->getSheet($i)->getChartCount();
} }
// Add drawing and image relationship parts // Add drawing and image relationship parts
if (($drawingCount > 0) || ($chartCount > 0)) { if (($drawingCount > 0) || ($chartCount > 0)) {
// Drawing relationships // Drawing relationships
$objZip->addFromString('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->_spreadSheet->getSheet($i), $chartRef1, $this->_includeCharts)); $objZip->addFromString('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->_spreadSheet->getSheet($i), $chartRef1, $this->includeCharts));
// Drawings // Drawings
$objZip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->_spreadSheet->getSheet($i), $chartRef2, $this->_includeCharts)); $objZip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->_spreadSheet->getSheet($i), $chartRef2, $this->includeCharts));
} }
// Add comment relationship parts // Add comment relationship parts

View File

@ -32,98 +32,98 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* *
* @var PHPExcel * @var PHPExcel
*/ */
protected $_phpExcel; protected $phpExcel;
/** /**
* Sheet index to write * Sheet index to write
* *
* @var int * @var int
*/ */
private $_sheetIndex = 0; private $sheetIndex = 0;
/** /**
* Images root * Images root
* *
* @var string * @var string
*/ */
private $_imagesRoot = '.'; private $imagesRoot = '.';
/** /**
* embed images, or link to images * embed images, or link to images
* *
* @var boolean * @var boolean
*/ */
private $_embedImages = false; private $embedImages = false;
/** /**
* Use inline CSS? * Use inline CSS?
* *
* @var boolean * @var boolean
*/ */
private $_useInlineCss = false; private $useInlineCss = false;
/** /**
* Array of CSS styles * Array of CSS styles
* *
* @var array * @var array
*/ */
private $_cssStyles = null; private $cssStyles;
/** /**
* Array of column widths in points * Array of column widths in points
* *
* @var array * @var array
*/ */
private $_columnWidths = null; private $columnWidths;
/** /**
* Default font * Default font
* *
* @var PHPExcel_Style_Font * @var PHPExcel_Style_Font
*/ */
private $_defaultFont; private $defaultFont;
/** /**
* Flag whether spans have been calculated * Flag whether spans have been calculated
* *
* @var boolean * @var boolean
*/ */
private $_spansAreCalculated = false; private $spansAreCalculated = false;
/** /**
* Excel cells that should not be written as HTML cells * Excel cells that should not be written as HTML cells
* *
* @var array * @var array
*/ */
private $_isSpannedCell = array(); private $isSpannedCell = array();
/** /**
* Excel cells that are upper-left corner in a cell merge * Excel cells that are upper-left corner in a cell merge
* *
* @var array * @var array
*/ */
private $_isBaseCell = array(); private $isBaseCell = array();
/** /**
* Excel rows that should not be written as HTML rows * Excel rows that should not be written as HTML rows
* *
* @var array * @var array
*/ */
private $_isSpannedRow = array(); private $isSpannedRow = array();
/** /**
* Is the current writer creating PDF? * Is the current writer creating PDF?
* *
* @var boolean * @var boolean
*/ */
protected $_isPdf = false; protected $isPdf = false;
/** /**
* Generate the Navigation block * Generate the Navigation block
* *
* @var boolean * @var boolean
*/ */
private $_generateSheetNavigationBlock = true; private $generateSheetNavigationBlock = true;
/** /**
* Create a new PHPExcel_Writer_HTML * Create a new PHPExcel_Writer_HTML
@ -132,8 +132,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function __construct(PHPExcel $phpExcel) public function __construct(PHPExcel $phpExcel)
{ {
$this->_phpExcel = $phpExcel; $this->phpExcel = $phpExcel;
$this->_defaultFont = $this->_phpExcel->getDefaultStyle()->getFont(); $this->defaultFont = $this->phpExcel->getDefaultStyle()->getFont();
} }
/** /**
@ -145,15 +145,15 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
public function save($pFilename = null) public function save($pFilename = null)
{ {
// garbage collect // garbage collect
$this->_phpExcel->garbageCollect(); $this->phpExcel->garbageCollect();
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog(); $saveDebugLog = PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->getWriteDebugLog();
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(false); PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->setWriteDebugLog(false);
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
// Build CSS // Build CSS
$this->buildCSS(!$this->_useInlineCss); $this->buildCSS(!$this->useInlineCss);
// Open file // Open file
$fileHandle = fopen($pFilename, 'wb+'); $fileHandle = fopen($pFilename, 'wb+');
@ -162,10 +162,10 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
} }
// Write headers // Write headers
fwrite($fileHandle, $this->generateHTMLHeader(!$this->_useInlineCss)); fwrite($fileHandle, $this->generateHTMLHeader(!$this->useInlineCss));
// Write navigation (tabs) // Write navigation (tabs)
if ((!$this->_isPdf) && ($this->_generateSheetNavigationBlock)) { if ((!$this->isPdf) && ($this->generateSheetNavigationBlock)) {
fwrite($fileHandle, $this->generateNavigation()); fwrite($fileHandle, $this->generateNavigation());
} }
@ -179,7 +179,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
fclose($fileHandle); fclose($fileHandle);
PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType); PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType);
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog); PHPExcel_Calculation::getInstance($this->phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog);
} }
/** /**
@ -188,7 +188,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param string $vAlign Vertical alignment * @param string $vAlign Vertical alignment
* @return string * @return string
*/ */
private function _mapVAlign($vAlign) private function mapVAlign($vAlign)
{ {
switch ($vAlign) { switch ($vAlign) {
case PHPExcel_Style_Alignment::VERTICAL_BOTTOM: case PHPExcel_Style_Alignment::VERTICAL_BOTTOM:
@ -209,7 +209,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param string $hAlign Horizontal alignment * @param string $hAlign Horizontal alignment
* @return string|false * @return string|false
*/ */
private function _mapHAlign($hAlign) private function mapHAlign($hAlign)
{ {
switch ($hAlign) { switch ($hAlign) {
case PHPExcel_Style_Alignment::HORIZONTAL_GENERAL: case PHPExcel_Style_Alignment::HORIZONTAL_GENERAL:
@ -234,7 +234,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param int $borderStyle Sheet index * @param int $borderStyle Sheet index
* @return string * @return string
*/ */
private function _mapBorderStyle($borderStyle) private function mapBorderStyle($borderStyle)
{ {
switch ($borderStyle) { switch ($borderStyle) {
case PHPExcel_Style_Border::BORDER_NONE: case PHPExcel_Style_Border::BORDER_NONE:
@ -278,7 +278,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function getSheetIndex() public function getSheetIndex()
{ {
return $this->_sheetIndex; return $this->sheetIndex;
} }
/** /**
@ -289,7 +289,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function setSheetIndex($pValue = 0) public function setSheetIndex($pValue = 0)
{ {
$this->_sheetIndex = $pValue; $this->sheetIndex = $pValue;
return $this; return $this;
} }
@ -300,7 +300,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function getGenerateSheetNavigationBlock() public function getGenerateSheetNavigationBlock()
{ {
return $this->_generateSheetNavigationBlock; return $this->generateSheetNavigationBlock;
} }
/** /**
@ -311,7 +311,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function setGenerateSheetNavigationBlock($pValue = true) public function setGenerateSheetNavigationBlock($pValue = true)
{ {
$this->_generateSheetNavigationBlock = (bool) $pValue; $this->generateSheetNavigationBlock = (bool) $pValue;
return $this; return $this;
} }
@ -320,7 +320,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function writeAllSheets() public function writeAllSheets()
{ {
$this->_sheetIndex = null; $this->sheetIndex = null;
return $this; return $this;
} }
@ -334,12 +334,12 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
public function generateHTMLHeader($pIncludeStyles = false) public function generateHTMLHeader($pIncludeStyles = false)
{ {
// PHPExcel object known? // PHPExcel object known?
if (is_null($this->_phpExcel)) { if (is_null($this->phpExcel)) {
throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
} }
// Construct HTML // Construct HTML
$properties = $this->_phpExcel->getProperties(); $properties = $this->phpExcel->getProperties();
$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' . PHP_EOL; $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' . PHP_EOL;
$html .= '<!-- Generated by PHPExcel - http://www.phpexcel.net -->' . PHP_EOL; $html .= '<!-- Generated by PHPExcel - http://www.phpexcel.net -->' . PHP_EOL;
$html .= '<html>' . PHP_EOL; $html .= '<html>' . PHP_EOL;
@ -393,21 +393,21 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
public function generateSheetData() public function generateSheetData()
{ {
// PHPExcel object known? // PHPExcel object known?
if (is_null($this->_phpExcel)) { if (is_null($this->phpExcel)) {
throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
} }
// Ensure that Spans have been calculated? // Ensure that Spans have been calculated?
if (!$this->_spansAreCalculated) { if (!$this->spansAreCalculated) {
$this->_calculateSpans(); $this->calculateSpans();
} }
// Fetch sheets // Fetch sheets
$sheets = array(); $sheets = array();
if (is_null($this->_sheetIndex)) { if (is_null($this->sheetIndex)) {
$sheets = $this->_phpExcel->getAllSheets(); $sheets = $this->phpExcel->getAllSheets();
} else { } else {
$sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex); $sheets[] = $this->phpExcel->getSheet($this->sheetIndex);
} }
// Construct HTML // Construct HTML
@ -417,7 +417,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$sheetId = 0; $sheetId = 0;
foreach ($sheets as $sheet) { foreach ($sheets as $sheet) {
// Write table header // Write table header
$html .= $this->_generateTableHeader($sheet); $html .= $this->generateTableHeader($sheet);
// Get worksheet dimension // Get worksheet dimension
$dimension = explode(':', $sheet->calculateWorksheetDimension()); $dimension = explode(':', $sheet->calculateWorksheetDimension());
@ -460,7 +460,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
} }
// Write row if there are HTML table cells in it // Write row if there are HTML table cells in it
if (!isset($this->_isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row])) { if (!isset($this->isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row])) {
// Start a new rowData // Start a new rowData
$rowData = array(); $rowData = array();
// Loop through columns // Loop through columns
@ -473,7 +473,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$rowData[$column] = ''; $rowData[$column] = '';
} }
} }
$html .= $this->_generateRow($sheet, $rowData, $row - 1, $cellType); $html .= $this->generateRow($sheet, $rowData, $row - 1, $cellType);
} }
// </thead> ? // </thead> ?
@ -481,17 +481,17 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$html .= ' </thead>' . PHP_EOL; $html .= ' </thead>' . PHP_EOL;
} }
} }
$html .= $this->_extendRowsForChartsAndImages($sheet, $row); $html .= $this->extendRowsForChartsAndImages($sheet, $row);
// Close table body. // Close table body.
$html .= ' </tbody>' . PHP_EOL; $html .= ' </tbody>' . PHP_EOL;
// Write table footer // Write table footer
$html .= $this->_generateTableFooter(); $html .= $this->generateTableFooter();
// Writing PDF? // Writing PDF?
if ($this->_isPdf) { if ($this->isPdf) {
if (is_null($this->_sheetIndex) && $sheetId + 1 < $this->_phpExcel->getSheetCount()) { if (is_null($this->sheetIndex) && $sheetId + 1 < $this->phpExcel->getSheetCount()) {
$html .= '<div style="page-break-before:always" />'; $html .= '<div style="page-break-before:always" />';
} }
} }
@ -512,16 +512,16 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
public function generateNavigation() public function generateNavigation()
{ {
// PHPExcel object known? // PHPExcel object known?
if (is_null($this->_phpExcel)) { if (is_null($this->phpExcel)) {
throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
} }
// Fetch sheets // Fetch sheets
$sheets = array(); $sheets = array();
if (is_null($this->_sheetIndex)) { if (is_null($this->sheetIndex)) {
$sheets = $this->_phpExcel->getAllSheets(); $sheets = $this->phpExcel->getAllSheets();
} else { } else {
$sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex); $sheets[] = $this->phpExcel->getSheet($this->sheetIndex);
} }
// Construct HTML // Construct HTML
@ -545,11 +545,11 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
return $html; return $html;
} }
private function _extendRowsForChartsAndImages(PHPExcel_Worksheet $pSheet, $row) private function extendRowsForChartsAndImages(PHPExcel_Worksheet $pSheet, $row)
{ {
$rowMax = $row; $rowMax = $row;
$colMax = 'A'; $colMax = 'A';
if ($this->_includeCharts) { if ($this->includeCharts) {
foreach ($pSheet->getChartCollection() as $chart) { foreach ($pSheet->getChartCollection() as $chart) {
if ($chart instanceof PHPExcel_Chart) { if ($chart instanceof PHPExcel_Chart) {
$chartCoordinates = $chart->getTopLeftPosition(); $chartCoordinates = $chart->getTopLeftPosition();
@ -583,9 +583,9 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$html .= '<tr>'; $html .= '<tr>';
for ($col = 'A'; $col != $colMax; ++$col) { for ($col = 'A'; $col != $colMax; ++$col) {
$html .= '<td>'; $html .= '<td>';
$html .= $this->_writeImageInCell($pSheet, $col.$row); $html .= $this->writeImageInCell($pSheet, $col.$row);
if ($this->_includeCharts) { if ($this->includeCharts) {
$html .= $this->_writeChartInCell($pSheet, $col.$row); $html .= $this->writeChartInCell($pSheet, $col.$row);
} }
$html .= '</td>'; $html .= '</td>';
} }
@ -604,7 +604,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string * @return string
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeImageInCell(PHPExcel_Worksheet $pSheet, $coordinates) private function writeImageInCell(PHPExcel_Worksheet $pSheet, $coordinates)
{ {
// Construct HTML // Construct HTML
$html = ''; $html = '';
@ -632,7 +632,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$filename = htmlspecialchars($filename); $filename = htmlspecialchars($filename);
$html .= PHP_EOL; $html .= PHP_EOL;
if ((!$this->_embedImages) || ($this->_isPdf)) { if ((!$this->embedImages) || ($this->isPdf)) {
$imageData = $filename; $imageData = $filename;
} else { } else {
$imageDetails = getimagesize($filename); $imageDetails = getimagesize($filename);
@ -669,7 +669,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string * @return string
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeChartInCell(PHPExcel_Worksheet $pSheet, $coordinates) private function writeChartInCell(PHPExcel_Worksheet $pSheet, $coordinates)
{ {
// Construct HTML // Construct HTML
$html = ''; $html = '';
@ -718,7 +718,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
public function generateStyles($generateSurroundingHTML = true) public function generateStyles($generateSurroundingHTML = true)
{ {
// PHPExcel object known? // PHPExcel object known?
if (is_null($this->_phpExcel)) { if (is_null($this->phpExcel)) {
throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
} }
@ -731,13 +731,13 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
// Start styles // Start styles
if ($generateSurroundingHTML) { if ($generateSurroundingHTML) {
$html .= ' <style type="text/css">' . PHP_EOL; $html .= ' <style type="text/css">' . PHP_EOL;
$html .= ' html { ' . $this->_assembleCSS($css['html']) . ' }' . PHP_EOL; $html .= ' html { ' . $this->assembleCSS($css['html']) . ' }' . PHP_EOL;
} }
// Write all other styles // Write all other styles
foreach ($css as $styleName => $styleDefinition) { foreach ($css as $styleName => $styleDefinition) {
if ($styleName != 'html') { if ($styleName != 'html') {
$html .= ' ' . $styleName . ' { ' . $this->_assembleCSS($styleDefinition) . ' }' . PHP_EOL; $html .= ' ' . $styleName . ' { ' . $this->assembleCSS($styleDefinition) . ' }' . PHP_EOL;
} }
} }
@ -760,18 +760,18 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
public function buildCSS($generateSurroundingHTML = true) public function buildCSS($generateSurroundingHTML = true)
{ {
// PHPExcel object known? // PHPExcel object known?
if (is_null($this->_phpExcel)) { if (is_null($this->phpExcel)) {
throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.');
} }
// Cached? // Cached?
if (!is_null($this->_cssStyles)) { if (!is_null($this->cssStyles)) {
return $this->_cssStyles; return $this->cssStyles;
} }
// Ensure that spans have been calculated // Ensure that spans have been calculated
if (!$this->_spansAreCalculated) { if (!$this->spansAreCalculated) {
$this->_calculateSpans(); $this->calculateSpans();
} }
// Construct CSS // Construct CSS
@ -788,7 +788,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
// table { } // table { }
$css['table']['border-collapse'] = 'collapse'; $css['table']['border-collapse'] = 'collapse';
if (!$this->_isPdf) { if (!$this->isPdf) {
$css['table']['page-break-after'] = 'always'; $css['table']['page-break-after'] = 'always';
} }
@ -815,17 +815,17 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$css['.s']['text-align'] = 'left'; // STRING $css['.s']['text-align'] = 'left'; // STRING
// Calculate cell style hashes // Calculate cell style hashes
foreach ($this->_phpExcel->getCellXfCollection() as $index => $style) { foreach ($this->phpExcel->getCellXfCollection() as $index => $style) {
$css['td.style' . $index] = $this->_createCSSStyle($style); $css['td.style' . $index] = $this->createCSSStyle($style);
$css['th.style' . $index] = $this->_createCSSStyle($style); $css['th.style' . $index] = $this->createCSSStyle($style);
} }
// Fetch sheets // Fetch sheets
$sheets = array(); $sheets = array();
if (is_null($this->_sheetIndex)) { if (is_null($this->sheetIndex)) {
$sheets = $this->_phpExcel->getAllSheets(); $sheets = $this->phpExcel->getAllSheets();
} else { } else {
$sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex); $sheets[] = $this->phpExcel->getSheet($this->sheetIndex);
} }
// Build styles per sheet // Build styles per sheet
@ -841,16 +841,16 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()) - 1; $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()) - 1;
$column = -1; $column = -1;
while ($column++ < $highestColumnIndex) { while ($column++ < $highestColumnIndex) {
$this->_columnWidths[$sheetIndex][$column] = 42; // approximation $this->columnWidths[$sheetIndex][$column] = 42; // approximation
$css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = '42pt'; $css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = '42pt';
} }
// col elements, loop through columnDimensions and set width // col elements, loop through columnDimensions and set width
foreach ($sheet->getColumnDimensions() as $columnDimension) { foreach ($sheet->getColumnDimensions() as $columnDimension) {
if (($width = PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth(), $this->_defaultFont)) >= 0) { if (($width = PHPExcel_Shared_Drawing::cellDimensionToPixels($columnDimension->getWidth(), $this->defaultFont)) >= 0) {
$width = PHPExcel_Shared_Drawing::pixelsToPoints($width); $width = PHPExcel_Shared_Drawing::pixelsToPoints($width);
$column = PHPExcel_Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1; $column = PHPExcel_Cell::columnIndexFromString($columnDimension->getColumnIndex()) - 1;
$this->_columnWidths[$sheetIndex][$column] = $width; $this->columnWidths[$sheetIndex][$column] = $width;
$css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = $width . 'pt'; $css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = $width . 'pt';
if ($columnDimension->getVisible() === false) { if ($columnDimension->getVisible() === false) {
@ -867,7 +867,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$css['table.sheet' . $sheetIndex . ' tr'] = array(); $css['table.sheet' . $sheetIndex . ' tr'] = array();
if ($rowDimension->getRowHeight() == -1) { if ($rowDimension->getRowHeight() == -1) {
$pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->_phpExcel->getDefaultStyle()->getFont()); $pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->phpExcel->getDefaultStyle()->getFont());
} else { } else {
$pt_height = $rowDimension->getRowHeight(); $pt_height = $rowDimension->getRowHeight();
} }
@ -885,7 +885,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$css['table.sheet' . $sheetIndex . ' tr.row' . $row] = array(); $css['table.sheet' . $sheetIndex . ' tr.row' . $row] = array();
if ($rowDimension->getRowHeight() == -1) { if ($rowDimension->getRowHeight() == -1) {
$pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->_phpExcel->getDefaultStyle()->getFont()); $pt_height = PHPExcel_Shared_Font::getDefaultRowHeightByFont($this->phpExcel->getDefaultStyle()->getFont());
} else { } else {
$pt_height = $rowDimension->getRowHeight(); $pt_height = $rowDimension->getRowHeight();
} }
@ -898,8 +898,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
} }
// Cache // Cache
if (is_null($this->_cssStyles)) { if (is_null($this->cssStyles)) {
$this->_cssStyles = $css; $this->cssStyles = $css;
} }
// Return // Return
@ -912,17 +912,17 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param PHPExcel_Style $pStyle PHPExcel_Style * @param PHPExcel_Style $pStyle PHPExcel_Style
* @return array * @return array
*/ */
private function _createCSSStyle(PHPExcel_Style $pStyle) private function createCSSStyle(PHPExcel_Style $pStyle)
{ {
// Construct CSS // Construct CSS
$css = ''; $css = '';
// Create CSS // Create CSS
$css = array_merge( $css = array_merge(
$this->_createCSSStyleAlignment($pStyle->getAlignment()), $this->createCSSStyleAlignment($pStyle->getAlignment()),
$this->_createCSSStyleBorders($pStyle->getBorders()), $this->createCSSStyleBorders($pStyle->getBorders()),
$this->_createCSSStyleFont($pStyle->getFont()), $this->createCSSStyleFont($pStyle->getFont()),
$this->_createCSSStyleFill($pStyle->getFill()) $this->createCSSStyleFill($pStyle->getFill())
); );
// Return // Return
@ -935,14 +935,14 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param PHPExcel_Style_Alignment $pStyle PHPExcel_Style_Alignment * @param PHPExcel_Style_Alignment $pStyle PHPExcel_Style_Alignment
* @return array * @return array
*/ */
private function _createCSSStyleAlignment(PHPExcel_Style_Alignment $pStyle) private function createCSSStyleAlignment(PHPExcel_Style_Alignment $pStyle)
{ {
// Construct CSS // Construct CSS
$css = array(); $css = array();
// Create CSS // Create CSS
$css['vertical-align'] = $this->_mapVAlign($pStyle->getVertical()); $css['vertical-align'] = $this->mapVAlign($pStyle->getVertical());
if ($textAlign = $this->_mapHAlign($pStyle->getHorizontal())) { if ($textAlign = $this->mapHAlign($pStyle->getHorizontal())) {
$css['text-align'] = $textAlign; $css['text-align'] = $textAlign;
if (in_array($textAlign, array('left', 'right'))) { if (in_array($textAlign, array('left', 'right'))) {
$css['padding-'.$textAlign] = (string)((int)$pStyle->getIndent() * 9).'px'; $css['padding-'.$textAlign] = (string)((int)$pStyle->getIndent() * 9).'px';
@ -958,7 +958,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param PHPExcel_Style_Font $pStyle PHPExcel_Style_Font * @param PHPExcel_Style_Font $pStyle PHPExcel_Style_Font
* @return array * @return array
*/ */
private function _createCSSStyleFont(PHPExcel_Style_Font $pStyle) private function createCSSStyleFont(PHPExcel_Style_Font $pStyle)
{ {
// Construct CSS // Construct CSS
$css = array(); $css = array();
@ -991,16 +991,16 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param PHPExcel_Style_Borders $pStyle PHPExcel_Style_Borders * @param PHPExcel_Style_Borders $pStyle PHPExcel_Style_Borders
* @return array * @return array
*/ */
private function _createCSSStyleBorders(PHPExcel_Style_Borders $pStyle) private function createCSSStyleBorders(PHPExcel_Style_Borders $pStyle)
{ {
// Construct CSS // Construct CSS
$css = array(); $css = array();
// Create CSS // Create CSS
$css['border-bottom'] = $this->_createCSSStyleBorder($pStyle->getBottom()); $css['border-bottom'] = $this->createCSSStyleBorder($pStyle->getBottom());
$css['border-top'] = $this->_createCSSStyleBorder($pStyle->getTop()); $css['border-top'] = $this->createCSSStyleBorder($pStyle->getTop());
$css['border-left'] = $this->_createCSSStyleBorder($pStyle->getLeft()); $css['border-left'] = $this->createCSSStyleBorder($pStyle->getLeft());
$css['border-right'] = $this->_createCSSStyleBorder($pStyle->getRight()); $css['border-right'] = $this->createCSSStyleBorder($pStyle->getRight());
return $css; return $css;
} }
@ -1011,12 +1011,12 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param PHPExcel_Style_Border $pStyle PHPExcel_Style_Border * @param PHPExcel_Style_Border $pStyle PHPExcel_Style_Border
* @return string * @return string
*/ */
private function _createCSSStyleBorder(PHPExcel_Style_Border $pStyle) private function createCSSStyleBorder(PHPExcel_Style_Border $pStyle)
{ {
// Create CSS // Create CSS
// $css = $this->_mapBorderStyle($pStyle->getBorderStyle()) . ' #' . $pStyle->getColor()->getRGB(); // $css = $this->mapBorderStyle($pStyle->getBorderStyle()) . ' #' . $pStyle->getColor()->getRGB();
// Create CSS - add !important to non-none border styles for merged cells // Create CSS - add !important to non-none border styles for merged cells
$borderStyle = $this->_mapBorderStyle($pStyle->getBorderStyle()); $borderStyle = $this->mapBorderStyle($pStyle->getBorderStyle());
$css = $borderStyle . ' #' . $pStyle->getColor()->getRGB() . (($borderStyle == 'none') ? '' : ' !important'); $css = $borderStyle . ' #' . $pStyle->getColor()->getRGB() . (($borderStyle == 'none') ? '' : ' !important');
return $css; return $css;
@ -1028,7 +1028,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param PHPExcel_Style_Fill $pStyle PHPExcel_Style_Fill * @param PHPExcel_Style_Fill $pStyle PHPExcel_Style_Fill
* @return array * @return array
*/ */
private function _createCSSStyleFill(PHPExcel_Style_Fill $pStyle) private function createCSSStyleFill(PHPExcel_Style_Fill $pStyle)
{ {
// Construct HTML // Construct HTML
$css = array(); $css = array();
@ -1061,22 +1061,22 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string * @return string
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _generateTableHeader($pSheet) private function generateTableHeader($pSheet)
{ {
$sheetIndex = $pSheet->getParent()->getIndex($pSheet); $sheetIndex = $pSheet->getParent()->getIndex($pSheet);
// Construct HTML // Construct HTML
$html = ''; $html = '';
$html .= $this->_setMargins($pSheet); $html .= $this->setMargins($pSheet);
if (!$this->_useInlineCss) { if (!$this->useInlineCss) {
$gridlines = $pSheet->getShowGridlines() ? ' gridlines' : ''; $gridlines = $pSheet->getShowGridlines() ? ' gridlines' : '';
$html .= ' <table border="0" cellpadding="0" cellspacing="0" id="sheet' . $sheetIndex . '" class="sheet' . $sheetIndex . $gridlines . '">' . PHP_EOL; $html .= ' <table border="0" cellpadding="0" cellspacing="0" id="sheet' . $sheetIndex . '" class="sheet' . $sheetIndex . $gridlines . '">' . PHP_EOL;
} else { } else {
$style = isset($this->_cssStyles['table']) ? $style = isset($this->cssStyles['table']) ?
$this->_assembleCSS($this->_cssStyles['table']) : ''; $this->assembleCSS($this->cssStyles['table']) : '';
if ($this->_isPdf && $pSheet->getShowGridlines()) { if ($this->isPdf && $pSheet->getShowGridlines()) {
$html .= ' <table border="1" cellpadding="1" id="sheet' . $sheetIndex . '" cellspacing="1" style="' . $style . '">' . PHP_EOL; $html .= ' <table border="1" cellpadding="1" id="sheet' . $sheetIndex . '" cellspacing="1" style="' . $style . '">' . PHP_EOL;
} else { } else {
$html .= ' <table border="0" cellpadding="1" id="sheet' . $sheetIndex . '" cellspacing="0" style="' . $style . '">' . PHP_EOL; $html .= ' <table border="0" cellpadding="1" id="sheet' . $sheetIndex . '" cellspacing="0" style="' . $style . '">' . PHP_EOL;
@ -1087,12 +1087,12 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1; $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1;
$i = -1; $i = -1;
while ($i++ < $highestColumnIndex) { while ($i++ < $highestColumnIndex) {
if (!$this->_isPdf) { if (!$this->isPdf) {
if (!$this->_useInlineCss) { if (!$this->useInlineCss) {
$html .= ' <col class="col' . $i . '">' . PHP_EOL; $html .= ' <col class="col' . $i . '">' . PHP_EOL;
} else { } else {
$style = isset($this->_cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) ? $style = isset($this->cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) ?
$this->_assembleCSS($this->_cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) : ''; $this->assembleCSS($this->cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) : '';
$html .= ' <col style="' . $style . '">' . PHP_EOL; $html .= ' <col style="' . $style . '">' . PHP_EOL;
} }
} }
@ -1106,7 +1106,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* *
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _generateTableFooter() private function generateTableFooter()
{ {
$html = ' </table>' . PHP_EOL; $html = ' </table>' . PHP_EOL;
@ -1122,7 +1122,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string * @return string
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _generateRow(PHPExcel_Worksheet $pSheet, $pValues = null, $pRow = 0, $cellType = 'td') private function generateRow(PHPExcel_Worksheet $pSheet, $pValues = null, $pRow = 0, $cellType = 'td')
{ {
if (is_array($pValues)) { if (is_array($pValues)) {
// Construct HTML // Construct HTML
@ -1132,28 +1132,28 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$sheetIndex = $pSheet->getParent()->getIndex($pSheet); $sheetIndex = $pSheet->getParent()->getIndex($pSheet);
// DomPDF and breaks // DomPDF and breaks
if ($this->_isPdf && count($pSheet->getBreaks()) > 0) { if ($this->isPdf && count($pSheet->getBreaks()) > 0) {
$breaks = $pSheet->getBreaks(); $breaks = $pSheet->getBreaks();
// check if a break is needed before this row // check if a break is needed before this row
if (isset($breaks['A' . $pRow])) { if (isset($breaks['A' . $pRow])) {
// close table: </table> // close table: </table>
$html .= $this->_generateTableFooter(); $html .= $this->generateTableFooter();
// insert page break // insert page break
$html .= '<div style="page-break-before:always" />'; $html .= '<div style="page-break-before:always" />';
// open table again: <table> + <col> etc. // open table again: <table> + <col> etc.
$html .= $this->_generateTableHeader($pSheet); $html .= $this->generateTableHeader($pSheet);
} }
} }
// Write row start // Write row start
if (!$this->_useInlineCss) { if (!$this->useInlineCss) {
$html .= ' <tr class="row' . $pRow . '">' . PHP_EOL; $html .= ' <tr class="row' . $pRow . '">' . PHP_EOL;
} else { } else {
$style = isset($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]) $style = isset($this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow])
? $this->_assembleCSS($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]) : ''; ? $this->assembleCSS($this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]) : '';
$html .= ' <tr style="' . $style . '">' . PHP_EOL; $html .= ' <tr style="' . $style . '">' . PHP_EOL;
} }
@ -1163,18 +1163,18 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
foreach ($pValues as $cellAddress) { foreach ($pValues as $cellAddress) {
$cell = ($cellAddress > '') ? $pSheet->getCell($cellAddress) : ''; $cell = ($cellAddress > '') ? $pSheet->getCell($cellAddress) : '';
$coordinate = PHPExcel_Cell::stringFromColumnIndex($colNum) . ($pRow + 1); $coordinate = PHPExcel_Cell::stringFromColumnIndex($colNum) . ($pRow + 1);
if (!$this->_useInlineCss) { if (!$this->useInlineCss) {
$cssClass = ''; $cssClass = '';
$cssClass = 'column' . $colNum; $cssClass = 'column' . $colNum;
} else { } else {
$cssClass = array(); $cssClass = array();
if ($cellType == 'th') { if ($cellType == 'th') {
if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' th.column' . $colNum])) { if (isset($this->cssStyles['table.sheet' . $sheetIndex . ' th.column' . $colNum])) {
$this->_cssStyles['table.sheet' . $sheetIndex . ' th.column' . $colNum]; $this->cssStyles['table.sheet' . $sheetIndex . ' th.column' . $colNum];
} }
} else { } else {
if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum])) { if (isset($this->cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum])) {
$this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum]; $this->cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum];
} }
} }
} }
@ -1197,7 +1197,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
foreach ($elements as $element) { foreach ($elements as $element) {
// Rich text start? // Rich text start?
if ($element instanceof PHPExcel_RichText_Run) { if ($element instanceof PHPExcel_RichText_Run) {
$cellData .= '<span style="' . $this->_assembleCSS($this->_createCSSStyleFont($element->getFont())) . '">'; $cellData .= '<span style="' . $this->assembleCSS($this->createCSSStyleFont($element->getFont())) . '">';
if ($element->getFont()->getSuperScript()) { if ($element->getFont()->getSuperScript()) {
$cellData .= '<sup>'; $cellData .= '<sup>';
@ -1250,25 +1250,25 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$cellData = nl2br($cellData); $cellData = nl2br($cellData);
// Extend CSS class? // Extend CSS class?
if (!$this->_useInlineCss) { if (!$this->useInlineCss) {
$cssClass .= ' style' . $cell->getXfIndex(); $cssClass .= ' style' . $cell->getXfIndex();
$cssClass .= ' ' . $cell->getDataType(); $cssClass .= ' ' . $cell->getDataType();
} else { } else {
if ($cellType == 'th') { if ($cellType == 'th') {
if (isset($this->_cssStyles['th.style' . $cell->getXfIndex()])) { if (isset($this->cssStyles['th.style' . $cell->getXfIndex()])) {
$cssClass = array_merge($cssClass, $this->_cssStyles['th.style' . $cell->getXfIndex()]); $cssClass = array_merge($cssClass, $this->cssStyles['th.style' . $cell->getXfIndex()]);
} }
} else { } else {
if (isset($this->_cssStyles['td.style' . $cell->getXfIndex()])) { if (isset($this->cssStyles['td.style' . $cell->getXfIndex()])) {
$cssClass = array_merge($cssClass, $this->_cssStyles['td.style' . $cell->getXfIndex()]); $cssClass = array_merge($cssClass, $this->cssStyles['td.style' . $cell->getXfIndex()]);
} }
} }
// General horizontal alignment: Actual horizontal alignment depends on dataType // General horizontal alignment: Actual horizontal alignment depends on dataType
$sharedStyle = $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex()); $sharedStyle = $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex());
if ($sharedStyle->getAlignment()->getHorizontal() == PHPExcel_Style_Alignment::HORIZONTAL_GENERAL if ($sharedStyle->getAlignment()->getHorizontal() == PHPExcel_Style_Alignment::HORIZONTAL_GENERAL
&& isset($this->_cssStyles['.' . $cell->getDataType()]['text-align'])) { && isset($this->cssStyles['.' . $cell->getDataType()]['text-align'])) {
$cssClass['text-align'] = $this->_cssStyles['.' . $cell->getDataType()]['text-align']; $cssClass['text-align'] = $this->cssStyles['.' . $cell->getDataType()]['text-align'];
} }
} }
} }
@ -1279,21 +1279,21 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
} }
// Should the cell be written or is it swallowed by a rowspan or colspan? // Should the cell be written or is it swallowed by a rowspan or colspan?
$writeCell = !(isset($this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum]) $writeCell = !(isset($this->isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])
&& $this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum]); && $this->isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum]);
// Colspan and Rowspan // Colspan and Rowspan
$colspan = 1; $colspan = 1;
$rowspan = 1; $rowspan = 1;
if (isset($this->_isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])) { if (isset($this->isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])) {
$spans = $this->_isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum]; $spans = $this->isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum];
$rowSpan = $spans['rowspan']; $rowSpan = $spans['rowspan'];
$colSpan = $spans['colspan']; $colSpan = $spans['colspan'];
// Also apply style from last cell in merge to fix borders - // Also apply style from last cell in merge to fix borders -
// relies on !important for non-none border declarations in _createCSSStyleBorder // relies on !important for non-none border declarations in createCSSStyleBorder
$endCellCoord = PHPExcel_Cell::stringFromColumnIndex($colNum + $colSpan - 1) . ($pRow + $rowSpan); $endCellCoord = PHPExcel_Cell::stringFromColumnIndex($colNum + $colSpan - 1) . ($pRow + $rowSpan);
if (!$this->_useInlineCss) { if (!$this->useInlineCss) {
$cssClass .= ' style' . $pSheet->getCell($endCellCoord)->getXfIndex(); $cssClass .= ' style' . $pSheet->getCell($endCellCoord)->getXfIndex();
} }
} }
@ -1302,7 +1302,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
if ($writeCell) { if ($writeCell) {
// Column start // Column start
$html .= ' <' . $cellType; $html .= ' <' . $cellType;
if (!$this->_useInlineCss) { if (!$this->useInlineCss) {
$html .= ' class="' . $cssClass . '"'; $html .= ' class="' . $cssClass . '"';
} else { } else {
//** Necessary redundant code for the sake of PHPExcel_Writer_PDF ** //** Necessary redundant code for the sake of PHPExcel_Writer_PDF **
@ -1312,21 +1312,21 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$i = $colNum - 1; $i = $colNum - 1;
$e = $colNum + $colSpan - 1; $e = $colNum + $colSpan - 1;
while ($i++ < $e) { while ($i++ < $e) {
if (isset($this->_columnWidths[$sheetIndex][$i])) { if (isset($this->columnWidths[$sheetIndex][$i])) {
$width += $this->_columnWidths[$sheetIndex][$i]; $width += $this->columnWidths[$sheetIndex][$i];
} }
} }
$cssClass['width'] = $width . 'pt'; $cssClass['width'] = $width . 'pt';
// We must also explicitly write the height of the <td> element because TCPDF // We must also explicitly write the height of the <td> element because TCPDF
// does not recognize e.g. <tr style="height:50pt"> // does not recognize e.g. <tr style="height:50pt">
if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]['height'])) { if (isset($this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]['height'])) {
$height = $this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]['height']; $height = $this->cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]['height'];
$cssClass['height'] = $height; $cssClass['height'] = $height;
} }
//** end of redundant code ** //** end of redundant code **
$html .= ' style="' . $this->_assembleCSS($cssClass) . '"'; $html .= ' style="' . $this->assembleCSS($cssClass) . '"';
} }
if ($colSpan > 1) { if ($colSpan > 1) {
$html .= ' colspan="' . $colSpan . '"'; $html .= ' colspan="' . $colSpan . '"';
@ -1337,11 +1337,11 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$html .= '>'; $html .= '>';
// Image? // Image?
$html .= $this->_writeImageInCell($pSheet, $coordinate); $html .= $this->writeImageInCell($pSheet, $coordinate);
// Chart? // Chart?
if ($this->_includeCharts) { if ($this->includeCharts) {
$html .= $this->_writeChartInCell($pSheet, $coordinate); $html .= $this->writeChartInCell($pSheet, $coordinate);
} }
// Cell data // Cell data
@ -1371,7 +1371,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param array * @param array
* @return string * @return string
*/ */
private function _assembleCSS($pValue = array()) private function assembleCSS($pValue = array())
{ {
$pairs = array(); $pairs = array();
foreach ($pValue as $property => $value) { foreach ($pValue as $property => $value) {
@ -1389,7 +1389,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function getImagesRoot() public function getImagesRoot()
{ {
return $this->_imagesRoot; return $this->imagesRoot;
} }
/** /**
@ -1400,7 +1400,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function setImagesRoot($pValue = '.') public function setImagesRoot($pValue = '.')
{ {
$this->_imagesRoot = $pValue; $this->imagesRoot = $pValue;
return $this; return $this;
} }
@ -1411,7 +1411,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function getEmbedImages() public function getEmbedImages()
{ {
return $this->_embedImages; return $this->embedImages;
} }
/** /**
@ -1422,7 +1422,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function setEmbedImages($pValue = '.') public function setEmbedImages($pValue = '.')
{ {
$this->_embedImages = $pValue; $this->embedImages = $pValue;
return $this; return $this;
} }
@ -1433,7 +1433,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function getUseInlineCss() public function getUseInlineCss()
{ {
return $this->_useInlineCss; return $this->useInlineCss;
} }
/** /**
@ -1444,7 +1444,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
*/ */
public function setUseInlineCss($pValue = false) public function setUseInlineCss($pValue = false)
{ {
$this->_useInlineCss = $pValue; $this->useInlineCss = $pValue;
return $this; return $this;
} }
@ -1482,22 +1482,22 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
/** /**
* Calculate information about HTML colspan and rowspan which is not always the same as Excel's * Calculate information about HTML colspan and rowspan which is not always the same as Excel's
*/ */
private function _calculateSpans() private function calculateSpans()
{ {
// Identify all cells that should be omitted in HTML due to cell merge. // Identify all cells that should be omitted in HTML due to cell merge.
// In HTML only the upper-left cell should be written and it should have // In HTML only the upper-left cell should be written and it should have
// appropriate rowspan / colspan attribute // appropriate rowspan / colspan attribute
$sheetIndexes = $this->_sheetIndex !== null ? $sheetIndexes = $this->sheetIndex !== null ?
array($this->_sheetIndex) : range(0, $this->_phpExcel->getSheetCount() - 1); array($this->sheetIndex) : range(0, $this->phpExcel->getSheetCount() - 1);
foreach ($sheetIndexes as $sheetIndex) { foreach ($sheetIndexes as $sheetIndex) {
$sheet = $this->_phpExcel->getSheet($sheetIndex); $sheet = $this->phpExcel->getSheet($sheetIndex);
$candidateSpannedRow = array(); $candidateSpannedRow = array();
// loop through all Excel merged cells // loop through all Excel merged cells
foreach ($sheet->getMergeCells() as $cells) { foreach ($sheet->getMergeCells() as $cells) {
list($cells, ) = PHPExcel_Cell::splitRange($cells); list($cells,) = PHPExcel_Cell::splitRange($cells);
$first = $cells[0]; $first = $cells[0];
$last = $cells[1]; $last = $cells[1];
@ -1517,12 +1517,12 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
while ($c++ < $lc) { while ($c++ < $lc) {
if (!($c == $fc && $r == $fr)) { if (!($c == $fc && $r == $fr)) {
// not the upper-left cell (should not be written in HTML) // not the upper-left cell (should not be written in HTML)
$this->_isSpannedCell[$sheetIndex][$r][$c] = array( $this->isSpannedCell[$sheetIndex][$r][$c] = array(
'baseCell' => array($fr, $fc), 'baseCell' => array($fr, $fc),
); );
} else { } else {
// upper-left is the base cell that should hold the colspan/rowspan attribute // upper-left is the base cell that should hold the colspan/rowspan attribute
$this->_isBaseCell[$sheetIndex][$r][$c] = array( $this->isBaseCell[$sheetIndex][$r][$c] = array(
'xlrowspan' => $lr - $fr + 1, // Excel rowspan 'xlrowspan' => $lr - $fr + 1, // Excel rowspan
'rowspan' => $lr - $fr + 1, // HTML rowspan, value may change 'rowspan' => $lr - $fr + 1, // HTML rowspan, value may change
'xlcolspan' => $lc - $fc + 1, // Excel colspan 'xlcolspan' => $lc - $fc + 1, // Excel colspan
@ -1537,25 +1537,25 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
// participate in a merge and the where base cells are somewhere above. // participate in a merge and the where base cells are somewhere above.
$countColumns = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()); $countColumns = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn());
foreach ($candidateSpannedRow as $rowIndex) { foreach ($candidateSpannedRow as $rowIndex) {
if (isset($this->_isSpannedCell[$sheetIndex][$rowIndex])) { if (isset($this->isSpannedCell[$sheetIndex][$rowIndex])) {
if (count($this->_isSpannedCell[$sheetIndex][$rowIndex]) == $countColumns) { if (count($this->isSpannedCell[$sheetIndex][$rowIndex]) == $countColumns) {
$this->_isSpannedRow[$sheetIndex][$rowIndex] = $rowIndex; $this->isSpannedRow[$sheetIndex][$rowIndex] = $rowIndex;
}; };
} }
} }
// For each of the omitted rows we found above, the affected rowspans should be subtracted by 1 // For each of the omitted rows we found above, the affected rowspans should be subtracted by 1
if (isset($this->_isSpannedRow[$sheetIndex])) { if (isset($this->isSpannedRow[$sheetIndex])) {
foreach ($this->_isSpannedRow[$sheetIndex] as $rowIndex) { foreach ($this->isSpannedRow[$sheetIndex] as $rowIndex) {
$adjustedBaseCells = array(); $adjustedBaseCells = array();
$c = -1; $c = -1;
$e = $countColumns - 1; $e = $countColumns - 1;
while ($c++ < $e) { while ($c++ < $e) {
$baseCell = $this->_isSpannedCell[$sheetIndex][$rowIndex][$c]['baseCell']; $baseCell = $this->isSpannedCell[$sheetIndex][$rowIndex][$c]['baseCell'];
if (!in_array($baseCell, $adjustedBaseCells)) { if (!in_array($baseCell, $adjustedBaseCells)) {
// subtract rowspan by 1 // subtract rowspan by 1
--$this->_isBaseCell[$sheetIndex][ $baseCell[0] ][ $baseCell[1] ]['rowspan']; --$this->isBaseCell[$sheetIndex][ $baseCell[0] ][ $baseCell[1] ]['rowspan'];
$adjustedBaseCells[] = $baseCell; $adjustedBaseCells[] = $baseCell;
} }
} }
@ -1566,10 +1566,10 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
} }
// We have calculated the spans // We have calculated the spans
$this->_spansAreCalculated = true; $this->spansAreCalculated = true;
} }
private function _setMargins(PHPExcel_Worksheet $pSheet) private function setMargins(PHPExcel_Worksheet $pSheet)
{ {
$htmlPage = '@page { '; $htmlPage = '@page { ';
$htmlBody = 'body { '; $htmlBody = 'body { ';

View File

@ -320,7 +320,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
protected function prepareForSave($pFilename = null) protected function prepareForSave($pFilename = null)
{ {
// garbage collect // garbage collect
$this->_phpExcel->garbageCollect(); $this->phpExcel->garbageCollect();
$this->saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); $this->saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
@ -332,7 +332,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
} }
// Set PDF // Set PDF
$this->_isPdf = true; $this->isPdf = true;
// Build CSS // Build CSS
$this->buildCSS(true); $this->buildCSS(true);

View File

@ -60,15 +60,15 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
// Check for paper size and page orientation // Check for paper size and page orientation
if (is_null($this->getSheetIndex())) { if (is_null($this->getSheetIndex())) {
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() $orientation = ($this->phpExcel->getSheet(0)->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); $printPaperSize = $this->phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); $printMargins = $this->phpExcel->getSheet(0)->getPageMargins();
} else { } else {
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() $orientation = ($this->phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printPaperSize = $this->phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); $printMargins = $this->phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
} }
$orientation = ($orientation == 'L') ? 'landscape' : 'portrait'; $orientation = ($orientation == 'L') ? 'landscape' : 'portrait';

View File

@ -60,15 +60,15 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
// Check for paper size and page orientation // Check for paper size and page orientation
if (is_null($this->getSheetIndex())) { if (is_null($this->getSheetIndex())) {
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() $orientation = ($this->phpExcel->getSheet(0)->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); $printPaperSize = $this->phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); $printMargins = $this->phpExcel->getSheet(0)->getPageMargins();
} else { } else {
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() $orientation = ($this->phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printPaperSize = $this->phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); $printMargins = $this->phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
} }
$this->setOrientation($orientation); $this->setOrientation($orientation);
@ -98,11 +98,11 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
$pdf->AddPage($orientation); $pdf->AddPage($orientation);
// Document info // Document info
$pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); $pdf->SetTitle($this->phpExcel->getProperties()->getTitle());
$pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); $pdf->SetAuthor($this->phpExcel->getProperties()->getCreator());
$pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); $pdf->SetSubject($this->phpExcel->getProperties()->getSubject());
$pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); $pdf->SetKeywords($this->phpExcel->getProperties()->getKeywords());
$pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); $pdf->SetCreator($this->phpExcel->getProperties()->getCreator());
$pdf->WriteHTML( $pdf->WriteHTML(
$this->generateHTMLHeader(false) . $this->generateHTMLHeader(false) .

View File

@ -61,15 +61,15 @@ class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPE
// Check for paper size and page orientation // Check for paper size and page orientation
if (is_null($this->getSheetIndex())) { if (is_null($this->getSheetIndex())) {
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() $orientation = ($this->phpExcel->getSheet(0)->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); $printPaperSize = $this->phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); $printMargins = $this->phpExcel->getSheet(0)->getPageMargins();
} else { } else {
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() $orientation = ($this->phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P'; == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printPaperSize = $this->phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); $printMargins = $this->phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
} }
// Override Page Orientation // Override Page Orientation
@ -109,11 +109,11 @@ class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPE
); );
// Document info // Document info
$pdf->SetTitle($this->_phpExcel->getProperties()->getTitle()); $pdf->SetTitle($this->phpExcel->getProperties()->getTitle());
$pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator()); $pdf->SetAuthor($this->phpExcel->getProperties()->getCreator());
$pdf->SetSubject($this->_phpExcel->getProperties()->getSubject()); $pdf->SetSubject($this->phpExcel->getProperties()->getSubject());
$pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords()); $pdf->SetKeywords($this->phpExcel->getProperties()->getKeywords());
$pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); $pdf->SetCreator($this->phpExcel->getProperties()->getCreator());
// Write to file // Write to file
fwrite($fileHandle, $pdf->output($pFilename, 'S')); fwrite($fileHandle, $pdf->output($pFilename, 'S'));

View File

@ -3,4 +3,4 @@
-10, 3, -3 -10, 3, -3
10, 2.2, 4 10, 2.2, 4
5.5, 2.667, 2 5.5, 2.667, 2
-7, 2, -4 -7, 2, -3