Upgraded PHPExcel to v1.8.1

Fixes issues with PHP 7
This commit is contained in:
Raphaël Doursenaud 2015-11-03 10:48:57 +01:00
parent 0e155be4e8
commit e5915ce8d9
146 changed files with 8438 additions and 2225 deletions

View File

@ -24,7 +24,7 @@ Mobiledetect 2.8.3 MIT License Yes
NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
odtPHP 1.0.1 GPL-2+ b Yes Library to build/edit ODT files
PHPExcel 1.8.0 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
PHPExcel 1.8.1 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP
PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service
PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests

View File

@ -19,7 +19,7 @@
"ckeditor/ckeditor": "dev-full/4.3.x#0b7c3f1",
"mike42/escpos-php": "dev-master",
"mobiledetect/mobiledetectlib": "2.8.3",
"phpoffice/phpexcel": "1.8.0",
"phpoffice/phpexcel": "1.8.1",
"restler/framework": "^3.0",
"tecnick.com/tcpdf": "6.2.6",
"raven/raven": "^0.12.0",

12
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "4dfedf298cf48a9a69726e02121890aa",
"hash": "1c6ca041da94484642adcbde492ad50b",
"packages": [
{
"name": "ccampbell/chromephp",
@ -238,16 +238,16 @@
},
{
"name": "phpoffice/phpexcel",
"version": "1.8.0",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PHPExcel.git",
"reference": "e69a5e4d0ffa7fb6f171859e0a04346e580df30b"
"reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/e69a5e4d0ffa7fb6f171859e0a04346e580df30b",
"reference": "e69a5e4d0ffa7fb6f171859e0a04346e580df30b",
"url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/372c7cbb695a6f6f1e62649381aeaa37e7e70b32",
"reference": "372c7cbb695a6f6f1e62649381aeaa37e7e70b32",
"shasum": ""
},
"require": {
@ -291,7 +291,7 @@
"xls",
"xlsx"
],
"time": "2014-03-02 15:22:49"
"time": "2015-05-01 07:00:55"
},
{
"name": "raven/raven",

View File

@ -6,6 +6,12 @@ php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
matrix:
allow_failures:
- php: hhvm
script:
- phpunit -c ./unitTests/

View File

@ -461,10 +461,12 @@ class PHPExcel
* Get active sheet
*
* @return PHPExcel_Worksheet
*
* @throws PHPExcel_Exception
*/
public function getActiveSheet()
{
return $this->_workSheetCollection[$this->_activeSheetIndex];
return $this->getSheet($this->_activeSheetIndex);
}
/**
@ -570,16 +572,14 @@ class PHPExcel
*/
public function getSheet($pIndex = 0)
{
$numSheets = count($this->_workSheetCollection);
if ($pIndex > $numSheets - 1) {
if (!isset($this->_workSheetCollection[$pIndex])) {
$numSheets = $this->getSheetCount();
throw new PHPExcel_Exception(
"Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}."
);
} else {
return $this->_workSheetCollection[$pIndex];
"Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}."
);
}
return $this->_workSheetCollection[$pIndex];
}
/**
@ -682,7 +682,7 @@ class PHPExcel
*/
public function setActiveSheetIndex($pIndex = 0)
{
$numSheets = count($this->_workSheetCollection);
$numSheets = count($this->_workSheetCollection);
if ($pIndex > $numSheets - 1) {
throw new PHPExcel_Exception(
@ -1011,7 +1011,7 @@ class PHPExcel
*/
public function getCellStyleXfByHashCode($pValue = '')
{
foreach ($this->_cellXfStyleCollection as $cellStyleXf) {
foreach ($this->_cellStyleXfCollection as $cellStyleXf) {
if ($cellStyleXf->getHashCode() == $pValue) {
return $cellStyleXf;
}

View File

@ -55,7 +55,11 @@ class PHPExcel_Autoloader
spl_autoload_register('__autoload');
}
// Register ourselves with SPL
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'), true, true);
} else {
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
}
} // function Register()

View File

@ -80,7 +80,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
* @access public
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
@ -102,7 +102,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
*
* @access public
* @param string $pCoord Coordinate address of the cell to check
* @return void
* @throws PHPExcel_Exception
* @return boolean
*/
public function isDataSet($pCoord) {
@ -165,7 +165,7 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {

View File

@ -136,7 +136,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
* Add or Update a cell in cache
*
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function updateCacheData(PHPExcel_Cell $cell) {
@ -151,7 +151,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
* @throws PHPExcel_Exception
*/
public function deleteCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
if ($pCoord === $this->_currentObjectID && !is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObjectID = $this->_currentObject = null;
}
@ -167,7 +167,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList() {
return array_keys($this->_cellCache);
@ -177,7 +177,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
/**
* Sort the list of all cell addresses currently held in cache by row and column
*
* @return void
* @return string[]
*/
public function getSortedCellList() {
$sortKeys = array();
@ -206,7 +206,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
sscanf($coord,'%[A-Z]%d', $c, $r);
$row[$r] = $r;
$col[$c] = strlen($c).$c;
}
}
if (!empty($row)) {
// Determine highest column and row
$highestRow = max($row);
@ -243,12 +243,12 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
/**
* Return the row address of the currently active cell object
*
* @return string
* @return integer
*/
public function getCurrentRow()
{
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
return $row;
return (integer) $row;
}
/**
@ -333,6 +333,35 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
}
} // function copyCellCollection()
/**
* Remove a row, deleting all cells in that row
*
* @param string $row Row number to remove
* @return void
*/
public function removeRow($row) {
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $c, $r);
if ($r == $row) {
$this->deleteCacheData($coord);
}
}
}
/**
* Remove a column, deleting all cells in that column
*
* @param string $column Column ID to remove
* @return void
*/
public function removeColumn($column) {
foreach ($this->getCellList() as $coord) {
sscanf($coord,'%[A-Z]%d', $c, $r);
if ($c == $column) {
$this->deleteCacheData($coord);
}
}
}
/**
* Identify whether the caching method is currently available

View File

@ -69,11 +69,11 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
$this->_currentObject->detach();
fseek($this->_fileHandle,0,SEEK_END);
$offset = ftell($this->_fileHandle);
fwrite($this->_fileHandle, serialize($this->_currentObject));
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
'sz' => ftell($this->_fileHandle) - $offset
);
$this->_cellCache[$this->_currentObjectID] = array(
'ptr' => ftell($this->_fileHandle),
'sz' => fwrite($this->_fileHandle, serialize($this->_currentObject))
);
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
@ -85,7 +85,7 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
@ -122,8 +122,8 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
fseek($this->_fileHandle, $this->_cellCache[$pCoord]['ptr']);
$this->_currentObject = unserialize(fread($this->_fileHandle, $this->_cellCache[$pCoord]['sz']));
// Re-attach this as the cell's parent
$this->_currentObject->attach($this);
@ -135,7 +135,7 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {

View File

@ -40,7 +40,7 @@ interface PHPExcel_CachedObjectStorage_ICache
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell);
@ -49,7 +49,7 @@ interface PHPExcel_CachedObjectStorage_ICache
* Add or Update a cell in cache
*
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function updateCacheData(PHPExcel_Cell $cell);
@ -82,14 +82,14 @@ interface PHPExcel_CachedObjectStorage_ICache
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList();
/**
* Get the list of all cell addresses currently held in cache sorted by column and row
*
* @return void
* @return string[]
*/
public function getSortedCellList();

View File

@ -58,7 +58,7 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
@ -107,7 +107,7 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {

View File

@ -86,7 +86,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
@ -107,7 +107,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @param string $pCoord Coordinate address of the cell to check
* @return void
* @return boolean
* @return boolean
*/
public function isDataSet($pCoord) {
@ -169,7 +169,7 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {

View File

@ -58,7 +58,7 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
@ -107,7 +107,7 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {

View File

@ -58,7 +58,7 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
@ -107,7 +107,7 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {

View File

@ -61,11 +61,11 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
$this->_currentObject->detach();
fseek($this->_fileHandle,0,SEEK_END);
$offset = ftell($this->_fileHandle);
fwrite($this->_fileHandle, serialize($this->_currentObject));
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
'sz' => ftell($this->_fileHandle) - $offset
);
$this->_cellCache[$this->_currentObjectID] = array(
'ptr' => ftell($this->_fileHandle),
'sz' => fwrite($this->_fileHandle, serialize($this->_currentObject))
);
$this->_currentCellIsDirty = false;
}
$this->_currentObjectID = $this->_currentObject = null;
@ -77,7 +77,7 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
@ -127,7 +127,7 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {

View File

@ -73,7 +73,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
@ -198,7 +198,7 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {

View File

@ -104,7 +104,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
@ -231,7 +231,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {

View File

@ -85,7 +85,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
@ -169,7 +169,7 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
* @return string[]
*/
public function getCellList() {
if ($this->_currentObjectID !== null) {

View File

@ -58,8 +58,8 @@ class PHPExcel_CalcEngine_CyclicReferenceStack {
* @param mixed $value
*/
public function push($value) {
$this->_stack[] = $value;
} // function push()
$this->_stack[$value] = $value;
}
/**
* Pop the last entry from the stack
@ -68,7 +68,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack {
*/
public function pop() {
return array_pop($this->_stack);
} // function pop()
}
/**
* Test to see if a specified entry exists on the stack
@ -76,7 +76,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack {
* @param mixed $value The value to test
*/
public function onStack($value) {
return in_array($value, $this->_stack);
return isset($this->_stack[$value]);
}
/**
@ -84,7 +84,7 @@ class PHPExcel_CalcEngine_CyclicReferenceStack {
*/
public function clear() {
$this->_stack = array();
} // function push()
}
/**
* Return an array of all entries on the stack
@ -95,4 +95,4 @@ class PHPExcel_CalcEngine_CyclicReferenceStack {
return $this->_stack;
}
} // class PHPExcel_CalcEngine_CyclicReferenceStack
}

View File

@ -194,6 +194,8 @@ class PHPExcel_Calculation {
*/
private $_cyclicReferenceStack;
private $_cellStack = array();
/**
* Current iteration counter for cyclic formulae
* If the value is 0 (or less) then cyclic formulae will throw an exception,
@ -202,7 +204,7 @@ class PHPExcel_Calculation {
* @var integer
*
*/
private $_cyclicFormulaCount = 0;
private $_cyclicFormulaCount = 1;
private $_cyclicFormulaCell = '';
@ -212,7 +214,7 @@ class PHPExcel_Calculation {
* @var integer
*
*/
public $cyclicFormulaCount = 0;
public $cyclicFormulaCount = 1;
/**
* Precision used for calculations
@ -1626,7 +1628,7 @@ class PHPExcel_Calculation {
'argumentCount' => '2'
),
'VALUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
'functionCall' => 'PHPExcel_Calculation_TextData::VALUE',
'argumentCount' => '1'
),
'VAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
@ -1724,6 +1726,7 @@ class PHPExcel_Calculation {
if ($this->_savedPrecision < $setPrecision) {
ini_set('precision',$setPrecision);
}
$this->delta = 1 * pow(10, -$setPrecision);
if ($workbook !== NULL) {
self::$_workbookSets[$workbook->getID()] = $this;
@ -2240,9 +2243,17 @@ class PHPExcel_Calculation {
}
// Execute the calculation for the cell formula
$this->_cellStack[] = array(
'sheet' => $pCell->getWorksheet()->getTitle(),
'cell' => $pCell->getCoordinate(),
);
try {
$result = self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell));
$cellAddress = array_pop($this->_cellStack);
$this->_workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
} catch (PHPExcel_Exception $e) {
$cellAddress = array_pop($this->_cellStack);
$this->_workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
throw new PHPExcel_Calculation_Exception($e->getMessage());
}
@ -2333,24 +2344,22 @@ class PHPExcel_Calculation {
} // function calculateFormula()
public function getValueFromCache($worksheetName, $cellID, &$cellValue) {
public function getValueFromCache($cellReference, &$cellValue) {
// Is calculation cacheing enabled?
// Is the value present in calculation cache?
//echo 'Test cache for ',$worksheetName,'!',$cellID,PHP_EOL;
$this->_debugLog->writeDebugLog('Testing cache value for cell ', $worksheetName, '!', $cellID);
if (($this->_calculationCacheEnabled) && (isset($this->_calculationCache[$worksheetName][$cellID]))) {
//echo 'Retrieve from cache',PHP_EOL;
$this->_debugLog->writeDebugLog('Retrieving value for cell ', $worksheetName, '!', $cellID, ' from cache');
$this->_debugLog->writeDebugLog('Testing cache value for cell ', $cellReference);
if (($this->_calculationCacheEnabled) && (isset($this->_calculationCache[$cellReference]))) {
$this->_debugLog->writeDebugLog('Retrieving value for cell ', $cellReference, ' from cache');
// Return the cached result
$cellValue = $this->_calculationCache[$worksheetName][$cellID];
$cellValue = $this->_calculationCache[$cellReference];
return TRUE;
}
return FALSE;
}
public function saveValueToCache($worksheetName, $cellID, $cellValue) {
public function saveValueToCache($cellReference, $cellValue) {
if ($this->_calculationCacheEnabled) {
$this->_calculationCache[$worksheetName][$cellID] = $cellValue;
$this->_calculationCache[$cellReference] = $cellValue;
}
}
@ -2364,49 +2373,49 @@ class PHPExcel_Calculation {
* @throws PHPExcel_Calculation_Exception
*/
public function _calculateFormulaValue($formula, $cellID=null, PHPExcel_Cell $pCell = null) {
$cellValue = '';
$cellValue = null;
// Basic validation that this is indeed a formula
// We simply return the cell value if not
$formula = trim($formula);
if ($formula{0} != '=') return self::_wrapResult($formula);
$formula = ltrim(substr($formula,1));
$formula = ltrim(substr($formula, 1));
if (!isset($formula{0})) return self::_wrapResult($formula);
$pCellParent = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL;
$wsTitle = ($pCellParent !== NULL) ? $pCellParent->getTitle() : "\x00Wrk";
$wsCellReference = $wsTitle . '!' . $cellID;
if (($cellID !== NULL) && ($this->getValueFromCache($wsTitle, $cellID, $cellValue))) {
if (($cellID !== NULL) && ($this->getValueFromCache($wsCellReference, $cellValue))) {
return $cellValue;
}
if (($wsTitle{0} !== "\x00") && ($this->_cyclicReferenceStack->onStack($wsTitle.'!'.$cellID))) {
if ($this->cyclicFormulaCount <= 0) {
if (($wsTitle{0} !== "\x00") && ($this->_cyclicReferenceStack->onStack($wsCellReference))) {
if ($this->cyclicFormulaCount <= 0) {
$this->_cyclicFormulaCell = '';
return $this->_raiseFormulaError('Cyclic Reference in Formula');
} elseif (($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) &&
($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID)) {
return $cellValue;
} elseif ($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID) {
} elseif ($this->_cyclicFormulaCell === $wsCellReference) {
++$this->_cyclicFormulaCount;
if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
$this->_cyclicFormulaCell = '';
return $cellValue;
}
} elseif ($this->_cyclicFormulaCell == '') {
$this->_cyclicFormulaCell = $wsTitle.'!'.$cellID;
if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
return $cellValue;
}
$this->_cyclicFormulaCell = $wsCellReference;
}
}
// Parse the formula onto the token stack and calculate the value
$this->_cyclicReferenceStack->push($wsTitle.'!'.$cellID);
$this->_cyclicReferenceStack->push($wsCellReference);
$cellValue = $this->_processTokenStack($this->_parseFormula($formula, $pCell), $cellID, $pCell);
$this->_cyclicReferenceStack->pop();
// Save to calculation cache
if ($cellID !== NULL) {
$this->saveValueToCache($wsTitle, $cellID, $cellValue);
$this->saveValueToCache($wsCellReference, $cellValue);
}
// Return the calculated value
@ -2640,7 +2649,7 @@ class PHPExcel_Calculation {
} // function _showTypeDetails()
private static function _convertMatrixReferences($formula) {
private function _convertMatrixReferences($formula) {
static $matrixReplaceFrom = array('{',';','}');
static $matrixReplaceTo = array('MKMATRIX(MKMATRIX(','),MKMATRIX(','))');
@ -2729,7 +2738,7 @@ class PHPExcel_Calculation {
// Convert infix to postfix notation
private function _parseFormula($formula, PHPExcel_Cell $pCell = NULL) {
if (($formula = self::_convertMatrixReferences(trim($formula))) === FALSE) {
if (($formula = $this->_convertMatrixReferences(trim($formula))) === FALSE) {
return FALSE;
}
@ -2911,11 +2920,11 @@ class PHPExcel_Calculation {
// echo 'Element with value '.$val.' is an Operand, Variable, Constant, String, Number, Cell Reference or Function<br />';
if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) {
$val = preg_replace('/\s/','',$val);
$val = preg_replace('/\s/u','',$val);
// echo 'Element '.$val.' is a Function<br />';
if (isset(self::$_PHPExcelFunctions[strtoupper($matches[1])]) || isset(self::$_controlFunctions[strtoupper($matches[1])])) { // it's a function
$stack->push('Function', strtoupper($val));
$ax = preg_match('/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch);
$ax = preg_match('/^\s*(\s*\))/ui', substr($formula, $index+$length), $amatch);
if ($ax) {
$stack->push('Operand Count for Function '.strtoupper($val).')', 0);
$expectingOperator = TRUE;
@ -3592,27 +3601,39 @@ class PHPExcel_Calculation {
break;
// Equality
case '=':
$result = ($operand1 == $operand2);
if (is_numeric($operand1) && is_numeric($operand2)) {
$result = (abs($operand1 - $operand2) < $this->delta);
} else {
$result = strcmp($operand1, $operand2) == 0;
}
break;
// Greater than or equal
case '>=':
if ($useLowercaseFirstComparison) {
if (is_numeric($operand1) && is_numeric($operand2)) {
$result = ((abs($operand1 - $operand2) < $this->delta) || ($operand1 > $operand2));
} elseif ($useLowercaseFirstComparison) {
$result = $this->strcmpLowercaseFirst($operand1, $operand2) >= 0;
} else {
$result = ($operand1 >= $operand2);
$result = strcmp($operand1, $operand2) >= 0;
}
break;
// Less than or equal
case '<=':
if ($useLowercaseFirstComparison) {
if (is_numeric($operand1) && is_numeric($operand2)) {
$result = ((abs($operand1 - $operand2) < $this->delta) || ($operand1 < $operand2));
} elseif ($useLowercaseFirstComparison) {
$result = $this->strcmpLowercaseFirst($operand1, $operand2) <= 0;
} else {
$result = ($operand1 <= $operand2);
$result = strcmp($operand1, $operand2) <= 0;
}
break;
// Inequality
case '<>':
$result = ($operand1 != $operand2);
if (is_numeric($operand1) && is_numeric($operand2)) {
$result = (abs($operand1 - $operand2) > 1E-14);
} else {
$result = strcmp($operand1, $operand2) != 0;
}
break;
}
@ -3620,21 +3641,19 @@ class PHPExcel_Calculation {
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result));
// And push the result onto the stack
$stack->push('Value',$result);
return TRUE;
} // function _executeBinaryComparisonOperation()
return true;
}
/**
* Compare two strings in the same way as strcmp() except that lowercase come before uppercase letters
* @param string $str1
* @param string $str2
* @return integer
* @param string $str1 First string value for the comparison
* @param string $str2 Second string value for the comparison
* @return integer
*/
private function strcmpLowercaseFirst($str1, $str2)
{
$from = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$to = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$inversedStr1 = strtr($str1, $from, $to);
$inversedStr2 = strtr($str2, $from, $to);
$inversedStr1 = PHPExcel_Shared_String::StrCaseReverse($str1);
$inversedStr2 = PHPExcel_Shared_String::StrCaseReverse($str2);
return strcmp($inversedStr1, $inversedStr2);
}

View File

@ -1071,7 +1071,9 @@ class PHPExcel_Calculation_DateTime {
public static function DAYOFMONTH($dateValue = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
if ($dateValue === null) {
$dateValue = 1;
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($dateValue == 0.0) {
return 0;
@ -1114,7 +1116,9 @@ class PHPExcel_Calculation_DateTime {
}
$style = floor($style);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
if ($dateValue === null) {
$dateValue = 1;
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
@ -1180,7 +1184,9 @@ class PHPExcel_Calculation_DateTime {
}
$method = floor($method);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
if ($dateValue === null) {
$dateValue = 1;
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
@ -1216,7 +1222,9 @@ class PHPExcel_Calculation_DateTime {
public static function MONTHOFYEAR($dateValue = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
if ($dateValue === null) {
$dateValue = 1;
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();
@ -1245,7 +1253,9 @@ class PHPExcel_Calculation_DateTime {
public static function YEAR($dateValue = 1) {
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
if ($dateValue === null) {
$dateValue = 1;
} elseif (is_string($dateValue = self::_getDateValue($dateValue))) {
return PHPExcel_Calculation_Functions::VALUE();
} elseif ($dateValue < 0.0) {
return PHPExcel_Calculation_Functions::NaN();

View File

@ -496,7 +496,7 @@ class PHPExcel_Calculation_Functions {
* @return string Version information
*/
public static function VERSION() {
return 'PHPExcel ##VERSION##, ##DATE##';
return 'PHPExcel 1.8.1, 2015-04-30';
} // function VERSION()
@ -578,7 +578,6 @@ class PHPExcel_Calculation_Functions {
return 4;
} elseif(is_array($value)) {
return 64;
break;
} elseif(is_string($value)) {
// Errors
if ((strlen($value) > 0) && ($value{0} == '#')) {
@ -711,7 +710,7 @@ if ((!function_exists('mb_str_replace')) &&
}
foreach((array) $search as $key => $s) {
if($s == '') {
if($s == '' && $s !== 0) {
continue;
}
$r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : '');

View File

@ -735,11 +735,7 @@ class PHPExcel_Calculation_LookupRef {
return PHPExcel_Calculation_Functions::NA();
} else {
// otherwise return the appropriate value
$result = $lookup_array[$rowNumber][$returnColumn];
if ((is_numeric($lookup_value) && is_numeric($result)) ||
(!is_numeric($lookup_value) && !is_numeric($result))) {
return $result;
}
return $lookup_array[$rowNumber][$returnColumn];
}
}
@ -802,8 +798,7 @@ class PHPExcel_Calculation_LookupRef {
return PHPExcel_Calculation_Functions::NA();
} else {
// otherwise return the appropriate value
$result = $lookup_array[$returnColumn][$rowNumber];
return $result;
return $lookup_array[$returnColumn][$rowNumber];
}
}

View File

@ -145,8 +145,8 @@ class PHPExcel_Calculation_MathTrig {
$significance = $number/abs($number);
}
if ((is_numeric($number)) && (is_numeric($significance))) {
if ($significance == 0.0) {
if ((is_numeric($number)) && (is_numeric($significance))) {
if (($number == 0.0 ) || ($significance == 0.0)) {
return 0.0;
} elseif (self::SIGN($number) == self::SIGN($significance)) {
return ceil($number / $significance) * $significance;
@ -316,15 +316,17 @@ class PHPExcel_Calculation_MathTrig {
}
if ((is_numeric($number)) && (is_numeric($significance))) {
if ((float) $significance == 0.0) {
return PHPExcel_Calculation_Functions::DIV0();
}
if (self::SIGN($number) == self::SIGN($significance)) {
if ($significance == 0.0) {
return PHPExcel_Calculation_Functions::DIV0();
} elseif ($number == 0.0) {
return 0.0;
} elseif (self::SIGN($number) == self::SIGN($significance)) {
return floor($number / $significance) * $significance;
} else {
return PHPExcel_Calculation_Functions::NaN();
}
}
} else
return PHPExcel_Calculation_Functions::VALUE();
} // function FLOOR()
@ -607,27 +609,27 @@ class PHPExcel_Calculation_MathTrig {
if (!is_array($matrixData1)) { $matrixData1 = array(array($matrixData1)); }
if (!is_array($matrixData2)) { $matrixData2 = array(array($matrixData2)); }
$rowA = 0;
foreach($matrixData1 as $matrixRow) {
if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
$columnA = 0;
foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$matrixAData[$rowA][$columnA] = $matrixCell;
++$columnA;
}
++$rowA;
}
try {
$rowA = 0;
foreach($matrixData1 as $matrixRow) {
if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
$columnA = 0;
foreach($matrixRow as $matrixCell) {
if ((!is_numeric($matrixCell)) || ($matrixCell === null)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$matrixAData[$rowA][$columnA] = $matrixCell;
++$columnA;
}
++$rowA;
}
$matrixA = new PHPExcel_Shared_JAMA_Matrix($matrixAData);
$rowB = 0;
foreach($matrixData2 as $matrixRow) {
if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
$columnB = 0;
foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) {
if ((!is_numeric($matrixCell)) || ($matrixCell === null)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$matrixBData[$rowB][$columnB] = $matrixCell;
@ -637,12 +639,13 @@ class PHPExcel_Calculation_MathTrig {
}
$matrixB = new PHPExcel_Shared_JAMA_Matrix($matrixBData);
if (($rowA != $columnB) || ($rowB != $columnA)) {
if ($columnA != $rowB) {
return PHPExcel_Calculation_Functions::VALUE();
}
return $matrixA->times($matrixB)->getArray();
} catch (PHPExcel_Exception $ex) {
var_dump($ex->getMessage());
return PHPExcel_Calculation_Functions::VALUE();
}
} // function MMULT()
@ -880,9 +883,9 @@ class PHPExcel_Calculation_MathTrig {
$max = PHPExcel_Calculation_Functions::flattenSingleValue($max);
if ($min == 0 && $max == 0) {
return (rand(0,10000000)) / 10000000;
return (mt_rand(0,10000000)) / 10000000;
} else {
return rand($min, $max);
return mt_rand($min, $max);
}
} // function RAND()

View File

@ -2737,7 +2737,7 @@ class PHPExcel_Calculation_Statistical {
$mean = PHPExcel_Calculation_Functions::flattenSingleValue($mean);
if ((is_numeric($value)) && (is_numeric($mean))) {
if (($value <= 0) || ($mean <= 0)) {
if (($value < 0) || ($mean <= 0)) {
return PHPExcel_Calculation_Functions::NaN();
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {

View File

@ -104,7 +104,7 @@ class PHPExcel_Calculation_TextData {
}
if (is_string($stringValue) || is_numeric($stringValue)) {
return str_replace(self::$_invalidChars,'',trim($stringValue,"\x00..\x1F"));
return str_replace(self::$_invalidChars, '', trim($stringValue, "\x00..\x1F"));
}
return NULL;
} // function TRIMNONPRINTABLE()
@ -118,13 +118,12 @@ class PHPExcel_Calculation_TextData {
*/
public static function TRIMSPACES($stringValue = '') {
$stringValue = PHPExcel_Calculation_Functions::flattenSingleValue($stringValue);
if (is_bool($stringValue)) {
return ($stringValue) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
}
if (is_string($stringValue) || is_numeric($stringValue)) {
return trim(preg_replace('/ +/',' ',trim($stringValue,' ')));
return trim(preg_replace('/ +/',' ',trim($stringValue, ' ')), ' ');
}
return NULL;
} // function TRIMSPACES()
@ -587,4 +586,45 @@ class PHPExcel_Calculation_TextData {
return (string) PHPExcel_Style_NumberFormat::toFormattedString($value,$format);
} // function TEXTFORMAT()
} // class PHPExcel_Calculation_TextData
/**
* VALUE
*
* @param mixed $value Value to check
* @return boolean
*/
public static function VALUE($value = '') {
$value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
if (!is_numeric($value)) {
$numberValue = str_replace(
PHPExcel_Shared_String::getThousandsSeparator(),
'',
trim($value, " \t\n\r\0\x0B" . PHPExcel_Shared_String::getCurrencyCode())
);
if (is_numeric($numberValue)) {
return (float) $numberValue;
}
$dateSetting = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
if (strpos($value, ':') !== false) {
$timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($value);
if ($timeValue !== PHPExcel_Calculation_Functions::VALUE()) {
PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
return $timeValue;
}
}
$dateValue = PHPExcel_Calculation_DateTime::DATEVALUE($value);
if ($dateValue !== PHPExcel_Calculation_Functions::VALUE()) {
PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
return $dateValue;
}
PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
return PHPExcel_Calculation_Functions::VALUE();
}
return (float) $value;
}
}

View File

@ -88,7 +88,7 @@ class PHPExcel_Cell
*
* @var int
*/
private $_xfIndex;
private $_xfIndex = 0;
/**
* Attributes of the formula
@ -113,8 +113,6 @@ class PHPExcel_Cell
}
public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent) {
$this->_parent = $parent;
}
@ -140,14 +138,9 @@ class PHPExcel_Cell
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2)
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
$this->_dataType = $pDataType;
} else {
if (!self::getValueBinder()->bindValue($this, $pValue)) {
throw new PHPExcel_Exception("Value could not be bound to cell.");
}
} elseif (!self::getValueBinder()->bindValue($this, $pValue)) {
throw new PHPExcel_Exception("Value could not be bound to cell.");
}
// set default index to cellXf
$this->_xfIndex = 0;
}
/**
@ -199,7 +192,7 @@ class PHPExcel_Cell
{
return (string) PHPExcel_Style_NumberFormat::toFormattedString(
$this->getCalculatedValue(),
$this->getWorksheet()->getParent()->getCellXfByIndex($this->getXfIndex())
$this->getStyle()
->getNumberFormat()->getFormatCode()
);
}
@ -496,6 +489,45 @@ class PHPExcel_Cell
return $this->_parent->getParent();
}
/**
* Is this cell in a merge range
*
* @return boolean
*/
public function isInMergeRange() {
return (boolean) $this->getMergeRange();
}
/**
* Is this cell the master (top left cell) in a merge range (that holds the actual data value)
*
* @return boolean
*/
public function isMergeRangeValueCell() {
if ($mergeRange = $this->getMergeRange()) {
$mergeRange = PHPExcel_Cell::splitRange($mergeRange);
list($startCell) = $mergeRange[0];
if ($this->getCoordinate() === $startCell) {
return true;
}
}
return false;
}
/**
* If this cell is in a merge range, then return the range
*
* @return string
*/
public function getMergeRange() {
foreach($this->getWorksheet()->getMergeCells() as $mergeRange) {
if ($this->isInRange($mergeRange)) {
return $mergeRange;
}
}
return false;
}
/**
* Get cell style
*
@ -503,7 +535,7 @@ class PHPExcel_Cell
*/
public function getStyle()
{
return $this->getWorksheet()->getParent()->getCellXfByIndex($this->getXfIndex());
return $this->getWorksheet()->getStyle($this->getCoordinate());
}
/**

View File

@ -57,13 +57,20 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
// sanitize UTF-8 strings
if (is_string($value)) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
} elseif (is_object($value)) {
// Handle any objects that might be injected
if ($value instanceof DateTime) {
$value = $value->format('Y-m-d H:i:s');
} elseif (!($value instanceof PHPExcel_RichText)) {
$value = (string) $value;
}
}
// Set value explicit
$cell->setValueExplicit( $value, self::dataTypeForValue($value) );
// Done!
return TRUE;
return true;
}
/**
@ -74,33 +81,30 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
*/
public static function dataTypeForValue($pValue = null) {
// Match the value against a few data types
if (is_null($pValue)) {
if ($pValue === null) {
return PHPExcel_Cell_DataType::TYPE_NULL;
} elseif ($pValue === '') {
return PHPExcel_Cell_DataType::TYPE_STRING;
} elseif ($pValue instanceof PHPExcel_RichText) {
return PHPExcel_Cell_DataType::TYPE_INLINE;
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
return PHPExcel_Cell_DataType::TYPE_FORMULA;
} elseif (is_bool($pValue)) {
return PHPExcel_Cell_DataType::TYPE_BOOL;
} elseif (is_float($pValue) || is_int($pValue)) {
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) {
} elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) {
$tValue = ltrim($pValue, '+-');
if (is_string($pValue) && $tValue{0} === '0' && strlen($tValue) > 1 && $tValue{1} !== '.' ) {
return PHPExcel_Cell_DataType::TYPE_STRING;
} elseif((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) {
return PHPExcel_Cell_DataType::TYPE_STRING;
}
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) {
return PHPExcel_Cell_DataType::TYPE_ERROR;
} else {
return PHPExcel_Cell_DataType::TYPE_STRING;
}
return PHPExcel_Cell_DataType::TYPE_STRING;
}
}

View File

@ -98,6 +98,33 @@ class PHPExcel_Chart
*/
private $_displayBlanksAs = '0';
/**
* Chart Asix Y as
*
* @var PHPExcel_Chart_Axis
*/
private $_yAxis = null;
/**
* Chart Asix X as
*
* @var PHPExcel_Chart_Axis
*/
private $_xAxis = null;
/**
* Chart Major Gridlines as
*
* @var PHPExcel_Chart_GridLines
*/
private $_majorGridlines = null;
/**
* Chart Minor Gridlines as
*
* @var PHPExcel_Chart_GridLines
*/
private $_minorGridlines = null;
/**
* Top-Left Cell Position
@ -150,7 +177,7 @@ class PHPExcel_Chart
/**
* Create a new PHPExcel_Chart
*/
public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null)
public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null, PHPExcel_Chart_Axis $xAxis = null, PHPExcel_Chart_Axis $yAxis = null, PHPExcel_Chart_GridLines $majorGridlines = null, PHPExcel_Chart_GridLines $minorGridlines = null)
{
$this->_name = $name;
$this->_title = $title;
@ -160,6 +187,10 @@ class PHPExcel_Chart
$this->_plotArea = $plotArea;
$this->_plotVisibleOnly = $plotVisibleOnly;
$this->_displayBlanksAs = $displayBlanksAs;
$this->_xAxis = $xAxis;
$this->_yAxis = $yAxis;
$this->_majorGridlines = $majorGridlines;
$this->_minorGridlines = $minorGridlines;
}
/**
@ -327,6 +358,59 @@ class PHPExcel_Chart
}
/**
* Get yAxis
*
* @return PHPExcel_Chart_Axis
*/
public function getChartAxisY() {
if($this->_yAxis !== NULL){
return $this->_yAxis;
}
return new PHPExcel_Chart_Axis();
}
/**
* Get xAxis
*
* @return PHPExcel_Chart_Axis
*/
public function getChartAxisX() {
if($this->_xAxis !== NULL){
return $this->_xAxis;
}
return new PHPExcel_Chart_Axis();
}
/**
* Get Major Gridlines
*
* @return PHPExcel_Chart_GridLines
*/
public function getMajorGridlines() {
if($this->_majorGridlines !== NULL){
return $this->_majorGridlines;
}
return new PHPExcel_Chart_GridLines();
}
/**
* Get Minor Gridlines
*
* @return PHPExcel_Chart_GridLines
*/
public function getMinorGridlines() {
if($this->_minorGridlines !== NULL){
return $this->_minorGridlines;
}
return new PHPExcel_Chart_GridLines();
}
/**
* Set the Top Left position for the chart
*

View File

@ -0,0 +1,584 @@
<?php
require_once 'Properties.php';
/**
* Created by PhpStorm.
* User: Wiktor Trzonkowski
* Date: 6/17/14
* Time: 12:11 PM
*/
class PHPExcel_Chart_Axis extends
PHPExcel_Properties {
/**
* Axis Number
*
* @var array of mixed
*/
private
$_axis_number = array(
'format' => self::FORMAT_CODE_GENERAL,
'source_linked' => 1
);
/**
* Axis Options
*
* @var array of mixed
*/
private $_axis_options = array(
'minimum' => NULL,
'maximum' => NULL,
'major_unit' => NULL,
'minor_unit' => NULL,
'orientation' => self::ORIENTATION_NORMAL,
'minor_tick_mark' => self::TICK_MARK_NONE,
'major_tick_mark' => self::TICK_MARK_NONE,
'axis_labels' => self::AXIS_LABELS_NEXT_TO,
'horizontal_crosses' => self::HORIZONTAL_CROSSES_AUTOZERO,
'horizontal_crosses_value' => NULL
);
/**
* Fill Properties
*
* @var array of mixed
*/
private $_fill_properties = array(
'type' => self::EXCEL_COLOR_TYPE_ARGB,
'value' => NULL,
'alpha' => 0
);
/**
* Line Properties
*
* @var array of mixed
*/
private $_line_properties = array(
'type' => self::EXCEL_COLOR_TYPE_ARGB,
'value' => NULL,
'alpha' => 0
);
/**
* Line Style Properties
*
* @var array of mixed
*/
private $_line_style_properties = array(
'width' => '9525',
'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
'dash' => self::LINE_STYLE_DASH_SOLID,
'cap' => self::LINE_STYLE_CAP_FLAT,
'join' => self::LINE_STYLE_JOIN_BEVEL,
'arrow' => array(
'head' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_5
),
'end' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_8
),
)
);
/**
* Shadow Properties
*
* @var array of mixed
*/
private $_shadow_properties = array(
'presets' => self::SHADOW_PRESETS_NOSHADOW,
'effect' => NULL,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 40,
),
'size' => array(
'sx' => NULL,
'sy' => NULL,
'kx' => NULL
),
'blur' => NULL,
'direction' => NULL,
'distance' => NULL,
'algn' => NULL,
'rotWithShape' => NULL
);
/**
* Glow Properties
*
* @var array of mixed
*/
private $_glow_properties = array(
'size' => NULL,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 40
)
);
/**
* Soft Edge Properties
*
* @var array of mixed
*/
private $_soft_edges = array(
'size' => NULL
);
/**
* Get Series Data Type
*
* @return string
*/
public function setAxisNumberProperties($format_code) {
$this->_axis_number['format'] = (string) $format_code;
$this->_axis_number['source_linked'] = 0;
}
/**
* Get Axis Number Format Data Type
*
* @return string
*/
public function getAxisNumberFormat() {
return $this->_axis_number['format'];
}
/**
* Get Axis Number Source Linked
*
* @return string
*/
public function getAxisNumberSourceLinked() {
return (string) $this->_axis_number['source_linked'];
}
/**
* Set Axis Options Properties
*
* @param string $axis_labels
* @param string $horizontal_crosses_value
* @param string $horizontal_crosses
* @param string $axis_orientation
* @param string $major_tmt
* @param string $minor_tmt
* @param string $minimum
* @param string $maximum
* @param string $major_unit
* @param string $minor_unit
*
*/
public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = NULL, $horizontal_crosses = NULL,
$axis_orientation = NULL, $major_tmt = NULL, $minor_tmt = NULL, $minimum = NULL, $maximum = NULL, $major_unit = NULL,
$minor_unit = NULL) {
$this->_axis_options['axis_labels'] = (string) $axis_labels;
($horizontal_crosses_value !== NULL)
? $this->_axis_options['horizontal_crosses_value'] = (string) $horizontal_crosses_value : NULL;
($horizontal_crosses !== NULL) ? $this->_axis_options['horizontal_crosses'] = (string) $horizontal_crosses : NULL;
($axis_orientation !== NULL) ? $this->_axis_options['orientation'] = (string) $axis_orientation : NULL;
($major_tmt !== NULL) ? $this->_axis_options['major_tick_mark'] = (string) $major_tmt : NULL;
($minor_tmt !== NULL) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : NULL;
($minor_tmt !== NULL) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : NULL;
($minimum !== NULL) ? $this->_axis_options['minimum'] = (string) $minimum : NULL;
($maximum !== NULL) ? $this->_axis_options['maximum'] = (string) $maximum : NULL;
($major_unit !== NULL) ? $this->_axis_options['major_unit'] = (string) $major_unit : NULL;
($minor_unit !== NULL) ? $this->_axis_options['minor_unit'] = (string) $minor_unit : NULL;
}
/**
* Get Axis Options Property
*
* @param string $property
*
* @return string
*/
public function getAxisOptionsProperty($property) {
return $this->_axis_options[$property];
}
/**
* Set Axis Orientation Property
*
* @param string $orientation
*
*/
public function setAxisOrientation($orientation) {
$this->orientation = (string) $orientation;
}
/**
* Set Fill Property
*
* @param string $color
* @param int $alpha
* @param string $type
*
*/
public function setFillParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) {
$this->_fill_properties = $this->setColorProperties($color, $alpha, $type);
}
/**
* Set Line Property
*
* @param string $color
* @param int $alpha
* @param string $type
*
*/
public function setLineParameters($color, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_ARGB) {
$this->_line_properties = $this->setColorProperties($color, $alpha, $type);
}
/**
* Get Fill Property
*
* @param string $property
*
* @return string
*/
public function getFillProperty($property) {
return $this->_fill_properties[$property];
}
/**
* Get Line Property
*
* @param string $property
*
* @return string
*/
public function getLineProperty($property) {
return $this->_line_properties[$property];
}
/**
* Set Line Style Properties
*
* @param float $line_width
* @param string $compound_type
* @param string $dash_type
* @param string $cap_type
* @param string $join_type
* @param string $head_arrow_type
* @param string $head_arrow_size
* @param string $end_arrow_type
* @param string $end_arrow_size
*
*/
public function setLineStyleProperties($line_width = NULL, $compound_type = NULL,
$dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_type = NULL,
$head_arrow_size = NULL, $end_arrow_type = NULL, $end_arrow_size = NULL) {
(!is_null($line_width)) ? $this->_line_style_properties['width'] = $this->getExcelPointsWidth((float) $line_width)
: NULL;
(!is_null($compound_type)) ? $this->_line_style_properties['compound'] = (string) $compound_type : NULL;
(!is_null($dash_type)) ? $this->_line_style_properties['dash'] = (string) $dash_type : NULL;
(!is_null($cap_type)) ? $this->_line_style_properties['cap'] = (string) $cap_type : NULL;
(!is_null($join_type)) ? $this->_line_style_properties['join'] = (string) $join_type : NULL;
(!is_null($head_arrow_type)) ? $this->_line_style_properties['arrow']['head']['type'] = (string) $head_arrow_type
: NULL;
(!is_null($head_arrow_size)) ? $this->_line_style_properties['arrow']['head']['size'] = (string) $head_arrow_size
: NULL;
(!is_null($end_arrow_type)) ? $this->_line_style_properties['arrow']['end']['type'] = (string) $end_arrow_type
: NULL;
(!is_null($end_arrow_size)) ? $this->_line_style_properties['arrow']['end']['size'] = (string) $end_arrow_size
: NULL;
}
/**
* Get Line Style Property
*
* @param array|string $elements
*
* @return string
*/
public function getLineStyleProperty($elements) {
return $this->getArrayElementsValue($this->_line_style_properties, $elements);
}
/**
* Get Line Style Arrow Excel Width
*
* @param string $arrow
*
* @return string
*/
public function getLineStyleArrowWidth($arrow) {
return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'w');
}
/**
* Get Line Style Arrow Excel Length
*
* @param string $arrow
*
* @return string
*/
public function getLineStyleArrowLength($arrow) {
return $this->getLineStyleArrowSize($this->_line_style_properties['arrow'][$arrow]['size'], 'len');
}
/**
* Set Shadow Properties
*
* @param int $shadow_presets
* @param string $sh_color_value
* @param string $sh_color_type
* @param string $sh_color_alpha
* @param float $sh_blur
* @param int $sh_angle
* @param float $sh_distance
*
*/
public function setShadowProperties($sh_presets, $sh_color_value = NULL, $sh_color_type = NULL, $sh_color_alpha = NULL, $sh_blur = NULL, $sh_angle = NULL, $sh_distance = NULL) {
$this
->_setShadowPresetsProperties((int) $sh_presets)
->_setShadowColor(
is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value
, is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha'] : $sh_color_alpha
, is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type)
->_setShadowBlur($sh_blur)
->_setShadowAngle($sh_angle)
->_setShadowDistance($sh_distance);
}
/**
* Set Shadow Color
*
* @param int $shadow_presets
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowPresetsProperties($shadow_presets) {
$this->_shadow_properties['presets'] = $shadow_presets;
$this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
return $this;
}
/**
* Set Shadow Properties from Maped Values
*
* @param array $properties_map
* @param * $reference
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) {
$base_reference = $reference;
foreach ($properties_map as $property_key => $property_val) {
if (is_array($property_val)) {
if ($reference === NULL) {
$reference = & $this->_shadow_properties[$property_key];
} else {
$reference = & $reference[$property_key];
}
$this->_setShadowProperiesMapValues($property_val, $reference);
} else {
if ($base_reference === NULL) {
$this->_shadow_properties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
}
}
}
return $this;
}
/**
* Set Shadow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowColor($color, $alpha, $type) {
$this->_shadow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
/**
* Set Shadow Blur
*
* @param float $blur
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowBlur($blur) {
if ($blur !== NULL) {
$this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
}
return $this;
}
/**
* Set Shadow Angle
*
* @param int $angle
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowAngle($angle) {
if ($angle !== NULL) {
$this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
}
return $this;
}
/**
* Set Shadow Distance
*
* @param float $distance
*
* @return PHPExcel_Chart_Axis
*/
private function _setShadowDistance($distance) {
if ($distance !== NULL) {
$this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
}
return $this;
}
/**
* Get Glow Property
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*/
public function getShadowProperty($elements) {
return $this->getArrayElementsValue($this->_shadow_properties, $elements);
}
/**
* Set Glow Properties
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*/
public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) {
$this
->_setGlowSize($size)
->_setGlowColor(
is_null($color_value) ? $this->_glow_properties['color']['value'] : $color_value
, is_null($color_alpha) ? (int) $this->_glow_properties['color']['alpha'] : $color_alpha
, is_null($color_type) ? $this->_glow_properties['color']['type'] : $color_type);
}
/**
* Get Glow Property
*
* @param array|string $property
*
* @return string
*/
public function getGlowProperty($property) {
return $this->getArrayElementsValue($this->_glow_properties, $property);
}
/**
* Set Glow Color
*
* @param float $size
*
* @return PHPExcel_Chart_Axis
*/
private function _setGlowSize($size) {
if (!is_null($size)) {
$this->_glow_properties['size'] = $this->getExcelPointsWidth($size);
}
return $this;
}
/**
* Set Glow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_Axis
*/
private function _setGlowColor($color, $alpha, $type) {
$this->_glow_properties['color'] = $this->setColorProperties($color, $alpha, $type);
return $this;
}
/**
* Set Soft Edges Size
*
* @param float $size
*/
public function setSoftEdges($size) {
if (!is_null($size)) {
$_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
}
}
/**
* Get Soft Edges Size
*
* @return string
*/
public function getSoftEdgesSize() {
return $this->_soft_edges['size'];
}
}

View File

@ -137,7 +137,7 @@ class PHPExcel_Chart_DataSeries
/**
* Create a new PHPExcel_Chart_DataSeries
*/
public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $smoothLine = null, $plotStyle = null)
public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $plotDirection = null, $smoothLine = null, $plotStyle = null)
{
$this->_plotType = $plotType;
$this->_plotGrouping = $plotGrouping;
@ -155,6 +155,11 @@ class PHPExcel_Chart_DataSeries
$this->_plotCategory = $plotCategory;
$this->_smoothLine = $smoothLine;
$this->_plotStyle = $plotStyle;
if (is_null($plotDirection)) {
$plotDirection = self::DIRECTION_COL;
}
$this->_plotDirection = $plotDirection;
}
/**

View File

@ -0,0 +1,458 @@
<?php
require_once 'Properties.php';
/**
* Created by PhpStorm.
* User: Wiktor Trzonkowski
* Date: 7/2/14
* Time: 2:36 PM
*/
class PHPExcel_Chart_GridLines extends
PHPExcel_Properties {
/**
* Properties of Class:
* Object State (State for Minor Tick Mark) @var bool
* Line Properties @var array of mixed
* Shadow Properties @var array of mixed
* Glow Properties @var array of mixed
* Soft Properties @var array of mixed
*
*/
private
$_object_state = FALSE,
$_line_properties = array(
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => NULL,
'alpha' => 0
),
'style' => array(
'width' => '9525',
'compound' => self::LINE_STYLE_COMPOUND_SIMPLE,
'dash' => self::LINE_STYLE_DASH_SOLID,
'cap' => self::LINE_STYLE_CAP_FLAT,
'join' => self::LINE_STYLE_JOIN_BEVEL,
'arrow' => array(
'head' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_5
),
'end' => array(
'type' => self::LINE_STYLE_ARROW_TYPE_NOARROW,
'size' => self::LINE_STYLE_ARROW_SIZE_8
),
)
)
),
$_shadow_properties = array(
'presets' => self::SHADOW_PRESETS_NOSHADOW,
'effect' => NULL,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 85,
),
'size' => array(
'sx' => NULL,
'sy' => NULL,
'kx' => NULL
),
'blur' => NULL,
'direction' => NULL,
'distance' => NULL,
'algn' => NULL,
'rotWithShape' => NULL
),
$_glow_properties = array(
'size' => NULL,
'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black',
'alpha' => 40
)
),
$_soft_edges = array(
'size' => NULL
);
/**
* Get Object State
*
* @return bool
*/
public function getObjectState() {
return $this->_object_state;
}
/**
* Change Object State to True
*
* @return PHPExcel_Chart_GridLines
*/
private function _activateObject() {
$this->_object_state = TRUE;
return $this;
}
/**
* Set Line Color Properties
*
* @param string $value
* @param int $alpha
* @param string $type
*/
public function setLineColorProperties($value, $alpha = 0, $type = self::EXCEL_COLOR_TYPE_STANDARD) {
$this
->_activateObject()
->_line_properties['color'] = $this->setColorProperties(
$value,
$alpha,
$type);
}
/**
* Set Line Color Properties
*
* @param float $line_width
* @param string $compound_type
* @param string $dash_type
* @param string $cap_type
* @param string $join_type
* @param string $head_arrow_type
* @param string $head_arrow_size
* @param string $end_arrow_type
* @param string $end_arrow_size
*/
public function setLineStyleProperties($line_width = NULL, $compound_type = NULL, $dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_type = NULL, $head_arrow_size = NULL, $end_arrow_type = NULL, $end_arrow_size = NULL) {
$this->_activateObject();
(!is_null($line_width))
? $this->_line_properties['style']['width'] = $this->getExcelPointsWidth((float) $line_width)
: NULL;
(!is_null($compound_type))
? $this->_line_properties['style']['compound'] = (string) $compound_type
: NULL;
(!is_null($dash_type))
? $this->_line_properties['style']['dash'] = (string) $dash_type
: NULL;
(!is_null($cap_type))
? $this->_line_properties['style']['cap'] = (string) $cap_type
: NULL;
(!is_null($join_type))
? $this->_line_properties['style']['join'] = (string) $join_type
: NULL;
(!is_null($head_arrow_type))
? $this->_line_properties['style']['arrow']['head']['type'] = (string) $head_arrow_type
: NULL;
(!is_null($head_arrow_size))
? $this->_line_properties['style']['arrow']['head']['size'] = (string) $head_arrow_size
: NULL;
(!is_null($end_arrow_type))
? $this->_line_properties['style']['arrow']['end']['type'] = (string) $end_arrow_type
: NULL;
(!is_null($end_arrow_size))
? $this->_line_properties['style']['arrow']['end']['size'] = (string) $end_arrow_size
: NULL;
}
/**
* Get Line Color Property
*
* @param string $parameter
*
* @return string
*/
public function getLineColorProperty($parameter) {
return $this->_line_properties['color'][$parameter];
}
/**
* Get Line Style Property
*
* @param array|string $elements
*
* @return string
*/
public function getLineStyleProperty($elements) {
return $this->getArrayElementsValue($this->_line_properties['style'], $elements);
}
/**
* Set Glow Properties
*
* @param float $size
* @param string $color_value
* @param int $color_alpha
* @param string $color_type
*
*/
public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) {
$this
->_activateObject()
->_setGlowSize($size)
->_setGlowColor($color_value, $color_alpha, $color_type);
}
/**
* Get Glow Color Property
*
* @param string $property
*
* @return string
*/
public function getGlowColor($property) {
return $this->_glow_properties['color'][$property];
}
/**
* Get Glow Size
*
* @return string
*/
public function getGlowSize() {
return $this->_glow_properties['size'];
}
/**
* Set Glow Size
*
* @param float $size
*
* @return PHPExcel_Chart_GridLines
*/
private function _setGlowSize($size) {
$this->_glow_properties['size'] = $this->getExcelPointsWidth((float) $size);
return $this;
}
/**
* Set Glow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_GridLines
*/
private function _setGlowColor($color, $alpha, $type) {
if (!is_null($color)) {
$this->_glow_properties['color']['value'] = (string) $color;
}
if (!is_null($alpha)) {
$this->_glow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
}
if (!is_null($type)) {
$this->_glow_properties['color']['type'] = (string) $type;
}
return $this;
}
/**
* Get Line Style Arrow Parameters
*
* @param string $arrow_selector
* @param string $property_selector
*
* @return string
*/
public function getLineStyleArrowParameters($arrow_selector, $property_selector) {
return $this->getLineStyleArrowSize($this->_line_properties['style']['arrow'][$arrow_selector]['size'], $property_selector);
}
/**
* Set Shadow Properties
*
* @param int $sh_presets
* @param string $sh_color_value
* @param string $sh_color_type
* @param int $sh_color_alpha
* @param string $sh_blur
* @param int $sh_angle
* @param float $sh_distance
*
*/
public function setShadowProperties($sh_presets, $sh_color_value = NULL, $sh_color_type = NULL, $sh_color_alpha = NULL, $sh_blur = NULL, $sh_angle = NULL, $sh_distance = NULL) {
$this
->_activateObject()
->_setShadowPresetsProperties((int) $sh_presets)
->_setShadowColor(
is_null($sh_color_value) ? $this->_shadow_properties['color']['value'] : $sh_color_value
, is_null($sh_color_alpha) ? (int) $this->_shadow_properties['color']['alpha']
: $this->getTrueAlpha($sh_color_alpha)
, is_null($sh_color_type) ? $this->_shadow_properties['color']['type'] : $sh_color_type)
->_setShadowBlur($sh_blur)
->_setShadowAngle($sh_angle)
->_setShadowDistance($sh_distance);
}
/**
* Set Shadow Presets Properties
*
* @param int $shadow_presets
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowPresetsProperties($shadow_presets) {
$this->_shadow_properties['presets'] = $shadow_presets;
$this->_setShadowProperiesMapValues($this->getShadowPresetsMap($shadow_presets));
return $this;
}
/**
* Set Shadow Properties Values
*
* @param array $properties_map
* @param * $reference
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) {
$base_reference = $reference;
foreach ($properties_map as $property_key => $property_val) {
if (is_array($property_val)) {
if ($reference === NULL) {
$reference = & $this->_shadow_properties[$property_key];
} else {
$reference = & $reference[$property_key];
}
$this->_setShadowProperiesMapValues($property_val, $reference);
} else {
if ($base_reference === NULL) {
$this->_shadow_properties[$property_key] = $property_val;
} else {
$reference[$property_key] = $property_val;
}
}
}
return $this;
}
/**
* Set Shadow Color
*
* @param string $color
* @param int $alpha
* @param string $type
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowColor($color, $alpha, $type) {
if (!is_null($color)) {
$this->_shadow_properties['color']['value'] = (string) $color;
}
if (!is_null($alpha)) {
$this->_shadow_properties['color']['alpha'] = $this->getTrueAlpha((int) $alpha);
}
if (!is_null($type)) {
$this->_shadow_properties['color']['type'] = (string) $type;
}
return $this;
}
/**
* Set Shadow Blur
*
* @param float $blur
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowBlur($blur) {
if ($blur !== NULL) {
$this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
}
return $this;
}
/**
* Set Shadow Angle
*
* @param int $angle
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowAngle($angle) {
if ($angle !== NULL) {
$this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
}
return $this;
}
/**
* Set Shadow Distance
*
* @param float $distance
*
* @return PHPExcel_Chart_GridLines
*/
private function _setShadowDistance($distance) {
if ($distance !== NULL) {
$this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
}
return $this;
}
/**
* Get Shadow Property
*
* @param string $elements
* @param array $elements
*
* @return string
*/
public function getShadowProperty($elements) {
return $this->getArrayElementsValue($this->_shadow_properties, $elements);
}
/**
* Set Soft Edges Size
*
* @param float $size
*/
public function setSoftEdgesSize($size) {
if (!is_null($size)) {
$this->_activateObject();
$_soft_edges['size'] = (string) $this->getExcelPointsWidth($size);
}
}
/**
* Get Soft Edges Size
*
* @return string
*/
public function getSoftEdgesSize() {
return $this->_soft_edges['size'];
}
}

View File

@ -0,0 +1,359 @@
<?php
/**
* Created by PhpStorm.
* User: nhw2h8s
* Date: 7/2/14
* Time: 5:45 PM
*/
abstract class PHPExcel_Properties {
const
EXCEL_COLOR_TYPE_STANDARD = 'prstClr',
EXCEL_COLOR_TYPE_SCHEME = 'schemeClr',
EXCEL_COLOR_TYPE_ARGB = 'srgbClr';
const
AXIS_LABELS_LOW = 'low',
AXIS_LABELS_HIGH = 'high',
AXIS_LABELS_NEXT_TO = 'nextTo',
AXIS_LABELS_NONE = 'none';
const
TICK_MARK_NONE = 'none',
TICK_MARK_INSIDE = 'in',
TICK_MARK_OUTSIDE = 'out',
TICK_MARK_CROSS = 'cross';
const
HORIZONTAL_CROSSES_AUTOZERO = 'autoZero',
HORIZONTAL_CROSSES_MAXIMUM = 'max';
const
FORMAT_CODE_GENERAL = 'General',
FORMAT_CODE_NUMBER = '#,##0.00',
FORMAT_CODE_CURRENCY = '$#,##0.00',
FORMAT_CODE_ACCOUNTING = '_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)',
FORMAT_CODE_DATE = 'm/d/yyyy',
FORMAT_CODE_TIME = '[$-F400]h:mm:ss AM/PM',
FORMAT_CODE_PERCENTAGE = '0.00%',
FORMAT_CODE_FRACTION = '# ?/?',
FORMAT_CODE_SCIENTIFIC = '0.00E+00',
FORMAT_CODE_TEXT = '@',
FORMAT_CODE_SPECIAL = '00000';
const
ORIENTATION_NORMAL = 'minMax',
ORIENTATION_REVERSED = 'maxMin';
const
LINE_STYLE_COMPOUND_SIMPLE = 'sng',
LINE_STYLE_COMPOUND_DOUBLE = 'dbl',
LINE_STYLE_COMPOUND_THICKTHIN = 'thickThin',
LINE_STYLE_COMPOUND_THINTHICK = 'thinThick',
LINE_STYLE_COMPOUND_TRIPLE = 'tri',
LINE_STYLE_DASH_SOLID = 'solid',
LINE_STYLE_DASH_ROUND_DOT = 'sysDot',
LINE_STYLE_DASH_SQUERE_DOT = 'sysDash',
LINE_STYPE_DASH_DASH = 'dash',
LINE_STYLE_DASH_DASH_DOT = 'dashDot',
LINE_STYLE_DASH_LONG_DASH = 'lgDash',
LINE_STYLE_DASH_LONG_DASH_DOT = 'lgDashDot',
LINE_STYLE_DASH_LONG_DASH_DOT_DOT = 'lgDashDotDot',
LINE_STYLE_CAP_SQUARE = 'sq',
LINE_STYLE_CAP_ROUND = 'rnd',
LINE_STYLE_CAP_FLAT = 'flat',
LINE_STYLE_JOIN_ROUND = 'bevel',
LINE_STYLE_JOIN_MITER = 'miter',
LINE_STYLE_JOIN_BEVEL = 'bevel',
LINE_STYLE_ARROW_TYPE_NOARROW = NULL,
LINE_STYLE_ARROW_TYPE_ARROW = 'triangle',
LINE_STYLE_ARROW_TYPE_OPEN = 'arrow',
LINE_STYLE_ARROW_TYPE_STEALTH = 'stealth',
LINE_STYLE_ARROW_TYPE_DIAMOND = 'diamond',
LINE_STYLE_ARROW_TYPE_OVAL = 'oval',
LINE_STYLE_ARROW_SIZE_1 = 1,
LINE_STYLE_ARROW_SIZE_2 = 2,
LINE_STYLE_ARROW_SIZE_3 = 3,
LINE_STYLE_ARROW_SIZE_4 = 4,
LINE_STYLE_ARROW_SIZE_5 = 5,
LINE_STYLE_ARROW_SIZE_6 = 6,
LINE_STYLE_ARROW_SIZE_7 = 7,
LINE_STYLE_ARROW_SIZE_8 = 8,
LINE_STYLE_ARROW_SIZE_9 = 9;
const
SHADOW_PRESETS_NOSHADOW = NULL,
SHADOW_PRESETS_OUTER_BOTTTOM_RIGHT = 1,
SHADOW_PRESETS_OUTER_BOTTOM = 2,
SHADOW_PRESETS_OUTER_BOTTOM_LEFT = 3,
SHADOW_PRESETS_OUTER_RIGHT = 4,
SHADOW_PRESETS_OUTER_CENTER = 5,
SHADOW_PRESETS_OUTER_LEFT = 6,
SHADOW_PRESETS_OUTER_TOP_RIGHT = 7,
SHADOW_PRESETS_OUTER_TOP = 8,
SHADOW_PRESETS_OUTER_TOP_LEFT = 9,
SHADOW_PRESETS_INNER_BOTTTOM_RIGHT = 10,
SHADOW_PRESETS_INNER_BOTTOM = 11,
SHADOW_PRESETS_INNER_BOTTOM_LEFT = 12,
SHADOW_PRESETS_INNER_RIGHT = 13,
SHADOW_PRESETS_INNER_CENTER = 14,
SHADOW_PRESETS_INNER_LEFT = 15,
SHADOW_PRESETS_INNER_TOP_RIGHT = 16,
SHADOW_PRESETS_INNER_TOP = 17,
SHADOW_PRESETS_INNER_TOP_LEFT = 18,
SHADOW_PRESETS_PERSPECTIVE_BELOW = 19,
SHADOW_PRESETS_PERSPECTIVE_UPPER_RIGHT = 20,
SHADOW_PRESETS_PERSPECTIVE_UPPER_LEFT = 21,
SHADOW_PRESETS_PERSPECTIVE_LOWER_RIGHT = 22,
SHADOW_PRESETS_PERSPECTIVE_LOWER_LEFT = 23;
protected function getExcelPointsWidth($width) {
return $width * 12700;
}
protected function getExcelPointsAngle($angle) {
return $angle * 60000;
}
protected function getTrueAlpha($alpha) {
return (string) 100 - $alpha . '000';
}
protected function setColorProperties($color, $alpha, $type) {
return array(
'type' => (string) $type,
'value' => (string) $color,
'alpha' => (string) $this->getTrueAlpha($alpha)
);
}
protected function getLineStyleArrowSize($array_selector, $array_kay_selector) {
$sizes = array(
1 => array('w' => 'sm', 'len' => 'sm'),
2 => array('w' => 'sm', 'len' => 'med'),
3 => array('w' => 'sm', 'len' => 'lg'),
4 => array('w' => 'med', 'len' => 'sm'),
5 => array('w' => 'med', 'len' => 'med'),
6 => array('w' => 'med', 'len' => 'lg'),
7 => array('w' => 'lg', 'len' => 'sm'),
8 => array('w' => 'lg', 'len' => 'med'),
9 => array('w' => 'lg', 'len' => 'lg')
);
return $sizes[$array_selector][$array_kay_selector];
}
protected function getShadowPresetsMap($shadow_presets_option) {
$presets_options = array(
//OUTER
1 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '2700000',
'algn' => 'tl',
'rotWithShape' => '0'
),
2 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '5400000',
'algn' => 't',
'rotWithShape' => '0'
),
3 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '8100000',
'algn' => 'tr',
'rotWithShape' => '0'
),
4 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'algn' => 'l',
'rotWithShape' => '0'
),
5 => array(
'effect' => 'outerShdw',
'size' => array(
'sx' => '102000',
'sy' => '102000'
)
,
'blur' => '63500',
'distance' => '38100',
'algn' => 'ctr',
'rotWithShape' => '0'
),
6 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '10800000',
'algn' => 'r',
'rotWithShape' => '0'
),
7 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '18900000',
'algn' => 'bl',
'rotWithShape' => '0'
),
8 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '16200000',
'rotWithShape' => '0'
),
9 => array(
'effect' => 'outerShdw',
'blur' => '50800',
'distance' => '38100',
'direction' => '13500000',
'algn' => 'br',
'rotWithShape' => '0'
),
//INNER
10 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '2700000',
),
11 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '5400000',
),
12 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '8100000',
),
13 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
),
14 => array(
'effect' => 'innerShdw',
'blur' => '114300',
),
15 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '10800000',
),
16 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '18900000',
),
17 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '16200000',
),
18 => array(
'effect' => 'innerShdw',
'blur' => '63500',
'distance' => '50800',
'direction' => '13500000',
),
//perspective
19 => array(
'effect' => 'outerShdw',
'blur' => '152400',
'distance' => '317500',
'size' => array(
'sx' => '90000',
'sy' => '-19000',
),
'direction' => '5400000',
'rotWithShape' => '0',
),
20 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'direction' => '18900000',
'size' => array(
'sy' => '23000',
'kx' => '-1200000',
),
'algn' => 'bl',
'rotWithShape' => '0',
),
21 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'direction' => '13500000',
'size' => array(
'sy' => '23000',
'kx' => '1200000',
),
'algn' => 'br',
'rotWithShape' => '0',
),
22 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'distance' => '12700',
'direction' => '2700000',
'size' => array(
'sy' => '-23000',
'kx' => '-800400',
),
'algn' => 'bl',
'rotWithShape' => '0',
),
23 => array(
'effect' => 'outerShdw',
'blur' => '76200',
'distance' => '12700',
'direction' => '8100000',
'size' => array(
'sy' => '-23000',
'kx' => '800400',
),
'algn' => 'br',
'rotWithShape' => '0',
),
);
return $presets_options[$shadow_presets_option];
}
protected function getArrayElementsValue($properties, $elements) {
$reference = & $properties;
if (!is_array($elements)) {
return $reference[$elements];
} else {
foreach ($elements as $keys) {
$reference = & $reference[$keys];
}
return $reference;
}
return $this;
}
}

View File

@ -554,7 +554,7 @@ class PHPExcel_Chart_Renderer_jpgraph
private function _renderAreaChart($groupCount, $dimensions = '2d') {
require_once('jpgraph_line.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
$this->_renderCartesianPlotArea();
@ -565,7 +565,7 @@ class PHPExcel_Chart_Renderer_jpgraph
private function _renderLineChart($groupCount, $dimensions = '2d') {
require_once('jpgraph_line.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
$this->_renderCartesianPlotArea();
@ -576,7 +576,7 @@ class PHPExcel_Chart_Renderer_jpgraph
private function _renderBarChart($groupCount, $dimensions = '2d') {
require_once('jpgraph_bar.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php');
$this->_renderCartesianPlotArea();
@ -587,9 +587,9 @@ class PHPExcel_Chart_Renderer_jpgraph
private function _renderScatterChart($groupCount) {
require_once('jpgraph_scatter.php');
require_once('jpgraph_regstat.php');
require_once('jpgraph_line.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
$this->_renderCartesianPlotArea('linlin');
@ -600,7 +600,7 @@ class PHPExcel_Chart_Renderer_jpgraph
private function _renderBubbleChart($groupCount) {
require_once('jpgraph_scatter.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php');
$this->_renderCartesianPlotArea('linlin');
@ -611,9 +611,9 @@ class PHPExcel_Chart_Renderer_jpgraph
private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False) {
require_once('jpgraph_pie.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie.php');
if ($dimensions == '3d') {
require_once('jpgraph_pie3d.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie3d.php');
}
$this->_renderPiePlotArea($doughnut);
@ -686,7 +686,7 @@ class PHPExcel_Chart_Renderer_jpgraph
private function _renderRadarChart($groupCount) {
require_once('jpgraph_radar.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_radar.php');
$this->_renderRadarPlotArea();
@ -697,7 +697,7 @@ class PHPExcel_Chart_Renderer_jpgraph
private function _renderStockChart($groupCount) {
require_once('jpgraph_stock.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_stock.php');
$this->_renderCartesianPlotArea('intint');
@ -708,7 +708,7 @@ class PHPExcel_Chart_Renderer_jpgraph
private function _renderContourChart($groupCount,$dimensions) {
require_once('jpgraph_contour.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_contour.php');
$this->_renderCartesianPlotArea('intint');
@ -719,11 +719,11 @@ class PHPExcel_Chart_Renderer_jpgraph
private function _renderCombinationChart($groupCount,$dimensions,$outputDestination) {
require_once('jpgraph_line.php');
require_once('jpgraph_bar.php');
require_once('jpgraph_scatter.php');
require_once('jpgraph_regstat.php');
require_once('jpgraph_line.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
$this->_renderCartesianPlotArea();

View File

@ -0,0 +1,762 @@
<?php
class PHPExcel_Helper_HTML
{
protected static $colourMap = array(
'aliceblue' => 'f0f8ff',
'antiquewhite' => 'faebd7',
'antiquewhite1' => 'ffefdb',
'antiquewhite2' => 'eedfcc',
'antiquewhite3' => 'cdc0b0',
'antiquewhite4' => '8b8378',
'aqua' => '00ffff',
'aquamarine1' => '7fffd4',
'aquamarine2' => '76eec6',
'aquamarine4' => '458b74',
'azure1' => 'f0ffff',
'azure2' => 'e0eeee',
'azure3' => 'c1cdcd',
'azure4' => '838b8b',
'beige' => 'f5f5dc',
'bisque1' => 'ffe4c4',
'bisque2' => 'eed5b7',
'bisque3' => 'cdb79e',
'bisque4' => '8b7d6b',
'black' => '000000',
'blanchedalmond' => 'ffebcd',
'blue' => '0000ff',
'blue1' => '0000ff',
'blue2' => '0000ee',
'blue4' => '00008b',
'blueviolet' => '8a2be2',
'brown' => 'a52a2a',
'brown1' => 'ff4040',
'brown2' => 'ee3b3b',
'brown3' => 'cd3333',
'brown4' => '8b2323',
'burlywood' => 'deb887',
'burlywood1' => 'ffd39b',
'burlywood2' => 'eec591',
'burlywood3' => 'cdaa7d',
'burlywood4' => '8b7355',
'cadetblue' => '5f9ea0',
'cadetblue1' => '98f5ff',
'cadetblue2' => '8ee5ee',
'cadetblue3' => '7ac5cd',
'cadetblue4' => '53868b',
'chartreuse1' => '7fff00',
'chartreuse2' => '76ee00',
'chartreuse3' => '66cd00',
'chartreuse4' => '458b00',
'chocolate' => 'd2691e',
'chocolate1' => 'ff7f24',
'chocolate2' => 'ee7621',
'chocolate3' => 'cd661d',
'coral' => 'ff7f50',
'coral1' => 'ff7256',
'coral2' => 'ee6a50',
'coral3' => 'cd5b45',
'coral4' => '8b3e2f',
'cornflowerblue' => '6495ed',
'cornsilk1' => 'fff8dc',
'cornsilk2' => 'eee8cd',
'cornsilk3' => 'cdc8b1',
'cornsilk4' => '8b8878',
'cyan1' => '00ffff',
'cyan2' => '00eeee',
'cyan3' => '00cdcd',
'cyan4' => '008b8b',
'darkgoldenrod' => 'b8860b',
'darkgoldenrod1' => 'ffb90f',
'darkgoldenrod2' => 'eead0e',
'darkgoldenrod3' => 'cd950c',
'darkgoldenrod4' => '8b6508',
'darkgreen' => '006400',
'darkkhaki' => 'bdb76b',
'darkolivegreen' => '556b2f',
'darkolivegreen1' => 'caff70',
'darkolivegreen2' => 'bcee68',
'darkolivegreen3' => 'a2cd5a',
'darkolivegreen4' => '6e8b3d',
'darkorange' => 'ff8c00',
'darkorange1' => 'ff7f00',
'darkorange2' => 'ee7600',
'darkorange3' => 'cd6600',
'darkorange4' => '8b4500',
'darkorchid' => '9932cc',
'darkorchid1' => 'bf3eff',
'darkorchid2' => 'b23aee',
'darkorchid3' => '9a32cd',
'darkorchid4' => '68228b',
'darksalmon' => 'e9967a',
'darkseagreen' => '8fbc8f',
'darkseagreen1' => 'c1ffc1',
'darkseagreen2' => 'b4eeb4',
'darkseagreen3' => '9bcd9b',
'darkseagreen4' => '698b69',
'darkslateblue' => '483d8b',
'darkslategray' => '2f4f4f',
'darkslategray1' => '97ffff',
'darkslategray2' => '8deeee',
'darkslategray3' => '79cdcd',
'darkslategray4' => '528b8b',
'darkturquoise' => '00ced1',
'darkviolet' => '9400d3',
'deeppink1' => 'ff1493',
'deeppink2' => 'ee1289',
'deeppink3' => 'cd1076',
'deeppink4' => '8b0a50',
'deepskyblue1' => '00bfff',
'deepskyblue2' => '00b2ee',
'deepskyblue3' => '009acd',
'deepskyblue4' => '00688b',
'dimgray' => '696969',
'dodgerblue1' => '1e90ff',
'dodgerblue2' => '1c86ee',
'dodgerblue3' => '1874cd',
'dodgerblue4' => '104e8b',
'firebrick' => 'b22222',
'firebrick1' => 'ff3030',
'firebrick2' => 'ee2c2c',
'firebrick3' => 'cd2626',
'firebrick4' => '8b1a1a',
'floralwhite' => 'fffaf0',
'forestgreen' => '228b22',
'fuchsia' => 'ff00ff',
'gainsboro' => 'dcdcdc',
'ghostwhite' => 'f8f8ff',
'gold1' => 'ffd700',
'gold2' => 'eec900',
'gold3' => 'cdad00',
'gold4' => '8b7500',
'goldenrod' => 'daa520',
'goldenrod1' => 'ffc125',
'goldenrod2' => 'eeb422',
'goldenrod3' => 'cd9b1d',
'goldenrod4' => '8b6914',
'gray' => 'bebebe',
'gray1' => '030303',
'gray10' => '1a1a1a',
'gray11' => '1c1c1c',
'gray12' => '1f1f1f',
'gray13' => '212121',
'gray14' => '242424',
'gray15' => '262626',
'gray16' => '292929',
'gray17' => '2b2b2b',
'gray18' => '2e2e2e',
'gray19' => '303030',
'gray2' => '050505',
'gray20' => '333333',
'gray21' => '363636',
'gray22' => '383838',
'gray23' => '3b3b3b',
'gray24' => '3d3d3d',
'gray25' => '404040',
'gray26' => '424242',
'gray27' => '454545',
'gray28' => '474747',
'gray29' => '4a4a4a',
'gray3' => '080808',
'gray30' => '4d4d4d',
'gray31' => '4f4f4f',
'gray32' => '525252',
'gray33' => '545454',
'gray34' => '575757',
'gray35' => '595959',
'gray36' => '5c5c5c',
'gray37' => '5e5e5e',
'gray38' => '616161',
'gray39' => '636363',
'gray4' => '0a0a0a',
'gray40' => '666666',
'gray41' => '696969',
'gray42' => '6b6b6b',
'gray43' => '6e6e6e',
'gray44' => '707070',
'gray45' => '737373',
'gray46' => '757575',
'gray47' => '787878',
'gray48' => '7a7a7a',
'gray49' => '7d7d7d',
'gray5' => '0d0d0d',
'gray50' => '7f7f7f',
'gray51' => '828282',
'gray52' => '858585',
'gray53' => '878787',
'gray54' => '8a8a8a',
'gray55' => '8c8c8c',
'gray56' => '8f8f8f',
'gray57' => '919191',
'gray58' => '949494',
'gray59' => '969696',
'gray6' => '0f0f0f',
'gray60' => '999999',
'gray61' => '9c9c9c',
'gray62' => '9e9e9e',
'gray63' => 'a1a1a1',
'gray64' => 'a3a3a3',
'gray65' => 'a6a6a6',
'gray66' => 'a8a8a8',
'gray67' => 'ababab',
'gray68' => 'adadad',
'gray69' => 'b0b0b0',
'gray7' => '121212',
'gray70' => 'b3b3b3',
'gray71' => 'b5b5b5',
'gray72' => 'b8b8b8',
'gray73' => 'bababa',
'gray74' => 'bdbdbd',
'gray75' => 'bfbfbf',
'gray76' => 'c2c2c2',
'gray77' => 'c4c4c4',
'gray78' => 'c7c7c7',
'gray79' => 'c9c9c9',
'gray8' => '141414',
'gray80' => 'cccccc',
'gray81' => 'cfcfcf',
'gray82' => 'd1d1d1',
'gray83' => 'd4d4d4',
'gray84' => 'd6d6d6',
'gray85' => 'd9d9d9',
'gray86' => 'dbdbdb',
'gray87' => 'dedede',
'gray88' => 'e0e0e0',
'gray89' => 'e3e3e3',
'gray9' => '171717',
'gray90' => 'e5e5e5',
'gray91' => 'e8e8e8',
'gray92' => 'ebebeb',
'gray93' => 'ededed',
'gray94' => 'f0f0f0',
'gray95' => 'f2f2f2',
'gray97' => 'f7f7f7',
'gray98' => 'fafafa',
'gray99' => 'fcfcfc',
'green' => '00ff00',
'green1' => '00ff00',
'green2' => '00ee00',
'green3' => '00cd00',
'green4' => '008b00',
'greenyellow' => 'adff2f',
'honeydew1' => 'f0fff0',
'honeydew2' => 'e0eee0',
'honeydew3' => 'c1cdc1',
'honeydew4' => '838b83',
'hotpink' => 'ff69b4',
'hotpink1' => 'ff6eb4',
'hotpink2' => 'ee6aa7',
'hotpink3' => 'cd6090',
'hotpink4' => '8b3a62',
'indianred' => 'cd5c5c',
'indianred1' => 'ff6a6a',
'indianred2' => 'ee6363',
'indianred3' => 'cd5555',
'indianred4' => '8b3a3a',
'ivory1' => 'fffff0',
'ivory2' => 'eeeee0',
'ivory3' => 'cdcdc1',
'ivory4' => '8b8b83',
'khaki' => 'f0e68c',
'khaki1' => 'fff68f',
'khaki2' => 'eee685',
'khaki3' => 'cdc673',
'khaki4' => '8b864e',
'lavender' => 'e6e6fa',
'lavenderblush1' => 'fff0f5',
'lavenderblush2' => 'eee0e5',
'lavenderblush3' => 'cdc1c5',
'lavenderblush4' => '8b8386',
'lawngreen' => '7cfc00',
'lemonchiffon1' => 'fffacd',
'lemonchiffon2' => 'eee9bf',
'lemonchiffon3' => 'cdc9a5',
'lemonchiffon4' => '8b8970',
'light' => 'eedd82',
'lightblue' => 'add8e6',
'lightblue1' => 'bfefff',
'lightblue2' => 'b2dfee',
'lightblue3' => '9ac0cd',
'lightblue4' => '68838b',
'lightcoral' => 'f08080',
'lightcyan1' => 'e0ffff',
'lightcyan2' => 'd1eeee',
'lightcyan3' => 'b4cdcd',
'lightcyan4' => '7a8b8b',
'lightgoldenrod1' => 'ffec8b',
'lightgoldenrod2' => 'eedc82',
'lightgoldenrod3' => 'cdbe70',
'lightgoldenrod4' => '8b814c',
'lightgoldenrodyellow' => 'fafad2',
'lightgray' => 'd3d3d3',
'lightpink' => 'ffb6c1',
'lightpink1' => 'ffaeb9',
'lightpink2' => 'eea2ad',
'lightpink3' => 'cd8c95',
'lightpink4' => '8b5f65',
'lightsalmon1' => 'ffa07a',
'lightsalmon2' => 'ee9572',
'lightsalmon3' => 'cd8162',
'lightsalmon4' => '8b5742',
'lightseagreen' => '20b2aa',
'lightskyblue' => '87cefa',
'lightskyblue1' => 'b0e2ff',
'lightskyblue2' => 'a4d3ee',
'lightskyblue3' => '8db6cd',
'lightskyblue4' => '607b8b',
'lightslateblue' => '8470ff',
'lightslategray' => '778899',
'lightsteelblue' => 'b0c4de',
'lightsteelblue1' => 'cae1ff',
'lightsteelblue2' => 'bcd2ee',
'lightsteelblue3' => 'a2b5cd',
'lightsteelblue4' => '6e7b8b',
'lightyellow1' => 'ffffe0',
'lightyellow2' => 'eeeed1',
'lightyellow3' => 'cdcdb4',
'lightyellow4' => '8b8b7a',
'lime' => '00ff00',
'limegreen' => '32cd32',
'linen' => 'faf0e6',
'magenta' => 'ff00ff',
'magenta2' => 'ee00ee',
'magenta3' => 'cd00cd',
'magenta4' => '8b008b',
'maroon' => 'b03060',
'maroon1' => 'ff34b3',
'maroon2' => 'ee30a7',
'maroon3' => 'cd2990',
'maroon4' => '8b1c62',
'medium' => '66cdaa',
'mediumaquamarine' => '66cdaa',
'mediumblue' => '0000cd',
'mediumorchid' => 'ba55d3',
'mediumorchid1' => 'e066ff',
'mediumorchid2' => 'd15fee',
'mediumorchid3' => 'b452cd',
'mediumorchid4' => '7a378b',
'mediumpurple' => '9370db',
'mediumpurple1' => 'ab82ff',
'mediumpurple2' => '9f79ee',
'mediumpurple3' => '8968cd',
'mediumpurple4' => '5d478b',
'mediumseagreen' => '3cb371',
'mediumslateblue' => '7b68ee',
'mediumspringgreen' => '00fa9a',
'mediumturquoise' => '48d1cc',
'mediumvioletred' => 'c71585',
'midnightblue' => '191970',
'mintcream' => 'f5fffa',
'mistyrose1' => 'ffe4e1',
'mistyrose2' => 'eed5d2',
'mistyrose3' => 'cdb7b5',
'mistyrose4' => '8b7d7b',
'moccasin' => 'ffe4b5',
'navajowhite1' => 'ffdead',
'navajowhite2' => 'eecfa1',
'navajowhite3' => 'cdb38b',
'navajowhite4' => '8b795e',
'navy' => '000080',
'navyblue' => '000080',
'oldlace' => 'fdf5e6',
'olive' => '808000',
'olivedrab' => '6b8e23',
'olivedrab1' => 'c0ff3e',
'olivedrab2' => 'b3ee3a',
'olivedrab4' => '698b22',
'orange' => 'ffa500',
'orange1' => 'ffa500',
'orange2' => 'ee9a00',
'orange3' => 'cd8500',
'orange4' => '8b5a00',
'orangered1' => 'ff4500',
'orangered2' => 'ee4000',
'orangered3' => 'cd3700',
'orangered4' => '8b2500',
'orchid' => 'da70d6',
'orchid1' => 'ff83fa',
'orchid2' => 'ee7ae9',
'orchid3' => 'cd69c9',
'orchid4' => '8b4789',
'pale' => 'db7093',
'palegoldenrod' => 'eee8aa',
'palegreen' => '98fb98',
'palegreen1' => '9aff9a',
'palegreen2' => '90ee90',
'palegreen3' => '7ccd7c',
'palegreen4' => '548b54',
'paleturquoise' => 'afeeee',
'paleturquoise1' => 'bbffff',
'paleturquoise2' => 'aeeeee',
'paleturquoise3' => '96cdcd',
'paleturquoise4' => '668b8b',
'palevioletred' => 'db7093',
'palevioletred1' => 'ff82ab',
'palevioletred2' => 'ee799f',
'palevioletred3' => 'cd6889',
'palevioletred4' => '8b475d',
'papayawhip' => 'ffefd5',
'peachpuff1' => 'ffdab9',
'peachpuff2' => 'eecbad',
'peachpuff3' => 'cdaf95',
'peachpuff4' => '8b7765',
'pink' => 'ffc0cb',
'pink1' => 'ffb5c5',
'pink2' => 'eea9b8',
'pink3' => 'cd919e',
'pink4' => '8b636c',
'plum' => 'dda0dd',
'plum1' => 'ffbbff',
'plum2' => 'eeaeee',
'plum3' => 'cd96cd',
'plum4' => '8b668b',
'powderblue' => 'b0e0e6',
'purple' => 'a020f0',
'rebeccapurple' => '663399',
'purple1' => '9b30ff',
'purple2' => '912cee',
'purple3' => '7d26cd',
'purple4' => '551a8b',
'red' => 'ff0000',
'red1' => 'ff0000',
'red2' => 'ee0000',
'red3' => 'cd0000',
'red4' => '8b0000',
'rosybrown' => 'bc8f8f',
'rosybrown1' => 'ffc1c1',
'rosybrown2' => 'eeb4b4',
'rosybrown3' => 'cd9b9b',
'rosybrown4' => '8b6969',
'royalblue' => '4169e1',
'royalblue1' => '4876ff',
'royalblue2' => '436eee',
'royalblue3' => '3a5fcd',
'royalblue4' => '27408b',
'saddlebrown' => '8b4513',
'salmon' => 'fa8072',
'salmon1' => 'ff8c69',
'salmon2' => 'ee8262',
'salmon3' => 'cd7054',
'salmon4' => '8b4c39',
'sandybrown' => 'f4a460',
'seagreen1' => '54ff9f',
'seagreen2' => '4eee94',
'seagreen3' => '43cd80',
'seagreen4' => '2e8b57',
'seashell1' => 'fff5ee',
'seashell2' => 'eee5de',
'seashell3' => 'cdc5bf',
'seashell4' => '8b8682',
'sienna' => 'a0522d',
'sienna1' => 'ff8247',
'sienna2' => 'ee7942',
'sienna3' => 'cd6839',
'sienna4' => '8b4726',
'silver' => 'c0c0c0',
'skyblue' => '87ceeb',
'skyblue1' => '87ceff',
'skyblue2' => '7ec0ee',
'skyblue3' => '6ca6cd',
'skyblue4' => '4a708b',
'slateblue' => '6a5acd',
'slateblue1' => '836fff',
'slateblue2' => '7a67ee',
'slateblue3' => '6959cd',
'slateblue4' => '473c8b',
'slategray' => '708090',
'slategray1' => 'c6e2ff',
'slategray2' => 'b9d3ee',
'slategray3' => '9fb6cd',
'slategray4' => '6c7b8b',
'snow1' => 'fffafa',
'snow2' => 'eee9e9',
'snow3' => 'cdc9c9',
'snow4' => '8b8989',
'springgreen1' => '00ff7f',
'springgreen2' => '00ee76',
'springgreen3' => '00cd66',
'springgreen4' => '008b45',
'steelblue' => '4682b4',
'steelblue1' => '63b8ff',
'steelblue2' => '5cacee',
'steelblue3' => '4f94cd',
'steelblue4' => '36648b',
'tan' => 'd2b48c',
'tan1' => 'ffa54f',
'tan2' => 'ee9a49',
'tan3' => 'cd853f',
'tan4' => '8b5a2b',
'teal' => '008080',
'thistle' => 'd8bfd8',
'thistle1' => 'ffe1ff',
'thistle2' => 'eed2ee',
'thistle3' => 'cdb5cd',
'thistle4' => '8b7b8b',
'tomato1' => 'ff6347',
'tomato2' => 'ee5c42',
'tomato3' => 'cd4f39',
'tomato4' => '8b3626',
'turquoise' => '40e0d0',
'turquoise1' => '00f5ff',
'turquoise2' => '00e5ee',
'turquoise3' => '00c5cd',
'turquoise4' => '00868b',
'violet' => 'ee82ee',
'violetred' => 'd02090',
'violetred1' => 'ff3e96',
'violetred2' => 'ee3a8c',
'violetred3' => 'cd3278',
'violetred4' => '8b2252',
'wheat' => 'f5deb3',
'wheat1' => 'ffe7ba',
'wheat2' => 'eed8ae',
'wheat3' => 'cdba96',
'wheat4' => '8b7e66',
'white' => 'ffffff',
'whitesmoke' => 'f5f5f5',
'yellow' => 'ffff00',
'yellow1' => 'ffff00',
'yellow2' => 'eeee00',
'yellow3' => 'cdcd00',
'yellow4' => '8b8b00',
'yellowgreen' => '9acd32',
);
protected $face;
protected $size;
protected $color;
protected $bold = false;
protected $italic = false;
protected $underline = false;
protected $superscript = false;
protected $subscript = false;
protected $strikethrough = false;
protected $startTagCallbacks = array(
'font' => 'startFontTag',
'b' => 'startBoldTag',
'strong' => 'startBoldTag',
'i' => 'startItalicTag',
'em' => 'startItalicTag',
'u' => 'startUnderlineTag',
'ins' => 'startUnderlineTag',
'del' => 'startStrikethruTag',
'sup' => 'startSuperscriptTag',
'sub' => 'startSubscriptTag',
);
protected $endTagCallbacks = array(
'font' => 'endFontTag',
'b' => 'endBoldTag',
'strong' => 'endBoldTag',
'i' => 'endItalicTag',
'em' => 'endItalicTag',
'u' => 'endUnderlineTag',
'ins' => 'endUnderlineTag',
'del' => 'endStrikethruTag',
'sup' => 'endSuperscriptTag',
'sub' => 'endSubscriptTag',
'br' => 'breakTag',
'p' => 'breakTag',
'h1' => 'breakTag',
'h2' => 'breakTag',
'h3' => 'breakTag',
'h4' => 'breakTag',
'h5' => 'breakTag',
'h6' => 'breakTag',
);
protected $stack = array();
protected $stringData = '';
protected $richTextObject;
protected function initialise() {
$this->face = $this->size = $this->color = null;
$this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false;
$this->stack = array();
$this->stringData = '';
}
public function toRichTextObject($html) {
$this->initialise();
// Create a new DOM object
$dom = new domDocument;
// Load the HTML file into the DOM object
// Note the use of error suppression, because typically this will be an html fragment, so not fully valid markup
$loaded = @$dom->loadHTML($html);
// Discard excess white space
$dom->preserveWhiteSpace = false;
$this->richTextObject = new PHPExcel_RichText();;
$this->parseElements($dom);
return $this->richTextObject;
}
protected function buildTextRun() {
$text = $this->stringData;
if (trim($text) === '')
return;
$richtextRun = $this->richTextObject->createTextRun($this->stringData);
if ($this->face) {
$richtextRun->getFont()->setName($this->face);
}
if ($this->size) {
$richtextRun->getFont()->setSize($this->size);
}
if ($this->color) {
$richtextRun->getFont()->setColor( new PHPExcel_Style_Color( 'ff' . $this->color ) );
}
if ($this->bold) {
$richtextRun->getFont()->setBold(true);
}
if ($this->italic) {
$richtextRun->getFont()->setItalic(true);
}
if ($this->underline) {
$richtextRun->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
}
if ($this->superscript) {
$richtextRun->getFont()->setSuperScript(true);
}
if ($this->subscript) {
$richtextRun->getFont()->setSubScript(true);
}
if ($this->strikethrough) {
$richtextRun->getFont()->setStrikethrough(true);
}
$this->stringData = '';
}
protected function rgbToColour($rgb) {
preg_match_all('/\d+/', $rgb, $values);
foreach($values[0] as &$value) {
$value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
}
return implode($values[0]);
}
protected function colourNameLookup($rgb) {
return self::$colourMap[$rgb];
}
protected function startFontTag($tag) {
foreach ($tag->attributes as $attribute) {
$attributeName = strtolower($attribute->name);
$attributeValue = $attribute->value;
if ($attributeName == 'color') {
if (preg_match('/rgb\s*\(/', $attributeValue)) {
$this->$attributeName = $this->rgbToColour($attributeValue);
} elseif(strpos(trim($attributeValue), '#') === 0) {
$this->$attributeName = ltrim($attributeValue, '#');
} else {
$this->$attributeName = $this->colourNameLookup($attributeValue);
}
} else {
$this->$attributeName = $attributeValue;
}
}
}
protected function endFontTag() {
$this->face = $this->size = $this->color = null;
}
protected function startBoldTag() {
$this->bold = true;
}
protected function endBoldTag() {
$this->bold = false;
}
protected function startItalicTag() {
$this->italic = true;
}
protected function endItalicTag() {
$this->italic = false;
}
protected function startUnderlineTag() {
$this->underline = true;
}
protected function endUnderlineTag() {
$this->underline = false;
}
protected function startSubscriptTag() {
$this->subscript = true;
}
protected function endSubscriptTag() {
$this->subscript = false;
}
protected function startSuperscriptTag() {
$this->superscript = true;
}
protected function endSuperscriptTag() {
$this->superscript = false;
}
protected function startStrikethruTag() {
$this->strikethrough = true;
}
protected function endStrikethruTag() {
$this->strikethrough = false;
}
protected function breakTag() {
$this->stringData .= PHP_EOL;
}
protected function parseTextNode(DOMText $textNode) {
$domText = preg_replace('/\s+/u', ' ', ltrim($textNode->nodeValue));
$this->stringData .= $domText;
$this->buildTextRun();
}
protected function handleCallback($element, $callbackTag, $callbacks) {
if (isset($callbacks[$callbackTag])) {
$elementHandler = $callbacks[$callbackTag];
if (method_exists($this, $elementHandler)) {
call_user_func(array($this, $elementHandler), $element);
}
}
}
protected function parseElementNode(DOMElement $element) {
$callbackTag = strtolower($element->nodeName);
$this->stack[] = $callbackTag;
$this->handleCallback($element, $callbackTag, $this->startTagCallbacks);
$this->parseElements($element);
$this->stringData .= ' ';
array_pop($this->stack);
$this->handleCallback($element, $callbackTag, $this->endTagCallbacks);
}
protected function parseElements(DOMNode $element) {
foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) {
$this->parseTextNode($child);
} elseif ($child instanceof DOMElement) {
$this->parseElementNode($child);
}
}
}
}

View File

@ -145,7 +145,10 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/
public function setLoadSheetsOnly($value = NULL)
{
$this->_loadSheetsOnly = is_array($value) ?
if ($value === NULL)
return $this->setLoadAllSheets();
$this->_loadSheetsOnly = is_array($value) ?
$value : array($value);
return $this;
}
@ -224,4 +227,29 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
return $readable;
}
/**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
*
* @param string $xml
* @throws PHPExcel_Reader_Exception
*/
public function securityScan($xml)
{
$pattern = '/\\0?' . implode('\\0?', str_split('<!DOCTYPE')) . '\\0?/';
if (preg_match($pattern, $xml)) {
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
}
return $xml;
}
/**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
*
* @param string $filestream
* @throws PHPExcel_Reader_Exception
*/
public function securityScanFile($filestream)
{
return $this->securityScan(file_get_contents($filestream));
}
}

View File

@ -68,14 +68,6 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
*/
private $_enclosure = '"';
/**
* Line ending
*
* @access private
* @var string
*/
private $_lineEnding = PHP_EOL;
/**
* Sheet index to read
*
@ -348,26 +340,6 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
return $this;
}
/**
* Get line ending
*
* @return string
*/
public function getLineEnding() {
return $this->_lineEnding;
}
/**
* Set line ending
*
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
* @return PHPExcel_Reader_CSV
*/
public function setLineEnding($pValue = PHP_EOL) {
$this->_lineEnding = $pValue;
return $this;
}
/**
* Get sheet index
*

View File

@ -49,14 +49,14 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
*
* @var array
*/
private $_styles = array();
protected $_styles = array();
/**
* Character set used in the file
*
* @var string
*/
private $_charSet = 'UTF-8';
protected $_charSet = 'UTF-8';
/**
@ -137,7 +137,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$worksheetNames = array();
$xml = simplexml_load_file($pFilename, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$xml = simplexml_load_string($this->securityScan(file_get_contents($pFilename)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$namespaces = $xml->getNamespaces(true);
$xml_ss = $xml->children($namespaces['ss']);
@ -165,7 +165,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$worksheetInfo = array();
$xml = simplexml_load_file($pFilename, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$xml = simplexml_load_string($this->securityScan(file_get_contents($pFilename)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$namespaces = $xml->getNamespaces(true);
$worksheetID = 1;
@ -232,13 +232,14 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
$objPHPExcel->removeSheetByIndex(0);
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
$styleAttributeValue = strtolower($styleAttributeValue);
foreach($styleList as $style) {
if ($styleAttributeValue == strtolower($style)) {
@ -255,7 +256,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
* @param pxs
* @return
*/
private static function _pixel2WidthUnits($pxs) {
protected static function _pixel2WidthUnits($pxs) {
$UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219);
$widthUnits = 256 * ($pxs / 7);
@ -269,7 +270,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
* @param widthUnits
* @return
*/
private static function _widthUnits2Pixel($widthUnits) {
protected static function _widthUnits2Pixel($widthUnits) {
$pixels = ($widthUnits / 256) * 7;
$offsetWidthUnits = $widthUnits % 256;
$pixels += round($offsetWidthUnits / (256 / 7));
@ -277,7 +278,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
}
private static function _hex2str($hex) {
protected static function _hex2str($hex) {
return chr(hexdec($hex[1]));
}
@ -330,7 +331,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$xml = simplexml_load_file($pFilename, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$xml = simplexml_load_string($this->securityScan(file_get_contents($pFilename)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$namespaces = $xml->getNamespaces(true);
$docProps = $objPHPExcel->getProperties();
@ -576,6 +577,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$rowID = 1;
if (isset($worksheet->Table->Row)) {
$additionalMergedCells = 0;
foreach($worksheet->Table->Row as $rowData) {
$rowHasData = false;
$row_ss = $rowData->attributes($namespaces['ss']);
@ -602,6 +604,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
if ((isset($cell_ss['MergeAcross'])) || (isset($cell_ss['MergeDown']))) {
$columnTo = $columnID;
if (isset($cell_ss['MergeAcross'])) {
$additionalMergedCells += (int)$cell_ss['MergeAcross'];
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cell_ss['MergeAcross'] -1);
}
$rowTo = $rowID;
@ -759,6 +762,10 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
}
}
++$columnID;
while ($additionalMergedCells > 0) {
++$columnID;
$additionalMergedCells--;
}
}
if ($rowHasData) {
@ -783,7 +790,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
}
private static function _convertStringEncoding($string,$charset) {
protected static function _convertStringEncoding($string,$charset) {
if ($charset != 'UTF-8') {
return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8',$charset);
}
@ -791,7 +798,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
}
private function _parseRichText($is = '') {
protected function _parseRichText($is = '') {
$value = new PHPExcel_RichText();
$value->createText(self::_convertStringEncoding($is,$this->_charSet));

View File

@ -94,7 +94,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$zip = new $zipClass;
if ($zip->open($pFilename) === true) {
// check if it is an OOXML archive
$rels = simplexml_load_string($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) {
foreach ($rels->Relationship as $rel) {
switch ($rel["Type"]) {
@ -136,13 +136,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
$rels = simplexml_load_string(
$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");
foreach ($rels->Relationship as $rel) {
switch ($rel["Type"]) {
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
$xmlWorkbook = simplexml_load_string(
$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");
if ($xmlWorkbook->sheets) {
@ -180,11 +180,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$zip = new $zipClass;
$zip->open($pFilename);
$rels = simplexml_load_string($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) {
if ($rel["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument") {
$dir = dirname($rel["Target"]);
$relsWorkbook = simplexml_load_string($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");
$worksheets = array();
@ -194,7 +194,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
}
}
$xmlWorkbook = simplexml_load_string($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) {
$dir = dirname($rel["Target"]);
foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
@ -209,7 +209,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$xml = new XMLReader();
$res = $xml->open('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());
$xml->setParserProperty(2,true);
$currCells = 0;
@ -338,6 +338,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
@ -361,14 +362,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$zip->open($pFilename);
// Read the theme first, because we need the colour scheme when reading the styles
$wbRels = simplexml_load_string($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) {
switch ($rel["Type"]) {
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme":
$themeOrderArray = array('lt1','dk1','lt2','dk2');
$themeOrderAdditional = count($themeOrderArray);
$xmlTheme = simplexml_load_string($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)) {
$xmlThemeName = $xmlTheme->attributes();
$xmlTheme = $xmlTheme->children("http://schemas.openxmlformats.org/drawingml/2006/main");
@ -398,11 +399,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
}
}
$rels = simplexml_load_string($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) {
switch ($rel["Type"]) {
case "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties":
$xmlCore = simplexml_load_string($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)) {
$xmlCore->registerXPathNamespace("dc", "http://purl.org/dc/elements/1.1/");
$xmlCore->registerXPathNamespace("dcterms", "http://purl.org/dc/terms/");
@ -421,7 +422,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
break;
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties":
$xmlCore = simplexml_load_string($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)) {
$docProps = $excel->getProperties();
if (isset($xmlCore->Company))
@ -432,7 +433,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
break;
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties":
$xmlCore = simplexml_load_string($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)) {
$docProps = $excel->getProperties();
foreach ($xmlCore as $xmlProperty) {
@ -458,12 +459,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
break;
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
$dir = dirname($rel["Target"]);
$relsWorkbook = simplexml_load_string($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");
$sharedStrings = array();
$xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']"));
$xmlStrings = simplexml_load_string($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)) {
foreach ($xmlStrings->si as $val) {
if (isset($val->t)) {
@ -478,7 +479,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$macros = $customUI = NULL;
foreach ($relsWorkbook->Relationship as $ele) {
switch($ele['Type']){
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":
$worksheets[(string) $ele["Id"]] = $ele["Target"];
break;
// a vbaProject ? (: some macros)
@ -502,7 +503,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$styles = array();
$cellStyles = array();
$xpath = self::array_item($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']"));
$xmlStyles = simplexml_load_string($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;
if ($xmlStyles && $xmlStyles->numFmts[0]) {
$numFmts = $xmlStyles->numFmts[0];
@ -606,7 +607,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
}
}
$xmlWorkbook = simplexml_load_string($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
if ($xmlWorkbook->workbookPr) {
@ -649,7 +650,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// reverse
$docSheet->setTitle((string) $eleSheet["name"],false);
$fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$xmlSheet = simplexml_load_string($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();
@ -756,7 +757,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
}
if (isset($xmlSheet->sheetFormatPr['zeroHeight']) &&
((string)$xmlSheet->sheetFormatPr['zeroHeight'] == '1')) {
$docSheet->getDefaultRowDimension()->setzeroHeight(true);
$docSheet->getDefaultRowDimension()->setZeroHeight(true);
}
}
@ -1005,102 +1006,106 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
}
if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) {
$autoFilter = $docSheet->getAutoFilter();
$autoFilter->setRange((string) $xmlSheet->autoFilter["ref"]);
foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) {
$column = $autoFilter->getColumnByOffset((integer) $filterColumn["colId"]);
// Check for standard filters
if ($filterColumn->filters) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER);
$filters = $filterColumn->filters;
if ((isset($filters["blank"])) && ($filters["blank"] == 1)) {
$column->createRule()->setRule(
NULL, // Operator is undefined, but always treated as EQUAL
''
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
}
// Standard filters are always an OR join, so no join rule needs to be set
// Entries can be either filter elements
foreach ($filters->filter as $filterRule) {
$column->createRule()->setRule(
NULL, // Operator is undefined, but always treated as EQUAL
(string) $filterRule["val"]
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
}
// Or Date Group elements
foreach ($filters->dateGroupItem as $dateGroupItem) {
$column->createRule()->setRule(
NULL, // Operator is undefined, but always treated as EQUAL
array(
'year' => (string) $dateGroupItem["year"],
'month' => (string) $dateGroupItem["month"],
'day' => (string) $dateGroupItem["day"],
'hour' => (string) $dateGroupItem["hour"],
'minute' => (string) $dateGroupItem["minute"],
'second' => (string) $dateGroupItem["second"],
),
(string) $dateGroupItem["dateTimeGrouping"]
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP);
}
}
// Check for custom filters
if ($filterColumn->customFilters) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER);
$customFilters = $filterColumn->customFilters;
// Custom filters can an AND or an OR join;
// and there should only ever be one or two entries
if ((isset($customFilters["and"])) && ($customFilters["and"] == 1)) {
$column->setJoin(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND);
}
foreach ($customFilters->customFilter as $filterRule) {
$column->createRule()->setRule(
(string) $filterRule["operator"],
(string) $filterRule["val"]
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
}
}
// Check for dynamic filters
if ($filterColumn->dynamicFilter) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER);
// We should only ever have one dynamic filter
foreach ($filterColumn->dynamicFilter as $filterRule) {
$column->createRule()->setRule(
NULL, // Operator is undefined, but always treated as EQUAL
(string) $filterRule["val"],
(string) $filterRule["type"]
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER);
if (isset($filterRule["val"])) {
$column->setAttribute('val',(string) $filterRule["val"]);
}
if (isset($filterRule["maxVal"])) {
$column->setAttribute('maxVal',(string) $filterRule["maxVal"]);
}
}
}
// Check for dynamic filters
if ($filterColumn->top10) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER);
// We should only ever have one top10 filter
foreach ($filterColumn->top10 as $filterRule) {
$column->createRule()->setRule(
(((isset($filterRule["percent"])) && ($filterRule["percent"] == 1))
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT
: PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE
),
(string) $filterRule["val"],
(((isset($filterRule["top"])) && ($filterRule["top"] == 1))
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP
: PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM
)
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER);
}
}
$autoFilterRange = (string) $xmlSheet->autoFilter["ref"];
if (strpos($autoFilterRange, ':') !== false) {
$autoFilter = $docSheet->getAutoFilter();
$autoFilter->setRange($autoFilterRange);
foreach ($xmlSheet->autoFilter->filterColumn as $filterColumn) {
$column = $autoFilter->getColumnByOffset((integer) $filterColumn["colId"]);
// Check for standard filters
if ($filterColumn->filters) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER);
$filters = $filterColumn->filters;
if ((isset($filters["blank"])) && ($filters["blank"] == 1)) {
$column->createRule()->setRule(
NULL, // Operator is undefined, but always treated as EQUAL
''
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
}
// Standard filters are always an OR join, so no join rule needs to be set
// Entries can be either filter elements
foreach ($filters->filter as $filterRule) {
$column->createRule()->setRule(
NULL, // Operator is undefined, but always treated as EQUAL
(string) $filterRule["val"]
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER);
}
// Or Date Group elements
foreach ($filters->dateGroupItem as $dateGroupItem) {
$column->createRule()->setRule(
NULL, // Operator is undefined, but always treated as EQUAL
array(
'year' => (string) $dateGroupItem["year"],
'month' => (string) $dateGroupItem["month"],
'day' => (string) $dateGroupItem["day"],
'hour' => (string) $dateGroupItem["hour"],
'minute' => (string) $dateGroupItem["minute"],
'second' => (string) $dateGroupItem["second"],
),
(string) $dateGroupItem["dateTimeGrouping"]
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP);
}
}
// Check for custom filters
if ($filterColumn->customFilters) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER);
$customFilters = $filterColumn->customFilters;
// Custom filters can an AND or an OR join;
// and there should only ever be one or two entries
if ((isset($customFilters["and"])) && ($customFilters["and"] == 1)) {
$column->setJoin(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND);
}
foreach ($customFilters->customFilter as $filterRule) {
$column->createRule()->setRule(
(string) $filterRule["operator"],
(string) $filterRule["val"]
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_CUSTOMFILTER);
}
}
// Check for dynamic filters
if ($filterColumn->dynamicFilter) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER);
// We should only ever have one dynamic filter
foreach ($filterColumn->dynamicFilter as $filterRule) {
$column->createRule()->setRule(
NULL, // Operator is undefined, but always treated as EQUAL
(string) $filterRule["val"],
(string) $filterRule["type"]
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER);
if (isset($filterRule["val"])) {
$column->setAttribute('val',(string) $filterRule["val"]);
}
if (isset($filterRule["maxVal"])) {
$column->setAttribute('maxVal',(string) $filterRule["maxVal"]);
}
}
}
// Check for dynamic filters
if ($filterColumn->top10) {
$column->setFilterType(PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER);
// We should only ever have one top10 filter
foreach ($filterColumn->top10 as $filterRule) {
$column->createRule()->setRule(
(((isset($filterRule["percent"])) && ($filterRule["percent"] == 1))
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT
: PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE
),
(string) $filterRule["val"],
(((isset($filterRule["top"])) && ($filterRule["top"] == 1))
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP
: PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM
)
)
->setRuleType(PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER);
}
}
}
}
}
@ -1234,7 +1239,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (!$this->_readDataOnly) {
// Locate hyperlink relations
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($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) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink") {
$hyperlinks[(string)$ele["Id"]] = (string)$ele["Target"];
@ -1275,7 +1280,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (!$this->_readDataOnly) {
// Locate comment relations
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($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) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments") {
$comments[(string)$ele["Id"]] = (string)$ele["Target"];
@ -1290,7 +1295,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
foreach ($comments as $relName => $relPath) {
// Load comments file
$relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath);
$commentsFile = simplexml_load_string($this->_getFromZipArchive($zip, $relPath) , 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$commentsFile = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $relPath)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
// Utility variables
$authors = array();
@ -1302,7 +1307,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Loop through contents
foreach ($commentsFile->commentList->comment as $comment) {
$docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] );
if(!empty($comment['authorId']))
$docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] );
$docSheet->getComment( (string)$comment['ref'] )->setText( $this->_parseRichText($comment->text) );
}
}
@ -1311,7 +1317,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
foreach ($vmlComments as $relName => $relPath) {
// Load VML comments file
$relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath);
$vmlCommentsFile = simplexml_load_string( $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');
$shapes = $vmlCommentsFile->xpath('//v:shape');
@ -1362,7 +1368,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Header/footer images
if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->_readDataOnly) {
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($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 = '';
foreach ($relsWorksheet->Relationship as $ele) {
@ -1373,7 +1379,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ($vmlRelationship != '') {
// Fetch linked images
$relsVML = simplexml_load_string($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();
foreach ($relsVML->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
@ -1382,7 +1388,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
}
// Fetch VML document
$vmlDrawing = simplexml_load_string($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');
$hfImages = array();
@ -1421,7 +1427,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// TODO: Autoshapes from twoCellAnchors!
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($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();
foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing") {
@ -1431,7 +1437,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ($xmlSheet->drawing && !$this->_readDataOnly) {
foreach ($xmlSheet->drawing as $drawing) {
$fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$relsDrawing = simplexml_load_string($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();
if ($relsDrawing && $relsDrawing->Relationship) {
@ -1447,7 +1453,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
}
}
}
$xmlDrawing = simplexml_load_string($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) {
foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) {
@ -1504,10 +1510,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff));
$objDrawing->setResizeProportional(false);
$objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cx")));
$objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cy")));
if ($xfrm) {
$objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cx")));
$objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cy")));
$objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot")));
}
if ($outerShdw) {
@ -1573,7 +1578,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
case '_xlnm._FilterDatabase':
if ((string)$definedName['hidden'] !== '1') {
$docSheet->getAutoFilter()->setRange($extractedRange);
$extractedRange = explode(',', $extractedRange);
foreach ($extractedRange as $range) {
$autoFilterRange = $range;
if (strpos($autoFilterRange, ':') !== false) {
$docSheet->getAutoFilter()->setRange($autoFilterRange);
}
}
}
break;
@ -1711,13 +1722,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (!$this->_readDataOnly) {
$contentTypes = simplexml_load_string($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) {
switch ($contentType["ContentType"]) {
case "application/vnd.openxmlformats-officedocument.drawingml.chart+xml":
if ($this->_includeCharts) {
$chartEntryRef = ltrim($contentType['PartName'],'/');
$chartElements = simplexml_load_string($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'));
// echo 'Chart ',$chartEntryRef,'<br />';
@ -1878,6 +1889,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment["wrapText"]));
$docStyle->getAlignment()->setShrinkToFit(self::boolean((string) $style->alignment["shrinkToFit"]));
$docStyle->getAlignment()->setIndent( intval((string)$style->alignment["indent"]) > 0 ? intval((string)$style->alignment["indent"]) : 0 );
$docStyle->getAlignment()->setReadorder( intval((string)$style->alignment["readingOrder"]) > 0 ? intval((string)$style->alignment["readingOrder"]) : 0 );
}
// protection
@ -1922,6 +1934,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($is->t)) {
$value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) );
} else {
if(is_object($is->r)) {
foreach ($is->r as $run) {
if (!isset($run->rPr)) {
$objText = $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) );
@ -1973,6 +1986,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
}
}
}
}
}
return $value;
@ -1984,14 +1998,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$nameCustomUI = basename($customUITarget);
// get the xml file (ribbon)
$localRibbon = $this->_getFromZipArchive($zip, $customUITarget);
$customUIImagesNames = array();
$customUIImagesNames = array();
$customUIImagesBinaries = array();
// something like customUI/_rels/customUI.xml.rels
$pathRels = $baseDir . '/_rels/' . $nameCustomUI . '.rels';
$dataRels = $this->_getFromZipArchive($zip, $pathRels);
if ($dataRels) {
// exists and not empty if the ribbon have some pictures (other than internal MSO)
$UIRels = simplexml_load_string($dataRels, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$UIRels = simplexml_load_string($this->securityScan($dataRels), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
if ($UIRels) {
// we need to save id and target to avoid parsing customUI.xml and "guess" if it's a pseudo callback who load the image
foreach ($UIRels->Relationship as $ele) {

View File

@ -1089,6 +1089,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
}
}
}
$this->_data = null;
return $this->_phpExcel;
}
@ -4561,6 +4562,9 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$offset += 4;
// offset: var; size: $us; character array of the URL, no Unicode string header, always 16-bit characters, zero-terminated
$url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false);
$nullOffset = strpos($url, 0x00);
if ($nullOffset)
$url = substr($url,0,$nullOffset);
$url .= $hasText ? '#' : '';
$offset += $us;
break;

View File

@ -116,8 +116,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
$xml = new XMLReader();
$xml->open(
'compress.zlib://'.realpath($pFilename), null, PHPExcel_Settings::getLibXmlLoaderOptions()
$xml->xml(
$this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions()
);
$xml->setParserProperty(2,true);
@ -150,8 +150,8 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
}
$xml = new XMLReader();
$xml->open(
'compress.zlib://'.realpath($pFilename), null, PHPExcel_Settings::getLibXmlLoaderOptions()
$xml->xml(
$this->securityScanFile('compress.zlib://'.realpath($pFilename)), null, PHPExcel_Settings::getLibXmlLoaderOptions()
);
$xml->setParserProperty(2,true);
@ -243,7 +243,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// echo htmlentities($gFileData,ENT_QUOTES,'UTF-8');
// echo '</pre><hr />';
//
$xml = simplexml_load_string($gFileData, 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$xml = simplexml_load_string($this->securityScan($gFileData), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$namespacesMeta = $xml->getNamespaces(true);
// var_dump($namespacesMeta);

View File

@ -1,4 +1,5 @@
<?php
/**
* PHPExcel
*
@ -24,15 +25,13 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
@ -44,425 +43,492 @@ if (!defined('PHPEXCEL_ROOT')) {
*/
class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
/**
* Input encoding
*
* @var string
*/
private $_inputEncoding = 'ANSI';
/**
* Sheet index to read
*
* @var int
*/
private $_sheetIndex = 0;
/**
* Input encoding
*
* @var string
*/
protected $_inputEncoding = 'ANSI';
/**
* Formats
*
* @var array
*/
private $_formats = array( 'h1' => array( 'font' => array( 'bold' => true,
'size' => 24,
),
), // Bold, 24pt
'h2' => array( 'font' => array( 'bold' => true,
'size' => 18,
),
), // Bold, 18pt
'h3' => array( 'font' => array( 'bold' => true,
'size' => 13.5,
),
), // Bold, 13.5pt
'h4' => array( 'font' => array( 'bold' => true,
'size' => 12,
),
), // Bold, 12pt
'h5' => array( 'font' => array( 'bold' => true,
'size' => 10,
),
), // Bold, 10pt
'h6' => array( 'font' => array( 'bold' => true,
'size' => 7.5,
),
), // Bold, 7.5pt
'a' => array( 'font' => array( 'underline' => true,
'color' => array( 'argb' => PHPExcel_Style_Color::COLOR_BLUE,
),
),
), // Blue underlined
'hr' => array( 'borders' => array( 'bottom' => array( 'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array( PHPExcel_Style_Color::COLOR_BLACK,
),
),
),
), // Bottom border
);
/**
* Sheet index to read
*
* @var int
*/
protected $_sheetIndex = 0;
/**
* Formats
*
* @var array
*/
protected $_formats = array(
'h1' => array('font' => array('bold' => true,
'size' => 24,
),
), // Bold, 24pt
'h2' => array('font' => array('bold' => true,
'size' => 18,
),
), // Bold, 18pt
'h3' => array('font' => array('bold' => true,
'size' => 13.5,
),
), // Bold, 13.5pt
'h4' => array('font' => array('bold' => true,
'size' => 12,
),
), // Bold, 12pt
'h5' => array('font' => array('bold' => true,
'size' => 10,
),
), // Bold, 10pt
'h6' => array('font' => array('bold' => true,
'size' => 7.5,
),
), // Bold, 7.5pt
'a' => array('font' => array('underline' => true,
'color' => array('argb' => PHPExcel_Style_Color::COLOR_BLUE,
),
),
), // Blue underlined
'hr' => array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array(\PHPExcel_Style_Color::COLOR_BLACK,
),
),
),
), // Bottom border
);
/**
* Create a new PHPExcel_Reader_HTML
*/
public function __construct() {
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
protected $rowspan = array();
/**
* Validate that the current file is an HTML file
*
* @return boolean
*/
protected function _isValidFormat()
{
// Reading 2048 bytes should be enough to validate that the format is HTML
$data = fread($this->_fileHandle, 2048);
if ((strpos($data, '<') !== FALSE) &&
(strlen($data) !== strlen(strip_tags($data)))) {
return TRUE;
}
/**
* Create a new PHPExcel_Reader_HTML
*/
public function __construct()
{
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
return FALSE;
}
/**
* Validate that the current file is an HTML file
*
* @return boolean
*/
protected function _isValidFormat()
{
// Reading 2048 bytes should be enough to validate that the format is HTML
$data = fread($this->_fileHandle, 2048);
if ((strpos($data, '<') !== FALSE) &&
(strlen($data) !== strlen(strip_tags($data)))) {
return TRUE;
}
/**
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
return FALSE;
}
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
/**
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
// Create new PHPExcel
$objPHPExcel = new PHPExcel();
/**
* Set input encoding
*
* @param string $pValue Input encoding
*/
public function setInputEncoding($pValue = 'ANSI')
{
$this->_inputEncoding = $pValue;
return $this;
}
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
/**
* Get input encoding
*
* @return string
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
}
/**
* Set input encoding
*
* @param string $pValue Input encoding
*/
public function setInputEncoding($pValue = 'ANSI')
{
$this->_inputEncoding = $pValue;
// Data Array used for testing only, should write to PHPExcel object on completion of tests
private $_dataArray = array();
return $this;
}
private $_tableLevel = 0;
private $_nestedColumn = array('A');
/**
* Get input encoding
*
* @return string
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
}
private function _setTableStartColumn($column) {
if ($this->_tableLevel == 0)
$column = 'A';
++$this->_tableLevel;
$this->_nestedColumn[$this->_tableLevel] = $column;
// Data Array used for testing only, should write to PHPExcel object on completion of tests
protected $_dataArray = array();
protected $_tableLevel = 0;
protected $_nestedColumn = array('A');
return $this->_nestedColumn[$this->_tableLevel];
}
protected function _setTableStartColumn($column)
{
if ($this->_tableLevel == 0)
$column = 'A';
++$this->_tableLevel;
$this->_nestedColumn[$this->_tableLevel] = $column;
private function _getTableStartColumn() {
return $this->_nestedColumn[$this->_tableLevel];
}
return $this->_nestedColumn[$this->_tableLevel];
}
private function _releaseTableStartColumn() {
--$this->_tableLevel;
return array_pop($this->_nestedColumn);
}
protected function _getTableStartColumn()
{
return $this->_nestedColumn[$this->_tableLevel];
}
private function _flushCell($sheet,$column,$row,&$cellContent) {
if (is_string($cellContent)) {
// Simple String content
if (trim($cellContent) > '') {
// Only actually write it if there's content in the string
protected function _releaseTableStartColumn()
{
--$this->_tableLevel;
return array_pop($this->_nestedColumn);
}
protected function _flushCell($sheet, $column, $row, &$cellContent)
{
if (is_string($cellContent)) {
// Simple String content
if (trim($cellContent) > '') {
// Only actually write it if there's content in the string
// echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '<br />';
// Write to worksheet to be done here...
// ... we return the cell so we can mess about with styles more easily
$cell = $sheet->setCellValue($column.$row,$cellContent,true);
$this->_dataArray[$row][$column] = $cellContent;
}
} else {
// We have a Rich Text run
// TODO
$this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
}
$cellContent = (string) '';
}
// Write to worksheet to be done here...
// ... we return the cell so we can mess about with styles more easily
$sheet->setCellValue($column . $row, $cellContent, true);
$this->_dataArray[$row][$column] = $cellContent;
}
} else {
// We have a Rich Text run
// TODO
$this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
}
$cellContent = (string) '';
}
private function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent){
foreach($element->childNodes as $child){
if ($child instanceof DOMText) {
$domText = preg_replace('/\s+/',' ',trim($child->nodeValue));
if (is_string($cellContent)) {
// simply append the text if the cell content is a plain text string
$cellContent .= $domText;
} else {
// but if we have a rich text run instead, we need to append it correctly
// TODO
}
} elseif($child instanceof DOMElement) {
protected function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null)
{
foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) {
$domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue));
if (is_string($cellContent)) {
// simply append the text if the cell content is a plain text string
$cellContent .= $domText;
} else {
// but if we have a rich text run instead, we need to append it correctly
// TODO
}
} elseif ($child instanceof DOMElement) {
// echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
$attributeArray = array();
foreach($child->attributes as $attribute) {
$attributeArray = array();
foreach ($child->attributes as $attribute) {
// echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
$attributeArray[$attribute->name] = $attribute->value;
}
$attributeArray[$attribute->name] = $attribute->value;
}
switch($child->nodeName) {
case 'meta' :
foreach($attributeArray as $attributeName => $attributeValue) {
switch($attributeName) {
case 'content':
// TODO
// Extract character set, so we can convert to UTF-8 if required
break;
}
}
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
break;
case 'title' :
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
$sheet->setTitle($cellContent);
$cellContent = '';
break;
case 'span' :
case 'div' :
case 'font' :
case 'i' :
case 'em' :
case 'strong':
case 'b' :
switch ($child->nodeName) {
case 'meta' :
foreach ($attributeArray as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'content':
// TODO
// Extract character set, so we can convert to UTF-8 if required
break;
}
}
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
break;
case 'title' :
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
$sheet->setTitle($cellContent);
$cellContent = '';
break;
case 'span' :
case 'div' :
case 'font' :
case 'i' :
case 'em' :
case 'strong':
case 'b' :
// echo 'STYLING, SPAN OR DIV<br />';
if ($cellContent > '')
$cellContent .= ' ';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
if ($cellContent > '')
$cellContent .= ' ';
if ($cellContent > '')
$cellContent .= ' ';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
if ($cellContent > '')
$cellContent .= ' ';
// echo 'END OF STYLING, SPAN OR DIV<br />';
break;
case 'hr' :
$this->_flushCell($sheet,$column,$row,$cellContent);
++$row;
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
} else {
$cellContent = '----------';
$this->_flushCell($sheet,$column,$row,$cellContent);
}
++$row;
case 'br' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
} else {
// Otherwise flush our existing content and move the row cursor on
$this->_flushCell($sheet,$column,$row,$cellContent);
++$row;
}
break;
case 'hr' :
$this->_flushCell($sheet, $column, $row, $cellContent);
++$row;
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]);
} else {
$cellContent = '----------';
$this->_flushCell($sheet, $column, $row, $cellContent);
}
++$row;
case 'br' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
} else {
// Otherwise flush our existing content and move the row cursor on
$this->_flushCell($sheet, $column, $row, $cellContent);
++$row;
}
// echo 'HARD LINE BREAK: ' , '<br />';
break;
case 'a' :
break;
case 'a' :
// echo 'START OF HYPERLINK: ' , '<br />';
foreach($attributeArray as $attributeName => $attributeValue) {
switch($attributeName) {
case 'href':
foreach ($attributeArray as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'href':
// echo 'Link to ' , $attributeValue , '<br />';
$sheet->getCell($column.$row)->getHyperlink()->setUrl($attributeValue);
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
}
break;
}
}
$cellContent .= ' ';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
$sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue);
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]);
}
break;
}
}
$cellContent .= ' ';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF HYPERLINK:' , '<br />';
break;
case 'h1' :
case 'h2' :
case 'h3' :
case 'h4' :
case 'h5' :
case 'h6' :
case 'ol' :
case 'ul' :
case 'p' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
break;
case 'h1' :
case 'h2' :
case 'h3' :
case 'h4' :
case 'h5' :
case 'h6' :
case 'ol' :
case 'ul' :
case 'p' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
// echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
} else {
if ($cellContent > '') {
$this->_flushCell($sheet,$column,$row,$cellContent);
$row += 2;
}
} else {
if ($cellContent > '') {
$this->_flushCell($sheet, $column, $row, $cellContent);
$row++;
}
// echo 'START OF PARAGRAPH: ' , '<br />';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF PARAGRAPH:' , '<br />';
$this->_flushCell($sheet,$column,$row,$cellContent);
$this->_flushCell($sheet, $column, $row, $cellContent);
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column.$row)->applyFromArray($this->_formats[$child->nodeName]);
}
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]);
}
$row += 2;
$column = 'A';
}
break;
case 'li' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
$row++;
$column = 'A';
}
break;
case 'li' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
// echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
} else {
if ($cellContent > '') {
$this->_flushCell($sheet,$column,$row,$cellContent);
}
++$row;
} else {
if ($cellContent > '') {
$this->_flushCell($sheet, $column, $row, $cellContent);
}
++$row;
// echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
$this->_flushCell($sheet,$column,$row,$cellContent);
$column = 'A';
}
break;
case 'table' :
$this->_flushCell($sheet,$column,$row,$cellContent);
$column = $this->_setTableStartColumn($column);
$this->_flushCell($sheet, $column, $row, $cellContent);
$column = 'A';
}
break;
case 'table' :
$this->_flushCell($sheet, $column, $row, $cellContent);
$column = $this->_setTableStartColumn($column);
// echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
if ($this->_tableLevel > 1)
--$row;
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
if ($this->_tableLevel > 1)
--$row;
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
$column = $this->_releaseTableStartColumn();
if ($this->_tableLevel > 1) {
++$column;
} else {
++$row;
}
break;
case 'thead' :
case 'tbody' :
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
break;
case 'tr' :
++$row;
$column = $this->_getTableStartColumn();
$cellContent = '';
$column = $this->_releaseTableStartColumn();
if ($this->_tableLevel > 1) {
++$column;
} else {
++$row;
}
break;
case 'thead' :
case 'tbody' :
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
break;
case 'tr' :
$column = $this->_getTableStartColumn();
$cellContent = '';
// echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />';
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
++$row;
// echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />';
break;
case 'th' :
case 'td' :
break;
case 'th' :
case 'td' :
// 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 />';
$this->_flushCell($sheet,$column,$row,$cellContent);
++$column;
break;
case 'body' :
$row = 1;
$column = 'A';
$content = '';
$this->_tableLevel = 0;
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
break;
default:
$this->_processDomElement($child,$sheet,$row,$column,$cellContent);
}
}
}
}
/**
* Loads PHPExcel from file into PHPExcel instance
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Open file to validate
$this->_openFile($pFilename);
if (!$this->_isValidFormat()) {
fclose ($this->_fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
}
// Close after validating
fclose ($this->_fileHandle);
while (isset($this->rowspan[$column . $row])) {
++$column;
}
// Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
$objPHPExcel->createSheet();
}
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
$this->_flushCell($sheet, $column, $row, $cellContent);
// Create a new DOM object
$dom = new domDocument;
// Reload the HTML file into the DOM object
$loaded = $dom->loadHTMLFile($pFilename, PHPExcel_Settings::getLibXmlLoaderOptions());
if ($loaded === FALSE) {
throw new PHPExcel_Reader_Exception('Failed to load ',$pFilename,' as a DOM Document');
}
// if (isset($attributeArray['style']) && !empty($attributeArray['style'])) {
// $styleAry = $this->getPhpExcelStyleArray($attributeArray['style']);
//
// if (!empty($styleAry)) {
// $sheet->getStyle($column . $row)->applyFromArray($styleAry);
// }
// }
// Discard white space
$dom->preserveWhiteSpace = false;
if (isset($attributeArray['rowspan']) && isset($attributeArray['colspan'])) {
//create merging rowspan and colspan
$columnTo = $column;
for ($i = 0; $i < $attributeArray['colspan'] - 1; $i++) {
++$columnTo;
}
$range = $column . $row . ':' . $columnTo . ($row + $attributeArray['rowspan'] - 1);
foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) {
$this->rowspan[$value] = true;
}
$sheet->mergeCells($range);
$column = $columnTo;
} elseif (isset($attributeArray['rowspan'])) {
//create merging rowspan
$range = $column . $row . ':' . $column . ($row + $attributeArray['rowspan'] - 1);
foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) {
$this->rowspan[$value] = true;
}
$sheet->mergeCells($range);
} elseif (isset($attributeArray['colspan'])) {
//create merging colspan
$columnTo = $column;
for ($i = 0; $i < $attributeArray['colspan'] - 1; $i++) {
++$columnTo;
}
$sheet->mergeCells($column . $row . ':' . $columnTo . $row);
$column = $columnTo;
}
++$column;
break;
case 'body' :
$row = 1;
$column = 'A';
$content = '';
$this->_tableLevel = 0;
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
break;
default:
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
}
}
}
}
/**
* Loads PHPExcel from file into PHPExcel instance
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Open file to validate
$this->_openFile($pFilename);
if (!$this->_isValidFormat()) {
fclose($this->_fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
}
// Close after validating
fclose($this->_fileHandle);
$row = 0;
$column = 'A';
$content = '';
$this->_processDomElement($dom,$objPHPExcel->getActiveSheet(),$row,$column,$content);
// Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
$objPHPExcel->createSheet();
}
$objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
// echo '<hr />';
// var_dump($this->_dataArray);
// Create a new DOM object
$dom = new domDocument;
// Reload the HTML file into the DOM object
$loaded = $dom->loadHTML($this->securityScanFile($pFilename));
if ($loaded === FALSE) {
throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document');
}
// Discard white space
$dom->preserveWhiteSpace = false;
$row = 0;
$column = 'A';
$content = '';
$this->_processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
// Return
return $objPHPExcel;
}
return $objPHPExcel;
}
/**
* Get sheet index
*
* @return int
*/
public function getSheetIndex()
{
return $this->_sheetIndex;
}
/**
* Set sheet index
*
* @param int $pValue Sheet index
* @return PHPExcel_Reader_HTML
*/
public function setSheetIndex($pValue = 0)
{
$this->_sheetIndex = $pValue;
return $this;
}
/**
* Get sheet index
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
*
* @return int
* @param string $xml
* @throws PHPExcel_Reader_Exception
*/
public function getSheetIndex() {
return $this->_sheetIndex;
}
/**
* Set sheet index
*
* @param int $pValue Sheet index
* @return PHPExcel_Reader_HTML
*/
public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue;
return $this;
}
public function securityScan($xml)
{
$pattern = '/\\0?' . implode('\\0?', str_split('<!ENTITY')) . '\\0?/';
if (preg_match($pattern, $xml)) {
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
}
return $xml;
}
}

View File

@ -47,6 +47,7 @@ interface PHPExcel_Reader_IReader
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename);

View File

@ -90,7 +90,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
if ($stat && ($stat['size'] <= 255)) {
$mimeType = $zip->getFromName($stat['name']);
} elseif($stat = $zip->statName('META-INF/manifest.xml')) {
$xml = simplexml_load_string($zip->getFromName('META-INF/manifest.xml'), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$xml = simplexml_load_string($this->securityScan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$namespacesContent = $xml->getNamespaces(true);
if (isset($namespacesContent['manifest'])) {
$manifest = $xml->children($namespacesContent['manifest']);
@ -136,7 +136,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$worksheetNames = array();
$xml = new XMLReader();
$res = $xml->open('zip://'.realpath($pFilename).'#content.xml', null, PHPExcel_Settings::getLibXmlLoaderOptions());
$res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$xml->setParserProperty(2,true);
// Step into the first level of content of the XML
@ -188,7 +188,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
}
$xml = new XMLReader();
$res = $xml->open('zip://'.realpath($pFilename).'#content.xml', null, PHPExcel_Settings::getLibXmlLoaderOptions());
$res = $xml->xml($this->securityScanFile('zip://'.realpath($pFilename).'#content.xml'), null, PHPExcel_Settings::getLibXmlLoaderOptions());
$xml->setParserProperty(2,true);
// Step into the first level of content of the XML
@ -345,7 +345,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
}
// echo '<h1>Meta Information</h1>';
$xml = simplexml_load_string($zip->getFromName("meta.xml"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$xml = simplexml_load_string($this->securityScan($zip->getFromName("meta.xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$namespacesMeta = $xml->getNamespaces(true);
// echo '<pre>';
// print_r($namespacesMeta);
@ -431,7 +431,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo '<h1>Workbook Content</h1>';
$xml = simplexml_load_string($zip->getFromName("content.xml"), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$xml = simplexml_load_string($this->securityScan($zip->getFromName("content.xml")), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$namespacesContent = $xml->getNamespaces(true);
// echo '<pre>';
// print_r($namespacesContent);
@ -515,9 +515,13 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$annotationText = $cellDataOffice->annotation->children($namespacesContent['text']);
$textArray = array();
foreach($annotationText as $t) {
foreach($t->span as $text) {
$textArray[] = (string)$text;
}
if (isset($t->span)) {
foreach($t->span as $text) {
$textArray[] = (string)$text;
}
} else {
$textArray[] = (string) $t;
}
}
$text = implode("\n",$textArray);
// echo $text,'<br />';

View File

@ -363,10 +363,12 @@ class PHPExcel_Settings
*/
public static function setLibXmlLoaderOptions($options = null)
{
if (is_null($options)) {
if (is_null($options) && defined(LIBXML_DTDLOAD)) {
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
}
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
}
self::$_libXmlLoaderOptions = $options;
} // function setLibXmlLoaderOptions
@ -378,10 +380,12 @@ class PHPExcel_Settings
*/
public static function getLibXmlLoaderOptions()
{
if (is_null(self::$_libXmlLoaderOptions)) {
if (is_null(self::$_libXmlLoaderOptions) && defined(LIBXML_DTDLOAD)) {
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
}
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
}
return self::$_libXmlLoaderOptions;
} // function getLibXmlLoaderOptions
}

View File

@ -83,12 +83,16 @@ class PHPExcel_Shared_CodePage
case 1258: return 'CP1258'; break; // ANSI Vietnamese
case 1361: return 'CP1361'; break; // ANSI Korean (Johab)
case 10000: return 'MAC'; break; // Apple Roman
case 10001: return 'CP932'; break; // Macintosh Japanese
case 10002: return 'CP950'; break; // Macintosh Chinese Traditional
case 10003: return 'CP1361'; break; // Macintosh Korean
case 10006: return 'MACGREEK'; break; // Macintosh Greek
case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic
case 10008: return 'CP936'; break; // Macintosh - Simplified Chinese (GB 2312)
case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe
case 10079: return 'MACICELAND'; break; // Macintosh Icelandic
case 10081: return 'MACTURKISH'; break; // Macintosh Turkish
case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic
case 10008: return 'CP936'; break; // Macintosh - Simplified Chinese (GB 2312)
case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe
case 10079: return 'MACICELAND'; break; // Macintosh Icelandic
case 10081: return 'MACTURKISH'; break; // Macintosh Turkish
case 21010: return 'UTF-16LE'; break; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
case 32768: return 'MAC'; break; // Apple Roman
case 32769: throw new PHPExcel_Exception('Code page 32769 not supported.');
break; // ANSI Latin I (BIFF2-BIFF3)

View File

@ -155,7 +155,7 @@ class PHPExcel_Shared_Date
* Convert a date from Excel to a PHP Date/Time object
*
* @param integer $dateValue Excel date/time value
* @return integer PHP date/time object
* @return DateTime PHP date/time object
*/
public static function ExcelToPHPObject($dateValue = 0) {
$dateTime = self::ExcelToPHP($dateValue);

View File

@ -199,7 +199,6 @@ class PHPExcel_Shared_Font
if (!in_array($pValue,self::$_autoSizeMethods)) {
return FALSE;
}
self::$autoSizeMethod = $pValue;
return TRUE;
@ -241,7 +240,7 @@ class PHPExcel_Shared_Font
return self::$trueTypeFontPath;
}
/**
/**
* Calculate an (approximate) OpenXML column width, based on font size and text contained
*
* @param PHPExcel_Style_Font $font Font object
@ -251,7 +250,6 @@ class PHPExcel_Shared_Font
* @return integer Column width
*/
public static function calculateColumnWidth(PHPExcel_Style_Font $font, $cellText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) {
// If it is rich text, use plain text
if ($cellText instanceof PHPExcel_RichText) {
$cellText = $cellText->getPlainText();
@ -260,7 +258,7 @@ class PHPExcel_Shared_Font
// Special case if there are one or more newline characters ("\n")
if (strpos($cellText, "\n") !== false) {
$lineTexts = explode("\n", $cellText);
$lineWitdhs = array();
$lineWidths = array();
foreach ($lineTexts as $lineText) {
$lineWidths[] = self::calculateColumnWidth($font, $lineText, $rotation = 0, $defaultFont);
}
@ -268,25 +266,24 @@ class PHPExcel_Shared_Font
}
// Try to get the exact text width in pixels
try {
// If autosize method is set to 'approx', use approximation
if (self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX) {
throw new PHPExcel_Exception('AutoSize method is set to approx');
}
$approximate = self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX;
if (!$approximate) {
$columnWidthAdjust = ceil(self::getTextWidthPixelsExact('n', $font, 0) * 1.07);
try {
// Width of text in pixels excl. padding
// and addition because Excel adds some padding, just use approx width of 'n' glyph
$columnWidth = self::getTextWidthPixelsExact($cellText, $font, $rotation) + $columnWidthAdjust;
} catch (PHPExcel_Exception $e) {
$approximate = true;
}
}
// Width of text in pixels excl. padding
$columnWidth = self::getTextWidthPixelsExact($cellText, $font, $rotation);
// Excel adds some padding, use 1.07 of the width of an 'n' glyph
$columnWidth += ceil(self::getTextWidthPixelsExact('0', $font, 0) * 1.07); // pixels incl. padding
} catch (PHPExcel_Exception $e) {
if ($approximate) {
$columnWidthAdjust = self::getTextWidthPixelsApprox('n', $font, 0);
// Width of text in pixels excl. padding, approximation
$columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation);
// Excel adds some padding, just use approx width of 'n' glyph
$columnWidth += self::getTextWidthPixelsApprox('n', $font, 0);
}
// and addition because Excel adds some padding, just use approx width of 'n' glyph
$columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation) + $columnWidthAdjust;
}
// Convert from pixel width to column width
$columnWidth = PHPExcel_Shared_Drawing::pixelsToCellDimension($columnWidth, $defaultFont);
@ -316,13 +313,13 @@ class PHPExcel_Shared_Font
// Get corners positions
$lowerLeftCornerX = $textBox[0];
$lowerLeftCornerY = $textBox[1];
// $lowerLeftCornerY = $textBox[1];
$lowerRightCornerX = $textBox[2];
$lowerRightCornerY = $textBox[3];
// $lowerRightCornerY = $textBox[3];
$upperRightCornerX = $textBox[4];
$upperRightCornerY = $textBox[5];
// $upperRightCornerY = $textBox[5];
$upperLeftCornerX = $textBox[6];
$upperLeftCornerY = $textBox[7];
// $upperLeftCornerY = $textBox[7];
// Consider the rotation when calculating the width
$textWidth = max($lowerRightCornerX - $upperLeftCornerX, $upperRightCornerX - $lowerLeftCornerX);
@ -353,9 +350,11 @@ class PHPExcel_Shared_Font
case 'Arial':
// value 7 was found via interpolation by inspecting real Excel files with Arial 10 font.
$columnWidth = (int) (7 * PHPExcel_Shared_String::CountCharacters($columnText));
// $columnWidth = (int) (7 * PHPExcel_Shared_String::CountCharacters($columnText));
// value 8 was set because of experience in different exports at Arial 10 font.
$columnWidth = (int) (8 * PHPExcel_Shared_String::CountCharacters($columnText));
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
break;
break;
case 'Verdana':
// value 8 was found via interpolation by inspecting real Excel files with Verdana 10 font.
@ -383,8 +382,7 @@ class PHPExcel_Shared_Font
}
// pixel width is an integer
$columnWidth = (int) $columnWidth;
return $columnWidth;
return (int) $columnWidth;
}
/**

View File

@ -1028,7 +1028,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$LU = new PHPExcel_Shared_JAMA_LUDecomposition($this);
return $LU->solve($B);
} else {
$QR = new QRDecomposition($this);
$QR = new PHPExcel_Shared_JAMA_QRDecomposition($this);
return $QR->solve($B);
}
} // function solve()
@ -1054,6 +1054,4 @@ class PHPExcel_Shared_JAMA_Matrix {
$L = new PHPExcel_Shared_JAMA_LUDecomposition($this);
return $L->det();
} // function det()
} // class PHPExcel_Shared_JAMA_Matrix

View File

@ -161,14 +161,6 @@ class PHPExcel_Shared_OLE_ChainedBlockStream
*/
public function stream_eof()
{
// As we don't support below 5.2 anymore, this is simply redundancy and overhead
// $eof = $this->pos >= strlen($this->data);
// // Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508
// if (version_compare(PHP_VERSION, '5.0', '>=') &&
// version_compare(PHP_VERSION, '5.1', '<')) {
// $eof = !$eof;
// }
// return $eof;
return $this->pos >= strlen($this->data);
}

View File

@ -5689,6 +5689,3 @@
return $p_path;
}
// --------------------------------------------------------------------------------
?>

View File

@ -403,7 +403,7 @@ class PHPExcel_Shared_String
* @return boolean
*/
public static function IsUTF8($value = '') {
return $string === '' || preg_match('/^./su', $string) === 1;
return $value === '' || preg_match('/^./su', $value) === 1;
}
/**
@ -626,6 +626,41 @@ class PHPExcel_Shared_String
return ucwords($pValue);
}
public static function mb_is_upper($char)
{
return mb_strtolower($char, "UTF-8") != $char;
}
public static function mb_str_split($string)
{
# Split at all position not after the start: ^
# and not before the end: $
return preg_split('/(?<!^)(?!$)/u', $string );
}
/**
* Reverse the case of a string, so that all uppercase characters become lowercase
* and all lowercase characters become uppercase
*
* @param string $pValue UTF-8 encoded string
* @return string
*/
public static function StrCaseReverse($pValue = '')
{
if (self::getIsMbstringEnabled()) {
$characters = self::mb_str_split($pValue);
foreach($characters as &$character) {
if(self::mb_is_upper($character)) {
$character = mb_strtolower($character, 'UTF-8');
} else {
$character = mb_strtoupper($character, 'UTF-8');
}
}
return implode('', $characters);
}
return strtolower($pValue) ^ strtoupper($pValue) ^ $pValue;
}
/**
* Identify whether a string contains a fractional numeric value,
* and convert it to a numeric if it is
@ -771,6 +806,6 @@ class PHPExcel_Shared_String
if (is_numeric($value))
return $value;
$v = floatval($value);
return (is_numeric(substr($value,0,strlen($v)))) ? $v : $value;
return (is_numeric(substr($value, 0, strlen($v)))) ? $v : $value;
}
}

View File

@ -26,7 +26,7 @@
*/
if (!defined('PCLZIP_TEMPORARY_DIR')) {
define('PCLZIP_TEMPORARY_DIR', PHPExcel_Shared_File::sys_get_temp_dir());
define('PCLZIP_TEMPORARY_DIR', PHPExcel_Shared_File::sys_get_temp_dir() . DIRECTORY_SEPARATOR);
}
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PCLZip/pclzip.lib.php';

View File

@ -36,49 +36,54 @@
class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
{
/* Horizontal alignment styles */
const HORIZONTAL_GENERAL = 'general';
const HORIZONTAL_LEFT = 'left';
const HORIZONTAL_RIGHT = 'right';
const HORIZONTAL_CENTER = 'center';
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous';
const HORIZONTAL_JUSTIFY = 'justify';
const HORIZONTAL_FILL = 'fill';
const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only
const HORIZONTAL_GENERAL = 'general';
const HORIZONTAL_LEFT = 'left';
const HORIZONTAL_RIGHT = 'right';
const HORIZONTAL_CENTER = 'center';
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous';
const HORIZONTAL_JUSTIFY = 'justify';
const HORIZONTAL_FILL = 'fill';
const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only
/* Vertical alignment styles */
const VERTICAL_BOTTOM = 'bottom';
const VERTICAL_TOP = 'top';
const VERTICAL_CENTER = 'center';
const VERTICAL_JUSTIFY = 'justify';
const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only
const VERTICAL_BOTTOM = 'bottom';
const VERTICAL_TOP = 'top';
const VERTICAL_CENTER = 'center';
const VERTICAL_JUSTIFY = 'justify';
const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only
/* Read order */
const READORDER_CONTEXT = 0;
const READORDER_LTR = 1;
const READORDER_RTL = 2;
/**
* Horizontal
* Horizontal alignment
*
* @var string
*/
protected $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
protected $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
/**
* Vertical
* Vertical alignment
*
* @var string
*/
protected $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
protected $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
/**
* Text rotation
*
* @var int
* @var integer
*/
protected $_textRotation = 0;
protected $_textRotation = 0;
/**
* Wrap text
*
* @var boolean
*/
protected $_wrapText = FALSE;
protected $_wrapText = FALSE;
/**
* Shrink to fit
@ -90,9 +95,16 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
/**
* Indent - only possible with horizontal alignment left and right
*
* @var int
* @var integer
*/
protected $_indent = 0;
protected $_indent = 0;
/**
* Read order
*
* @var integer
*/
protected $_readorder = 0;
/**
* Create a new PHPExcel_Style_Alignment
@ -180,6 +192,9 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
if (isset($pStyles['indent'])) {
$this->setIndent($pStyles['indent']);
}
if (isset($pStyles['readorder'])) {
$this->setReadorder($pStyles['readorder']);
}
}
} else {
throw new PHPExcel_Exception("Invalid style array passed.");
@ -389,6 +404,37 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
return $this;
}
/**
* Get read order
*
* @return integer
*/
public function getReadorder() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getReadorder();
}
return $this->_readorder;
}
/**
* Set read order
*
* @param int $pValue
* @return PHPExcel_Style_Alignment
*/
public function setReadorder($pValue = 0) {
if ($pValue < 0 || $pValue > 2) {
$pValue = 0;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('readorder' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->_readorder = $pValue;
}
return $this;
}
/**
* Get hash code
*
@ -405,6 +451,7 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
. ($this->_wrapText ? 't' : 'f')
. ($this->_shrinkToFit ? 't' : 'f')
. $this->_indent
. $this->_readorder
. __CLASS__
);
}

View File

@ -120,6 +120,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
if ($isConditional) {
$this->_formatCode = NULL;
$this->_builtInFormatCode = FALSE;
}
}
@ -497,13 +498,15 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
}
}
private static function _complexNumberFormatMask($number, $mask) {
private static function _complexNumberFormatMask($number, $mask, $level = 0) {
$sign = ($number < 0.0);
$number = abs($number);
if (strpos($mask,'.') !== false) {
$numbers = explode('.', $number . '.0');
$masks = explode('.', $mask . '.0');
$result1 = self::_complexNumberFormatMask($numbers[0], $masks[0]);
$result2 = strrev(self::_complexNumberFormatMask(strrev($numbers[1]), strrev($masks[1])));
return $result1 . '.' . $result2;
$result1 = self::_complexNumberFormatMask($numbers[0], $masks[0], 1);
$result2 = strrev(self::_complexNumberFormatMask(strrev($numbers[1]), strrev($masks[1]), 1));
return (($sign) ? '-' : '') . $result1 . '.' . $result2;
}
$r = preg_match_all('/0+/', $mask, $result, PREG_OFFSET_CAPTURE);
@ -520,7 +523,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
fmod($number, $divisor)
);
$number = floor($number / $divisor);
$mask = substr_replace($mask,$blockValue, $offset, $size);
$mask = substr_replace($mask, $blockValue, $offset, $size);
}
if ($number > 0) {
$mask = substr_replace($mask, $number, $offset, 0);
@ -530,7 +533,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
$result = $number;
}
return $result;
return (($sign) ? '-' : '') . $result;
}
/**
@ -613,9 +616,12 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
// Some non-number characters are escaped with \, which we don't need
$format = preg_replace("/\\\\/", '', $format);
// Handle escaped characters, such as \" to display a literal " or \\ to display a literal \
// $format = preg_replace('/(?<!\\\\)\"/', '', $format);
// $format = str_replace(array('\\"', '*'), array('"', ''), $format);
// Some non-number strings are quoted, so we'll get rid of the quotes, likewise any positional * symbols
$format = str_replace(array('"','*'), '', $format);
$format = str_replace(array('"', '*'), '', $format);
// Find out if we need thousands separator
// This is indicated by a comma enclosed by a digit placeholder:

View File

@ -1092,7 +1092,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function setCellValue($pCoordinate = 'A1', $pValue = null, $returnCell = false)
{
$cell = $this->getCell($pCoordinate)->setValue($pValue);
$cell = $this->getCell(strtoupper($pCoordinate))->setValue($pValue);
return ($returnCell) ? $cell : $this;
}
@ -1123,7 +1123,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function setCellValueExplicit($pCoordinate = 'A1', $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING, $returnCell = false)
{
// Set value
$cell = $this->getCell($pCoordinate)->setValueExplicit($pValue, $pDataType);
$cell = $this->getCell(strtoupper($pCoordinate))->setValueExplicit($pValue, $pDataType);
return ($returnCell) ? $cell : $this;
}
@ -1152,6 +1152,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function getCell($pCoordinate = 'A1')
{
$pCoordinate = strtoupper($pCoordinate);
// Check cell collection
if ($this->_cellCollection->isDataSet($pCoordinate)) {
return $this->_cellCollection->getCacheData($pCoordinate);
@ -1254,10 +1255,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function cellExists($pCoordinate = 'A1')
{
// Worksheet reference?
// Worksheet reference?
if (strpos($pCoordinate, '!') !== false) {
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
return $this->_parent->getSheetByName($worksheetReference[0])->cellExists($worksheetReference[1]);
return $this->_parent->getSheetByName($worksheetReference[0])->cellExists(strtoupper($worksheetReference[1]));
}
// Named range?
@ -1405,7 +1406,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
/**
* Get style for cell
*
* @param string $pCellCoordinate Cell coordinate to get style for
* @param string $pCellCoordinate Cell coordinate (or range) to get style for
* @return PHPExcel_Style
* @throws PHPExcel_Exception
*/
@ -1415,7 +1416,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->_parent->setActiveSheetIndex($this->_parent->getIndex($this));
// set cell coordinate as active
$this->setSelectedCells($pCellCoordinate);
$this->setSelectedCells(strtoupper($pCellCoordinate));
return $this->_parent->getCellXfSupervisor();
}
@ -1428,6 +1429,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function getConditionalStyles($pCoordinate = 'A1')
{
$pCoordinate = strtoupper($pCoordinate);
if (!isset($this->_conditionalStylesCollection[$pCoordinate])) {
$this->_conditionalStylesCollection[$pCoordinate] = array();
}
@ -1442,7 +1444,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function conditionalStylesExists($pCoordinate = 'A1')
{
if (isset($this->_conditionalStylesCollection[$pCoordinate])) {
if (isset($this->_conditionalStylesCollection[strtoupper($pCoordinate)])) {
return true;
}
return false;
@ -1456,7 +1458,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function removeConditionalStyles($pCoordinate = 'A1')
{
unset($this->_conditionalStylesCollection[$pCoordinate]);
unset($this->_conditionalStylesCollection[strtoupper($pCoordinate)]);
return $this;
}
@ -1479,7 +1481,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function setConditionalStyles($pCoordinate = 'A1', $pValue)
{
$this->_conditionalStylesCollection[$pCoordinate] = $pValue;
$this->_conditionalStylesCollection[strtoupper($pCoordinate)] = $pValue;
return $this;
}
@ -1488,10 +1490,18 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @param int $pColumn Numeric column coordinate of the cell
* @param int $pRow Numeric row coordinate of the cell
* @param int pColumn2 Numeric column coordinate of the range cell
* @param int pRow2 Numeric row coordinate of the range cell
* @return PHPExcel_Style
*/
public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1)
public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null)
{
if (!is_null($pColumn2) && !is_null($pRow2)) {
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' .
PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->getStyle($cellRange);
}
return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
}
@ -1894,6 +1904,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function setAutoFilter($pValue)
{
$pRange = strtoupper($pValue);
if (is_string($pValue)) {
$this->_autoFilter->setRange($pValue);
} elseif(is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) {
@ -2052,8 +2064,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function removeRow($pRow = 1, $pNumRows = 1) {
if ($pRow >= 1) {
$highestRow = $this->getHighestDataRow();
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this);
for($r = 0; $r < $pNumRows; ++$r) {
$this->getCellCacheController()->removeRow($highestRow);
--$highestRow;
}
} else {
throw new PHPExcel_Exception("Rows to be deleted should at least start from row 1.");
}
@ -2063,16 +2080,21 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
/**
* Remove a column, updating all possible related data
*
* @param int $pColumn Remove starting with this one
* @param int $pNumCols Number of columns to remove
* @param string $pColumn Remove starting with this one
* @param int $pNumCols Number of columns to remove
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet
*/
public function removeColumn($pColumn = 'A', $pNumCols = 1) {
if (!is_numeric($pColumn)) {
$highestColumn = $this->getHighestDataColumn();
$pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols);
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this);
for($c = 0; $c < $pNumCols; ++$c) {
$this->getCellCacheController()->removeColumn($highestColumn);
$highestColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($highestColumn) - 2);
}
} else {
throw new PHPExcel_Exception("Column references should not be numeric.");
}
@ -2537,11 +2559,25 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
/**
* Get row iterator
*
* @param integer $startRow The row number at which to start iterating
* @param integer $startRow The row number at which to start iterating
* @param integer $endRow The row number at which to stop iterating
*
* @return PHPExcel_Worksheet_RowIterator
*/
public function getRowIterator($startRow = 1) {
return new PHPExcel_Worksheet_RowIterator($this,$startRow);
public function getRowIterator($startRow = 1, $endRow = null) {
return new PHPExcel_Worksheet_RowIterator($this, $startRow, $endRow);
}
/**
* Get column iterator
*
* @param string $startColumn The column address at which to start iterating
* @param string $endColumn The column address at which to stop iterating
*
* @return PHPExcel_Worksheet_ColumnIterator
*/
public function getColumnIterator($startColumn = 'A', $endColumn = null) {
return new PHPExcel_Worksheet_ColumnIterator($this, $startColumn, $endColumn);
}
/**

View File

@ -633,7 +633,11 @@ class PHPExcel_Worksheet_AutoFilter
);
} else {
// Filter on date group values
$arguments = array();
$arguments = array(
'date' => array(),
'time' => array(),
'dateTime' => array(),
);
foreach($ruleDataSet as $ruleValue) {
$date = $time = '';
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) &&

View File

@ -257,7 +257,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
*
* @var string
*/
private $_operator = '';
private $_operator = self::AUTOFILTER_COLUMN_RULE_EQUAL;
/**
* DateTimeGrouping Group Value

View File

@ -321,7 +321,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function setWidth($pValue = 0) {
// Resize proportional?
if ($this->_resizeProportional && $pValue != 0) {
$ratio = $this->_height / $this->_width;
$ratio = $this->_height / ($this->_width != 0 ? $this->_width : 1);
$this->_height = round($ratio * $pValue);
}
@ -349,7 +349,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function setHeight($pValue = 0) {
// Resize proportional?
if ($this->_resizeProportional && $pValue != 0) {
$ratio = $this->_width / $this->_height;
$ratio = $this->_width / ($this->_height != 0 ? $this->_height : 1);
$this->_width = round($ratio * $pValue);
}
@ -373,8 +373,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* @return PHPExcel_Worksheet_BaseDrawing
*/
public function setWidthAndHeight($width = 0, $height = 0) {
$xratio = $width / $this->_width;
$yratio = $height / $this->_height;
$xratio = $width / ($this->_width != 0 ? $this->_width : 1);
$yratio = $height / ($this->_height != 0 ? $this->_height : 1);
if ($this->_resizeProportional && !($width == 0 || $height == 0)) {
if (($xratio * $this->_height) < $height) {
$this->_height = ceil($xratio * $this->_height);
@ -383,7 +383,11 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_width = ceil($yratio * $this->_width);
$this->_height = $height;
}
}
} else {
$this->_width = $width;
$this->_height = $height;
}
return $this;
}

View File

@ -22,7 +22,7 @@
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
* @version 1.8.0, 2014-03-02
*/
@ -35,47 +35,28 @@
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_CellIterator implements Iterator
abstract class PHPExcel_Worksheet_CellIterator
{
/**
* PHPExcel_Worksheet to iterate
*
* @var PHPExcel_Worksheet
*/
private $_subject;
/**
* Row index
*
* @var int
*/
private $_rowIndex;
protected $_subject;
/**
* Current iterator position
*
* @var int
* @var mixed
*/
private $_position = 0;
protected $_position = null;
/**
* Loop only existing cells
* Iterate only existing cells
*
* @var boolean
*/
private $_onlyExistingCells = true;
/**
* Create a new cell iterator
*
* @param PHPExcel_Worksheet $subject
* @param int $rowIndex
*/
public function __construct(PHPExcel_Worksheet $subject = null, $rowIndex = 1) {
// Set subject and row index
$this->_subject = $subject;
$this->_rowIndex = $rowIndex;
}
protected $_onlyExistingCells = false;
/**
* Destructor
@ -84,63 +65,6 @@ class PHPExcel_Worksheet_CellIterator implements Iterator
unset($this->_subject);
}
/**
* Rewind iterator
*/
public function rewind() {
$this->_position = 0;
}
/**
* Current PHPExcel_Cell
*
* @return PHPExcel_Cell
*/
public function current() {
return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex);
}
/**
* Current key
*
* @return int
*/
public function key() {
return $this->_position;
}
/**
* Next value
*/
public function next() {
++$this->_position;
}
/**
* Are there any more PHPExcel_Cell instances available?
*
* @return boolean
*/
public function valid() {
// columnIndexFromString() returns an index based at one,
// treat it as a count when comparing it to the base zero
// position.
$columnCount = PHPExcel_Cell::columnIndexFromString($this->_subject->getHighestColumn());
if ($this->_onlyExistingCells) {
// If we aren't looking at an existing cell, either
// because the first column doesn't exist or next() has
// been called onto a nonexistent cell, then loop until we
// find one, or pass the last column.
while ($this->_position < $columnCount &&
!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) {
++$this->_position;
}
}
return $this->_position < $columnCount;
}
/**
* Get loop only existing cells
*
@ -150,12 +74,22 @@ class PHPExcel_Worksheet_CellIterator implements Iterator
return $this->_onlyExistingCells;
}
/**
* Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary
*
* @throws PHPExcel_Exception
*/
abstract protected function adjustForExistingOnlyRange();
/**
* Set the iterator to loop only existing cells
*
* @param boolean $value
* @throws PHPExcel_Exception
*/
public function setIterateOnlyExistingCells($value = true) {
$this->_onlyExistingCells = $value;
$this->_onlyExistingCells = (boolean) $value;
$this->adjustForExistingOnlyRange();
}
}

View File

@ -0,0 +1,92 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_Column
*
* Represents a column in PHPExcel_Worksheet, used by PHPExcel_Worksheet_ColumnIterator
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_Column
{
/**
* PHPExcel_Worksheet
*
* @var PHPExcel_Worksheet
*/
private $_parent;
/**
* Column index
*
* @var string
*/
private $_columnIndex;
/**
* Create a new column
*
* @param PHPExcel_Worksheet $parent
* @param string $columnIndex
*/
public function __construct(PHPExcel_Worksheet $parent = null, $columnIndex = 'A') {
// Set parent and column index
$this->_parent = $parent;
$this->_columnIndex = $columnIndex;
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_parent);
}
/**
* Get column index
*
* @return int
*/
public function getColumnIndex() {
return $this->_columnIndex;
}
/**
* Get cell iterator
*
* @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating
* @return PHPExcel_Worksheet_CellIterator
*/
public function getCellIterator($startRow = 1, $endRow = null) {
return new PHPExcel_Worksheet_ColumnCellIterator($this->_parent, $this->_columnIndex, $startRow, $endRow);
}
}

View File

@ -0,0 +1,215 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_ColumnCellIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_ColumnCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator
{
/**
* Column index
*
* @var string
*/
protected $_columnIndex;
/**
* Start position
*
* @var int
*/
protected $_startRow = 1;
/**
* End position
*
* @var int
*/
protected $_endRow = 1;
/**
* Create a new row iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param string $columnIndex The column that we want to iterate
* @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $columnIndex, $startRow = 1, $endRow = null) {
// Set subject
$this->_subject = $subject;
$this->_columnIndex = PHPExcel_Cell::columnIndexFromString($columnIndex) - 1;
$this->resetEnd($endRow);
$this->resetStart($startRow);
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
/**
* (Re)Set the start row and the current row pointer
*
* @param integer $startRow The row number at which to start iterating
* @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception
*/
public function resetStart($startRow = 1) {
$this->_startRow = $startRow;
$this->adjustForExistingOnlyRange();
$this->seek($startRow);
return $this;
}
/**
* (Re)Set the end row
*
* @param integer $endRow The row number at which to stop iterating
* @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception
*/
public function resetEnd($endRow = null) {
$this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow();
$this->adjustForExistingOnlyRange();
return $this;
}
/**
* Set the row pointer to the selected row
*
* @param integer $row The row number to set the current pointer at
* @return PHPExcel_Worksheet_ColumnCellIterator
* @throws PHPExcel_Exception
*/
public function seek($row = 1) {
if (($row < $this->_startRow) || ($row > $this->_endRow)) {
throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})");
} elseif ($this->_onlyExistingCells && !($this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $row))) {
throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist');
}
$this->_position = $row;
return $this;
}
/**
* Rewind the iterator to the starting row
*/
public function rewind() {
$this->_position = $this->_startRow;
}
/**
* Return the current cell in this worksheet column
*
* @return PHPExcel_Worksheet_Row
*/
public function current() {
return $this->_subject->getCellByColumnAndRow($this->_columnIndex, $this->_position);
}
/**
* Return the current iterator key
*
* @return int
*/
public function key() {
return $this->_position;
}
/**
* Set the iterator to its next value
*/
public function next() {
do {
++$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) &&
($this->_position <= $this->_endRow));
}
/**
* Set the iterator to its previous value
*/
public function prev() {
if ($this->_position <= $this->_startRow) {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})");
}
do {
--$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_position)) &&
($this->_position >= $this->_startRow));
}
/**
* Indicate if more rows exist in the worksheet range of rows that we're iterating
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_endRow;
}
/**
* Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary
*
* @throws PHPExcel_Exception
*/
protected function adjustForExistingOnlyRange() {
if ($this->_onlyExistingCells) {
while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_startRow)) &&
($this->_startRow <= $this->_endRow)) {
++$this->_startRow;
}
if ($this->_startRow > $this->_endRow) {
throw new PHPExcel_Exception('No cells exist within the specified range');
}
while ((!$this->_subject->cellExistsByColumnAndRow($this->_columnIndex, $this->_endRow)) &&
($this->_endRow >= $this->_startRow)) {
--$this->_endRow;
}
if ($this->_endRow < $this->_startRow) {
throw new PHPExcel_Exception('No cells exist within the specified range');
}
}
}
}

View File

@ -0,0 +1,192 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_ColumnIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_ColumnIterator implements Iterator
{
/**
* PHPExcel_Worksheet to iterate
*
* @var PHPExcel_Worksheet
*/
private $_subject;
/**
* Current iterator position
*
* @var int
*/
private $_position = 0;
/**
* Start position
*
* @var int
*/
private $_startColumn = 0;
/**
* End position
*
* @var int
*/
private $_endColumn = 0;
/**
* Create a new column iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param string $startColumn The column address at which to start iterating
* @param string $endColumn Optionally, the column address at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $startColumn = 'A', $endColumn = null) {
// Set subject
$this->_subject = $subject;
$this->resetEnd($endColumn);
$this->resetStart($startColumn);
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
/**
* (Re)Set the start column and the current column pointer
*
* @param integer $startColumn The column address at which to start iterating
* @return PHPExcel_Worksheet_ColumnIterator
*/
public function resetStart($startColumn = 'A') {
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
$this->_startColumn = $startColumnIndex;
$this->seek($startColumn);
return $this;
}
/**
* (Re)Set the end column
*
* @param string $endColumn The column address at which to stop iterating
* @return PHPExcel_Worksheet_ColumnIterator
*/
public function resetEnd($endColumn = null) {
$endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn();
$this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
return $this;
}
/**
* Set the column pointer to the selected column
*
* @param string $column The column address to set the current pointer at
* @return PHPExcel_Worksheet_ColumnIterator
* @throws PHPExcel_Exception
*/
public function seek($column = 'A') {
$column = PHPExcel_Cell::columnIndexFromString($column) - 1;
if (($column < $this->_startColumn) || ($column > $this->_endColumn)) {
throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})");
}
$this->_position = $column;
return $this;
}
/**
* Rewind the iterator to the starting column
*/
public function rewind() {
$this->_position = $this->_startColumn;
}
/**
* Return the current column in this worksheet
*
* @return PHPExcel_Worksheet_Column
*/
public function current() {
return new PHPExcel_Worksheet_Column($this->_subject, PHPExcel_Cell::stringFromColumnIndex($this->_position));
}
/**
* Return the current iterator key
*
* @return string
*/
public function key() {
return PHPExcel_Cell::stringFromColumnIndex($this->_position);
}
/**
* Set the iterator to its next value
*/
public function next() {
++$this->_position;
}
/**
* Set the iterator to its previous value
*
* @throws PHPExcel_Exception
*/
public function prev() {
if ($this->_position <= $this->_startColumn) {
throw new PHPExcel_Exception(
"Column is already at the beginning of range (" .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")"
);
}
--$this->_position;
}
/**
* Indicate if more columns exist in the worksheet range of columns that we're iterating
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_endColumn;
}
}

View File

@ -82,9 +82,11 @@ class PHPExcel_Worksheet_Row
/**
* Get cell iterator
*
* @param string $startColumn The column address at which to start iterating
* @param string $endColumn Optionally, the column address at which to stop iterating
* @return PHPExcel_Worksheet_CellIterator
*/
public function getCellIterator() {
return new PHPExcel_Worksheet_CellIterator($this->_parent, $this->_rowIndex);
public function getCellIterator($startColumn = 'A', $endColumn = null) {
return new PHPExcel_Worksheet_RowCellIterator($this->_parent, $this->_rowIndex, $startColumn, $endColumn);
}
}

View File

@ -0,0 +1,224 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Worksheet_RowCellIterator
*
* Used to iterate columns in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_RowCellIterator extends PHPExcel_Worksheet_CellIterator implements Iterator
{
/**
* Row index
*
* @var int
*/
protected $_rowIndex;
/**
* Start position
*
* @var int
*/
protected $_startColumn = 0;
/**
* End position
*
* @var int
*/
protected $_endColumn = 0;
/**
* Create a new column iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param integer $rowIndex The row that we want to iterate
* @param string $startColumn The column address at which to start iterating
* @param string $endColumn Optionally, the column address at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $rowIndex = 1, $startColumn = 'A', $endColumn = null) {
// Set subject and row index
$this->_subject = $subject;
$this->_rowIndex = $rowIndex;
$this->resetEnd($endColumn);
$this->resetStart($startColumn);
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
/**
* (Re)Set the start column and the current column pointer
*
* @param integer $startColumn The column address at which to start iterating
* @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception
*/
public function resetStart($startColumn = 'A') {
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
$this->_startColumn = $startColumnIndex;
$this->adjustForExistingOnlyRange();
$this->seek(PHPExcel_Cell::stringFromColumnIndex($this->_startColumn));
return $this;
}
/**
* (Re)Set the end column
*
* @param string $endColumn The column address at which to stop iterating
* @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception
*/
public function resetEnd($endColumn = null) {
$endColumn = ($endColumn) ? $endColumn : $this->_subject->getHighestColumn();
$this->_endColumn = PHPExcel_Cell::columnIndexFromString($endColumn) - 1;
$this->adjustForExistingOnlyRange();
return $this;
}
/**
* Set the column pointer to the selected column
*
* @param string $column The column address to set the current pointer at
* @return PHPExcel_Worksheet_RowCellIterator
* @throws PHPExcel_Exception
*/
public function seek($column = 'A') {
$column = PHPExcel_Cell::columnIndexFromString($column) - 1;
if (($column < $this->_startColumn) || ($column > $this->_endColumn)) {
throw new PHPExcel_Exception("Column $column is out of range ({$this->_startColumn} - {$this->_endColumn})");
} elseif ($this->_onlyExistingCells && !($this->_subject->cellExistsByColumnAndRow($column, $this->_rowIndex))) {
throw new PHPExcel_Exception('In "IterateOnlyExistingCells" mode and Cell does not exist');
}
$this->_position = $column;
return $this;
}
/**
* Rewind the iterator to the starting column
*/
public function rewind() {
$this->_position = $this->_startColumn;
}
/**
* Return the current cell in this worksheet row
*
* @return PHPExcel_Cell
*/
public function current() {
return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex);
}
/**
* Return the current iterator key
*
* @return string
*/
public function key() {
return PHPExcel_Cell::stringFromColumnIndex($this->_position);
}
/**
* Set the iterator to its next value
*/
public function next() {
do {
++$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) &&
($this->_position <= $this->_endColumn));
}
/**
* Set the iterator to its previous value
*
* @throws PHPExcel_Exception
*/
public function prev() {
if ($this->_position <= $this->_startColumn) {
throw new PHPExcel_Exception(
"Column is already at the beginning of range (" .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . " - " .
PHPExcel_Cell::stringFromColumnIndex($this->_endColumn) . ")"
);
}
do {
--$this->_position;
} while (($this->_onlyExistingCells) &&
(!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) &&
($this->_position >= $this->_startColumn));
}
/**
* Indicate if more columns exist in the worksheet range of columns that we're iterating
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_endColumn;
}
/**
* Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary
*
* @throws PHPExcel_Exception
*/
protected function adjustForExistingOnlyRange() {
if ($this->_onlyExistingCells) {
while ((!$this->_subject->cellExistsByColumnAndRow($this->_startColumn, $this->_rowIndex)) &&
($this->_startColumn <= $this->_endColumn)) {
++$this->_startColumn;
}
if ($this->_startColumn > $this->_endColumn) {
throw new PHPExcel_Exception('No cells exist within the specified range');
}
while ((!$this->_subject->cellExistsByColumnAndRow($this->_endColumn, $this->_rowIndex)) &&
($this->_endColumn >= $this->_startColumn)) {
--$this->_endColumn;
}
if ($this->_endColumn < $this->_startColumn) {
throw new PHPExcel_Exception('No cells exist within the specified range');
}
}
}
}

View File

@ -145,7 +145,7 @@ class PHPExcel_Worksheet_RowDimension
*
* @return bool
*/
public function getzeroHeight() {
public function getZeroHeight() {
return $this->_zeroHeight;
}
@ -155,7 +155,7 @@ class PHPExcel_Worksheet_RowDimension
* @param bool $pValue
* @return PHPExcel_Worksheet_RowDimension
*/
public function setzeroHeight($pValue = false) {
public function setZeroHeight($pValue = false) {
$this->_zeroHeight = $pValue;
return $this;
}

View File

@ -59,15 +59,25 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
private $_startRow = 1;
/**
* End position
*
* @var int
*/
private $_endRow = 1;
/**
* Create a new row iterator
*
* @param PHPExcel_Worksheet $subject The worksheet to iterate over
* @param integer $startRow The row number at which to start iterating
* @param integer $endRow Optionally, the row number at which to stop iterating
*/
public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1) {
public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null) {
// Set subject
$this->_subject = $subject;
$this->resetEnd($endRow);
$this->resetStart($startRow);
}
@ -82,19 +92,41 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* (Re)Set the start row and the current row pointer
*
* @param integer $startRow The row number at which to start iterating
* @return PHPExcel_Worksheet_RowIterator
*/
public function resetStart($startRow = 1) {
$this->_startRow = $startRow;
$this->seek($startRow);
return $this;
}
/**
* (Re)Set the end row
*
* @param integer $endRow The row number at which to stop iterating
* @return PHPExcel_Worksheet_RowIterator
*/
public function resetEnd($endRow = null) {
$this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow();
return $this;
}
/**
* Set the row pointer to the selected row
*
* @param integer $row The row number to set the current pointer at
* @return PHPExcel_Worksheet_RowIterator
* @throws PHPExcel_Exception
*/
public function seek($row = 1) {
if (($row < $this->_startRow) || ($row > $this->_endRow)) {
throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})");
}
$this->_position = $row;
return $this;
}
/**
@ -133,16 +165,19 @@ class PHPExcel_Worksheet_RowIterator implements Iterator
* Set the iterator to its previous value
*/
public function prev() {
if ($this->_position > 1)
--$this->_position;
if ($this->_position <= $this->_startRow) {
throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})");
}
--$this->_position;
}
/**
* Indicate if more rows exist in the worksheet
* Indicate if more rows exist in the worksheet range of rows that we're iterating
*
* @return boolean
*/
public function valid() {
return $this->_position <= $this->_subject->getHighestRow();
return $this->_position <= $this->_endRow;
}
}

View File

@ -439,6 +439,9 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
if ($pStyle->getAlignment()->getIndent() > 0) {
$objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent());
}
if ($pStyle->getAlignment()->getReadorder() > 0) {
$objWriter->writeAttribute('readingOrder', $pStyle->getAlignment()->getReadorder());
}
$objWriter->endElement();
// protection

View File

@ -326,8 +326,8 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
}
// Set Zero Height row
if ((string)$pSheet->getDefaultRowDimension()->getzeroHeight() == '1' ||
strtolower((string)$pSheet->getDefaultRowDimension()->getzeroHeight()) == 'true' ) {
if ((string)$pSheet->getDefaultRowDimension()->getZeroHeight() == '1' ||
strtolower((string)$pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true' ) {
$objWriter->writeAttribute('zeroHeight', '1');
}

View File

@ -1430,6 +1430,7 @@ class PHPExcel_Writer_Excel5_Parser
{
if($this->_lookahead == '%'){
$result = $this->_createTree('ptgPercent', $this->_current_token, '');
$this->_advance(); // Skip the percentage operator once we've pre-built that tree
} else {
$result = $this->_createTree($this->_current_token, '', '');
}

View File

@ -1247,7 +1247,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$grbit |= $level;
if ($hidden) {
$grbit |= 0x0020;
$grbit |= 0x0030;
}
if ($height !== null) {
$grbit |= 0x0040; // fUnsynced

View File

@ -412,11 +412,13 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
// <thead> ?
if ($row == $theadStart) {
$html .= ' <thead>' . PHP_EOL;
$cellType = 'th';
}
// <tbody> ?
if ($row == $tbodyStart) {
$html .= ' <tbody>' . PHP_EOL;
$cellType = 'td';
}
// Write row if there are HTML table cells in it
@ -433,7 +435,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$rowData[$column] = '';
}
}
$html .= $this->_generateRow($sheet, $rowData, $row - 1);
$html .= $this->_generateRow($sheet, $rowData, $row - 1, $cellType);
}
// </thead> ?
@ -670,7 +672,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
/**
* Generate CSS styles
*
* @param boolean $generateSurroundingHTML Generate surrounding HTML tags? (<style> and </style>)
* @param boolean $generateSurroundingHTML Generate surrounding HTML tags? (&lt;style&gt; and &lt;/style&gt;)
* @return string
* @throws PHPExcel_Writer_Exception
*/
@ -751,6 +753,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
// .gridlines td { }
$css['.gridlines td']['border'] = '1px dotted black';
$css['.gridlines th']['border'] = '1px dotted black';
// .b {}
$css['.b']['text-align'] = 'center'; // BOOL
@ -773,6 +776,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
// Calculate cell style hashes
foreach ($this->_phpExcel->getCellXfCollection() as $index => $style) {
$css['td.style' . $index] = $this->_createCSSStyle( $style );
$css['th.style' . $index] = $this->_createCSSStyle( $style );
}
// Fetch sheets
@ -1077,7 +1081,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string
* @throws PHPExcel_Writer_Exception
*/
private function _generateRow(PHPExcel_Worksheet $pSheet, $pValues = null, $pRow = 0) {
private function _generateRow(PHPExcel_Worksheet $pSheet, $pValues = null, $pRow = 0, $cellType = 'td') {
if (is_array($pValues)) {
// Construct HTML
$html = '';
@ -1122,9 +1126,15 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$cssClass = 'column' . $colNum;
} else {
$cssClass = array();
if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum])) {
$this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum];
}
if ($cellType == 'th') {
if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' th.column' . $colNum])) {
$this->_cssStyles['table.sheet' . $sheetIndex . ' th.column' . $colNum];
}
} else {
if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum])) {
$this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum];
}
}
}
$colSpan = 1;
$rowSpan = 1;
@ -1176,7 +1186,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
array($this, 'formatColor')
);
} else {
$cellData = PHPExcel_Style_NumberFormat::ToFormattedString(
$cellData = PHPExcel_Style_NumberFormat::toFormattedString(
$cell->getValue(),
$pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(),
array($this, 'formatColor')
@ -1202,9 +1212,15 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$cssClass .= ' style' . $cell->getXfIndex();
$cssClass .= ' ' . $cell->getDataType();
} else {
if (isset($this->_cssStyles['td.style' . $cell->getXfIndex()])) {
$cssClass = array_merge($cssClass, $this->_cssStyles['td.style' . $cell->getXfIndex()]);
}
if ($cellType == 'th') {
if (isset($this->_cssStyles['th.style' . $cell->getXfIndex()])) {
$cssClass = array_merge($cssClass, $this->_cssStyles['th.style' . $cell->getXfIndex()]);
}
} else {
if (isset($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
$sharedStyle = $pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() );
@ -1244,7 +1260,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
// Write
if ($writeCell) {
// Column start
$html .= ' <td';
$html .= ' <' . $cellType;
if (!$this->_useInlineCss) {
$html .= ' class="' . $cssClass . '"';
} else {
@ -1291,7 +1307,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$html .= $cellData;
// Column end
$html .= '</td>' . PHP_EOL;
$html .= '</'.$cellType.'>' . PHP_EOL;
}
// Next column

View File

@ -0,0 +1,200 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Writer_OpenDocument
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
* @link http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html
*/
class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
{
/**
* Private writer parts
*
* @var PHPExcel_Writer_OpenDocument_WriterPart[]
*/
private $_writerParts = array();
/**
* Private PHPExcel
*
* @var PHPExcel
*/
private $_spreadSheet;
/**
* Create a new PHPExcel_Writer_OpenDocument
*
* @param PHPExcel $pPHPExcel
*/
public function __construct(PHPExcel $pPHPExcel = null)
{
$this->setPHPExcel($pPHPExcel);
$writerPartsArray = array(
'content' => 'PHPExcel_Writer_OpenDocument_Content',
'meta' => 'PHPExcel_Writer_OpenDocument_Meta',
'meta_inf' => 'PHPExcel_Writer_OpenDocument_MetaInf',
'mimetype' => 'PHPExcel_Writer_OpenDocument_Mimetype',
'settings' => 'PHPExcel_Writer_OpenDocument_Settings',
'styles' => 'PHPExcel_Writer_OpenDocument_Styles',
'thumbnails' => 'PHPExcel_Writer_OpenDocument_Thumbnails'
);
foreach ($writerPartsArray as $writer => $class) {
$this->_writerParts[$writer] = new $class($this);
}
}
/**
* Get writer part
*
* @param string $pPartName Writer part name
* @return PHPExcel_Writer_Excel2007_WriterPart
*/
public function getWriterPart($pPartName = '')
{
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
return $this->_writerParts[strtolower($pPartName)];
} else {
return null;
}
}
/**
* Save PHPExcel to file
*
* @param string $pFilename
* @throws PHPExcel_Writer_Exception
*/
public function save($pFilename = NULL)
{
if (!$this->_spreadSheet) {
throw new PHPExcel_Writer_Exception('PHPExcel object unassigned.');
}
// garbage collect
$this->_spreadSheet->garbageCollect();
// If $pFilename is php://output or php://stdout, make it a temporary file...
$originalFilename = $pFilename;
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
$pFilename = @tempnam(PHPExcel_Shared_File::sys_get_temp_dir(), 'phpxltmp');
if ($pFilename == '') {
$pFilename = $originalFilename;
}
}
$objZip = $this->_createZip($pFilename);
$objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('meta_inf')->writeManifest());
$objZip->addFromString('Thumbnails/thumbnail.png', $this->getWriterPart('thumbnails')->writeThumbnail());
$objZip->addFromString('content.xml', $this->getWriterPart('content')->write());
$objZip->addFromString('meta.xml', $this->getWriterPart('meta')->write());
$objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->write());
$objZip->addFromString('settings.xml', $this->getWriterPart('settings')->write());
$objZip->addFromString('styles.xml', $this->getWriterPart('styles')->write());
// Close file
if ($objZip->close() === false) {
throw new PHPExcel_Writer_Exception("Could not close zip file $pFilename.");
}
// If a temporary file was used, copy it to the correct file stream
if ($originalFilename != $pFilename) {
if (copy($pFilename, $originalFilename) === false) {
throw new PHPExcel_Writer_Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
}
@unlink($pFilename);
}
}
/**
* Create zip object
*
* @param string $pFilename
* @throws PHPExcel_Writer_Exception
* @return ZipArchive
*/
private function _createZip($pFilename)
{
// Create new ZIP file and open it for writing
$zipClass = PHPExcel_Settings::getZipClass();
$objZip = new $zipClass();
// Retrieve OVERWRITE and CREATE constants from the instantiated zip class
// This method of accessing constant values from a dynamic class should work with all appropriate versions of PHP
$ro = new ReflectionObject($objZip);
$zipOverWrite = $ro->getConstant('OVERWRITE');
$zipCreate = $ro->getConstant('CREATE');
if (file_exists($pFilename)) {
unlink($pFilename);
}
// Try opening the ZIP file
if ($objZip->open($pFilename, $zipOverWrite) !== true) {
if ($objZip->open($pFilename, $zipCreate) !== true) {
throw new PHPExcel_Writer_Exception("Could not open $pFilename for writing.");
}
}
return $objZip;
}
/**
* Get PHPExcel object
*
* @return PHPExcel
* @throws PHPExcel_Writer_Exception
*/
public function getPHPExcel()
{
if ($this->_spreadSheet !== null) {
return $this->_spreadSheet;
} else {
throw new PHPExcel_Writer_Exception('No PHPExcel assigned.');
}
}
/**
* Set PHPExcel object
*
* @param PHPExcel $pPHPExcel PHPExcel object
* @throws PHPExcel_Writer_Exception
* @return PHPExcel_Writer_Excel2007
*/
public function setPHPExcel(PHPExcel $pPHPExcel = null)
{
$this->_spreadSheet = $pPHPExcel;
return $this;
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Writer_OpenDocument_Cell_Comment
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
*/
class PHPExcel_Writer_OpenDocument_Cell_Comment
{
public static function write(PHPExcel_Shared_XMLWriter $objWriter, PHPExcel_Cell $cell)
{
$comments = $cell->getWorksheet()->getComments();
if (!isset($comments[$cell->getCoordinate()])) {
return;
}
$comment = $comments[$cell->getCoordinate()];
$objWriter->startElement('office:annotation');
//$objWriter->writeAttribute('draw:style-name', 'gr1');
//$objWriter->writeAttribute('draw:text-style-name', 'P1');
$objWriter->writeAttribute('svg:width', $comment->getWidth());
$objWriter->writeAttribute('svg:height', $comment->getHeight());
$objWriter->writeAttribute('svg:x', $comment->getMarginLeft());
$objWriter->writeAttribute('svg:y', $comment->getMarginTop());
//$objWriter->writeAttribute('draw:caption-point-x', $comment->getMarginLeft());
//$objWriter->writeAttribute('draw:caption-point-y', $comment->getMarginTop());
$objWriter->writeElement('dc:creator', $comment->getAuthor());
// TODO: Not realized in PHPExcel_Comment yet.
//$objWriter->writeElement('dc:date', $comment->getDate());
$objWriter->writeElement('text:p', $comment->getText()->getPlainText());
//$objWriter->writeAttribute('draw:text-style-name', 'P1');
$objWriter->endElement();
}
}

View File

@ -0,0 +1,272 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Writer_OpenDocument_Content
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
*/
class PHPExcel_Writer_OpenDocument_Content extends PHPExcel_Writer_OpenDocument_WriterPart
{
const NUMBER_COLS_REPEATED_MAX = 1024;
const NUMBER_ROWS_REPEATED_MAX = 1048576;
/**
* Write content.xml to XML format
*
* @param PHPExcel $pPHPExcel
* @return string XML Output
* @throws PHPExcel_Writer_Exception
*/
public function write(PHPExcel $pPHPExcel = null)
{
if (!$pPHPExcel) {
$pPHPExcel = $this->getParentWriter()->getPHPExcel(); /* @var $pPHPExcel PHPExcel */
}
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0', 'UTF-8');
// Content
$objWriter->startElement('office:document-content');
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
$objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
$objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
$objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
$objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
$objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
$objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
$objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0');
$objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
$objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
$objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
$objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
$objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
$objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
$objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
$objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
$objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
$objWriter->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms');
$objWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
$objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
$objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
$objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
$objWriter->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0');
$objWriter->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0');
$objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
$objWriter->writeAttribute('office:version', '1.2');
$objWriter->writeElement('office:scripts');
$objWriter->writeElement('office:font-face-decls');
$objWriter->writeElement('office:automatic-styles');
$objWriter->startElement('office:body');
$objWriter->startElement('office:spreadsheet');
$objWriter->writeElement('table:calculation-settings');
$this->_writeSheets($objWriter);
$objWriter->writeElement('table:named-expressions');
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
return $objWriter->getData();
}
/**
* Write sheets
*
* @param PHPExcel_Shared_XMLWriter $objWriter
*/
private function _writeSheets(PHPExcel_Shared_XMLWriter $objWriter)
{
$pPHPExcel = $this->getParentWriter()->getPHPExcel(); /* @var $pPHPExcel PHPExcel */
$sheet_count = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheet_count; $i++) {
//$this->getWriterPart('Worksheet')->writeWorksheet());
$objWriter->startElement('table:table');
$objWriter->writeAttribute('table:name', $pPHPExcel->getSheet($i)->getTitle());
$objWriter->writeElement('office:forms');
$objWriter->startElement('table:table-column');
$objWriter->writeAttribute('table:number-columns-repeated', self::NUMBER_COLS_REPEATED_MAX);
$objWriter->endElement();
$this->_writeRows($objWriter, $pPHPExcel->getSheet($i));
$objWriter->endElement();
}
}
/**
* Write rows of the specified sheet
*
* @param PHPExcel_Shared_XMLWriter $objWriter
* @param PHPExcel_Worksheet $sheet
*/
private function _writeRows(PHPExcel_Shared_XMLWriter $objWriter, PHPExcel_Worksheet $sheet)
{
$number_rows_repeated = self::NUMBER_ROWS_REPEATED_MAX;
$span_row = 0;
$rows = $sheet->getRowIterator();
while ($rows->valid()) {
$number_rows_repeated--;
$row = $rows->current();
if ($row->getCellIterator()->valid()) {
if ($span_row) {
$objWriter->startElement('table:table-row');
if ($span_row > 1) {
$objWriter->writeAttribute('table:number-rows-repeated', $span_row);
}
$objWriter->startElement('table:table-cell');
$objWriter->writeAttribute('table:number-columns-repeated', self::NUMBER_COLS_REPEATED_MAX);
$objWriter->endElement();
$objWriter->endElement();
$span_row = 0;
}
$objWriter->startElement('table:table-row');
$this->_writeCells($objWriter, $row);
$objWriter->endElement();
} else {
$span_row++;
}
$rows->next();
}
}
/**
* Write cells of the specified row
*
* @param PHPExcel_Shared_XMLWriter $objWriter
* @param PHPExcel_Worksheet_Row $row
* @throws PHPExcel_Writer_Exception
*/
private function _writeCells(PHPExcel_Shared_XMLWriter $objWriter, PHPExcel_Worksheet_Row $row)
{
$number_cols_repeated = self::NUMBER_COLS_REPEATED_MAX;
$prev_column = -1;
$cells = $row->getCellIterator();
while ($cells->valid()) {
$cell = $cells->current();
$column = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1;
$this->_writeCellSpan($objWriter, $column, $prev_column);
$objWriter->startElement('table:table-cell');
switch ($cell->getDataType()) {
case PHPExcel_Cell_DataType::TYPE_BOOL:
$objWriter->writeAttribute('office:value-type', 'boolean');
$objWriter->writeAttribute('office:value', $cell->getValue());
$objWriter->writeElement('text:p', $cell->getValue());
break;
case PHPExcel_Cell_DataType::TYPE_ERROR:
throw new PHPExcel_Writer_Exception('Writing of error not implemented yet.');
break;
case PHPExcel_Cell_DataType::TYPE_FORMULA:
try {
$formula_value = $cell->getCalculatedValue();
} catch (Exception $e) {
$formula_value = $cell->getValue();
}
$objWriter->writeAttribute('table:formula', 'of:' . $cell->getValue());
if (is_numeric($formula_value)) {
$objWriter->writeAttribute('office:value-type', 'float');
} else {
$objWriter->writeAttribute('office:value-type', 'string');
}
$objWriter->writeAttribute('office:value', $formula_value);
$objWriter->writeElement('text:p', $formula_value);
break;
case PHPExcel_Cell_DataType::TYPE_INLINE:
throw new PHPExcel_Writer_Exception('Writing of inline not implemented yet.');
break;
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
$objWriter->writeAttribute('office:value-type', 'float');
$objWriter->writeAttribute('office:value', $cell->getValue());
$objWriter->writeElement('text:p', $cell->getValue());
break;
case PHPExcel_Cell_DataType::TYPE_STRING:
$objWriter->writeAttribute('office:value-type', 'string');
$objWriter->writeElement('text:p', $cell->getValue());
break;
}
PHPExcel_Writer_OpenDocument_Cell_Comment::write($objWriter, $cell);
$objWriter->endElement();
$prev_column = $column;
$cells->next();
}
$number_cols_repeated = $number_cols_repeated - $prev_column - 1;
if ($number_cols_repeated > 0) {
if ($number_cols_repeated > 1) {
$objWriter->startElement('table:table-cell');
$objWriter->writeAttribute('table:number-columns-repeated', $number_cols_repeated);
$objWriter->endElement();
} else {
$objWriter->writeElement('table:table-cell');
}
}
}
/**
* Write span
*
* @param PHPExcel_Shared_XMLWriter $objWriter
* @param integer $curColumn
* @param integer $prevColumn
*/
private function _writeCellSpan(PHPExcel_Shared_XMLWriter $objWriter, $curColumn, $prevColumn)
{
$diff = $curColumn - $prevColumn - 1;
if (1 === $diff) {
$objWriter->writeElement('table:table-cell');
} elseif ($diff > 1) {
$objWriter->startElement('table:table-cell');
$objWriter->writeAttribute('table:number-columns-repeated', $diff);
$objWriter->endElement();
}
}
}

View File

@ -0,0 +1,98 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Writer_OpenDocument_Meta
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
*/
class PHPExcel_Writer_OpenDocument_Meta extends PHPExcel_Writer_OpenDocument_WriterPart
{
/**
* Write meta.xml to XML format
*
* @param PHPExcel $pPHPExcel
* @return string XML Output
* @throws PHPExcel_Writer_Exception
*/
public function write(PHPExcel $pPHPExcel = null)
{
if (!$pPHPExcel) {
$pPHPExcel = $this->getParentWriter()->getPHPExcel();
}
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0', 'UTF-8');
// Meta
$objWriter->startElement('office:document-meta');
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
$objWriter->writeAttribute('office:version', '1.2');
$objWriter->startElement('office:meta');
$objWriter->writeElement('meta:initial-creator', $pPHPExcel->getProperties()->getCreator());
$objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
$objWriter->writeElement('meta:creation-date', date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
$objWriter->writeElement('dc:date', date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
$objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle());
$objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription());
$objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject());
$keywords = explode(' ', $pPHPExcel->getProperties()->getKeywords());
foreach ($keywords as $keyword) {
$objWriter->writeElement('meta:keyword', $keyword);
}
//<meta:document-statistic meta:table-count="XXX" meta:cell-count="XXX" meta:object-count="XXX"/>
$objWriter->startElement('meta:user-defined');
$objWriter->writeAttribute('meta:name', 'Company');
$objWriter->writeRaw($pPHPExcel->getProperties()->getCompany());
$objWriter->endElement();
$objWriter->startElement('meta:user-defined');
$objWriter->writeAttribute('meta:name', 'category');
$objWriter->writeRaw($pPHPExcel->getProperties()->getCategory());
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
return $objWriter->getData();
}
}

View File

@ -0,0 +1,96 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Writer_OpenDocument_MetaInf
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
*/
class PHPExcel_Writer_OpenDocument_MetaInf extends PHPExcel_Writer_OpenDocument_WriterPart
{
/**
* Write META-INF/manifest.xml to XML format
*
* @param PHPExcel $pPHPExcel
* @return string XML Output
* @throws PHPExcel_Writer_Exception
*/
public function writeManifest(PHPExcel $pPHPExcel = null)
{
if (!$pPHPExcel) {
$pPHPExcel = $this->getParentWriter()->getPHPExcel();
}
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0', 'UTF-8');
// Manifest
$objWriter->startElement('manifest:manifest');
$objWriter->writeAttribute('xmlns:manifest', 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0');
$objWriter->writeAttribute('manifest:version', '1.2');
$objWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:full-path', '/');
$objWriter->writeAttribute('manifest:version', '1.2');
$objWriter->writeAttribute('manifest:media-type', 'application/vnd.oasis.opendocument.spreadsheet');
$objWriter->endElement();
$objWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:full-path', 'meta.xml');
$objWriter->writeAttribute('manifest:media-type', 'text/xml');
$objWriter->endElement();
$objWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:full-path', 'settings.xml');
$objWriter->writeAttribute('manifest:media-type', 'text/xml');
$objWriter->endElement();
$objWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:full-path', 'content.xml');
$objWriter->writeAttribute('manifest:media-type', 'text/xml');
$objWriter->endElement();
$objWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:full-path', 'Thumbnails/thumbnail.png');
$objWriter->writeAttribute('manifest:media-type', 'image/png');
$objWriter->endElement();
$objWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:full-path', 'styles.xml');
$objWriter->writeAttribute('manifest:media-type', 'text/xml');
$objWriter->endElement();
$objWriter->endElement();
return $objWriter->getData();
}
}

View File

@ -0,0 +1,50 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Writer_OpenDocument_Mimetype
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
*/
class PHPExcel_Writer_OpenDocument_Mimetype extends PHPExcel_Writer_OpenDocument_WriterPart
{
/**
* Write mimetype to plain text format
*
* @param PHPExcel $pPHPExcel
* @return string XML Output
* @throws PHPExcel_Writer_Exception
*/
public function write(PHPExcel $pPHPExcel = null)
{
return 'application/vnd.oasis.opendocument.spreadsheet';
}
}

View File

@ -0,0 +1,85 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Writer_OpenDocument_Settings
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
*/
class PHPExcel_Writer_OpenDocument_Settings extends PHPExcel_Writer_OpenDocument_WriterPart
{
/**
* Write settings.xml to XML format
*
* @param PHPExcel $pPHPExcel
* @return string XML Output
* @throws PHPExcel_Writer_Exception
*/
public function write(PHPExcel $pPHPExcel = null)
{
if (!$pPHPExcel) {
$pPHPExcel = $this->getParentWriter()->getPHPExcel();
}
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0', 'UTF-8');
// Settings
$objWriter->startElement('office:document-settings');
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$objWriter->writeAttribute('xmlns:config', 'urn:oasis:names:tc:opendocument:xmlns:config:1.0');
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
$objWriter->writeAttribute('office:version', '1.2');
$objWriter->startElement('office:settings');
$objWriter->startElement('config:config-item-set');
$objWriter->writeAttribute('config:name', 'ooo:view-settings');
$objWriter->startElement('config:config-item-map-indexed');
$objWriter->writeAttribute('config:name', 'Views');
$objWriter->endElement();
$objWriter->endElement();
$objWriter->startElement('config:config-item-set');
$objWriter->writeAttribute('config:name', 'ooo:configuration-settings');
$objWriter->endElement();
$objWriter->endElement();
$objWriter->endElement();
return $objWriter->getData();
}
}

View File

@ -0,0 +1,101 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Writer_OpenDocument_Styles
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
*/
class PHPExcel_Writer_OpenDocument_Styles extends PHPExcel_Writer_OpenDocument_WriterPart
{
/**
* Write styles.xml to XML format
*
* @param PHPExcel $pPHPExcel
* @return string XML Output
* @throws PHPExcel_Writer_Exception
*/
public function write(PHPExcel $pPHPExcel = null)
{
if (!$pPHPExcel) {
$pPHPExcel = $this->getParentWriter()->getPHPExcel();
}
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0', 'UTF-8');
// Content
$objWriter->startElement('office:document-styles');
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
$objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
$objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
$objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
$objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
$objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
$objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
$objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0');
$objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
$objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
$objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
$objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
$objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
$objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
$objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
$objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
$objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
$objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
$objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
$objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
$objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
$objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
$objWriter->writeAttribute('office:version', '1.2');
$objWriter->writeElement('office:font-face-decls');
$objWriter->writeElement('office:styles');
$objWriter->writeElement('office:automatic-styles');
$objWriter->writeElement('office:master-styles');
$objWriter->endElement();
return $objWriter->getData();
}
}

View File

@ -0,0 +1,50 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Writer_OpenDocument_Thumbnails
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
*/
class PHPExcel_Writer_OpenDocument_Thumbnails extends PHPExcel_Writer_OpenDocument_WriterPart
{
/**
* Write Thumbnails/thumbnail.png to PNG format
*
* @param PHPExcel $pPHPExcel
* @return string XML Output
* @throws PHPExcel_Writer_Exception
*/
public function writeThumbnail(PHPExcel $pPHPExcel = null)
{
return '';
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Writer_OpenDocument_WriterPart
*
* @category PHPExcel
* @package PHPExcel_Writer_OpenDocument
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
abstract class PHPExcel_Writer_OpenDocument_WriterPart extends PHPExcel_Writer_Excel2007_WriterPart
{
}

View File

@ -33,7 +33,7 @@
* @package PHPExcel_Writer_PDF
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_PDF
class PHPExcel_Writer_PDF implements PHPExcel_Writer_IWriter
{
/**
@ -87,4 +87,11 @@ class PHPExcel_Writer_PDF
return call_user_func_array(array($this->_renderer, $name), $arguments);
}
/**
* {@inheritdoc}
*/
public function save($pFilename = null)
{
$this->_renderer->save($pFilename);
}
}

View File

@ -83,6 +83,9 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
}
$orientation = ($orientation == 'L') ? 'landscape' : 'portrait';
// Override Page Orientation
if (!is_null($this->getOrientation())) {
$orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT)
@ -98,7 +101,6 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
$paperSize = self::$_paperSizes[$printPaperSize];
}
$orientation = ($orientation == 'L') ? 'landscape' : 'portrait';
// Create PDF
$pdf = new DOMPDF();

View File

@ -0,0 +1,89 @@
<?php
/**
* PHPExcel
*
* Copyright (C) 2006 - 2014 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
if (PHP_SAPI == 'cli')
die('This example should only be run from a Web Browser');
/** Include PHPExcel */
require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
// Set document properties
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document")
->setSubject("Office 2007 XLSX Test Document")
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
->setKeywords("office 2007 openxml php")
->setCategory("Test result file");
// Add some data
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello')
->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!');
// Miscellaneous glyphs, UTF-8
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A4', 'Miscellaneous glyphs')
->setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');
// Rename worksheet
$objPHPExcel->getActiveSheet()->setTitle('Simple');
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
// Redirect output to a clients web browser (OpenDocument)
header('Content-Type: application/vnd.oasis.opendocument.spreadsheet');
header('Content-Disposition: attachment;filename="01simple.ods"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'OpenDocument');
$objWriter->save('php://output');
exit;

View File

@ -267,12 +267,13 @@ echo date('H:i:s') , " Unprotect a cell" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
// Add a hyperlink to the sheet
echo date('H:i:s') , " Add a hyperlink to the sheet" , EOL;
echo date('H:i:s') , " Add a hyperlink to an external website" , EOL;
$objPHPExcel->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');
$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net');
$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website');
$objPHPExcel->getActiveSheet()->getStyle('E26')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
echo date('H:i:s') , " Add a hyperlink to another cell on a different worksheet within the workbook" , EOL;
$objPHPExcel->getActiveSheet()->setCellValue('E27', 'Terms and conditions');
$objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setUrl("sheet://'Terms and conditions'!A1");
$objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setTooltip('Review terms and conditions');

View File

@ -34,6 +34,7 @@ date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
mt_srand(1234567890);
/** Include PHPExcel */
require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';

View File

@ -59,7 +59,7 @@ $objWorksheet->fromArray(
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels = array(
$dataSeriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
@ -92,13 +92,13 @@ $series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_AREACHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$dataSeriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series));
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT, NULL, false);
@ -111,7 +111,7 @@ $chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel

View File

@ -59,7 +59,7 @@ $objWorksheet->fromArray(
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels = array(
$dataSeriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
@ -92,7 +92,7 @@ $series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STACKED, // plotGrouping
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$dataSeriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
@ -101,7 +101,7 @@ $series = new PHPExcel_Chart_DataSeries(
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_BAR);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series));
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
@ -114,7 +114,7 @@ $chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel

View File

@ -59,7 +59,7 @@ $objWorksheet->fromArray(
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels = array(
$dataSeriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
@ -92,7 +92,7 @@ $series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$dataSeriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
@ -101,7 +101,7 @@ $series = new PHPExcel_Chart_DataSeries(
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_BAR);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series));
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
@ -114,7 +114,7 @@ $chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel

View File

@ -67,7 +67,7 @@ $objWorksheet->fromArray(
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels = array(
$dataSeriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 'Budget'
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 'Forecast'
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$E$1', NULL, 1), // 'Actual'
@ -100,7 +100,7 @@ $series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$dataSeriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
@ -109,7 +109,7 @@ $series = new PHPExcel_Chart_DataSeries(
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series));
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_BOTTOM, NULL, false);
@ -123,7 +123,7 @@ $chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
$xAxisLabel, // xAxisLabel

View File

@ -59,7 +59,7 @@ $objWorksheet->fromArray(
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels = array(
$dataSeriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
@ -92,7 +92,7 @@ $series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$dataSeriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
@ -101,7 +101,7 @@ $series = new PHPExcel_Chart_DataSeries(
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series));
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
@ -114,7 +114,7 @@ $chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel

View File

@ -68,13 +68,13 @@ $objWorksheet->fromArray(
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels1 = array(
$dataSeriesLabels1 = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // Temperature
);
$dataseriesLabels2 = array(
$dataSeriesLabels2 = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // Rainfall
);
$dataseriesLabels3 = array(
$dataSeriesLabels3 = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // Humidity
);
@ -106,7 +106,7 @@ $series1 = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping
range(0, count($dataSeriesValues1)-1), // plotOrder
$dataseriesLabels1, // plotLabel
$dataSeriesLabels1, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues1 // plotValues
);
@ -131,7 +131,7 @@ $series2 = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_LINECHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
range(0, count($dataSeriesValues2)-1), // plotOrder
$dataseriesLabels2, // plotLabel
$dataSeriesLabels2, // plotLabel
NULL, // plotCategory
$dataSeriesValues2 // plotValues
);
@ -153,14 +153,14 @@ $series3 = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_AREACHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
range(0, count($dataSeriesValues2)-1), // plotOrder
$dataseriesLabels3, // plotLabel
$dataSeriesLabels3, // plotLabel
NULL, // plotCategory
$dataSeriesValues3 // plotValues
);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series1, $series2, $series3));
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series1, $series2, $series3));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
@ -172,7 +172,7 @@ $chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel

View File

@ -59,7 +59,7 @@ $objWorksheet->fromArray(
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels = array(
$dataSeriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
@ -92,13 +92,13 @@ $series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_LINECHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STACKED, // plotGrouping
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$dataSeriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series));
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT, NULL, false);
@ -111,7 +111,7 @@ $chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel

View File

@ -60,7 +60,7 @@ $objWorksheet->fromArray(
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels1 = array(
$dataSeriesLabels1 = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
@ -93,13 +93,13 @@ $series1 = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_AREACHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_PERCENT_STACKED, // plotGrouping
range(0, count($dataSeriesValues1)-1), // plotOrder
$dataseriesLabels1, // plotLabel
$dataSeriesLabels1, // plotLabel
$xAxisTickValues1, // plotCategory
$dataSeriesValues1 // plotValues
);
// Set the series in the plot area
$plotarea1 = new PHPExcel_Chart_PlotArea(NULL, array($series1));
$plotArea1 = new PHPExcel_Chart_PlotArea(NULL, array($series1));
// Set the chart legend
$legend1 = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT, NULL, false);
@ -112,7 +112,7 @@ $chart1 = new PHPExcel_Chart(
'chart1', // name
$title1, // title
$legend1, // legend
$plotarea1, // plotArea
$plotArea1, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel
@ -134,7 +134,7 @@ $objWorksheet->addChart($chart1);
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels2 = array(
$dataSeriesLabels2 = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
@ -167,7 +167,7 @@ $series2 = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
range(0, count($dataSeriesValues2)-1), // plotOrder
$dataseriesLabels2, // plotLabel
$dataSeriesLabels2, // plotLabel
$xAxisTickValues2, // plotCategory
$dataSeriesValues2 // plotValues
);
@ -176,7 +176,7 @@ $series2 = new PHPExcel_Chart_DataSeries(
$series2->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
// Set the series in the plot area
$plotarea2 = new PHPExcel_Chart_PlotArea(NULL, array($series2));
$plotArea2 = new PHPExcel_Chart_PlotArea(NULL, array($series2));
// Set the chart legend
$legend2 = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
@ -189,7 +189,7 @@ $chart2 = new PHPExcel_Chart(
'chart2', // name
$title2, // title
$legend2, // legend
$plotarea2, // plotArea
$plotArea2, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel

View File

@ -60,7 +60,7 @@ $objWorksheet->fromArray(
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels1 = array(
$dataSeriesLabels1 = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
);
// Set the X-Axis Labels
@ -87,9 +87,9 @@ $dataSeriesValues1 = array(
// Build the dataseries
$series1 = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_PIECHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
NULL, // plotGrouping (Pie charts don't have any grouping)
range(0, count($dataSeriesValues1)-1), // plotOrder
$dataseriesLabels1, // plotLabel
$dataSeriesLabels1, // plotLabel
$xAxisTickValues1, // plotCategory
$dataSeriesValues1 // plotValues
);
@ -100,7 +100,7 @@ $layout1->setShowVal(TRUE);
$layout1->setShowPercent(TRUE);
// Set the series in the plot area
$plotarea1 = new PHPExcel_Chart_PlotArea($layout1, array($series1));
$plotArea1 = new PHPExcel_Chart_PlotArea($layout1, array($series1));
// Set the chart legend
$legend1 = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
@ -112,7 +112,7 @@ $chart1 = new PHPExcel_Chart(
'chart1', // name
$title1, // title
$legend1, // legend
$plotarea1, // plotArea
$plotArea1, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel
@ -134,7 +134,7 @@ $objWorksheet->addChart($chart1);
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels2 = array(
$dataSeriesLabels2 = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
);
// Set the X-Axis Labels
@ -161,9 +161,9 @@ $dataSeriesValues2 = array(
// Build the dataseries
$series2 = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_DONUTCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
NULL, // plotGrouping (Donut charts don't have any grouping)
range(0, count($dataSeriesValues2)-1), // plotOrder
$dataseriesLabels2, // plotLabel
$dataSeriesLabels2, // plotLabel
$xAxisTickValues2, // plotCategory
$dataSeriesValues2 // plotValues
);
@ -174,7 +174,7 @@ $layout2->setShowVal(TRUE);
$layout2->setShowCatName(TRUE);
// Set the series in the plot area
$plotarea2 = new PHPExcel_Chart_PlotArea($layout2, array($series2));
$plotArea2 = new PHPExcel_Chart_PlotArea($layout2, array($series2));
$title2 = new PHPExcel_Chart_Title('Test Donut Chart');
@ -184,7 +184,7 @@ $chart2 = new PHPExcel_Chart(
'chart2', // name
$title2, // title
NULL, // legend
$plotarea2, // plotArea
$plotArea2, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel

View File

@ -68,7 +68,7 @@ $objWorksheet->fromArray(
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels = array(
$dataSeriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
);
@ -98,9 +98,9 @@ $dataSeriesValues = array(
// Build the dataseries
$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_RADARCHART, // plotType
NULL, // plotGrouping
NULL, // plotGrouping (Radar charts don't have any grouping)
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$dataSeriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues, // plotValues
NULL, // smooth line
@ -111,7 +111,7 @@ $series = new PHPExcel_Chart_DataSeries(
$layout = new PHPExcel_Chart_Layout();
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea($layout, array($series));
$plotArea = new PHPExcel_Chart_PlotArea($layout, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
@ -123,7 +123,7 @@ $chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel

View File

@ -59,7 +59,7 @@ $objWorksheet->fromArray(
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels = array(
$dataSeriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
@ -86,7 +86,7 @@ $series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART, // plotType
NULL, // plotGrouping (Scatter charts don't have any grouping)
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$dataSeriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues, // plotValues
NULL, // smooth line
@ -94,7 +94,7 @@ $series = new PHPExcel_Chart_DataSeries(
);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series));
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT, NULL, false);
@ -107,7 +107,7 @@ $chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel

View File

@ -62,7 +62,7 @@ $objWorksheet->getStyle('B2:E6')->getNumberFormat()->setFormatCode(PHPExcel_Styl
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels = array(
$dataSeriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), //Max / Open
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), //Min / Close
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), //Min Threshold / Min
@ -97,13 +97,13 @@ $series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_STOCKCHART, // plotType
null, // plotGrouping - if we set this to not null, then xlsx throws error
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$dataSeriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series));
$plotArea = new PHPExcel_Chart_PlotArea(NULL, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
@ -116,7 +116,7 @@ $chart = new PHPExcel_Chart(
'stock-chart', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
$plotArea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
$xAxisLabel, // xAxisLabel

Some files were not shown because too many files have changed in this diff Show More