Update library PHPExcel to version 1.7.3

This commit is contained in:
Dieter Adriaenssens
2010-05-25 22:10:48 +02:00
parent b90a1b496b
commit ee0b2895ce
136 changed files with 7979 additions and 5040 deletions

View File

@@ -19,6 +19,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
master, todo: update PHP excel?)
- bug #3023507 [core] No result set display from stored procedure SELECT
- bug [export] CSV for MS Excel (Windows) should have semi-colon as separator
- [core] Update library PHPExcel to version 1.7.3
3.3.4.0 (2010-06-28)
- bug #2996161 [import] properly escape import value

View File

@@ -22,36 +22,22 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Autoloader::Register();
PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
}
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_DocumentProperties */
require_once PHPEXCEL_ROOT . 'PHPExcel/DocumentProperties.php';
/** PHPExcel_DocumentSecurity */
require_once PHPEXCEL_ROOT . 'PHPExcel/DocumentSecurity.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Shared_ZipStreamWrapper */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/ZipStreamWrapper.php';
/** PHPExcel_NamedRange */
require_once PHPEXCEL_ROOT . 'PHPExcel/NamedRange.php';
/** PHPExcel_WorksheetIterator */
require_once PHPEXCEL_ROOT . 'PHPExcel/WorksheetIterator.php';
/**
* PHPExcel
@@ -146,6 +132,16 @@ class PHPExcel
$this->addCellStyleXf(new PHPExcel_Style);
}
public function disconnectWorksheets() {
foreach($this->_workSheetCollection as $k => &$worksheet) {
$worksheet->disconnectCells();
$this->_workSheetCollection[$k] = null;
}
unset($worksheet);
$this->_workSheetCollection = array();
}
/**
* Get properties
*
@@ -379,6 +375,23 @@ class PHPExcel
return $this->getActiveSheet();
}
/**
* Set active sheet index by name
*
* @param string $pValue Sheet title
* @return PHPExcel_Worksheet
* @throws Exception
*/
public function setActiveSheetIndexByName($pValue = '')
{
if (($worksheet = $this->getSheetByName($pValue)) instanceof PHPExcel_Worksheet) {
$this->setActiveSheetIndex($worksheet->getParent()->getIndex($worksheet));
return $worksheet;
}
throw new Exception('Workbook does not contain sheet:' . $pValue);
}
/**
* Get sheet names
*
@@ -420,7 +433,8 @@ class PHPExcel
$pSheet->rebindParent($this);
// update the cellXfs
foreach ($pSheet->getCellCollection(false) as $cell) {
foreach ($pSheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID);
$cell->setXfIndex( $cell->getXfIndex() + $countCellXfs );
}
@@ -443,7 +457,13 @@ class PHPExcel
* @return PHPExcel
*/
public function addNamedRange(PHPExcel_NamedRange $namedRange) {
$this->_namedRanges[$namedRange->getWorksheet()->getTitle().'!'.$namedRange->getName()] = $namedRange;
if ($namedRange->getScope() == null) {
// global scope
$this->_namedRanges[$namedRange->getName()] = $namedRange;
} else {
// local scope
$this->_namedRanges[$namedRange->getScope()->getTitle().'!'.$namedRange->getName()] = $namedRange;
}
return true;
}
@@ -451,57 +471,42 @@ class PHPExcel
* Get named range
*
* @param string $namedRange
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
* @return PHPExcel_NamedRange|null
*/
public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
$returnValue = null;
if ($namedRange != '' && !is_null($namedRange)) {
if (!is_null($pSheet)) {
$key = $pSheet->getTitle().'!'.$namedRange;
if (isset($this->_namedRanges[$key])) {
return $this->_namedRanges[$key];
}
// first look for global defined name
if (isset($this->_namedRanges[$namedRange])) {
$returnValue = $this->_namedRanges[$namedRange];
}
$returnCount = 0;
foreach($this->_namedRanges as $_namedRange) {
if ($_namedRange->getName() == $namedRange) {
if ((!is_null($pSheet)) && ($_namedRange->getWorksheet()->getTitle() == $pSheet->getTitle())) {
return $_namedRange;
} else {
$returnCount++;
$returnValue = $_namedRange;
}
}
}
if ($returnCount == 1) {
return $returnValue;
// then look for local defined name (has priority over global defined name if both names exist)
if (!is_null($pSheet) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
$returnValue = $this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange];
}
}
return null;
return $returnValue;
}
/**
* Remove named range
*
* @param string $namedRange
* @param PHPExcel_Worksheet|null $pSheet. Scope. Use null for global scope.
* @return PHPExcel
*/
public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
if ($namedRange != '' && !is_null($namedRange)) {
if (!is_null($pSheet)) {
$key = $pSheet->getTitle().'!'.$namedRange;
if (isset($this->_namedRanges[$key])) {
unset($this->_namedRanges[$key]);
}
if (is_null($pSheet)) {
if (isset($this->_namedRanges[$namedRange])) {
unset($this->_namedRanges[$namedRange]);
}
foreach($this->_namedRanges as $_namedRange) {
if ($_namedRange->getName() == $namedRange) {
if ((!is_null($pSheet)) && ($_namedRange->getWorksheet()->getTitle() == $pSheet->getTitle())) {
$key = $pSheet->getTitle().'!'.$namedRange;
if (isset($this->_namedRanges[$key])) {
unset($this->_namedRanges[$key]);
}
}
}
} else {
if (isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
unset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange]);
}
}
return $this;
@@ -622,7 +627,8 @@ class PHPExcel
// then update cellXf indexes for cells
foreach ($this->_workSheetCollection as $worksheet) {
foreach ($worksheet->getCellCollection(false) as $cell) {
foreach ($worksheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID);
$xfIndex = $cell->getXfIndex();
if ($xfIndex > $pIndex ) {
// decrease xf index by 1
@@ -724,7 +730,8 @@ class PHPExcel
foreach ($this->getWorksheetIterator() as $sheet) {
// from cells
foreach ($sheet->getCellCollection(false) as $cell) {
foreach ($sheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID);
++$countReferencesCellXf[$cell->getXfIndex()];
}
@@ -756,7 +763,7 @@ class PHPExcel
// update the index for all cellXfs
foreach ($this->_cellXfCollection as $i => $cellXf) {
echo $cellXf->setIndex($i);
$cellXf->setIndex($i);
}
// make sure there is always at least one cellXf (there should be)
@@ -768,7 +775,8 @@ class PHPExcel
foreach ($this->getWorksheetIterator() as $sheet) {
// for all cells
foreach ($sheet->getCellCollection(false) as $cell) {
foreach ($sheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID);
$cell->setXfIndex( $map[$cell->getXfIndex()] );
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
class PHPExcel_Autoloader
{
public static function Register() {
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
} // function Register()
public static function Load($pObjectName){
if ((class_exists($pObjectName)) || (strpos($pObjectName, 'PHPExcel') === False)) {
return false;
}
$pObjectFilePath = PHPEXCEL_ROOT.
str_replace('_',DIRECTORY_SEPARATOR,$pObjectName).
'.php';
if ((file_exists($pObjectFilePath) === false) || (is_readable($pObjectFilePath) === false)) {
return false;
}
require($pObjectFilePath);
} // function Load()
}

View File

@@ -0,0 +1,193 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/**
* PHPExcel_CachedObjectStorage_APC
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
private $_cachePrefix = null;
private $_cacheTime = 600;
private function _storeData() {
$this->_currentObject->detach();
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
$this->__destruct();
throw new Exception('Failed to store cell in APC');
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_cellCache[$pCoord] = true;
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
return $cell;
} // function addCacheData()
/**
* 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
*/
public function isDataSet($pCoord) {
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->_currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in apc
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry no longer exists in APC');
}
return true;
}
return false;
} // function isDataSet()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) {
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
if ($obj === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry no longer exists in APC');
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($obj);
// Re-attach the parent worksheet
$this->_currentObject->attach($this->_parent);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws Exception
*/
public function deleteCacheData($pCoord) {
// Delete the entry from APC
apc_delete($this->_cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
} // function deleteCacheData()
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
// Flush the APC cache
$this->__destruct();
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->_cachePrefix)) {
if (function_exists('posix_getpid')) {
$baseUnique = posix_getpid();
} else {
$baseUnique = mt_rand();
}
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
$this->_cacheTime = $cacheTime;
parent::__construct($parent);
}
} // function __construct()
public function __destruct() {
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
apc_delete($this->_cachePrefix.$cellID.'.cache');
}
} // function __destruct()
}

View File

@@ -0,0 +1,162 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/**
* PHPExcel_CachedObjectStorage_CacheBase
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_CacheBase {
/**
* Parent worksheet
*
* @var PHPExcel_Worksheet
*/
protected $_parent;
/**
* The currently active Cell
*
* @var PHPExcel_Cell
*/
protected $_currentObject = null;
/**
* Coordinate address of the currently active Cell
*
* @var string
*/
protected $_currentObjectID = null;
/**
* An array of cells or cell pointers for the worksheet cells held in this cache,
* and indexed by their coordinate address within the worksheet
*
* @var array of mixed
*/
protected $_cellCache = array();
public function __construct(PHPExcel_Worksheet $parent) {
// Set our parent worksheet.
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
// they are woken from a serialized state
$this->_parent = $parent;
} // function __construct()
/**
* 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
*/
public function isDataSet($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return true;
}
// Check if the requested entry exists in the cache
return isset($this->_cellCache[$pCoord]);
} // function isDataSet()
/**
* Add or Update a cell in cache
*
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
*/
public function updateCacheData(PHPExcel_Cell $cell) {
$pCoord = $cell->getCoordinate();
return $this->addCacheData($pCoord,$cell);
} // function updateCacheData()
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws Exception
*/
public function deleteCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
$this->_currentObject->detach();
$this->_currentObjectID = $this->_currentObject = null;
}
if (isset($this->_cellCache[$pCoord])) {
$this->_cellCache[$pCoord]->detach();
unset($this->_cellCache[$pCoord]);
}
} // function deleteCacheData()
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList() {
return array_keys($this->_cellCache);
} // function getCellList()
/**
* Sort the list of all cell addresses currently held in cache by column and row
*
* @return void
*/
public function sortCellList() {
$sortValues = array();
foreach ($this->_cellCache as $coord => $value) {
preg_match('/^(\w+)(\d+)$/U',$coord,$matches);
list(,$colNum,$rowNum) = $matches;
$key = str_pad($rowNum . str_pad($colNum,3,'@',STR_PAD_LEFT),12,'0',STR_PAD_LEFT);
$sortValues[$key] = $coord;
}
ksort($sortValues);
// Rebuild cellCollection from the sorted index
$newCellCollection = array();
foreach ($sortValues as $coord) {
$newCellCollection[$coord] = $this->_cellCache[$coord];
}
$this->_cellCache = $newCellCollection;
} // function sortCellList()
}

View File

@@ -0,0 +1,143 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/**
* PHPExcel_CachedObjectStorage_DiscISAM
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
private $_fileName = null;
private $_fileHandle = null;
private function _storeData() {
$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->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// 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']));
// Re-attach the parent worksheet
$this->_currentObject->attach($this->_parent);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
// Close down the temporary cache file
$this->__destruct();
} // function unsetWorksheetCells()
public function __construct(PHPExcel_Worksheet $parent) {
parent::__construct($parent);
if (is_null($this->_fileHandle)) {
if (function_exists('posix_getpid')) {
$baseUnique = posix_getpid();
} else {
$baseUnique = mt_rand();
}
$this->_fileName = sys_get_temp_dir().'/PHPExcel.'.uniqid($baseUnique,true).'.cache';
$this->_fileHandle = fopen($this->_fileName,'a+');
}
} // function __construct()
public function __destruct() {
if (!is_null($this->_fileHandle)) {
fclose($this->_fileHandle);
unlink($this->_fileName);
}
$this->_fileHandle = null;
} // function __destruct()
}

View File

@@ -0,0 +1,97 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/**
* PHPExcel_CachedObjectStorage_ICache
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
interface PHPExcel_CachedObjectStorage_ICache
{
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell);
/**
* Add or Update a cell in cache
*
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
*/
public function updateCacheData(PHPExcel_Cell $cell);
/**
* Fetch a cell from cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to retrieve
* @return PHPExcel_Cell Cell that was found, or null if not found
* @throws Exception
*/
public function getCacheData($pCoord);
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws Exception
*/
public function deleteCacheData($pCoord);
/**
* 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
*/
public function isDataSet($pCoord);
/**
* Get a list of all cell addresses currently held in cache
*
* @return array of string
*/
public function getCellList();
/**
* Sort the list of all cell addresses currently held in cache by column and row
*
* @return void
*/
public function sortCellList();
}

View File

@@ -0,0 +1,209 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/**
* PHPExcel_CachedObjectStorage_Memcache
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
private $_cachePrefix = null;
private $_cacheTime = 600;
private $_memcache = null;
private function _storeData() {
$this->_currentObject->detach();
$obj = serialize($this->_currentObject);
if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
$this->__destruct();
throw new Exception('Failed to store cell in Memcache');
}
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_cellCache[$pCoord] = true;
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
return $cell;
} // function addCacheData()
/**
* 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
*/
public function isDataSet($pCoord) {
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->_currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in apc
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry no longer exists in Memcache');
}
return true;
}
return false;
} // function isDataSet()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) {
$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry no longer exists in Memcache');
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($obj);
// Re-attach the parent worksheet
$this->_currentObject->attach($this->_parent);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws Exception
*/
public function deleteCacheData($pCoord) {
// Delete the entry from Memcache
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
} // function deleteCacheData()
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
// Flush the Memcache cache
$this->__destruct();
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->_cachePrefix)) {
if (function_exists('posix_getpid')) {
$baseUnique = posix_getpid();
} else {
$baseUnique = mt_rand();
}
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
// Set a new Memcache object and connect to the Memcache server
$this->_memcache = new Memcache();
if (!$this->_memcache->connect($memcacheServer, $memcachePort)) {
throw new Exception('Could not connect to Memcache server at '.$memcacheServer.':'.$memcachePort);
}
$this->_cacheTime = $cacheTime;
parent::__construct($parent);
}
} // function __construct()
public function __destruct() {
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
}
} // function __destruct()
}
?>

View File

@@ -0,0 +1,85 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/**
* PHPExcel_CachedObjectStorage_Memory
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
$this->_cellCache[$pCoord] = $cell;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Return requested entry
return $this->_cellCache[$pCoord];
} // function getCacheData()
public function unsetWorksheetCells() {
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
foreach($this->_cellCache as $k => &$cell) {
$cell->detach();
$this->_cellCache[$k] = null;
}
unset($cell);
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
}

View File

@@ -0,0 +1,107 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/**
* PHPExcel_CachedObjectStorage_MemoryGZip
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
private function _storeData() {
$this->_currentObject->detach();
$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
// Re-attach the parent worksheet
$this->_currentObject->attach($this->_parent);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
}

View File

@@ -0,0 +1,107 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/**
* PHPExcel_CachedObjectStorage_MemorySerialized
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
private function _storeData() {
$this->_currentObject->detach();
$this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($this->_cellCache[$pCoord]);
// Re-attach the parent worksheet
$this->_currentObject->attach($this->_parent);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
}

View File

@@ -0,0 +1,137 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/**
* PHPExcel_CachedObjectStorage_PHPTemp
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
private $_fileHandle = null;
private function _storeData() {
$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->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
return $cell;
} // function addCacheData()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (!isset($this->_cellCache[$pCoord])) {
// Return null if requested entry doesn't exist in cache
return null;
}
// 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']));
// Re-attach the parent worksheet
$this->_currentObject->attach($this->_parent);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
// Close down the php://temp file
$this->__destruct();
} // function unsetWorksheetCells()
public function __construct(PHPExcel_Worksheet $parent, $memoryCacheSize = '1MB') {
$memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
parent::__construct($parent);
if (is_null($this->_fileHandle)) {
$this->_fileHandle = fopen('php://temp/maxmemory:'.$memoryCacheSize,'a+');
}
} // function __construct()
public function __destruct() {
if (!is_null($this->_fileHandle)) {
fclose($this->_fileHandle);
}
$this->_fileHandle = null;
} // function __destruct()
}

View File

@@ -0,0 +1,201 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/**
* PHPExcel_CachedObjectStorage_Wincache
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
private $_cachePrefix = null;
private $_cacheTime = 600;
private function _storeData() {
$this->_currentObject->detach();
$obj = serialize($this->_currentObject);
if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime);
} else {
wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime);
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()
/**
* Add or Update a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
* @return void
* @throws Exception
*/
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_cellCache[$pCoord] = true;
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
return $cell;
} // function addCacheData()
/**
* 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
*/
public function isDataSet($pCoord) {
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->_currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in cache
$success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in Wincache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry no longer exists in Wincache');
}
return true;
}
return false;
} // function isDataSet()
/**
* Get cell at a specific coordinate
*
* @param string $pCoord Coordinate of the cell
* @throws Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject;
}
$this->_storeData();
// Check if the entry that has been requested actually exists
$obj = null;
if (parent::isDataSet($pCoord)) {
$success = false;
$obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success);
if ($success === false) {
// Entry no longer exists in Wincache, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new Exception('Cell entry no longer exists in Wincache');
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($obj);
// Re-attach the parent worksheet
$this->_currentObject->attach($this->_parent);
// Return requested entry
return $this->_currentObject;
} // function getCacheData()
/**
* Delete a cell in cache identified by coordinate address
*
* @param string $pCoord Coordinate address of the cell to delete
* @throws Exception
*/
public function deleteCacheData($pCoord) {
// Delete the entry from Wincache
wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
} // function deleteCacheData()
public function unsetWorksheetCells() {
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
// Flush the Wincache cache
$this->__destruct();
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->_cachePrefix)) {
if (function_exists('posix_getpid')) {
$baseUnique = posix_getpid();
} else {
$baseUnique = mt_rand();
}
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
$this->_cacheTime = $cacheTime;
parent::__construct($parent);
}
} // function __construct()
public function __destruct() {
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache');
}
} // function __destruct()
}
?>

View File

@@ -0,0 +1,131 @@
<?php
class PHPExcel_CachedObjectStorageFactory {
const cache_in_memory = 'Memory';
const cache_in_memory_gzip = 'MemoryGZip';
const cache_in_memory_serialized = 'MemorySerialized';
const cache_to_discISAM = 'DiscISAM';
const cache_to_apc = 'APC';
const cache_to_memcache = 'Memcache';
const cache_to_phpTemp = 'PHPTemp';
const cache_to_wincache = 'Wincache';
private static $_cacheStorageMethod = null;
private static $_cacheStorageClass = null;
private static $_storageMethods = array(
self::cache_in_memory,
self::cache_in_memory_gzip,
self::cache_in_memory_serialized,
self::cache_to_phpTemp,
self::cache_to_discISAM,
self::cache_to_apc,
self::cache_to_memcache,
self::cache_to_wincache,
);
private static $_storageMethodDefaultParameters = array(
self::cache_in_memory => array(
),
self::cache_in_memory_gzip => array(
),
self::cache_in_memory_serialized => array(
),
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
),
self::cache_to_discISAM => array(
),
self::cache_to_apc => array( 'cacheTime' => 600
),
self::cache_to_memcache => array( 'memcacheServer' => 'localhost',
'memcachePort' => 11211,
'cacheTime' => 600
),
self::cache_to_wincache => array( 'cacheTime' => 600
)
);
private static $_storageMethodParameters = array();
public static function getCacheStorageMethod() {
if (!is_null(self::$_cacheStorageMethod)) {
return self::$_cacheStorageMethod;
}
return null;
} // function getCacheStorageMethod()
public static function getCacheStorageClass() {
if (!is_null(self::$_cacheStorageClass)) {
return self::$_cacheStorageClass;
}
return null;
} // function getCacheStorageClass()
public static function getCacheStorageMethods() {
return self::$_storageMethods;
} // function getCacheStorageMethods()
public static function initialize($method = self::cache_in_memory, $arguments = array()) {
if (!in_array($method,self::$_storageMethods)) {
return false;
}
switch($method) {
case self::cache_to_apc :
if (!function_exists('apc_store')) {
return false;
}
if (apc_sma_info() === false) {
return false;
}
break;
case self::cache_to_memcache :
if (!function_exists('memcache_add')) {
return false;
}
break;
case self::cache_to_wincache :
if (!function_exists('wincache_ucache_add')) {
return false;
}
break;
}
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
foreach($arguments as $k => $v) {
if (isset(self::$_storageMethodParameters[$method][$k])) {
self::$_storageMethodParameters[$method][$k] = $v;
}
}
if (is_null(self::$_cacheStorageMethod)) {
self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
self::$_cacheStorageMethod = $method;
}
return true;
} // function initialize()
public static function getInstance(PHPExcel_Worksheet $parent) {
if (is_null(self::$_cacheStorageMethod)) {
self::initialize();
}
$instance = new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]);
if (!is_null($instance)) {
return $instance;
}
return false;
} // function getInstance()
}

File diff suppressed because it is too large Load Diff

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/

View File

@@ -22,20 +22,9 @@
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Calculation_Exception */
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Exception.php';
/**
* PHPExcel_Calculation_ExceptionHandler
*
@@ -43,14 +32,14 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Exception.php';
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_ExceptionHandler {
class PHPExcel_Calculation_ExceptionHandler {
/**
* Register errorhandler
*/
public function __construct() {
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
}
/**
* Unregister errorhandler
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
@@ -49,17 +49,6 @@ PARTLY BASED ON:
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Calculation_FormulaToken */
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/FormulaToken.php';
/**
* PHPExcel_Calculation_FormulaParser
*

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/

File diff suppressed because it is too large Load Diff

View File

@@ -22,43 +22,10 @@
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
}
/** PHPExcel_Cell_DataType */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
/** PHPExcel_Cell_DataValidation */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataValidation.php';
/** PHPExcel_Cell_Hyperlink */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/Hyperlink.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Calculation */
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation.php';
/** PHPExcel_Cell_IValueBinder */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/IValueBinder.php';
/** PHPExcel_Cell_DefaultValueBinder */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DefaultValueBinder.php';
/** PHPExcel_Shared_String */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
/**
* PHPExcel_Cell
*
@@ -124,6 +91,24 @@ class PHPExcel_Cell
*/
private $_xfIndex;
/**
* Send notification to the cache controller
* @return void
**/
public function notifyCacheController() {
$this->_parent->getCellCacheController()->updateCacheData($this);
}
public function detach() {
$this->_parent = null;
}
public function attach($parent) {
$this->_parent = $parent;
}
/**
* Create a new Cell
*
@@ -256,11 +241,13 @@ class PHPExcel_Cell
// set the datatype
$this->_dataType = $pDataType;
$this->notifyCacheController();
return $this;
}
/**
* Get caluclated cell value
* Get calculated cell value
*
* @return mixed
*/
@@ -271,9 +258,11 @@ class PHPExcel_Cell
try {
// echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value<br />';
$result = PHPExcel_Calculation::getInstance()->calculateCellValue($this,$resetLog);
// echo $this->getCoordinate().' calculation result is '.$result.'<br />';
} catch ( Exception $ex ) {
// echo 'Calculation Exception: '.$ex->getMessage().'<br />';
$result = '#N/A';
throw(new Exception($ex->getMessage()));
}
if ((is_string($result)) && ($result == '#Not Yet Implemented')) {
@@ -308,6 +297,8 @@ class PHPExcel_Cell
if (!is_null($pValue)) {
$this->_calculatedValue = $pValue;
}
$this->notifyCacheController();
return $this;
}
@@ -340,6 +331,8 @@ class PHPExcel_Cell
public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
$this->_dataType = $pDataType;
$this->notifyCacheController();
return $this;
}
@@ -386,6 +379,8 @@ class PHPExcel_Cell
}
$this->_parent->setDataValidation($this->getCoordinate(), $pDataValidation);
$this->notifyCacheController();
return $this;
}
@@ -433,6 +428,8 @@ class PHPExcel_Cell
}
$this->_parent->setHyperlink($this->getCoordinate(), $pHyperlink);
$this->notifyCacheController();
return $this;
}
@@ -453,6 +450,8 @@ class PHPExcel_Cell
*/
public function rebindParent(PHPExcel_Worksheet $parent) {
$this->_parent = $parent;
$this->notifyCacheController();
return $this;
}
@@ -616,6 +615,30 @@ class PHPExcel_Cell
return array( ($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1) );
}
/**
* Calculate range boundaries
*
* @param string $pRange Cell range (e.g. A1:A1)
* @return array Range boundaries (staring Column, starting Row, Final Column, Final Row)
*/
public static function getRangeBoundaries($pRange = 'A1:A1')
{
// Uppercase coordinate
$pRange = strtoupper($pRange);
// Extract range
$rangeA = '';
$rangeB = '';
if (strpos($pRange, ':') === false) {
$rangeA = $pRange;
$rangeB = $pRange;
} else {
list($rangeA, $rangeB) = explode(':', $pRange);
}
return array( self::coordinateFromString($rangeA), self::coordinateFromString($rangeB));
}
/**
* Column index from string
*
@@ -625,6 +648,14 @@ class PHPExcel_Cell
*/
public static function columnIndexFromString($pString = 'A')
{
static $lookup = array(
'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10, 'K' => 11, 'L' => 12, 'M' => 13,
'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19, 'T' => 20, 'U' => 21, 'V' => 22, 'W' => 23, 'X' => 24, 'Y' => 25, 'Z' => 26
);
if (isset($lookup[$pString]))
return $lookup[$pString];
// Convert to uppercase
$pString = strtoupper($pString);
@@ -809,6 +840,8 @@ class PHPExcel_Cell
public function setXfIndex($pValue = 0)
{
$this->_xfIndex = $pValue;
$this->notifyCacheController();
return $this;
}

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,37 +22,10 @@
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Cell_IValueBinder */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/IValueBinder.php';
/** PHPExcel_Cell_DefaultValueBinder */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DefaultValueBinder.php';
/** PHPExcel_Style_NumberFormat */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
/** PHPExcel_Shared_Date */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
/** PHPExcel_Shared_String */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
/**
* PHPExcel_Cell_AdvancedValueBinder
*
@@ -78,49 +51,72 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Find out data type
$dataType = parent::dataTypeForValue($value);
// Style logic - strings
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
// Check for percentage
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
// Convert value to number
$cell->setValueExplicit( (float)str_replace('%', '', $value) / 100, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE );
return true;
}
// Check for time e.g. '9:45', '09:45'
// Check for time without seconds e.g. '9:45', '09:45'
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
list($h, $m) = explode(':', $value);
$days = $h / 24 + $m / 1440;
// Convert value to number
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
return true;
}
// Check for date
if (strtotime($value) !== false) {
// make sure we have UTC for the sake of strtotime
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
// Convert value to Excel date
$cell->setValueExplicit( PHPExcel_Shared_Date::PHPToExcel(strtotime($value)), PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Check for time with seconds '9:45:59', '09:45:59'
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) {
list($h, $m, $s) = explode(':', $value);
$days = $h / 24 + $m / 1440 + $s / 86400;
// Convert value to number
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2 );
// restore original value for timezone
date_default_timezone_set($saveTimeZone);
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
return true;
}
// Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10'
if (($v = PHPExcel_Shared_Date::stringToExcel($value)) !== false) {
// Convert value to Excel date
$cell->setValueExplicit($v, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style. Either there is a time part or not. Look for ':'
if (strpos($value, ':') !== false) {
$formatCode = 'yyyy-mm-dd h:mm';
} else {
$formatCode = 'yyyy-mm-dd';
}
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode($formatCode);
return true;
}
// Check for newline character "\n"
if (strpos($value, "\n") !== false) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
// Set style
$cell->getParent()->getStyle( $cell->getCoordinate() )->getAlignment()->setWrapText(true);
return true;
}
}

View File

@@ -22,22 +22,10 @@
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Cell_DefaultValueBinder */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DefaultValueBinder.php';
/**
* PHPExcel_Cell_DataType
*
@@ -71,7 +59,7 @@ class PHPExcel_Cell_DataType
public static function getErrorCodes() {
return self::$_errorCodes;
}
/**
* DataType for value
*

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
@@ -151,20 +151,12 @@ class PHPExcel_Cell_DataValidation
*/
private $_prompt;
/**
* Parent cell
*
* @var PHPExcel_Cell
*/
private $_parent;
/**
* Create a new PHPExcel_Cell_DataValidation
*
* @param PHPExcel_Cell $pCell Parent cell
* @throws Exception
*/
public function __construct(PHPExcel_Cell $pCell = null)
public function __construct()
{
// Initialise member variables
$this->_formula1 = '';
@@ -180,9 +172,6 @@ class PHPExcel_Cell_DataValidation
$this->_error = '';
$this->_promptTitle = '';
$this->_prompt = '';
// Set cell
$this->_parent = $pCell;
}
/**
@@ -445,26 +434,6 @@ class PHPExcel_Cell_DataValidation
return $this;
}
/**
* Get parent
*
* @return PHPExcel_Cell
*/
public function getParent() {
return $this->_parent;
}
/**
* Set Parent
*
* @param PHPExcel_Cell $value
* @return PHPExcel_Cell_DataValidation
*/
public function setParent($value = null) {
$this->_parent = $value;
return $this;
}
/**
* Get hash code
*
@@ -485,7 +454,6 @@ class PHPExcel_Cell_DataValidation
. $this->_error
. $this->_promptTitle
. $this->_prompt
. $this->_parent->getCoordinate()
. __CLASS__
);
}
@@ -494,12 +462,9 @@ class PHPExcel_Cell_DataValidation
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
// unbind parent
$this->setParent(null);
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value) && $key != '_parent') {
if (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,31 +22,10 @@
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Cell_IValueBinder */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/IValueBinder.php';
/** PHPExcel_Cell_DataType */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
/** PHPExcel_Shared_String */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
/**
* PHPExcel_Cell_DefaultValueBinder
*
@@ -72,11 +51,11 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
// Set value explicit
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::dataTypeForValue($value) );
// Done!
return true;
}
/**
* DataType for value
*
@@ -94,7 +73,7 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
} elseif ($pValue instanceof PHPExcel_RichText) {
return PHPExcel_Cell_DataType::TYPE_STRING;
} elseif ($pValue{0} === '=') {
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
return PHPExcel_Cell_DataType::TYPE_FORMULA;
} elseif (is_bool($pValue)) {

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
@@ -35,13 +35,6 @@
*/
class PHPExcel_Cell_Hyperlink
{
/**
* Cell representing the hyperlink
*
* @var PHPExcel_Cell
*/
private $_cell;
/**
* URL to link the cell to
*
@@ -59,19 +52,15 @@ class PHPExcel_Cell_Hyperlink
/**
* Create a new PHPExcel_Cell_Hyperlink
*
* @param PHPExcel_Cell $pCell Parent cell
* @param string $pUrl Url to link the cell to
* @param string $pTooltip Tooltip to display on the hyperlink
* @throws Exception
*/
public function __construct(PHPExcel_Cell $pCell = null, $pUrl = '', $pTooltip = '')
public function __construct($pUrl = '', $pTooltip = '')
{
// Initialise member variables
$this->_url = $pUrl;
$this->_tooltip = $pTooltip;
// Set cell
$this->_parent = $pCell;
}
/**
@@ -123,26 +112,6 @@ class PHPExcel_Cell_Hyperlink
return strpos($this->_url, 'sheet://') !== false;
}
/**
* Get parent
*
* @return PHPExcel_Cell
*/
public function getParent() {
return $this->_parent;
}
/**
* Set Parent
*
* @param PHPExcel_Cell $value
* @return PHPExcel_Cell_Hyperlink
*/
public function setParent($value = null) {
$this->_parent = $value;
return $this;
}
/**
* Get hash code
*
@@ -152,7 +121,6 @@ class PHPExcel_Cell_Hyperlink
return md5(
$this->_url
. $this->_tooltip
. $this->_parent->getCoordinate()
. __CLASS__
);
}

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,22 +22,10 @@
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/**
* PHPExcel_Cell_IValueBinder
*

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,28 +22,10 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
}
/** PHPExcel_RichText */
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText.php';
/** PHPExcel_Style_Color */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/**
* PHPExcel_Comment
*
@@ -59,59 +41,59 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @var string
*/
private $_author;
/**
* Rich text comment
*
* @var PHPExcel_RichText
*/
private $_text;
/**
* Comment width (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_width = '96pt';
/**
* Left margin (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_marginLeft = '59.25pt';
/**
* Top margin (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_marginTop = '1.5pt';
/**
* Visible
*
* @var boolean
*/
private $_visible = false;
/**
* Comment height (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_height = '55.5pt';
/**
* Comment fill color
*
* @var PHPExcel_Style_Color
*/
private $_fillColor;
/**
* Create a new PHPExcel_Comment
*
*
* @throws Exception
*/
public function __construct()
@@ -121,7 +103,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_text = new PHPExcel_RichText();
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
}
/**
* Get Author
*
@@ -130,7 +112,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getAuthor() {
return $this->_author;
}
/**
* Set Author
*
@@ -141,7 +123,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_author = $pValue;
return $this;
}
/**
* Get Rich text comment
*
@@ -150,7 +132,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getText() {
return $this->_text;
}
/**
* Set Rich text comment
*
@@ -161,7 +143,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_text = $pValue;
return $this;
}
/**
* Get comment width (CSS style, i.e. XXpx or YYpt)
*
@@ -170,7 +152,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getWidth() {
return $this->_width;
}
/**
* Set comment width (CSS style, i.e. XXpx or YYpt)
*
@@ -181,7 +163,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_width = $value;
return $this;
}
/**
* Get comment height (CSS style, i.e. XXpx or YYpt)
*
@@ -190,7 +172,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getHeight() {
return $this->_height;
}
/**
* Set comment height (CSS style, i.e. XXpx or YYpt)
*
@@ -201,7 +183,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_height = $value;
return $this;
}
/**
* Get left margin (CSS style, i.e. XXpx or YYpt)
*
@@ -210,7 +192,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getMarginLeft() {
return $this->_marginLeft;
}
/**
* Set left margin (CSS style, i.e. XXpx or YYpt)
*
@@ -221,7 +203,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_marginLeft = $value;
return $this;
}
/**
* Get top margin (CSS style, i.e. XXpx or YYpt)
*
@@ -230,7 +212,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getMarginTop() {
return $this->_marginTop;
}
/**
* Set top margin (CSS style, i.e. XXpx or YYpt)
*
@@ -241,7 +223,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_marginTop = $value;
return $this;
}
/**
* Is the comment visible by default?
*
@@ -250,7 +232,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getVisible() {
return $this->_visible;
}
/**
* Set comment default visibility
*
@@ -258,10 +240,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @return PHPExcel_Comment
*/
public function setVisible($value = false) {
$this->_visible = $value;
$this->_visible = $value;
return $this;
}
/**
* Get fill color
*
@@ -270,12 +252,12 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getFillColor() {
return $this->_fillColor;
}
/**
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
return md5(
$this->_author
@@ -289,7 +271,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,22 +22,10 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
}
/** PHPExcel_Shared_PasswordHasher */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PasswordHasher.php';
/**
* PHPExcel_DocumentSecurity
*
@@ -53,35 +41,35 @@ class PHPExcel_DocumentSecurity
* @var boolean
*/
private $_lockRevision;
/**
* LockStructure
*
* @var boolean
*/
private $_lockStructure;
/**
* LockWindows
*
* @var boolean
*/
private $_lockWindows;
/**
* RevisionsPassword
*
* @var string
*/
private $_revisionsPassword;
/**
* WorkbookPassword
*
* @var string
*/
private $_workbookPassword;
/**
* Create a new PHPExcel_DocumentSecurity
*/
@@ -94,7 +82,7 @@ class PHPExcel_DocumentSecurity
$this->_revisionsPassword = '';
$this->_workbookPassword = '';
}
/**
* Is some sort of dcument security enabled?
*
@@ -105,7 +93,7 @@ class PHPExcel_DocumentSecurity
$this->_lockStructure ||
$this->_lockWindows;
}
/**
* Get LockRevision
*
@@ -114,7 +102,7 @@ class PHPExcel_DocumentSecurity
function getLockRevision() {
return $this->_lockRevision;
}
/**
* Set LockRevision
*
@@ -125,7 +113,7 @@ class PHPExcel_DocumentSecurity
$this->_lockRevision = $pValue;
return $this;
}
/**
* Get LockStructure
*
@@ -134,7 +122,7 @@ class PHPExcel_DocumentSecurity
function getLockStructure() {
return $this->_lockStructure;
}
/**
* Set LockStructure
*
@@ -145,7 +133,7 @@ class PHPExcel_DocumentSecurity
$this->_lockStructure = $pValue;
return $this;
}
/**
* Get LockWindows
*
@@ -154,7 +142,7 @@ class PHPExcel_DocumentSecurity
function getLockWindows() {
return $this->_lockWindows;
}
/**
* Set LockWindows
*
@@ -165,7 +153,7 @@ class PHPExcel_DocumentSecurity
$this->_lockWindows = $pValue;
return $this;
}
/**
* Get RevisionsPassword (hashed)
*
@@ -174,7 +162,7 @@ class PHPExcel_DocumentSecurity
function getRevisionsPassword() {
return $this->_revisionsPassword;
}
/**
* Set RevisionsPassword
*
@@ -189,7 +177,7 @@ class PHPExcel_DocumentSecurity
$this->_revisionsPassword = $pValue;
return $this;
}
/**
* Get WorkbookPassword (hashed)
*

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,22 +22,10 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
}
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/**
* PHPExcel_HashTable
*
@@ -53,14 +41,14 @@ class PHPExcel_HashTable
* @var array
*/
public $_items = array();
/**
* HashTable key map
*
* @var array
*/
public $_keyMap = array();
/**
* Create a new PHPExcel_HashTable
*
@@ -74,7 +62,7 @@ class PHPExcel_HashTable
$this->addFromSource($pSource);
}
}
/**
* Add HashTable items from source
*
@@ -88,7 +76,7 @@ class PHPExcel_HashTable
} else if (!is_array($pSource)) {
throw new Exception('Invalid array parameter passed.');
}
foreach ($pSource as $item) {
$this->add($item);
}
@@ -106,7 +94,7 @@ class PHPExcel_HashTable
$this->_keyMap[ count($this->_items) - 1 ] = $pSource->getHashCode();
}
}
/**
* Remove HashTable item
*
@@ -116,21 +104,21 @@ class PHPExcel_HashTable
public function remove(PHPExcel_IComparable $pSource = null) {
if (isset($this->_items[ $pSource->getHashCode() ])) {
unset($this->_items[ $pSource->getHashCode() ]);
$deleteKey = -1;
foreach ($this->_keyMap as $key => $value) {
foreach ($this->_keyMap as $key => $value) {
if ($deleteKey >= 0) {
$this->_keyMap[$key - 1] = $value;
}
if ($value == $pSource->getHashCode()) {
$deleteKey = $key;
}
}
unset($this->_keyMap[ count($this->_keyMap) - 1 ]);
}
unset($this->_keyMap[ count($this->_keyMap) - 1 ]);
}
}
/**
* Clear HashTable
*
@@ -139,7 +127,7 @@ class PHPExcel_HashTable
$this->_items = array();
$this->_keyMap = array();
}
/**
* Count
*
@@ -148,7 +136,7 @@ class PHPExcel_HashTable
public function count() {
return count($this->_items);
}
/**
* Get index for hash code
*
@@ -158,7 +146,7 @@ class PHPExcel_HashTable
public function getIndexForHashCode($pHashCode = '') {
return array_search($pHashCode, $this->_keyMap);
}
/**
* Get by index
*
@@ -170,10 +158,10 @@ class PHPExcel_HashTable
if (isset($this->_keyMap[$pIndex])) {
return $this->getByHashCode( $this->_keyMap[$pIndex] );
}
return null;
}
/**
* Get by hashcode
*
@@ -185,10 +173,10 @@ class PHPExcel_HashTable
if (isset($this->_items[$pHashCode])) {
return $this->_items[$pHashCode];
}
return null;
}
/**
* HashTable to array
*
@@ -197,7 +185,7 @@ class PHPExcel_HashTable
public function toArray() {
return $this->_items;
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -20,7 +20,7 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/

View File

@@ -22,28 +22,25 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Autoloader::Register();
PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
}
/** PHPExcel */
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
/** PHPExcel_IWriter */
require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
/** PHPExcel_IReader */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
/**
* PHPExcel_IOFactory
*
@@ -54,9 +51,11 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
class PHPExcel_IOFactory
{
/**
* Search locations
* Search locations
*
* @var array
* @var array
* @access private
* @static
*/
private static $_searchLocations = array(
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
@@ -64,9 +63,11 @@ class PHPExcel_IOFactory
);
/**
* Autoresolve classes
* Autoresolve classes
*
* @var array
* @var array
* @access private
* @static
*/
private static $_autoResolveClasses = array(
'Excel2007',
@@ -79,24 +80,28 @@ class PHPExcel_IOFactory
);
/**
* Private constructor for PHPExcel_IOFactory
* Private constructor for PHPExcel_IOFactory
*/
private function __construct() { }
/**
* Get search locations
* Get search locations
*
* @return array
* @static
* @access public
* @return array
*/
public static function getSearchLocations() {
return self::$_searchLocations;
}
} // function getSearchLocations()
/**
* Set search locations
* Set search locations
*
* @param array $value
* @throws Exception
* @static
* @access public
* @param array $value
* @throws Exception
*/
public static function setSearchLocations($value) {
if (is_array($value)) {
@@ -104,25 +109,30 @@ class PHPExcel_IOFactory
} else {
throw new Exception('Invalid parameter passed.');
}
}
} // function setSearchLocations()
/**
* Add search location
* Add search location
*
* @param string $type Example: IWriter
* @param string $location Example: PHPExcel/Writer/{0}.php
* @param string $classname Example: PHPExcel_Writer_{0}
* @static
* @access public
* @param string $type Example: IWriter
* @param string $location Example: PHPExcel/Writer/{0}.php
* @param string $classname Example: PHPExcel_Writer_{0}
*/
public static function addSearchLocation($type = '', $location = '', $classname = '') {
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
}
} // function addSearchLocation()
/**
* Create PHPExcel_Writer_IWriter
* Create PHPExcel_Writer_IWriter
*
* @param PHPExcel $phpExcel
* @param string $writerType Example: Excel2007
* @return PHPExcel_Writer_IWriter
* @static
* @access public
* @param PHPExcel $phpExcel
* @param string $writerType Example: Excel2007
* @return PHPExcel_Writer_IWriter
* @throws Exception
*/
public static function createWriter(PHPExcel $phpExcel, $writerType = '') {
// Search type
@@ -134,10 +144,6 @@ class PHPExcel_IOFactory
$className = str_replace('{0}', $writerType, $searchLocation['class']);
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
if (!class_exists($className)) {
require_once PHPEXCEL_ROOT . $classFile;
}
$instance = new $className($phpExcel);
if (!is_null($instance)) {
return $instance;
@@ -147,13 +153,16 @@ class PHPExcel_IOFactory
// Nothing found...
throw new Exception("No $searchType found for type $writerType");
}
} // function createWriter()
/**
* Create PHPExcel_Reader_IReader
* Create PHPExcel_Reader_IReader
*
* @param string $readerType Example: Excel2007
* @return PHPExcel_Reader_IReader
* @static
* @access public
* @param string $readerType Example: Excel2007
* @return PHPExcel_Reader_IReader
* @throws Exception
*/
public static function createReader($readerType = '') {
// Search type
@@ -165,10 +174,6 @@ class PHPExcel_IOFactory
$className = str_replace('{0}', $readerType, $searchLocation['class']);
$classFile = str_replace('{0}', $readerType, $searchLocation['path']);
if (!class_exists($className)) {
require_once PHPEXCEL_ROOT . $classFile;
}
$instance = new $className();
if (!is_null($instance)) {
return $instance;
@@ -178,24 +183,47 @@ class PHPExcel_IOFactory
// Nothing found...
throw new Exception("No $searchType found for type $readerType");
}
} // function createReader()
/**
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
*
* @param string $pFileName
* @return PHPExcel
* @static
* @access public
* @param string $pFileName
* @return PHPExcel
* @throws Exception
*/
public static function load($pFilename) {
$reader = self::createReaderForFile($pFilename);
return $reader->load($pFilename);
}
} // function load()
/**
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
* Identify file type using automatic PHPExcel_Reader_IReader resolution
*
* @param string $pFileName
* @return PHPExcel_Reader_IReader
* @static
* @access public
* @param string $pFileName
* @return string
* @throws Exception
*/
public static function identify($pFilename) {
$reader = self::createReaderForFile($pFilename);
$className = get_class($reader);
$classType = explode('_',$className);
unset($reader);
return array_pop($classType);
} // function identify()
/**
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
*
* @static
* @access public
* @param string $pFileName
* @return PHPExcel_Reader_IReader
* @throws Exception
*/
public static function createReaderForFile($pFilename) {
@@ -203,41 +231,33 @@ class PHPExcel_IOFactory
$pathinfo = pathinfo($pFilename);
if (isset($pathinfo['extension'])) {
switch (strtolower($pathinfo['extension'])) {
case 'xlsx':
$reader = self::createReader('Excel2007');
break;
case 'xls':
$reader = self::createReader('Excel5');
break;
case 'ods':
$reader = self::createReader('OOCalc');
break;
case 'slk':
$reader = self::createReader('SYLK');
break;
case 'xml':
$reader = self::createReader('Excel2003XML');
break;
case 'csv':
// Do nothing
// We must not try to use CSV reader since it loads
// all files including Excel files etc.
break;
default:
break;
}
// Let's see if we are lucky
if ($reader->canRead($pFilename)) {
if (isset($reader) && $reader->canRead($pFilename)) {
return $reader;
}
@@ -253,5 +273,5 @@ class PHPExcel_IOFactory
}
}
}
} // function createReaderForFile()
}

View File

@@ -22,28 +22,10 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
}
/** PHPExcel */
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_ReferenceHelper */
require_once PHPEXCEL_ROOT . 'PHPExcel/ReferenceHelper.php';
/**
* PHPExcel_NamedRange
*
@@ -81,6 +63,13 @@ class PHPExcel_NamedRange
*/
private $_localOnly;
/**
* Scope
*
* @var PHPExcel_Worksheet
*/
private $_scope;
/**
* Create a new NamedRange
*
@@ -88,8 +77,9 @@ class PHPExcel_NamedRange
* @param PHPExcel_Worksheet $pWorksheet
* @param string $pRange
* @param bool $pLocalOnly
* @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
*/
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false)
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
{
// Validate data
if (is_null($pName) || is_null($pWorksheet)|| is_null($pRange)) {
@@ -101,6 +91,8 @@ class PHPExcel_NamedRange
$this->_worksheet = $pWorksheet;
$this->_range = $pRange;
$this->_localOnly = $pLocalOnly;
$this->_scope = ($pLocalOnly == true) ?
(($pScope == null) ? $pWorksheet : $pScope) : null;
}
/**
@@ -201,6 +193,28 @@ class PHPExcel_NamedRange
*/
public function setLocalOnly($value = false) {
$this->_localOnly = $value;
$this->_scope = $value ? $this->_worksheet : null;
return $this;
}
/**
* Get scope
*
* @return PHPExcel_Worksheet|null
*/
public function getScope() {
return $this->_scope;
}
/**
* Set scope
*
* @param PHPExcel_Worksheet|null $value
* @return PHPExcel_NamedRange
*/
public function setScope(PHPExcel_Worksheet $value = null) {
$this->_scope = $value;
$this->_localOnly = ($value == null) ? false : true;
return $this;
}
@@ -208,7 +222,7 @@ class PHPExcel_NamedRange
* Resolve a named range to a regular cell range
*
* @param string $pNamedRange Named range
* @param PHPExcel_Worksheet $pSheet Worksheet
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
* @return PHPExcel_NamedRange
*/
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) {

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
@@ -32,24 +32,15 @@ if (!defined('PHPEXCEL_ROOT')) {
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Autoloader::Register();
PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
}
/** PHPExcel */
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
/** PHPExcel_Reader_IReader */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Reader_DefaultReadFilter */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
/**
* PHPExcel_Reader_CSV
*
@@ -60,49 +51,55 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
{
/**
* Input encoding
* Input encoding
*
* @var string
* @access private
* @var string
*/
private $_inputEncoding;
/**
* Delimiter
* Delimiter
*
* @var string
* @access private
* @var string
*/
private $_delimiter;
/**
* Enclosure
* Enclosure
*
* @var string
* @access private
* @var string
*/
private $_enclosure;
/**
* Line ending
* Line ending
*
* @var string
* @access private
* @var string
*/
private $_lineEnding;
/**
* Sheet index to read
* Sheet index to read
*
* @var int
* @access private
* @var int
*/
private $_sheetIndex;
/**
* PHPExcel_Reader_IReadFilter instance
* PHPExcel_Reader_IReadFilter instance
*
* @var PHPExcel_Reader_IReadFilter
* @access private
* @var PHPExcel_Reader_IReadFilter
*/
private $_readFilter = null;
/**
* Create a new PHPExcel_Reader_CSV
* Create a new PHPExcel_Reader_CSV
*/
public function __construct() {
$this->_inputEncoding = 'UTF-8';
@@ -111,15 +108,17 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
$this->_lineEnding = PHP_EOL;
$this->_sheetIndex = 0;
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
} // function __construct()
/**
* Can the current PHPExcel_Reader_IReader read the file?
* Can the current PHPExcel_Reader_IReader read the file?
*
* @param string $pFileName
* @return boolean
*/
public function canRead($pFilename)
* @access public
* @param string $pFileName
* @return boolean
* @throws Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
@@ -127,13 +126,15 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
}
return true;
}
} // function canRead()
/**
* Loads PHPExcel from file
* Loads PHPExcel from file
*
* @param string $pFilename
* @throws Exception
* @access public
* @param string $pFilename
* @return PHPExcel
* @throws Exception
*/
public function load($pFilename)
{
@@ -142,52 +143,60 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
} // function load()
/**
* Read filter
* Read filter
*
* @return PHPExcel_Reader_IReadFilter
* @access public
* @return PHPExcel_Reader_IReadFilter
*/
public function getReadFilter() {
return $this->_readFilter;
}
} // function getReadFilter()
/**
* Set read filter
* Set read filter
*
* @param PHPExcel_Reader_IReadFilter $pValue
* @access public
* @param PHPExcel_Reader_IReadFilter $pValue
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
$this->_readFilter = $pValue;
}
return $this;
} // function setReadFilter()
/**
* Set input encoding
* Set input encoding
*
* @param string $pValue Input encoding
* @access public
* @param string $pValue Input encoding
*/
public function setInputEncoding($pValue = 'UTF-8')
{
$this->_inputEncoding = $pValue;
}
return $this;
} // function setInputEncoding()
/**
* Get input encoding
* Get input encoding
*
* @return string
* @access public
* @return string
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
}
} // function getInputEncoding()
/**
* Loads PHPExcel from file into PHPExcel instance
* Loads PHPExcel from file into PHPExcel instance
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @throws Exception
* @access public
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
@@ -214,7 +223,6 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
fgets($fileHandle, 4) == "\xEF\xBB\xBF" ?
fseek($fileHandle, 3) : fseek($fileHandle, 0);
break;
default:
break;
}
@@ -231,16 +239,14 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
// Unescape enclosures
$rowData[$i] = str_replace("\\" . $this->_enclosure, $this->_enclosure, $rowData[$i]);
$rowData[$i] = str_replace($this->_enclosure . $this->_enclosure, $this->_enclosure, $rowData[$i]);
// Convert encoding if necessary
if ($this->_inputEncoding !== 'UTF-8') {
$rowData[$i] = PHPExcel_Shared_String::ConvertEncoding($rowData[$i], 'UTF-8', $this->_inputEncoding);
}
// Set cell value
$objPHPExcel->getActiveSheet()->setCellValue(
$columnLetter . $currentRow, $rowData[$i]
);
$objPHPExcel->getActiveSheet()->getCell($columnLetter . $currentRow)->setValue($rowData[$i]);
}
}
}
@@ -250,42 +256,46 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
// Return
return $objPHPExcel;
}
} // function loadIntoExisting()
/**
* Get delimiter
* Get delimiter
*
* @return string
* @access public
* @return string
*/
public function getDelimiter() {
return $this->_delimiter;
}
} // function getDelimiter()
/**
* Set delimiter
* Set delimiter
*
* @param string $pValue Delimiter, defaults to ,
* @return PHPExcel_Reader_CSV
* @access public
* @param string $pValue Delimiter, defaults to ,
* @return PHPExcel_Reader_CSV
*/
public function setDelimiter($pValue = ',') {
$this->_delimiter = $pValue;
return $this;
}
} // function setDelimiter()
/**
* Get enclosure
* Get enclosure
*
* @return string
* @access public
* @return string
*/
public function getEnclosure() {
return $this->_enclosure;
}
} // function getEnclosure()
/**
* Set enclosure
* Set enclosure
*
* @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Reader_CSV
* @access public
* @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Reader_CSV
*/
public function setEnclosure($pValue = '"') {
if ($pValue == '') {
@@ -293,45 +303,49 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
}
$this->_enclosure = $pValue;
return $this;
}
} // function setEnclosure()
/**
* Get line ending
* Get line ending
*
* @return string
* @access public
* @return string
*/
public function getLineEnding() {
return $this->_lineEnding;
}
} // function getLineEnding()
/**
* Set line ending
* Set line ending
*
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
* @return PHPExcel_Reader_CSV
* @access public
* @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;
}
} // function setLineEnding()
/**
* Get sheet index
* Get sheet index
*
* @return int
* @access public
* @return int
*/
public function getSheetIndex() {
return $this->_sheetIndex;
}
} // function getSheetIndex()
/**
* Set sheet index
* Set sheet index
*
* @param int $pValue Sheet index
* @return PHPExcel_Reader_CSV
* @access public
* @param int $pValue Sheet index
* @return PHPExcel_Reader_CSV
*/
public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue;
return $this;
}
} // function setSheetIndex()
}

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,7 +22,7 @@
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
@@ -32,12 +32,15 @@ if (!defined('PHPEXCEL_ROOT')) {
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Autoloader::Register();
PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
}
/** PHPExcel_Reader_IReadFilter */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReadFilter.php';
/**
* PHPExcel_Reader_DefaultReadFilter
*
@@ -54,7 +57,7 @@ class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
* @param $row Row index
* @param $worksheetName Optional worksheet name
* @return boolean
*/
*/
public function readCell($column, $row, $worksheetName = '') {
return true;
}

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
@@ -32,27 +32,15 @@ if (!defined('PHPEXCEL_ROOT')) {
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Autoloader::Register();
PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
}
/** PHPExcel */
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
/** PHPExcel_Reader_IReader */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Calculation */
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation.php';
/** PHPExcel_Reader_DefaultReadFilter */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
/**
* PHPExcel_Reader_Excel2003XML
*
@@ -236,6 +224,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws Exception
*/
public function load($pFilename)
@@ -288,6 +277,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
@@ -508,7 +498,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
$objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($worksheetID);
if (isset($worksheet_ss['Name'])) {
$worksheetName = $worksheet_ss['Name'];
$worksheetName = (string) $worksheet_ss['Name'];
$objPHPExcel->getActiveSheet()->setTitle($worksheetName);
}
@@ -660,7 +650,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
// print_r($this->_styles[$style]);
// echo '<br />';
if (!$objPHPExcel->getActiveSheet()->cellExists($columnID.$rowID)) {
$objPHPExcel->getActiveSheet()->setCellValue($columnID.$rowID,NULL);
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(NULL);
}
$objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->_styles[$style]);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -22,41 +22,9 @@
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
}
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Shared_Escher_DggContainer */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer.php';
/** PHPExcel_Shared_Escher_DggContainer_BstoreContainer */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php';
/** PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php';
/** PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php';
/** PHPExcel_Shared_Escher_DgContainer */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DgContainer.php';
/** PHPExcel_Shared_Escher_DgContainer_SpgrContainer */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php';
/** PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php';
/**
* PHPExcel_Reader_Excel5_Escher
*
@@ -122,7 +90,7 @@ class PHPExcel_Reader_Excel5_Escher
{
$this->_object = $object;
}
/**
* Load Escher stream data. May be a partial Escher stream.
*
@@ -136,14 +104,14 @@ class PHPExcel_Reader_Excel5_Escher
$this->_dataSize = strlen($this->_data);
$this->_pos = 0;
// Parse Escher stream
while ($this->_pos < $this->_dataSize) {
// offset: 2; size: 2: Record Type
$fbt = $this->_GetInt2d($this->_data, $this->_pos + 2);
switch ($fbt) {
case self::DGGCONTAINER: $this->_readDggContainer(); break;
case self::DGG: $this->_readDgg(); break;
@@ -166,7 +134,7 @@ class PHPExcel_Reader_Excel5_Escher
default: $this->_readDefault(); break;
}
}
return $this->_object;
}
@@ -177,16 +145,16 @@ class PHPExcel_Reader_Excel5_Escher
{
// offset 0; size: 2; recVer and recInstance
$verInstance = $this->_GetInt2d($this->_data, $this->_pos);
// offset: 2; size: 2: Record Type
$fbt = $this->_GetInt2d($this->_data, $this->_pos + 2);
// bit: 0-3; mask: 0x000F; recVer
$recVer = (0x000F & $verInstance) >> 0;
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
}
@@ -216,7 +184,7 @@ class PHPExcel_Reader_Excel5_Escher
{
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
}
@@ -245,22 +213,22 @@ class PHPExcel_Reader_Excel5_Escher
private function _readBSE()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
// add BSE to BstoreContainer
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
$this->_object->addBSE($BSE);
$BSE->setBLIPType($recInstance);
// offset: 0; size: 1; btWin32 (MSOBLIPTYPE)
$btWin32 = ord($recordData[0]);
@@ -311,38 +279,38 @@ class PHPExcel_Reader_Excel5_Escher
private function _readBlipJPEG()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$pos = 0;
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
$rgbUid1 = substr($recordData, 0, 16);
$pos += 16;
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
if (in_array($recInstance, array(0x046B, 0x06E3))) {
$rgbUid2 = substr($recordData, 16, 16);
$pos += 16;
}
// offset: var; size: 1; tag
$tag = ord($recordData{$pos});
$pos += 1;
// offset: var; size: var; the raw image data
$data = substr($recordData, $pos);
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($data);
$this->_object->setBlip($blip);
}
@@ -352,38 +320,38 @@ class PHPExcel_Reader_Excel5_Escher
private function _readBlipPNG()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
$pos = 0;
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
$rgbUid1 = substr($recordData, 0, 16);
$pos += 16;
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
if ($recInstance == 0x06E1) {
$rgbUid2 = substr($recordData, 16, 16);
$pos += 16;
}
// offset: var; size: 1; tag
$tag = ord($recordData{$pos});
$pos += 1;
// offset: var; size: var; the raw image data
$data = substr($recordData, $pos);
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($data);
$this->_object->setBlip($blip);
}
@@ -393,13 +361,13 @@ class PHPExcel_Reader_Excel5_Escher
private function _readOPT()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
@@ -412,7 +380,7 @@ class PHPExcel_Reader_Excel5_Escher
private function _readTertiaryOPT()
{
// offset: 0; size: 2; recVer and recInstance
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
@@ -566,10 +534,10 @@ class PHPExcel_Reader_Excel5_Escher
{
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
// move stream pointer to next record
$this->_pos += 8 + $length;
// offset: 2; size: 2; upper-left corner column index (0-based)
$c1 = $this->_GetInt2d($recordData, 2);

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
@@ -32,27 +32,15 @@ if (!defined('PHPEXCEL_ROOT')) {
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Autoloader::Register();
PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
}
/** PHPExcel */
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
/** PHPExcel_Reader_IReader */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Calculation */
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation.php';
/** PHPExcel_Reader_DefaultReadFilter */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
/**
* PHPExcel_Reader_OOCalc
*
@@ -211,6 +199,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws Exception
*/
public function load($pFilename)
@@ -238,6 +227,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
@@ -335,7 +325,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
$objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($worksheetID);
if (isset($worksheetDataAttributes['name'])) {
$worksheetName = $worksheetDataAttributes['name'];
$worksheetName = (string) $worksheetDataAttributes['name'];
$objPHPExcel->getActiveSheet()->setTitle($worksheetName);
}
@@ -392,7 +382,9 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
break;
case 'date' :
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellDataOfficeAttributes['date-value']));
$dateObj = date_create($cellDataOfficeAttributes['date-value']);
list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s'));
$dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second);
if ($dataValue != floor($dataValue)) {
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
} else {
@@ -421,6 +413,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
if (($key % 2) == 0) {
$value = preg_replace('/\[\.(.*):\.(.*)\]/Ui','$1:$2',$value);
$value = preg_replace('/\[\.(.*)\]/Ui','$1',$value);
$value = PHPExcel_Calculation::_translateSeparator(';',',',$value);
}
}
unset($value);

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
@@ -32,27 +32,15 @@ if (!defined('PHPEXCEL_ROOT')) {
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Autoloader::Register();
PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
}
/** PHPExcel */
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
/** PHPExcel_Reader_IReader */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Calculation */
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation.php';
/** PHPExcel_Reader_DefaultReadFilter */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
/**
* PHPExcel_Reader_SYLK
*
@@ -167,6 +155,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
* Loads PHPExcel from file
*
* @param string $pFilename
* @return PHPExcel
* @throws Exception
*/
public function load($pFilename)
@@ -194,6 +183,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
$this->_readFilter = $pValue;
return $this;
}
/**
@@ -204,6 +194,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
public function setInputEncoding($pValue = 'ANSI')
{
$this->_inputEncoding = $pValue;
return $this;
}
/**
@@ -221,6 +212,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
*
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
@@ -248,8 +240,17 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
// Loop through file
$rowData = array();
$column = $row = '';
// loop through one row (line) at a time in the file
while (($rowData = fgets($fileHandle)) !== FALSE) {
$rowData = explode("\t",str_replace('<27>',';',str_replace(';',"\t",str_replace(';;','<27>',rtrim($rowData)))));
// convert SYLK encoded $rowData to UTF-8
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
// explode each row at semicolons while taking into account that literal semicolon (;)
// is escaped like this (;;)
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
$dataType = array_shift($rowData);
// Read shared styles
if ($dataType == 'P') {
@@ -337,8 +338,9 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
}
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
// Set cell value
$objPHPExcel->getActiveSheet()->setCellValue($columnLetter.$row, (($hasCalculatedValue) ? $cellDataFormula : $cellData));
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
if ($hasCalculatedValue) {
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
@@ -503,4 +505,5 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
$this->_sheetIndex = $pValue;
return $this;
}
}

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
@@ -32,18 +32,15 @@ if (!defined('PHPEXCEL_ROOT')) {
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Autoloader::Register();
PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
}
/** PHPExcel */
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
/** PHPExcel_Reader_IReader */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
/** PHPExcel_Shared_File */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/File.php';
/**
* PHPExcel_Reader_Serialized
*
@@ -58,17 +55,17 @@ class PHPExcel_Reader_Serialized implements PHPExcel_Reader_IReader
*
* @param string $pFileName
* @return boolean
*/
public function canRead($pFilename)
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
return $this->fileSupportsUnserializePHPExcel($pFilename);
}
/**
* Loads PHPExcel Serialized file
*

View File

@@ -22,40 +22,10 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
}
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Cell_DataType */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
/** PHPExcel_Style */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style.php';
/** PHPExcel_Worksheet_Drawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing.php';
/** PHPExcel_Calculation_FormulaParser */
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/FormulaParser.php';
/** PHPExcel_Calculation_FormulaToken */
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/FormulaToken.php';
/**
* PHPExcel_ReferenceHelper (Singleton)
*
@@ -100,12 +70,6 @@ class PHPExcel_ReferenceHelper
* @throws Exception
*/
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null) {
// Get a copy of the cell collection
/*$aTemp = $pSheet->getCellCollection();
$aCellCollection = array();
foreach ($aTemp as $key => $value) {
$aCellCollection[$key] = clone $value;
}*/
$aCellCollection = $pSheet->getCellCollection();
// Get coordinates of $pBefore
@@ -148,7 +112,9 @@ class PHPExcel_ReferenceHelper
// Loop through cells, bottom-up, and change cell coordinates
while ( ($cell = ($pNumCols < 0 || $pNumRows < 0) ? array_shift($aCellCollection) : array_pop($aCellCollection)) ) {
while (($cellID = ($pNumCols < 0 || $pNumRows < 0) ? array_shift($aCellCollection) : array_pop($aCellCollection))) {
$cell = $pSheet->getCell($cellID);
// New coordinates
$newCoordinates = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1 + $pNumCols ) . ($cell->getRow() + $pNumRows);
@@ -165,17 +131,15 @@ class PHPExcel_ReferenceHelper
// Insert this cell at its new location
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
// Formula should be adjusted
$pSheet->setCellValue(
$newCoordinates
, $this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows)
);
$pSheet->getCell($newCoordinates)
->setValue($this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows));
} else {
// Formula should not be adjusted
$pSheet->setCellValue($newCoordinates, $cell->getValue());
$pSheet->getCell($newCoordinates)->setValue($cell->getValue());
}
// Clear the original cell
$pSheet->setCellValue($cell->getCoordinate(), '');
$pSheet->getCell($cell->getCoordinate())->setValue('');
}
}
@@ -459,9 +423,10 @@ class PHPExcel_ReferenceHelper
if ($oldName == '') {
return;
}
foreach ($pPhpExcel->getWorksheetIterator() as $sheet) {
foreach ($sheet->getCellCollection(false) as $cell) {
foreach ($sheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID);
if (!is_null($cell) && $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
$formula = $cell->getValue();
if (strpos($formula, $oldName) !== false) {

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,39 +22,10 @@
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
}
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Cell_DataType */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
/** PHPExcel_RichText_ITextElement */
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/ITextElement.php';
/** PHPExcel_RichText_TextElement */
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/TextElement.php';
/** PHPExcel_RichText_Run */
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/Run.php';
/** PHPExcel_Style_Font */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
/**
* PHPExcel_RichText
*
@@ -70,14 +41,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
* @var PHPExcel_RichText_ITextElement[]
*/
private $_richTextElements;
/**
* Parent cell
*
* @var PHPExcel_Cell
*/
private $_parent;
/**
* Create a new PHPExcel_RichText instance
*
@@ -88,24 +52,21 @@ class PHPExcel_RichText implements PHPExcel_IComparable
{
// Initialise variables
$this->_richTextElements = array();
// Set parent?
// Rich-Text string attached to cell?
if (!is_null($pCell)) {
// Set parent cell
$this->_parent = $pCell;
// Add cell text and style
if ($this->_parent->getValue() != "") {
$objRun = new PHPExcel_RichText_Run($this->_parent->getValue());
$objRun->setFont(clone $this->_parent->getParent()->getStyle($this->_parent->getCoordinate())->getFont());
if ($pCell->getValue() != "") {
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
$objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont());
$this->addText($objRun);
}
// Set parent value
$this->_parent->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
$pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
}
}
/**
* Add text
*
@@ -118,7 +79,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
$this->_richTextElements[] = $pText;
return $this;
}
/**
* Create text
*
@@ -132,7 +93,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
$this->addText($objText);
return $objText;
}
/**
* Create text run
*
@@ -146,7 +107,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
$this->addText($objText);
return $objText;
}
/**
* Get plain text
*
@@ -156,16 +117,16 @@ class PHPExcel_RichText implements PHPExcel_IComparable
{
// Return value
$returnValue = '';
// Loop through all PHPExcel_RichText_ITextElement
foreach ($this->_richTextElements as $text) {
$returnValue .= $text->getText();
}
// Return
return $returnValue;
}
/**
* Convert to string
*
@@ -174,7 +135,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
public function __toString() {
return $this->getPlainText();
}
/**
* Get Rich Text elements
*
@@ -184,7 +145,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
{
return $this->_richTextElements;
}
/**
* Set Rich Text elements
*
@@ -201,70 +162,30 @@ class PHPExcel_RichText implements PHPExcel_IComparable
}
return $this;
}
/**
* Get parent
*
* @return PHPExcel_Cell
*/
public function getParent() {
return $this->_parent;
}
/**
* Set parent
*
* @param PHPExcel_Cell $value
* @return PHPExcel_RichText
*/
public function setParent(PHPExcel_Cell $value) {
// Set parent
$this->_parent = $value;
// Set parent value
$this->_parent->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
// Verify style information
$sheet = $this->_parent->getParent();
$cellFont = $sheet->getStyle($this->_parent->getCoordinate())->getFont()->getSharedComponent();
foreach ($this->getRichTextElements() as $element) {
if (!($element instanceof PHPExcel_RichText_Run)) continue;
if ($element->getFont()->getHashCode() == $sheet->getDefaultStyle()->getFont()->getHashCode()) {
if ($element->getFont()->getHashCode() != $cellFont->getHashCode()) {
$element->setFont(clone $cellFont);
}
}
}
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
$hashElements = '';
foreach ($this->_richTextElements as $element) {
$hashElements .= $element->getHashCode();
}
return md5(
$hashElements
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if ($key == '_parent') continue;
if (is_object($value)) {
$this->$key = clone $value;
} else {

View File

@@ -6,12 +6,12 @@
* 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
@@ -20,22 +20,10 @@
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Style_Font */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
/**
* PHPExcel_RichText_ITextElement
*
@@ -49,28 +37,28 @@ interface PHPExcel_RichText_ITextElement
* Get text
*
* @return string Text
*/
*/
public function getText();
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
*/
public function setText($pText = '');
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
*/
public function getFont();
/**
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode();
}

View File

@@ -6,12 +6,12 @@
* 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
@@ -20,28 +20,10 @@
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_RichText_ITextElement */
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/ITextElement.php';
/** PHPExcel_RichText_TextElement */
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/TextElement.php';
/** PHPExcel_Style_Font */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
/**
* PHPExcel_RichText_Run
*
@@ -50,14 +32,14 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
{
{
/**
* Font
*
* @var PHPExcel_Style_Font
*/
private $_font;
/**
* Create a new PHPExcel_RichText_Run instance
*
@@ -69,33 +51,33 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
$this->setText($pText);
$this->_font = new PHPExcel_Style_Font();
}
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
*/
public function getFont() {
return $this->_font;
}
/**
* Set font
*
* @param PHPExcel_Style_Font $pFont Font
* @throws Exception
* @return PHPExcel_RichText_ITextElement
*/
*/
public function setFont(PHPExcel_Style_Font $pFont = null) {
$this->_font = $pFont;
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
return md5(
$this->getText()
@@ -103,7 +85,7 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -6,12 +6,12 @@
* 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
@@ -20,25 +20,10 @@
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_RichText_ITextElement */
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/ITextElement.php';
/** PHPExcel_Style_Font */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
/**
* PHPExcel_RichText_TextElement
*
@@ -54,7 +39,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
* @var string
*/
private $_text;
/**
* Create a new PHPExcel_RichText_TextElement instance
*
@@ -65,48 +50,48 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
// Initialise variables
$this->_text = $pText;
}
/**
* Get text
*
* @return string Text
*/
*/
public function getText() {
return $this->_text;
}
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
*/
*/
public function setText($pText = '') {
$this->_text = $pText;
return $this;
}
/**
* Get font
*
* @return PHPExcel_Style_Font
*/
*/
public function getFont() {
return null;
}
/**
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
return md5(
$this->_text
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -0,0 +1,65 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_Settings
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Autoloader::Register();
PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
}
class PHPExcel_Settings
{
public static function getCacheStorageMethod() {
return PHPExcel_CachedObjectStorageFactory::$_cacheStorageMethod;
} // function getCacheStorageMethod()
public static function getCacheStorageClass() {
return PHPExcel_CachedObjectStorageFactory::$_cacheStorageClass;
} // function getCacheStorageClass()
public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, $arguments = array()) {
return PHPExcel_CachedObjectStorageFactory::initialize($method,$arguments);
} // function setCacheStorageMethod()
public static function setLocale($locale){
return PHPExcel_Calculation::getInstance()->setLocale($locale);
} // function setLocale()
}

View File

@@ -0,0 +1,94 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2010 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_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.3, 2010-05-17
*/
/**
* PHPExcel_Shared_CodePage
*
* @category PHPExcel
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Shared_CodePage
{
/**
* Convert Microsoft Code Page Identifier to Code Page Name which iconv
* and mbstring understands
*
* @param int $number Microsoft Code Page Indentifier
* @return string Code Page Name
* @throws Exception
*/
public static function NumberToName($codePage = '1252')
{
switch ($codePage) {
case 367: return 'ASCII'; break; // ASCII
case 437: return 'CP437'; break; //OEM US
case 720: throw new Exception('Code page 720 not supported.');
break; //OEM Arabic
case 737: return 'CP737'; break; //OEM Greek
case 775: return 'CP775'; break; //OEM Baltic
case 850: return 'CP850'; break; //OEM Latin I
case 852: return 'CP852'; break; //OEM Latin II (Central European)
case 855: return 'CP855'; break; //OEM Cyrillic
case 857: return 'CP857'; break; //OEM Turkish
case 858: return 'CP858'; break; //OEM Multilingual Latin I with Euro
case 860: return 'CP860'; break; //OEM Portugese
case 861: return 'CP861'; break; //OEM Icelandic
case 862: return 'CP862'; break; //OEM Hebrew
case 863: return 'CP863'; break; //OEM Canadian (French)
case 864: return 'CP864'; break; //OEM Arabic
case 865: return 'CP865'; break; //OEM Nordic
case 866: return 'CP866'; break; //OEM Cyrillic (Russian)
case 869: return 'CP869'; break; //OEM Greek (Modern)
case 874: return 'CP874'; break; //ANSI Thai
case 932: return 'CP932'; break; //ANSI Japanese Shift-JIS
case 936: return 'CP936'; break; //ANSI Chinese Simplified GBK
case 949: return 'CP949'; break; //ANSI Korean (Wansung)
case 950: return 'CP950'; break; //ANSI Chinese Traditional BIG5
case 1200: return 'UTF-16LE'; break; //UTF-16 (BIFF8)
case 1250: return 'CP1250'; break; // ANSI Latin II (Central European)
case 1251: return 'CP1251'; break; //ANSI Cyrillic
case 1252: return 'CP1252'; break; //ANSI Latin I (BIFF4-BIFF7)
case 1253: return 'CP1253'; break; //ANSI Greek
case 1254: return 'CP1254'; break; //ANSI Turkish
case 1255: return 'CP1255'; break; //ANSI Hebrew
case 1256: return 'CP1256'; break; //ANSI Arabic
case 1257: return 'CP1257'; break; //ANSI Baltic
case 1258: return 'CP1258'; break; //ANSI Vietnamese
case 1361: return 'CP1361'; break; //ANSI Korean (Johab)
case 10000: return 'MAC'; break; //Apple Roman
case 32768: return 'MAC'; break; //Apple Roman
case 32769: throw new Exception('Code page 32769 not supported.');
break; //ANSI Latin I (BIFF2-BIFF3)
case 65001: return 'UTF-8'; break; //Unicode (UTF-8)
}
throw new Exception('Unknown codepage: ' . $codePage);
}
}

View File

@@ -23,25 +23,10 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Style_NumberFormat */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
/**
* PHPExcel_Shared_Date
*
@@ -279,4 +264,40 @@ class PHPExcel_Shared_Date
// No date...
return false;
} // function isDateTimeFormatCode()
/**
* Convert a date/time string to Excel time
*
* @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
* @return float|false Excel date/time serial value
*/
public static function stringToExcel($dateValue = '') {
// restrict to dates and times like these because date_parse accepts too many strings
// '2009-12-31'
// '2009-12-31 15:59'
// '2009-12-31 15:59:10'
if (!preg_match('/^\d{4}\-\d{1,2}\-\d{1,2}( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/', $dateValue)) {
return false;
}
// now try with date_parse
$PHPDateArray = date_parse($dateValue);
if ($PHPDateArray['error_count'] == 0) {
$year = $PHPDateArray['year'] !== false ? $PHPDateArray['year'] : self::getExcelCalendar();
$month = $PHPDateArray['month'] !== false ? $PHPDateArray['month'] : 1;
$day = $PHPDateArray['day'] !== false ? $PHPDateArray['day'] : 0;
$hour = $PHPDateArray['hour'] !== false ? $PHPDateArray['hour'] : 0;
$minute = $PHPDateArray['minute'] !== false ? $PHPDateArray['minute'] : 0;
$second = $PHPDateArray['second'] !== false ? $PHPDateArray['second'] : 0;
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second);
return $excelDateValue;
}
return false;
}
}

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,22 +22,10 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Shared_String */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Font.php';
/**
* PHPExcel_Shared_Drawing
*
@@ -56,7 +44,7 @@ class PHPExcel_Shared_Drawing
public static function pixelsToEMU($pValue = 0) {
return round($pValue * 9525);
}
/**
* Convert EMU to pixels
*
@@ -70,7 +58,7 @@ class PHPExcel_Shared_Drawing
return 0;
}
}
/**
* Convert pixels to column width. Exact algorithm not known.
* By inspection of a real Excel file using Calibri 11, one finds 1000px ~ 142.85546875
@@ -142,7 +130,7 @@ class PHPExcel_Shared_Drawing
public static function pixelsToPoints($pValue = 0) {
return $pValue * 0.67777777;
}
/**
* Convert points to pixels
*
@@ -166,7 +154,7 @@ class PHPExcel_Shared_Drawing
public static function degreesToAngle($pValue = 0) {
return (int)round($pValue * 60000);
}
/**
* Convert angle to degrees
*
@@ -180,4 +168,105 @@ class PHPExcel_Shared_Drawing
return 0;
}
}
/**
* Create a new image from file. By alexander at alexauto dot nl
*
* @link http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214
* @param string $filename Path to Windows DIB (BMP) image
* @return resource
*/
public static function imagecreatefrombmp($p_sFile)
{
// Load the image into a string
$file = fopen($p_sFile,"rb");
$read = fread($file,10);
while(!feof($file)&&($read<>""))
$read .= fread($file,1024);
$temp = unpack("H*",$read);
$hex = $temp[1];
$header = substr($hex,0,108);
// Process the header
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
if (substr($header,0,4)=="424d")
{
// Cut it in parts of 2 bytes
$header_parts = str_split($header,2);
// Get the width 4 bytes
$width = hexdec($header_parts[19].$header_parts[18]);
// Get the height 4 bytes
$height = hexdec($header_parts[23].$header_parts[22]);
// Unset the header params
unset($header_parts);
}
// Define starting X and Y
$x = 0;
$y = 1;
// Create newimage
$image = imagecreatetruecolor($width,$height);
// Grab the body from the image
$body = substr($hex,108);
// Calculate if padding at the end-line is needed
// Divided by two to keep overview.
// 1 byte = 2 HEX-chars
$body_size = (strlen($body)/2);
$header_size = ($width*$height);
// Use end-line padding? Only when needed
$usePadding = ($body_size>($header_size*3)+4);
// Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
// Calculate the next DWORD-position in the body
for ($i=0;$i<$body_size;$i+=3)
{
// Calculate line-ending and padding
if ($x>=$width)
{
// If padding needed, ignore image-padding
// Shift i to the ending of the current 32-bit-block
if ($usePadding)
$i += $width%4;
// Reset horizontal position
$x = 0;
// Raise the height-position (bottom-up)
$y++;
// Reached the image-height? Break the for-loop
if ($y>$height)
break;
}
// Calculation of the RGB-pixel (defined as BGR in image-data)
// Define $i_pos as absolute position in the body
$i_pos = $i*2;
$r = hexdec($body[$i_pos+4].$body[$i_pos+5]);
$g = hexdec($body[$i_pos+2].$body[$i_pos+3]);
$b = hexdec($body[$i_pos].$body[$i_pos+1]);
// Calculate and draw the pixel
$color = imagecolorallocate($image,$r,$g,$b);
imagesetpixel($image,$x,$height-$y,$color);
// Raise the horizontal position
$x++;
}
// Unset the body / free the memory
unset($body);
// Return image-object
return $image;
}
}

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/**

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/**

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/**

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/**

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/**

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/**

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/**

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared_Escher
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/**

View File

@@ -22,26 +22,9 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Shared_Drawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Drawing.php';
/** PHPExcel_Shared_Font */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Font.php';
/**
* PHPExcel_Shared_Excel5
*
@@ -264,7 +247,7 @@ class PHPExcel_Shared_Excel5
list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinates);
$col_start = PHPExcel_Cell::columnIndexFromString($column) - 1;
$row_start = $row - 1;
$x1 = $offsetX;
$y1 = $offsetY;

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,22 +22,10 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Shared_String */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
/**
* PHPExcel_Shared_Font
*
@@ -71,7 +59,7 @@ class PHPExcel_Shared_Font
const CHARSET_ANSI_THAI = 0xDE;
const CHARSET_ANSI_LATIN_II = 0xEE;
const CHARSET_OEM_LATIN_I = 0xFF;
// XXX: Constants created!
/** Font filenames */
const ARIAL = 'arial.ttf';
@@ -230,7 +218,7 @@ class PHPExcel_Shared_Font
{
self::$trueTypeFontPath = $pValue;
}
/**
* Get the path to the folder containing .ttf files.
*
@@ -240,26 +228,31 @@ class PHPExcel_Shared_Font
{
return self::$trueTypeFontPath;
}
/**
* Calculate an (approximate) OpenXML column width, based on font size and text contained
*
* @param int $fontSize Font size (in pixels or points)
* @param bool $fontSizeInPixels Is the font size specified in pixels (true) or in points (false) ?
* @param string $columnText Text to calculate width
* @param string $cellText Text to calculate width
* @param int $rotation Rotation angle
* @return int Column width
*/
public static function calculateColumnWidth(PHPExcel_Style_Font $font, $columnText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) {
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 ($columnText instanceof PHPExcel_RichText) {
$columnText = $columnText->getPlainText();
if ($cellText instanceof PHPExcel_RichText) {
$cellText = $cellText->getPlainText();
}
// Only measure the part before the first newline character (is always "\n")
if (strpos($columnText, "\n") !== false) {
$columnText = substr($columnText, 0, strpos($columnText, "\n"));
// Special case if there are one or more newline characters ("\n")
if (strpos($cellText, "\n") !== false) {
$lineTexts = explode("\n", $cellText);
$lineWitdhs = array();
foreach ($lineTexts as $lineText) {
$lineWidths[] = self::calculateColumnWidth($font, $lineText, $rotation = 0, $defaultFont);
}
return max($lineWidths); // width of longest line in cell
}
// Try to get the exact text width in pixels
@@ -270,14 +263,14 @@ class PHPExcel_Shared_Font
}
// Width of text in pixels excl. padding
$columnWidth = self::getTextWidthPixelsExact($columnText, $font, $rotation);
$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 (Exception $e) {
// Width of text in pixels excl. padding, approximation
$columnWidth = self::getTextWidthPixelsApprox($columnText, $font, $rotation);
$columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation);
// Excel adds some padding, just use approx width of 'n' glyph
$columnWidth += self::getTextWidthPixelsApprox('n', $font, 0);
@@ -318,7 +311,7 @@ class PHPExcel_Shared_Font
$upperRightCornerY = $textBox[5];
$upperLeftCornerX = $textBox[6];
$upperLeftCornerY = $textBox[7];
// Consider the rotation when calculating the width
$textWidth = max($lowerRightCornerX - $upperLeftCornerX, $upperRightCornerX - $lowerLeftCornerX);
@@ -391,7 +384,7 @@ class PHPExcel_Shared_Font
public static function fontSizeToPixels($fontSizeInPoints = 11) {
return (int) ((4 / 3) * $fontSizeInPoints);
}
/**
* Calculate an (approximate) pixel size, based on inch size
*
@@ -401,7 +394,7 @@ class PHPExcel_Shared_Font
public static function inchSizeToPixels($sizeInInch = 1) {
return ($sizeInInch * 96);
}
/**
* Calculate an (approximate) pixel size, based on centimeter size
*
@@ -431,34 +424,34 @@ class PHPExcel_Shared_Font
switch ($name) {
case 'Arial':
$fontFile = (
$bold ? ($italic ? self::ARIAL_BOLD_ITALIC : self::ARIAL_BOLD)
$bold ? ($italic ? self::ARIAL_BOLD_ITALIC : self::ARIAL_BOLD)
: ($italic ? self::ARIAL_ITALIC : self::ARIAL)
);
break;
case 'Calibri':
$fontFile = (
$bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
$bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
: ($italic ? self::CALIBRI_ITALIC : self::CALIBRI)
);
break;
case 'Courier New':
$fontFile = (
$bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
$bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
: ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW)
);
break;
case 'Comic Sans MS':
$fontFile = (
$bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
$bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
);
break;
case 'Georgia':
$fontFile = (
$bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
$bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
: ($italic ? self::GEORGIA_ITALIC : self::GEORGIA)
);
break;
@@ -469,7 +462,7 @@ class PHPExcel_Shared_Font
case 'Liberation Sans':
$fontFile = (
$bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
$bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
: ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS)
);
break;
@@ -488,7 +481,7 @@ class PHPExcel_Shared_Font
case 'Palatino Linotype':
$fontFile = (
$bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
$bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
: ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE)
);
break;
@@ -499,27 +492,27 @@ class PHPExcel_Shared_Font
case 'Tahoma':
$fontFile = (
$bold ? self::TAHOMA_BOLD : self::TAHOMA
$bold ? self::TAHOMA_BOLD : self::TAHOMA
);
break;
case 'Times New Roman':
$fontFile = (
$bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
$bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
: ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN)
);
break;
case 'Trebuchet MS':
$fontFile = (
$bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
$bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
: ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS)
);
break;
case 'Verdana':
$fontFile = (
$bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
$bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
: ($italic ? self::VERDANA_ITALIC : self::VERDANA)
);
break;
@@ -589,7 +582,7 @@ class PHPExcel_Shared_Font
return $columnWidth;
}
/**
* Get the effective row height for rows without a row dimension or rows with height -1
* For example, for Calibri 11 this is 15 points

View File

@@ -12,6 +12,13 @@ if (!defined('PHPEXCEL_ROOT')) {
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
PHPExcel_Autoloader::Register();
PHPExcel_Shared_ZipStreamWrapper::register();
// check mbstring.func_overload
if (ini_get('mbstring.func_overload') & 2) {
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
}
}
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/utils/Error.php';
@@ -764,11 +771,11 @@ class Matrix {
for($j = 0; $j < $this->n; ++$j) {
$validValues = True;
$value = $M->get($i, $j);
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
}
if ((is_string($value)) && (!is_numeric($value))) {
if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
$value = trim($value,'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
}
@@ -850,11 +857,11 @@ class Matrix {
for($j = 0; $j < $this->n; ++$j) {
$validValues = True;
$value = $M->get($i, $j);
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
}
if ((is_string($value)) && (!is_numeric($value))) {
if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
$value = trim($value,'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
}
@@ -938,11 +945,11 @@ class Matrix {
for($j = 0; $j < $this->n; ++$j) {
$validValues = True;
$value = $M->get($i, $j);
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
}
if ((is_string($value)) && (!is_numeric($value))) {
if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
$value = trim($value,'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
}
@@ -989,11 +996,11 @@ class Matrix {
for($j = 0; $j < $this->n; ++$j) {
$validValues = True;
$value = $M->get($i, $j);
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
}
if ((is_string($value)) && (!is_numeric($value))) {
if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
$value = trim($value,'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
}
@@ -1246,11 +1253,11 @@ class Matrix {
for($j = 0; $j < $this->n; ++$j) {
$validValues = True;
$value = $M->get($i, $j);
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
}
if ((is_string($value)) && (!is_numeric($value))) {
if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
$value = trim($value,'"');
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
}

View File

@@ -19,19 +19,6 @@
//
// $Id: OLE.php,v 1.13 2007/03/07 14:38:25 schmidt Exp $
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE.php';
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_PPS.php';
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_File.php';
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_Root.php';
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/ChainedBlockStream.php';
/**
* Array for storing OLE instances that are accessed from
@@ -527,20 +514,9 @@ class PHPExcel_Shared_OLE
// factor used for separating numbers into 4 bytes parts
$factor = pow(2,32);
$high_part = 0;
for ($i = 0; $i < 4; ++$i) {
list(, $high_part) = unpack('C', $string{(7 - $i)});
if ($i < 3) {
$high_part *= 0x100;
}
}
$low_part = 0;
for ($i = 4; $i < 8; ++$i) {
list(, $low_part) = unpack('C', $string{(7 - $i)});
if ($i < 7) {
$low_part *= 0x100;
}
}
list(, $high_part) = unpack('V', substr($string, 4, 4));
list(, $low_part) = unpack('V', substr($string, 0, 4));
$big_date = ($high_part * $factor) + $low_part;
// translate to seconds
$big_date /= 10000000;

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,19 +22,9 @@
* @package PHPExcel_Shared_OLE
* @copyright Copyright (c) 2006 - 2007 Christian Schmidt
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
}
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE.php';
/**
* PHPExcel_Shared_OLE_ChainedBlockStream
*

View File

@@ -0,0 +1,218 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Xavier Noguer <xnoguer@php.net> |
// | Based on OLE::Storage_Lite by Kawai, Takanori |
// +----------------------------------------------------------------------+
//
// $Id: PPS.php,v 1.7 2007/02/13 21:00:42 schmidt Exp $
/**
* Class for creating PPS's for OLE containers
*
* @author Xavier Noguer <xnoguer@php.net>
* @category PHPExcel
* @package PHPExcel_Shared_OLE
*/
class PHPExcel_Shared_OLE_PPS
{
/**
* The PPS index
* @var integer
*/
public $No;
/**
* The PPS name (in Unicode)
* @var string
*/
public $Name;
/**
* The PPS type. Dir, Root or File
* @var integer
*/
public $Type;
/**
* The index of the previous PPS
* @var integer
*/
public $PrevPps;
/**
* The index of the next PPS
* @var integer
*/
public $NextPps;
/**
* The index of it's first child if this is a Dir or Root PPS
* @var integer
*/
public $DirPps;
/**
* A timestamp
* @var integer
*/
public $Time1st;
/**
* A timestamp
* @var integer
*/
public $Time2nd;
/**
* Starting block (small or big) for this PPS's data inside the container
* @var integer
*/
public $_StartBlock;
/**
* The size of the PPS's data (in bytes)
* @var integer
*/
public $Size;
/**
* The PPS's data (only used if it's not using a temporary file)
* @var string
*/
public $_data;
/**
* Array of child PPS's (only used by Root and Dir PPS's)
* @var array
*/
public $children = array();
/**
* Pointer to OLE container
* @var OLE
*/
public $ole;
/**
* The constructor
*
* @access public
* @param integer $No The PPS index
* @param string $name The PPS name
* @param integer $type The PPS type. Dir, Root or File
* @param integer $prev The index of the previous PPS
* @param integer $next The index of the next PPS
* @param integer $dir The index of it's first child if this is a Dir or Root PPS
* @param integer $time_1st A timestamp
* @param integer $time_2nd A timestamp
* @param string $data The (usually binary) source data of the PPS
* @param array $children Array containing children PPS for this PPS
*/
public function __construct($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children)
{
$this->No = $No;
$this->Name = $name;
$this->Type = $type;
$this->PrevPps = $prev;
$this->NextPps = $next;
$this->DirPps = $dir;
$this->Time1st = $time_1st;
$this->Time2nd = $time_2nd;
$this->_data = $data;
$this->children = $children;
if ($data != '') {
$this->Size = strlen($data);
} else {
$this->Size = 0;
}
}
/**
* Returns the amount of data saved for this PPS
*
* @access public
* @return integer The amount of data (in bytes)
*/
public function _DataLen()
{
if (!isset($this->_data)) {
return 0;
}
//if (isset($this->_PPS_FILE)) {
// fseek($this->_PPS_FILE, 0);
// $stats = fstat($this->_PPS_FILE);
// return $stats[7];
//} else {
return strlen($this->_data);
//}
}
/**
* Returns a string with the PPS's WK (What is a WK?)
*
* @access public
* @return string The binary string
*/
public function _getPpsWk()
{
$ret = $this->Name;
for ($i = 0; $i < (64 - strlen($this->Name)); ++$i) {
$ret .= "\x00";
}
$ret .= pack("v", strlen($this->Name) + 2) // 66
. pack("c", $this->Type) // 67
. pack("c", 0x00) //UK // 68
. pack("V", $this->PrevPps) //Prev // 72
. pack("V", $this->NextPps) //Next // 76
. pack("V", $this->DirPps) //Dir // 80
. "\x00\x09\x02\x00" // 84
. "\x00\x00\x00\x00" // 88
. "\xc0\x00\x00\x00" // 92
. "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root
. "\x00\x00\x00\x00" // 100
. PHPExcel_Shared_OLE::LocalDate2OLE($this->Time1st) // 108
. PHPExcel_Shared_OLE::LocalDate2OLE($this->Time2nd) // 116
. pack("V", isset($this->_StartBlock)?
$this->_StartBlock:0) // 120
. pack("V", $this->Size) // 124
. pack("V", 0); // 128
return $ret;
}
/**
* Updates index and pointers to previous, next and children PPS's for this
* PPS. I don't think it'll work with Dir PPS's.
*
* @access public
* @param array &$pps_array Reference to the array of PPS's for the whole OLE
* container
* @return integer The index for this PPS
*/
public function _savePpsSetPnt(&$pps_array)
{
$pps_array[count($pps_array)] = &$this;
$this->No = count($pps_array) - 1;
$this->PrevPps = 0xFFFFFFFF;
$this->NextPps = 0xFFFFFFFF;
if (count($this->children) > 0) {
$this->DirPps = $this->children[0]->_savePpsSetPnt($pps_array);
} else {
$this->DirPps = 0xFFFFFFFF;
}
return $this->No;
}
}

View File

@@ -0,0 +1,84 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Xavier Noguer <xnoguer@php.net> |
// | Based on OLE::Storage_Lite by Kawai, Takanori |
// +----------------------------------------------------------------------+
//
// $Id: File.php,v 1.11 2007/02/13 21:00:42 schmidt Exp $
/**
* Class for creating File PPS's for OLE containers
*
* @author Xavier Noguer <xnoguer@php.net>
* @category PHPExcel
* @package PHPExcel_Shared_OLE
*/
class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS
{
/**
* The constructor
*
* @access public
* @param string $name The name of the file (in Unicode)
* @see OLE::Asc2Ucs()
*/
public function __construct($name)
{
parent::__construct(
null,
$name,
PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE,
null,
null,
null,
null,
null,
'',
array());
}
/**
* Initialization method. Has to be called right after OLE_PPS_File().
*
* @access public
* @return mixed true on success
*/
public function init()
{
return true;
}
/**
* Append data to PPS
*
* @access public
* @param string $data The data to append
*/
public function append($data)
{
$this->_data .= $data;
}
/**
* Returns a stream for reading this file using fread() etc.
* @return resource a read-only stream
*/
public function getStream()
{
$this->ole->getStream($this);
}
}

View File

@@ -0,0 +1,447 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Author: Xavier Noguer <xnoguer@php.net> |
// | Based on OLE::Storage_Lite by Kawai, Takanori |
// +----------------------------------------------------------------------+
//
// $Id: Root.php,v 1.9 2005/04/23 21:53:49 dufuz Exp $
/**
* Class for creating Root PPS's for OLE containers
*
* @author Xavier Noguer <xnoguer@php.net>
* @category PHPExcel
* @package PHPExcel_Shared_OLE
*/
class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
{
/**
* @param integer $time_1st A timestamp
* @param integer $time_2nd A timestamp
*/
public function __construct($time_1st, $time_2nd, $raChild)
{
parent::__construct(
null,
PHPExcel_Shared_OLE::Asc2Ucs('Root Entry'),
PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT,
null,
null,
null,
$time_1st,
$time_2nd,
null,
$raChild);
}
/**
* Method for saving the whole OLE container (including files).
* In fact, if called with an empty argument (or '-'), it saves to a
* temporary file and then outputs it's contents to stdout.
* If a resource pointer to a stream created by fopen() is passed
* it will be used, but you have to close such stream by yourself.
*
* @param string|resource $filename The name of the file or stream where to save the OLE container.
* @access public
* @return mixed true on success
*/
public function save($filename)
{
// Initial Setting for saving
$this->_BIG_BLOCK_SIZE = pow(2,
((isset($this->_BIG_BLOCK_SIZE))? $this->_adjust2($this->_BIG_BLOCK_SIZE) : 9));
$this->_SMALL_BLOCK_SIZE= pow(2,
((isset($this->_SMALL_BLOCK_SIZE))? $this->_adjust2($this->_SMALL_BLOCK_SIZE): 6));
if (is_resource($filename)) {
$this->_FILEH_ = $filename;
} else {
$this->_FILEH_ = fopen($filename, "wb");
}
if ($this->_FILEH_ == false) {
throw new Exception("Can't open $filename. It may be in use or protected.");
}
// Make an array of PPS's (for Save)
$aList = array();
$this->_savePpsSetPnt($aList);
// calculate values for header
list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo);
// Save Header
$this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt);
// Make Small Data string (write SBD)
$this->_data = $this->_makeSmallData($aList);
// Write BB
$this->_saveBigData($iSBDcnt, $aList);
// Write PPS
$this->_savePps($aList);
// Write Big Block Depot and BDList and Adding Header informations
$this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt);
if (!is_resource($filename)) {
fclose($this->_FILEH_);
}
return true;
}
/**
* Calculate some numbers
*
* @access public
* @param array $raList Reference to an array of PPS's
* @return array The array of numbers
*/
public function _calcSize(&$raList)
{
// Calculate Basic Setting
list($iSBDcnt, $iBBcnt, $iPPScnt) = array(0,0,0);
$iSmallLen = 0;
$iSBcnt = 0;
for ($i = 0; $i < count($raList); ++$i) {
if ($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE) {
$raList[$i]->Size = $raList[$i]->_DataLen();
if ($raList[$i]->Size < PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) {
$iSBcnt += floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
} else {
$iBBcnt += (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
}
}
}
$iSmallLen = $iSBcnt * $this->_SMALL_BLOCK_SIZE;
$iSlCnt = floor($this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE);
$iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt)? 1:0);
$iBBcnt += (floor($iSmallLen / $this->_BIG_BLOCK_SIZE) +
(( $iSmallLen % $this->_BIG_BLOCK_SIZE)? 1: 0));
$iCnt = count($raList);
$iBdCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_PPS_SIZE;
$iPPScnt = (floor($iCnt/$iBdCnt) + (($iCnt % $iBdCnt)? 1: 0));
return array($iSBDcnt, $iBBcnt, $iPPScnt);
}
/**
* Helper function for caculating a magic value for block sizes
*
* @access public
* @param integer $i2 The argument
* @see save()
* @return integer
*/
public function _adjust2($i2)
{
$iWk = log($i2)/log(2);
return ($iWk > floor($iWk))? floor($iWk)+1:$iWk;
}
/**
* Save OLE header
*
* @access public
* @param integer $iSBDcnt
* @param integer $iBBcnt
* @param integer $iPPScnt
*/
public function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt)
{
$FILE = $this->_FILEH_;
// Calculate Basic Setting
$iBlCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE;
$i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE;
$iBdExL = 0;
$iAll = $iBBcnt + $iPPScnt + $iSBDcnt;
$iAllW = $iAll;
$iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0);
$iBdCnt = floor(($iAll + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0);
// Calculate BD count
if ($iBdCnt > $i1stBdL) {
while (1) {
++$iBdExL;
++$iAllW;
$iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0);
$iBdCnt = floor(($iAllW + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0);
if ($iBdCnt <= ($iBdExL*$iBlCnt+ $i1stBdL)) {
break;
}
}
}
// Save Header
fwrite($FILE,
"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1"
. "\x00\x00\x00\x00"
. "\x00\x00\x00\x00"
. "\x00\x00\x00\x00"
. "\x00\x00\x00\x00"
. pack("v", 0x3b)
. pack("v", 0x03)
. pack("v", -2)
. pack("v", 9)
. pack("v", 6)
. pack("v", 0)
. "\x00\x00\x00\x00"
. "\x00\x00\x00\x00"
. pack("V", $iBdCnt)
. pack("V", $iBBcnt+$iSBDcnt) //ROOT START
. pack("V", 0)
. pack("V", 0x1000)
. pack("V", $iSBDcnt ? 0 : -2) //Small Block Depot
. pack("V", $iSBDcnt)
);
// Extra BDList Start, Count
if ($iBdCnt < $i1stBdL) {
fwrite($FILE,
pack("V", -2). // Extra BDList Start
pack("V", 0) // Extra BDList Count
);
} else {
fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL));
}
// BDList
for ($i = 0; $i < $i1stBdL && $i < $iBdCnt; ++$i) {
fwrite($FILE, pack("V", $iAll+$i));
}
if ($i < $i1stBdL) {
for ($j = 0; $j < ($i1stBdL-$i); ++$j) {
fwrite($FILE, (pack("V", -1)));
}
}
}
/**
* Saving big data (PPS's with data bigger than PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL)
*
* @access public
* @param integer $iStBlk
* @param array &$raList Reference to array of PPS's
*/
public function _saveBigData($iStBlk, &$raList)
{
$FILE = $this->_FILEH_;
// cycle through PPS's
for ($i = 0; $i < count($raList); ++$i) {
if ($raList[$i]->Type != PHPExcel_Shared_OLE::OLE_PPS_TYPE_DIR) {
$raList[$i]->Size = $raList[$i]->_DataLen();
if (($raList[$i]->Size >= PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) ||
(($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data)))
{
// Write Data
//if (isset($raList[$i]->_PPS_FILE)) {
// $iLen = 0;
// fseek($raList[$i]->_PPS_FILE, 0); // To The Top
// while($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
// $iLen += strlen($sBuff);
// fwrite($FILE, $sBuff);
// }
//} else {
fwrite($FILE, $raList[$i]->_data);
//}
if ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE) {
for ($j = 0; $j < ($this->_BIG_BLOCK_SIZE - ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)); ++$j) {
fwrite($FILE, "\x00");
}
}
// Set For PPS
$raList[$i]->_StartBlock = $iStBlk;
$iStBlk +=
(floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
}
// Close file for each PPS, and unlink it
//if (isset($raList[$i]->_PPS_FILE)) {
// fclose($raList[$i]->_PPS_FILE);
// $raList[$i]->_PPS_FILE = null;
// unlink($raList[$i]->_tmp_filename);
//}
}
}
}
/**
* get small data (PPS's with data smaller than PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL)
*
* @access public
* @param array &$raList Reference to array of PPS's
*/
public function _makeSmallData(&$raList)
{
$sRes = '';
$FILE = $this->_FILEH_;
$iSmBlk = 0;
for ($i = 0; $i < count($raList); ++$i) {
// Make SBD, small data string
if ($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE) {
if ($raList[$i]->Size <= 0) {
continue;
}
if ($raList[$i]->Size < PHPExcel_Shared_OLE::OLE_DATA_SIZE_SMALL) {
$iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
// Add to SBD
for ($j = 0; $j < ($iSmbCnt-1); ++$j) {
fwrite($FILE, pack("V", $j+$iSmBlk+1));
}
fwrite($FILE, pack("V", -2));
//// Add to Data String(this will be written for RootEntry)
//if ($raList[$i]->_PPS_FILE) {
// fseek($raList[$i]->_PPS_FILE, 0); // To The Top
// while ($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
// $sRes .= $sBuff;
// }
//} else {
$sRes .= $raList[$i]->_data;
//}
if ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) {
for ($j = 0; $j < ($this->_SMALL_BLOCK_SIZE - ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)); ++$j) {
$sRes .= "\x00";
}
}
// Set for PPS
$raList[$i]->_StartBlock = $iSmBlk;
$iSmBlk += $iSmbCnt;
}
}
}
$iSbCnt = floor($this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE);
if ($iSmBlk % $iSbCnt) {
for ($i = 0; $i < ($iSbCnt - ($iSmBlk % $iSbCnt)); ++$i) {
fwrite($FILE, pack("V", -1));
}
}
return $sRes;
}
/**
* Saves all the PPS's WKs
*
* @access public
* @param array $raList Reference to an array with all PPS's
*/
public function _savePps(&$raList)
{
// Save each PPS WK
for ($i = 0; $i < count($raList); ++$i) {
fwrite($this->_FILEH_, $raList[$i]->_getPpsWk());
}
// Adjust for Block
$iCnt = count($raList);
$iBCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_PPS_SIZE;
if ($iCnt % $iBCnt) {
for ($i = 0; $i < (($iBCnt - ($iCnt % $iBCnt)) * PHPExcel_Shared_OLE::OLE_PPS_SIZE); ++$i) {
fwrite($this->_FILEH_, "\x00");
}
}
}
/**
* Saving Big Block Depot
*
* @access public
* @param integer $iSbdSize
* @param integer $iBsize
* @param integer $iPpsCnt
*/
public function _saveBbd($iSbdSize, $iBsize, $iPpsCnt)
{
$FILE = $this->_FILEH_;
// Calculate Basic Setting
$iBbCnt = $this->_BIG_BLOCK_SIZE / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE;
$i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / PHPExcel_Shared_OLE::OLE_LONG_INT_SIZE;
$iBdExL = 0;
$iAll = $iBsize + $iPpsCnt + $iSbdSize;
$iAllW = $iAll;
$iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0);
$iBdCnt = floor(($iAll + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt)? 1: 0);
// Calculate BD count
if ($iBdCnt >$i1stBdL) {
while (1) {
++$iBdExL;
++$iAllW;
$iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0);
$iBdCnt = floor(($iAllW + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt)? 1: 0);
if ($iBdCnt <= ($iBdExL*$iBbCnt+ $i1stBdL)) {
break;
}
}
}
// Making BD
// Set for SBD
if ($iSbdSize > 0) {
for ($i = 0; $i < ($iSbdSize - 1); ++$i) {
fwrite($FILE, pack("V", $i+1));
}
fwrite($FILE, pack("V", -2));
}
// Set for B
for ($i = 0; $i < ($iBsize - 1); ++$i) {
fwrite($FILE, pack("V", $i+$iSbdSize+1));
}
fwrite($FILE, pack("V", -2));
// Set for PPS
for ($i = 0; $i < ($iPpsCnt - 1); ++$i) {
fwrite($FILE, pack("V", $i+$iSbdSize+$iBsize+1));
}
fwrite($FILE, pack("V", -2));
// Set for BBD itself ( 0xFFFFFFFD : BBD)
for ($i = 0; $i < $iBdCnt; ++$i) {
fwrite($FILE, pack("V", 0xFFFFFFFD));
}
// Set for ExtraBDList
for ($i = 0; $i < $iBdExL; ++$i) {
fwrite($FILE, pack("V", 0xFFFFFFFC));
}
// Adjust for Block
if (($iAllW + $iBdCnt) % $iBbCnt) {
for ($i = 0; $i < ($iBbCnt - (($iAllW + $iBdCnt) % $iBbCnt)); ++$i) {
fwrite($FILE, pack("V", -1));
}
}
// Extra BDList
if ($iBdCnt > $i1stBdL) {
$iN=0;
$iNb=0;
for ($i = $i1stBdL;$i < $iBdCnt; $i++, ++$iN) {
if ($iN >= ($iBbCnt - 1)) {
$iN = 0;
++$iNb;
fwrite($FILE, pack("V", $iAll+$iBdCnt+$iNb));
}
fwrite($FILE, pack("V", $iBsize+$iSbdSize+$iPpsCnt+$i));
}
if (($iBdCnt-$i1stBdL) % ($iBbCnt-1)) {
for ($i = 0; $i < (($iBbCnt - 1) - (($iBdCnt - $i1stBdL) % ($iBbCnt - 1))); ++$i) {
fwrite($FILE, pack("V", -1));
}
}
fwrite($FILE, pack("V", -2));
}
}
}

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1));
@@ -213,6 +213,58 @@ class PHPExcel_Shared_OLERead {
}
}
/**
* Extract binary stream data, summary information
*
* @return string|null
*/
public function getSummaryInformation()
{
if (!isset($this->summaryInformation)) {
return null;
}
if ($this->props[$this->summaryInformation]['size'] < self::SMALL_BLOCK_THRESHOLD){
$rootdata = $this->_readData($this->props[$this->rootentry]['startBlock']);
$streamData = '';
$block = $this->props[$this->summaryInformation]['startBlock'];
$pos = 0;
while ($block != -2) {
$pos = $block * self::SMALL_BLOCK_SIZE;
$streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);
$block = $this->smallBlockChain[$block];
}
return $streamData;
} else {
$numBlocks = $this->props[$this->summaryInformation]['size'] / self::BIG_BLOCK_SIZE;
if ($this->props[$this->summaryInformation]['size'] % self::BIG_BLOCK_SIZE != 0) {
++$numBlocks;
}
if ($numBlocks == 0) return '';
$streamData = '';
$block = $this->props[$this->summaryInformation]['startBlock'];
$pos = 0;
while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
$block = $this->bigBlockChain[$block];
}
return $streamData;
}
}
/**
* Read a standard stream (by joining sectors using information from SAT)
*
@@ -280,6 +332,11 @@ class PHPExcel_Shared_OLERead {
$this->rootentry = count($this->props) - 1;
}
// Summary information
if ($name == chr(5) . 'SummaryInformation') {
$this->summaryInformation = count($this->props) - 1;
}
$offset += self::PROPERTY_STORAGE_BLOCK_SIZE;
}

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
@@ -48,6 +48,13 @@ class PHPExcel_Shared_String
*/
private static $_controlCharacters = array();
/**
* SYLK Characters array
*
* $var array
*/
private static $_SYLKCharacters = array();
/**
* Decimal separator
*
@@ -89,6 +96,171 @@ class PHPExcel_Shared_String
}
}
/**
* Build SYLK characters array
*/
private static function _buildSYLKCharacters()
{
self::$_SYLKCharacters = array(
"\x1B 0" => chr(0),
"\x1B 1" => chr(1),
"\x1B 2" => chr(2),
"\x1B 3" => chr(3),
"\x1B 4" => chr(4),
"\x1B 5" => chr(5),
"\x1B 6" => chr(6),
"\x1B 7" => chr(7),
"\x1B 8" => chr(8),
"\x1B 9" => chr(9),
"\x1B :" => chr(10),
"\x1B ;" => chr(11),
"\x1B <" => chr(12),
"\x1B :" => chr(13),
"\x1B >" => chr(14),
"\x1B ?" => chr(15),
"\x1B!0" => chr(16),
"\x1B!1" => chr(17),
"\x1B!2" => chr(18),
"\x1B!3" => chr(19),
"\x1B!4" => chr(20),
"\x1B!5" => chr(21),
"\x1B!6" => chr(22),
"\x1B!7" => chr(23),
"\x1B!8" => chr(24),
"\x1B!9" => chr(25),
"\x1B!:" => chr(26),
"\x1B!;" => chr(27),
"\x1B!<" => chr(28),
"\x1B!=" => chr(29),
"\x1B!>" => chr(30),
"\x1B!?" => chr(31),
"\x1B'?" => chr(127),
"\x1B(0" => '€', // 128 in CP1252
"\x1B(2" => '', // 130 in CP1252
"\x1B(3" => 'ƒ', // 131 in CP1252
"\x1B(4" => '„', // 132 in CP1252
"\x1B(5" => '…', // 133 in CP1252
"\x1B(6" => '†', // 134 in CP1252
"\x1B(7" => '‡', // 135 in CP1252
"\x1B(8" => 'ˆ', // 136 in CP1252
"\x1B(9" => '‰', // 137 in CP1252
"\x1B(:" => 'Š', // 138 in CP1252
"\x1B(;" => '', // 139 in CP1252
"\x1BNj" => 'Œ', // 140 in CP1252
"\x1B(>" => 'Ž', // 142 in CP1252
"\x1B)1" => '', // 145 in CP1252
"\x1B)2" => '', // 146 in CP1252
"\x1B)3" => '“', // 147 in CP1252
"\x1B)4" => '”', // 148 in CP1252
"\x1B)5" => '•', // 149 in CP1252
"\x1B)6" => '', // 150 in CP1252
"\x1B)7" => '—', // 151 in CP1252
"\x1B)8" => '˜', // 152 in CP1252
"\x1B)9" => '™', // 153 in CP1252
"\x1B):" => 'š', // 154 in CP1252
"\x1B);" => '', // 155 in CP1252
"\x1BNz" => 'œ', // 156 in CP1252
"\x1B)>" => 'ž', // 158 in CP1252
"\x1B)?" => 'Ÿ', // 159 in CP1252
"\x1B*0" => ' ', // 160 in CP1252
"\x1BN!" => '¡', // 161 in CP1252
"\x1BN\"" => '¢', // 162 in CP1252
"\x1BN#" => '£', // 163 in CP1252
"\x1BN(" => '¤', // 164 in CP1252
"\x1BN%" => '¥', // 165 in CP1252
"\x1B*6" => '¦', // 166 in CP1252
"\x1BN'" => '§', // 167 in CP1252
"\x1BNH " => '¨', // 168 in CP1252
"\x1BNS" => '©', // 169 in CP1252
"\x1BNc" => 'ª', // 170 in CP1252
"\x1BN+" => '«', // 171 in CP1252
"\x1B*<" => '¬', // 172 in CP1252
"\x1B*=" => '­', // 173 in CP1252
"\x1BNR" => '®', // 174 in CP1252
"\x1B*?" => '¯', // 175 in CP1252
"\x1BN0" => '°', // 176 in CP1252
"\x1BN1" => '±', // 177 in CP1252
"\x1BN2" => '²', // 178 in CP1252
"\x1BN3" => '³', // 179 in CP1252
"\x1BNB " => '´', // 180 in CP1252
"\x1BN5" => 'µ', // 181 in CP1252
"\x1BN6" => '¶', // 182 in CP1252
"\x1BN7" => '·', // 183 in CP1252
"\x1B+8" => '¸', // 184 in CP1252
"\x1BNQ" => '¹', // 185 in CP1252
"\x1BNk" => 'º', // 186 in CP1252
"\x1BN;" => '»', // 187 in CP1252
"\x1BN<" => '¼', // 188 in CP1252
"\x1BN=" => '½', // 189 in CP1252
"\x1BN>" => '¾', // 190 in CP1252
"\x1BN?" => '¿', // 191 in CP1252
"\x1BNAA" => 'À', // 192 in CP1252
"\x1BNBA" => 'Á', // 193 in CP1252
"\x1BNCA" => 'Â', // 194 in CP1252
"\x1BNDA" => 'Ã', // 195 in CP1252
"\x1BNHA" => 'Ä', // 196 in CP1252
"\x1BNJA" => 'Å', // 197 in CP1252
"\x1BNa" => 'Æ', // 198 in CP1252
"\x1BNKC" => 'Ç', // 199 in CP1252
"\x1BNAE" => 'È', // 200 in CP1252
"\x1BNBE" => 'É', // 201 in CP1252
"\x1BNCE" => 'Ê', // 202 in CP1252
"\x1BNHE" => 'Ë', // 203 in CP1252
"\x1BNAI" => 'Ì', // 204 in CP1252
"\x1BNBI" => 'Í', // 205 in CP1252
"\x1BNCI" => 'Î', // 206 in CP1252
"\x1BNHI" => 'Ï', // 207 in CP1252
"\x1BNb" => 'Ð', // 208 in CP1252
"\x1BNDN" => 'Ñ', // 209 in CP1252
"\x1BNAO" => 'Ò', // 210 in CP1252
"\x1BNBO" => 'Ó', // 211 in CP1252
"\x1BNCO" => 'Ô', // 212 in CP1252
"\x1BNDO" => 'Õ', // 213 in CP1252
"\x1BNHO" => 'Ö', // 214 in CP1252
"\x1B-7" => '×', // 215 in CP1252
"\x1BNi" => 'Ø', // 216 in CP1252
"\x1BNAU" => 'Ù', // 217 in CP1252
"\x1BNBU" => 'Ú', // 218 in CP1252
"\x1BNCU" => 'Û', // 219 in CP1252
"\x1BNHU" => 'Ü', // 220 in CP1252
"\x1B-=" => 'Ý', // 221 in CP1252
"\x1BNl" => 'Þ', // 222 in CP1252
"\x1BN{" => 'ß', // 223 in CP1252
"\x1BNAa" => 'à', // 224 in CP1252
"\x1BNBa" => 'á', // 225 in CP1252
"\x1BNCa" => 'â', // 226 in CP1252
"\x1BNDa" => 'ã', // 227 in CP1252
"\x1BNHa" => 'ä', // 228 in CP1252
"\x1BNJa" => 'å', // 229 in CP1252
"\x1BNq" => 'æ', // 230 in CP1252
"\x1BNKc" => 'ç', // 231 in CP1252
"\x1BNAe" => 'è', // 232 in CP1252
"\x1BNBe" => 'é', // 233 in CP1252
"\x1BNCe" => 'ê', // 234 in CP1252
"\x1BNHe" => 'ë', // 235 in CP1252
"\x1BNAi" => 'ì', // 236 in CP1252
"\x1BNBi" => 'í', // 237 in CP1252
"\x1BNCi" => 'î', // 238 in CP1252
"\x1BNHi" => 'ï', // 239 in CP1252
"\x1BNs" => 'ð', // 240 in CP1252
"\x1BNDn" => 'ñ', // 241 in CP1252
"\x1BNAo" => 'ò', // 242 in CP1252
"\x1BNBo" => 'ó', // 243 in CP1252
"\x1BNCo" => 'ô', // 244 in CP1252
"\x1BNDo" => 'õ', // 245 in CP1252
"\x1BNHo" => 'ö', // 246 in CP1252
"\x1B/7" => '÷', // 247 in CP1252
"\x1BNy" => 'ø', // 248 in CP1252
"\x1BNAu" => 'ù', // 249 in CP1252
"\x1BNBu" => 'ú', // 250 in CP1252
"\x1BNCu" => 'û', // 251 in CP1252
"\x1BNHu" => 'ü', // 252 in CP1252
"\x1B/=" => 'ý', // 253 in CP1252
"\x1BN|" => 'þ', // 254 in CP1252
"\x1BNHy" => 'ÿ', // 255 in CP1252
);
}
/**
* Get whether mbstring extension is available
*
@@ -117,21 +289,37 @@ class PHPExcel_Shared_String
return self::$_isIconvEnabled;
}
// Check that iconv exists
// Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
// we cannot use iconv when that happens
// Also, sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0
// we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773)
if (function_exists('iconv')
&& @iconv('UTF-8', 'UTF-16LE', 'x')
&& @iconv_substr('A', 0, 1, 'UTF-8') ) {
self::$_isIconvEnabled = true;
} else {
// Fail if iconv doesn't exist
if (!function_exists('iconv')) {
self::$_isIconvEnabled = false;
return false;
}
return self::$_isIconvEnabled;
// Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
if (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
self::$_isIconvEnabled = false;
return false;
}
// Sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0
// we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773)
if (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
self::$_isIconvEnabled = false;
return false;
}
// CUSTOM: IBM AIX iconv() does not work
if ( defined('PHP_OS') && @stristr(PHP_OS, 'AIX')
&& defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0)
&& defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0) )
{
self::$_isIconvEnabled = false;
return false;
}
// If we reach here no problems were detected with iconv
self::$_isIconvEnabled = true;
return true;
}
/**
@@ -277,7 +465,7 @@ class PHPExcel_Shared_String
}
/**
* Convert string from one encoding to another. First try mbstring, then iconv, or no convertion
* Convert string from one encoding to another. First try iconv, then mbstring, or no convertion
*
* @param string $value
* @param string $to Encoding to convert to, e.g. 'UTF-8'
@@ -295,10 +483,45 @@ class PHPExcel_Shared_String
$value = mb_convert_encoding($value, $to, $from);
return $value;
}
if($from == 'UTF-16LE'){
return self::utf16_decode($value, false);
}else if($from == 'UTF-16BE'){
return self::utf16_decode($value);
}
// else, no conversion
return $value;
}
/**
* Decode UTF-16 encoded strings.
*
* Can handle both BOM'ed data and un-BOM'ed data.
* Assumes Big-Endian byte order if no BOM is available.
* This function was taken from http://php.net/manual/en/function.utf8-decode.php
* and $bom_be parameter added.
*
* @param string $str UTF-16 encoded data to decode.
* @return string UTF-8 / ISO encoded data.
* @access public
* @version 0.2 / 2010-05-13
* @author Rasmus Andersson {@link http://rasmusandersson.se/}
* @author vadik56
*/
function utf16_decode( $str, $bom_be=true ) {
if( strlen($str) < 2 ) return $str;
$c0 = ord($str{0});
$c1 = ord($str{1});
if( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); }
elseif( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; }
$len = strlen($str);
$newstr = '';
for($i=0;$i<$len;$i+=2) {
if( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); }
else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); }
$newstr .= ($val == 0x228) ? "\n" : chr($val);
}
return $newstr;
}
/**
* Get character count. First try mbstring, then iconv, finally strlen
@@ -427,4 +650,28 @@ class PHPExcel_Shared_String
self::$_thousandsSeparator = $pValue;
}
/**
* Convert SYLK encoded string to UTF-8
*
* @param string $pValue
* @return string UTF-8 encoded string
*/
public static function SYLKtoUTF8($pValue = '')
{
// If there is no escape character in the string there is nothing to do
if (strpos($pValue, '') === false) {
return $pValue;
}
if(empty(self::$_SYLKCharacters)) {
self::_buildSYLKCharacters();
}
foreach (self::$_SYLKCharacters as $k => $v) {
$pValue = str_replace($k, $v, $pValue);
}
return $pValue;
}
}

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
if (!defined('DATE_W3C')) {

View File

@@ -22,14 +22,10 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** Register new zip wrapper */
PHPExcel_Shared_ZipStreamWrapper::register();
/**
* PHPExcel_Shared_ZipStreamWrapper
*
@@ -83,24 +79,9 @@ class PHPExcel_Shared_ZipStreamWrapper {
throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
}
// Parse URL
$url = @parse_url(str_replace('zip://', 'file://', $path));
// Fix URL
if (!is_array($url)) {
$url['host'] = substr($path, strlen('zip://'));
$url['path'] = '';
}
if (strpos($url['host'], '#') !== false) {
if (!isset($url['fragment'])) {
$url['fragment'] = substr($url['host'], strpos($url['host'], '#') + 1) . $url['path'];
$url['host'] = substr($url['host'], 0, strpos($url['host'], '#'));
unset($url['path']);
}
} else {
$url['host'] = $url['host'] . $url['path'];
unset($url['path']);
}
$pos = strrpos($path, '#');
$url['host'] = substr($path, 6, $pos - 6); // 6: strlen('zip://')
$url['fragment'] = substr($path, $pos + 1);
// Open archive
$this->_archive = new ZipArchive();

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Shared_Best_Fit
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/

View File

@@ -22,18 +22,10 @@
* @package PHPExcel_Shared_Best_Fit
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');

View File

@@ -22,18 +22,10 @@
* @package PHPExcel_Shared_Best_Fit
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');

View File

@@ -22,18 +22,10 @@
* @package PHPExcel_Shared_Best_Fit
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
}
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');

View File

@@ -22,18 +22,10 @@
* @package PHPExcel_Shared_Best_Fit
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
}
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php';
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/Matrix.php';

View File

@@ -22,18 +22,10 @@
* @package PHPExcel_Shared_Best_Fit
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
}
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php';

View File

@@ -1,13 +1,5 @@
<?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
}
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/linearBestFitClass.php';
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/logarithmicBestFitClass.php';
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/exponentialBestFitClass.php';

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,45 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
}
/** PHPExcel_Style_Color */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
/** PHPExcel_Style_Font */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
/** PHPExcel_Style_Fill */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Fill.php';
/** PHPExcel_Style_Borders */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Borders.php';
/** PHPExcel_Style_Alignment */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Alignment.php';
/** PHPExcel_Style_NumberFormat */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
/** PHPExcel_Style_Conditional */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Conditional.php';
/** PHPExcel_Style_Protection */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Protection.php';
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style
*
@@ -76,7 +41,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
* @var PHPExcel_Style_Font
*/
private $_font;
/**
* Fill
*
@@ -90,28 +55,28 @@ class PHPExcel_Style implements PHPExcel_IComparable
* @var PHPExcel_Style_Borders
*/
private $_borders;
/**
* Alignment
*
* @var PHPExcel_Style_Alignment
*/
private $_alignment;
/**
* Number Format
*
* @var PHPExcel_Style_NumberFormat
*/
private $_numberFormat;
/**
* Conditional styles
*
* @var PHPExcel_Style_Conditional[]
*/
private $_conditionalStyles;
/**
* Protection
*
@@ -181,7 +146,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
$this->_parent = $parent;
return $this;
}
/**
* Is this a supervisor or a real style component?
*
@@ -258,7 +223,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
/**
* Apply styles from array
*
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray(
* array(
@@ -289,9 +254,9 @@ class PHPExcel_Style implements PHPExcel_IComparable
* )
* );
* </code>
*
*
* @param array $pStyles Array containing style information
* @param boolean $pAdvanced Advanced mode for setting borders.
* @param boolean $pAdvanced Advanced mode for setting borders.
* @throws Exception
* @return PHPExcel_Style
*/
@@ -373,7 +338,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
// loop through up to 3 x 3 = 9 regions
for ($x = 1; $x <= $xMax; ++$x) {
// start column index for region
$colStart = ($x == 3) ?
$colStart = ($x == 3) ?
PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0])
: PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $x - 1);
@@ -417,7 +382,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
// build range for region
$range = $colStart . $rowStart . ':' . $colEnd . $rowEnd;
// retrieve relevant style array for region
$regionStyles = $pStyles;
unset($regionStyles['borders']['inside']);
@@ -503,7 +468,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
$style = $workbook->getCellXfByIndex($oldXfIndex);
$newStyle = clone $style;
$newStyle->applyFromArray($pStyles);
if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) {
// there is already such cell Xf in our collection
$newXfIndexes[$oldXfIndex] = $existingStyle->getIndex();
@@ -579,7 +544,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getFill() {
return $this->_fill;
}
/**
* Get Font
*
@@ -609,7 +574,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getBorders() {
return $this->_borders;
}
/**
* Get Alignment
*
@@ -618,7 +583,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getAlignment() {
return $this->_alignment;
}
/**
* Get Number Format
*
@@ -627,7 +592,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getNumberFormat() {
return $this->_numberFormat;
}
/**
* Get Conditional Styles. Only used on supervisor.
*
@@ -636,7 +601,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getConditionalStyles() {
return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell());
}
/**
* Set Conditional Styles. Only used on supervisor.
*
@@ -651,7 +616,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Protection
*
@@ -660,18 +625,18 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getProtection() {
return $this->_protection;
}
/**
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
$hashConditionals = '';
foreach ($this->_conditionalStyles as $conditional) {
$hashConditionals .= $conditional->getHashCode();
}
return md5(
$this->getFill()->getHashCode()
. $this->getFont()->getHashCode()
@@ -683,7 +648,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Get own index in style collection
*

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,22 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Alignment
*
@@ -46,7 +34,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Alignment implements PHPExcel_IComparable
{
{
/* Horizontal alignment styles */
const HORIZONTAL_GENERAL = 'general';
const HORIZONTAL_LEFT = 'left';
@@ -54,55 +42,55 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
const HORIZONTAL_CENTER = 'center';
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous';
const HORIZONTAL_JUSTIFY = 'justify';
/* Vertical alignment styles */
const VERTICAL_BOTTOM = 'bottom';
const VERTICAL_TOP = 'top';
const VERTICAL_CENTER = 'center';
const VERTICAL_JUSTIFY = 'justify';
/**
* Horizontal
*
* @var string
*/
private $_horizontal;
/**
* Vertical
*
* @var string
*/
private $_vertical;
/**
* Text rotation
*
* @var int
*/
private $_textRotation;
/**
* Wrap text
*
* @var boolean
*/
private $_wrapText;
/**
* Shrink to fit
*
* @var boolean
*/
private $_shrinkToFit;
/**
* Indent - only possible with horizontal alignment left and right
*
* @var int
*/
private $_indent;
/**
* Parent Borders
*
@@ -219,7 +207,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
/**
* Apply styles from array
*
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray(
* array(
@@ -230,7 +218,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
* )
* );
* </code>
*
*
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Alignment
@@ -264,7 +252,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Horizontal
*
@@ -276,7 +264,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_horizontal;
}
/**
* Set Horizontal
*
@@ -287,7 +275,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('horizontal' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -297,7 +285,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Vertical
*
@@ -309,7 +297,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_vertical;
}
/**
* Set Vertical
*
@@ -320,7 +308,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('vertical' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -329,7 +317,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this;
}
/**
* Get TextRotation
*
@@ -341,7 +329,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_textRotation;
}
/**
* Set TextRotation
*
@@ -366,10 +354,10 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
} else {
throw new Exception("Text rotation should be a value between -90 and 90.");
}
return $this;
}
/**
* Get Wrap Text
*
@@ -381,7 +369,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_wrapText;
}
/**
* Set Wrap Text
*
@@ -400,7 +388,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Shrink to fit
*
@@ -412,7 +400,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_shrinkToFit;
}
/**
* Set Shrink to fit
*
@@ -443,7 +431,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_indent;
}
/**
* Set indent
*
@@ -464,12 +452,12 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
@@ -484,7 +472,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,25 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Style_Color */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Border
*
@@ -65,17 +50,17 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
const BORDER_SLANTDASHDOT = 'slantDashDot';
const BORDER_THICK = 'thick';
const BORDER_THIN = 'thin';
/**
* Border style
*
* @var string
*/
private $_borderStyle;
/**
* Border color
*
*
* @var PHPExcel_Style_Color
*/
private $_color;
@@ -132,7 +117,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
$this->_parentPropertyName = $parentPropertyName;
return $this;
}
/**
* Is this a supervisor or a real style component?
*
@@ -270,7 +255,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
/**
* Apply styles from array
*
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->applyFromArray(
* array(
@@ -281,7 +266,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
* )
* );
* </code>
*
*
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Border
@@ -303,7 +288,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Border style
*
@@ -315,7 +300,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
}
return $this->_borderStyle;
}
/**
* Set Border style
*
@@ -323,7 +308,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
* @return PHPExcel_Style_Border
*/
public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) {
if ($pValue == '') {
$pValue = PHPExcel_Style_Border::BORDER_NONE;
}
@@ -335,7 +320,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Border Color
*
@@ -344,7 +329,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
public function getColor() {
return $this->_color;
}
/**
* Set Border Color
*
@@ -355,7 +340,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
public function setColor(PHPExcel_Style_Color $pValue = null) {
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
if ($this->_isSupervisor) {
$styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -364,12 +349,12 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
}
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
@@ -380,7 +365,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,25 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Style_Border */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Border.php';
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Borders
*
@@ -55,84 +40,84 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
const DIAGONAL_UP = 1;
const DIAGONAL_DOWN = 2;
const DIAGONAL_BOTH = 3;
/**
* Left
*
* @var PHPExcel_Style_Border
*/
private $_left;
/**
* Right
*
* @var PHPExcel_Style_Border
*/
private $_right;
/**
* Top
*
* @var PHPExcel_Style_Border
*/
private $_top;
/**
* Bottom
*
* @var PHPExcel_Style_Border
*/
private $_bottom;
/**
* Diagonal
*
* @var PHPExcel_Style_Border
*/
private $_diagonal;
/**
* DiagonalDirection
*
* @var int
*/
private $_diagonalDirection;
/**
* All borders psedo-border. Only applies to supervisor.
*
* @var PHPExcel_Style_Border
*/
private $_allBorders;
/**
* Outline psedo-border. Only applies to supervisor.
*
* @var PHPExcel_Style_Border
*/
private $_outline;
/**
* Inside psedo-border. Only applies to supervisor.
*
* @var PHPExcel_Style_Border
*/
private $_inside;
/**
* Vertical pseudo-border. Only applies to supervisor.
*
* @var PHPExcel_Style_Border
*/
private $_vertical;
/**
* Horizontal pseudo-border. Only applies to supervisor.
*
* @var PHPExcel_Style_Border
*/
private $_horizontal;
/**
* Parent Borders
*
@@ -271,7 +256,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
/**
* Apply styles from array
*
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray(
* array(
@@ -302,7 +287,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
* )
* );
* </code>
*
*
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Borders
@@ -336,7 +321,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Left
*
@@ -345,7 +330,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
public function getLeft() {
return $this->_left;
}
/**
* Get Right
*
@@ -354,7 +339,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
public function getRight() {
return $this->_right;
}
/**
* Get Top
*
@@ -363,7 +348,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
public function getTop() {
return $this->_top;
}
/**
* Get Bottom
*
@@ -381,7 +366,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
public function getDiagonal() {
return $this->_diagonal;
}
/**
* Get AllBorders (pseudo-border). Only applies to supervisor.
*
@@ -394,7 +379,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_allBorders;
}
/**
* Get Outline (pseudo-border). Only applies to supervisor.
*
@@ -407,7 +392,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_outline;
}
/**
* Get Inside (pseudo-border). Only applies to supervisor.
*
@@ -420,7 +405,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_inside;
}
/**
* Get Vertical (pseudo-border). Only applies to supervisor.
*
@@ -433,7 +418,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_vertical;
}
/**
* Get Horizontal (pseudo-border). Only applies to supervisor.
*
@@ -446,7 +431,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_horizontal;
}
/**
* Get DiagonalDirection
*
@@ -458,7 +443,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_diagonalDirection;
}
/**
* Set DiagonalDirection
*
@@ -477,12 +462,12 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashcode();
@@ -497,7 +482,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,22 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Color
*
@@ -58,14 +46,14 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
const COLOR_DARKGREEN = 'FF008000';
const COLOR_YELLOW = 'FFFFFF00';
const COLOR_DARKYELLOW = 'FF808000';
/**
* Indexed colors array
*
* @var array
*/
private static $_indexedColors;
/**
* ARGB - Alpha RGB
*
@@ -96,7 +84,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
/**
* Create a new PHPExcel_Style_Color
*
*
* @param string $pARGB
*/
public function __construct($pARGB = PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor = false)
@@ -107,7 +95,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
// Initialise values
$this->_argb = $pARGB;
}
/**
* Bind parent. Only used for supervisor
*
@@ -214,11 +202,11 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
/**
* Apply styles from array
*
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->getColor()->applyFromArray( array('rgb' => '808080') );
* </code>
*
*
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Color
@@ -240,7 +228,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
}
return $this;
}
/**
* Get ARGB
*
@@ -252,7 +240,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
}
return $this->_argb;
}
/**
* Set ARGB
*
@@ -271,7 +259,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
}
return $this;
}
/**
* Get RGB
*
@@ -283,7 +271,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
}
return substr($this->_argb, 2);
}
/**
* Set RGB
*
@@ -302,17 +290,17 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
}
return $this;
}
/**
* Get indexed color
*
*
* @param int $pIndex
* @return PHPExcel_Style_Color
*/
public static function indexedColor($pIndex) {
// Clean parameter
$pIndex = intval($pIndex);
// Indexed colors
if (is_null(self::$_indexedColors)) {
self::$_indexedColors = array();
@@ -381,11 +369,11 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
self::$_indexedColors[] = '00333399';
self::$_indexedColors[] = '00333333';
}
if (array_key_exists($pIndex, self::$_indexedColors)) {
return new PHPExcel_Style_Color(self::$_indexedColors[$pIndex]);
}
return new PHPExcel_Style_Color();
}
@@ -393,7 +381,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
@@ -403,7 +391,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,25 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Style */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style.php';
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Conditional
*
@@ -55,7 +40,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
const CONDITION_CELLIS = 'cellIs';
const CONDITION_CONTAINSTEXT = 'containsText';
const CONDITION_EXPRESSION = 'expression';
/* Operator types */
const OPERATOR_NONE = '';
const OPERATOR_BEGINSWITH = 'beginsWith';
@@ -69,42 +54,42 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
const OPERATOR_CONTAINSTEXT = 'containsText';
const OPERATOR_NOTCONTAINS = 'notContains';
const OPERATOR_BETWEEN = 'between';
/**
* Condition type
*
* @var int
*/
private $_conditionType;
/**
* Operator type
*
* @var int
*/
private $_operatorType;
/**
* Text
*
* @var string
*/
private $_text;
/**
* Condition
*
* @var string[]
*/
private $_condition = array();
/**
* Style
*
*
* @var PHPExcel_Style
*/
private $_style;
/**
* Create a new PHPExcel_Style_Conditional
*/
@@ -117,7 +102,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
$this->_condition = array();
$this->_style = new PHPExcel_Style();
}
/**
* Get Condition type
*
@@ -126,7 +111,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function getConditionType() {
return $this->_conditionType;
}
/**
* Set Condition type
*
@@ -137,7 +122,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
$this->_conditionType = $pValue;
return $this;
}
/**
* Get Operator type
*
@@ -146,7 +131,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function getOperatorType() {
return $this->_operatorType;
}
/**
* Set Operator type
*
@@ -157,7 +142,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
$this->_operatorType = $pValue;
return $this;
}
/**
* Get text
*
@@ -166,7 +151,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function getText() {
return $this->_text;
}
/**
* Set text
*
@@ -177,7 +162,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
$this->_text = $value;
return $this;
}
/**
* Get Condition
*
@@ -188,10 +173,10 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
if (isset($this->_condition[0])) {
return $this->_condition[0];
}
return '';
}
/**
* Set Condition
*
@@ -202,10 +187,10 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function setCondition($pValue = '') {
if (!is_array($pValue))
$pValue = array($pValue);
return $this->setConditions($pValue);
}
/**
* Get Conditions
*
@@ -214,7 +199,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function getConditions() {
return $this->_condition;
}
/**
* Set Conditions
*
@@ -224,11 +209,11 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function setConditions($pValue) {
if (!is_array($pValue))
$pValue = array($pValue);
$this->_condition = $pValue;
return $this;
}
/**
* Add Condition
*
@@ -239,7 +224,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
$this->_condition[] = $pValue;
return $this;
}
/**
* Get Style
*
@@ -248,7 +233,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function getStyle() {
return $this->_style;
}
/**
* Set Style
*
@@ -265,7 +250,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
return md5(
$this->_conditionType
@@ -275,7 +260,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,25 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Style_Color */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Fill
*
@@ -79,28 +64,28 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
* @var string
*/
private $_fillType;
/**
* Rotation
*
* @var double
*/
private $_rotation;
/**
* Start color
*
*
* @var PHPExcel_Style_Color
*/
private $_startColor;
/**
* End color
*
*
* @var PHPExcel_Style_Color
*/
private $_endColor;
/**
* Parent Borders
*
@@ -221,7 +206,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
/**
* Apply styles from array
*
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFill()->applyFromArray(
* array(
@@ -236,7 +221,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
* )
* );
* </code>
*
*
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Fill
@@ -267,7 +252,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Fill Type
*
@@ -279,7 +264,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this->_fillType;
}
/**
* Set Fill Type
*
@@ -295,7 +280,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Rotation
*
@@ -307,7 +292,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this->_rotation;
}
/**
* Set Rotation
*
@@ -323,7 +308,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Start Color
*
@@ -332,7 +317,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
public function getStartColor() {
return $this->_startColor;
}
/**
* Set Start Color
*
@@ -343,7 +328,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
public function setStartColor(PHPExcel_Style_Color $pValue = null) {
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
if ($this->_isSupervisor) {
$styleArray = $this->getStartColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -352,7 +337,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this;
}
/**
* Get End Color
*
@@ -361,7 +346,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
public function getEndColor() {
return $this->_endColor;
}
/**
* Set End Color
*
@@ -372,7 +357,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
public function setEndColor(PHPExcel_Style_Color $pValue = null) {
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
if ($this->_isSupervisor) {
$styleArray = $this->getEndColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -386,7 +371,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
@@ -399,7 +384,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,25 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_Style_Color */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Font
*
@@ -56,63 +41,63 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
const UNDERLINE_DOUBLEACCOUNTING = 'doubleAccounting';
const UNDERLINE_SINGLE = 'single';
const UNDERLINE_SINGLEACCOUNTING = 'singleAccounting';
/**
* Name
*
* @var string
*/
private $_name;
/**
* Bold
*
* @var boolean
*/
private $_bold;
/**
* Italic
*
* @var boolean
*/
private $_italic;
/**
* Superscript
*
* @var boolean
*/
private $_superScript;
/**
* Subscript
*
* @var boolean
*/
private $_subScript;
/**
* Underline
*
* @var string
*/
private $_underline;
/**
* Strikethrough
*
* @var boolean
*/
private $_strikethrough;
/**
* Foreground color
*
*
* @var PHPExcel_Style_Color
*/
private $_color;
private $_color;
/**
* Parent Borders
*
@@ -179,7 +164,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
{
return $this->_isSupervisor;
}
/**
* Get the shared style component for the currently active cell in currently active sheet.
* Only used for style supervisor
@@ -236,7 +221,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
/**
* Apply styles from array
*
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray(
* array(
@@ -251,7 +236,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
* )
* );
* </code>
*
*
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Font
@@ -294,7 +279,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Name
*
@@ -306,7 +291,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_name;
}
/**
* Set Name
*
@@ -325,7 +310,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Size
*
@@ -337,7 +322,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_size;
}
/**
* Set Size
*
@@ -356,7 +341,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Bold
*
@@ -368,7 +353,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_bold;
}
/**
* Set Bold
*
@@ -387,7 +372,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Italic
*
@@ -399,7 +384,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_italic;
}
/**
* Set Italic
*
@@ -418,7 +403,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
/**
* Get SuperScript
*
@@ -430,7 +415,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_superScript;
}
/**
* Set SuperScript
*
@@ -450,7 +435,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
/**
* Get SubScript
*
@@ -462,7 +447,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_subScript;
}
/**
* Set SubScript
*
@@ -482,7 +467,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Underline
*
@@ -494,7 +479,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_underline;
}
/**
* Set Underline
*
@@ -513,7 +498,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Striketrough
*
@@ -523,7 +508,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
public function getStriketrough() {
return $this->getStrikethrough();
}
/**
* Set Striketrough
*
@@ -534,7 +519,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
public function setStriketrough($pValue = false) {
return $this->setStrikethrough($pValue);
}
/**
* Get Strikethrough
*
@@ -546,7 +531,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_strikethrough;
}
/**
* Set Strikethrough
*
@@ -574,7 +559,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
public function getColor() {
return $this->_color;
}
/**
* Set Color
*
@@ -585,7 +570,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
public function setColor(PHPExcel_Style_Color $pValue = null) {
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
if ($this->_isSupervisor) {
$styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -599,7 +584,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
@@ -617,7 +602,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -22,28 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/** PHPExcel_Shared_Date */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
/** PHPExcel_Calculation_Functions */
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Functions.php';
/**
* PHPExcel_Style_NumberFormat
*
@@ -143,17 +125,17 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
private $_parent;
/**
* Create a new PHPExcel_Style_NumberFormat
*/
public function __construct($isSupervisor = false)
{
// Supervisor?
* Create a new PHPExcel_Style_NumberFormat
*/
public function __construct($isSupervisor = false)
{
// Supervisor?
$this->_isSupervisor = $isSupervisor;
// Initialise values
$this->_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
$this->_builtInFormatCode = 0;
}
// Initialise values
$this->_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
$this->_builtInFormatCode = 0;
}
/**
* Bind parent. Only used for supervisor
@@ -230,22 +212,23 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
return array('numberformat' => $array);
}
/**
* Apply styles from array
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray(
* array(
* 'code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE
* )
* );
* </code>
*
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_NumberFormat
*/
public function applyFromArray($pStyles = null) {
/**
* Apply styles from array
*
* <code>
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray(
* array(
* 'code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE
* )
* );
* </code>
*
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_NumberFormat
*/
public function applyFromArray($pStyles = null)
{
if (is_array($pStyles)) {
if ($this->_isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
@@ -260,32 +243,34 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
return $this;
}
/**
* Get Format Code
*
* @return string
*/
public function getFormatCode() {
/**
* Get Format Code
*
* @return string
*/
public function getFormatCode()
{
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getFormatCode();
}
if ($this->_builtInFormatCode !== false)
{
return self::builtInFormatCode($this->_builtInFormatCode);
}
return $this->_formatCode;
}
if ($this->_builtInFormatCode !== false)
{
return self::builtInFormatCode($this->_builtInFormatCode);
}
return $this->_formatCode;
}
/**
* Set Format Code
*
* @param string $pValue
* @return PHPExcel_Style_NumberFormat
*/
public function setFormatCode($pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL) {
if ($pValue == '') {
$pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
}
/**
* Set Format Code
*
* @param string $pValue
* @return PHPExcel_Style_NumberFormat
*/
public function setFormatCode($pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL)
{
if ($pValue == '') {
$pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
}
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('code' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -294,27 +279,29 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
$this->_builtInFormatCode = self::builtInFormatCodeIndex($pValue);
}
return $this;
}
}
/**
* Get Built-In Format Code
*
* @return int
*/
public function getBuiltInFormatCode() {
* Get Built-In Format Code
*
* @return int
*/
public function getBuiltInFormatCode()
{
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getBuiltInFormatCode();
}
return $this->_builtInFormatCode;
}
return $this->_builtInFormatCode;
}
/**
* Set Built-In Format Code
*
* @param int $pValue
* @return PHPExcel_Style_NumberFormat
*/
public function setBuiltInFormatCode($pValue = 0) {
/**
* Set Built-In Format Code
*
* @param int $pValue
* @return PHPExcel_Style_NumberFormat
*/
public function setBuiltInFormatCode($pValue = 0)
{
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('code' => self::builtInFormatCode($pValue)));
@@ -324,15 +311,15 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
$this->_formatCode = self::builtInFormatCode($pValue);
}
return $this;
}
}
/**
* Fill built-in format codes
*/
private static function fillBuiltInFormatCodes()
{
// Built-in format codes
if (is_null(self::$_builtInFormats)) {
/**
* Fill built-in format codes
*/
private static function fillBuiltInFormatCodes()
{
// Built-in format codes
if (is_null(self::$_builtInFormats)) {
self::$_builtInFormats = array();
// General
@@ -388,68 +375,72 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
// Flip array (for faster lookups)
self::$_flippedBuiltInFormats = array_flip(self::$_builtInFormats);
}
}
}
}
/**
* Get built-in format code
*
* @param int $pIndex
* @return string
*/
public static function builtInFormatCode($pIndex) {
// Clean parameter
/**
* Get built-in format code
*
* @param int $pIndex
* @return string
*/
public static function builtInFormatCode($pIndex)
{
// Clean parameter
$pIndex = intval($pIndex);
// Ensure built-in format codes are available
self::fillBuiltInFormatCodes();
self::fillBuiltInFormatCodes();
// Lookup format code
if (array_key_exists($pIndex, self::$_builtInFormats)) {
return self::$_builtInFormats[$pIndex];
}
return '';
}
return '';
}
/**
* Get built-in format code index
*
* @param string $formatCode
* @return int|boolean
*/
public static function builtInFormatCodeIndex($formatCode) {
// Ensure built-in format codes are available
self::fillBuiltInFormatCodes();
/**
* Get built-in format code index
*
* @param string $formatCode
* @return int|boolean
*/
public static function builtInFormatCodeIndex($formatCode)
{
// Ensure built-in format codes are available
self::fillBuiltInFormatCodes();
// Lookup format code
if (array_key_exists($formatCode, self::$_flippedBuiltInFormats)) {
return self::$_flippedBuiltInFormats[$formatCode];
}
return false;
}
return false;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
public function getHashCode()
{
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
}
return md5(
$this->_formatCode
. $this->_builtInFormatCode
. __CLASS__
);
}
return md5(
$this->_formatCode
. $this->_builtInFormatCode
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
public function __clone()
{
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
@@ -511,7 +502,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
* @param array $callBack Callback function for additional formatting of string
* @return string Formatted string
*/
public static function toFormattedString($value = '', $format = '', $callBack = null) {
public static function toFormattedString($value = '', $format = '', $callBack = null)
{
// For now we do not treat strings although section 4 of a format code affects strings
if (!is_numeric($value)) return $value;
@@ -587,7 +579,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
$format = strtr($format,self::$_dateFormatReplacements12);
}
$value = gmdate($format, PHPExcel_Shared_Date::ExcelToPHP($value));
$dateObj = PHPExcel_Shared_Date::ExcelToPHPObject($value);
$value = $dateObj->format($format);
} else if (preg_match('/%$/', $format)) { // % number format
if ($format === self::FORMAT_PERCENTAGE) {
@@ -606,31 +599,44 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
}
} else {
if (preg_match ("/^([0-9.,-]+)$/", $value)) {
if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) {
$value = 'EUR ' . sprintf('%1.2f', $value);
if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) {
$value = 'EUR ' . sprintf('%1.2f', $value);
} else {
// In Excel formats, "_" is used to add spacing, which we can't do in HTML
$format = preg_replace('/_./', '', $format);
} else {
// In Excel formats, "_" is used to add spacing, which we can't do in HTML
$format = preg_replace('/_./', '', $format);
// Some non-number characters are escaped with \, which we don't need
$format = preg_replace("/\\\\/", '', $format);
// Some non-number characters are escaped with \, which we don't need
$format = preg_replace("/\\\\/", '', $format);
// Some non-number strings are quoted, so we'll get rid of the quotes
$format = preg_replace('/"/', '', $format);
// Some non-number strings are quoted, so we'll get rid of the quotes
$format = preg_replace('/"/', '', $format);
// TEMPORARY - Convert # to 0
$format = preg_replace('/\\#/', '0', $format);
// Find out if we need thousands separator
// This is indicated by a comma enclosed by a digit placeholder:
// #,# or 0,0
$useThousands = preg_match('/(#,#|0,0)/', $format);
if ($useThousands) {
$format = preg_replace('/0,0/', '00', $format);
$format = preg_replace('/#,#/', '##', $format);
}
// Find out if we need thousands separator
$useThousands = preg_match('/,/', $format);
if ($useThousands) {
$format = preg_replace('/,/', '', $format);
}
// Scale thousands, millions,...
// This is indicated by a number of commas after a digit placeholder:
// #, or 0.0,,
$scale = 1; // same as no scale
$matches = array();
if (preg_match('/(#|0)(,+)/', $format, $matches)) {
$scale = pow(1000, strlen($matches[2]));
if (preg_match('/0?.*\?\/\?/', $format, $m)) {
//echo 'Format mask is fractional '.$format.' <br />';
// strip the commas
$format = preg_replace('/0,+/', '0', $format);
$format = preg_replace('/#,+/', '#', $format);
}
if (preg_match('/#?.*\?\/\?/', $format, $m)) {
//echo 'Format mask is fractional '.$format.' <br />';
if ($value != (int)$value) {
$sign = ($value < 0) ? '-' : '';
$integerPart = floor(abs($value));
@@ -650,28 +656,41 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
$adjustedDecimalPart += $integerPart * $adjustedDecimalDivisor;
$value = "$sign$adjustedDecimalPart/$adjustedDecimalDivisor";
}
}
} else {
// Handle the number itself
$number_regex = "/(\d+)(\.?)(\d*)/";
if (preg_match($number_regex, $format, $matches)) {
$left = $matches[1];
$dec = $matches[2];
$right = $matches[3];
if ($useThousands) {
$value = number_format(
$value
, strlen($right)
, PHPExcel_Shared_String::getDecimalSeparator()
, PHPExcel_Shared_String::getThousandsSeparator()
);
} else {
// Handle the number itself
} else {
$sprintf_pattern = "%1." . strlen($right) . "f";
$value = sprintf($sprintf_pattern, $value);
}
$value = preg_replace($number_regex, $value, $format);
// scale number
$value = $value / $scale;
// Strip #
$format = preg_replace('/\\#/', '', $format);
$number_regex = "/(0+)(\.?)(0*)/";
$matches = array();
if (preg_match($number_regex, $format, $matches)) {
$left = $matches[1];
$dec = $matches[2];
$right = $matches[3];
// minimun width of formatted number (including dot)
$minWidth = strlen($left) + strlen($dec) + strlen($right);
if ($useThousands) {
$value = number_format(
$value
, strlen($right)
, PHPExcel_Shared_String::getDecimalSeparator()
, PHPExcel_Shared_String::getThousandsSeparator()
);
} else {
$sprintf_pattern = "%0$minWidth." . strlen($right) . "f";
$value = sprintf($sprintf_pattern, $value);
}
$value = preg_replace($number_regex, $value, $format);
}
}
}
@@ -685,4 +704,5 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
return $value;
}
}

View File

@@ -26,18 +26,6 @@
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/**
* PHPExcel_Style_Protection
*
@@ -276,7 +264,7 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -22,94 +22,10 @@
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
}
/** PHPExcel */
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/** PHPExcel_Cell_DataType */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
/** PHPExcel_Worksheet_RowDimension */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/RowDimension.php';
/** PHPExcel_Worksheet_ColumnDimension */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/ColumnDimension.php';
/** PHPExcel_Worksheet_PageSetup */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/PageSetup.php';
/** PHPExcel_Worksheet_PageMargins */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/PageMargins.php';
/** PHPExcel_Worksheet_HeaderFooter */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/HeaderFooter.php';
/** PHPExcel_Worksheet_BaseDrawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/BaseDrawing.php';
/** PHPExcel_Worksheet_Drawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing.php';
/** PHPExcel_Worksheet_MemoryDrawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/MemoryDrawing.php';
/** PHPExcel_Worksheet_HeaderFooterDrawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/HeaderFooterDrawing.php';
/** PHPExcel_Worksheet_SheetView */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/SheetView.php';
/** PHPExcel_Worksheet_Protection */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Protection.php';
/** PHPExcel_Worksheet_RowIterator */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/RowIterator.php';
/** PHPExcel_Comment */
require_once PHPEXCEL_ROOT . 'PHPExcel/Comment.php';
/** PHPExcel_Style */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style.php';
/** PHPExcel_Style_Fill */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Fill.php';
/** PHPExcel_Style_Color */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
/** PHPExcel_Style_NumberFormat */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/** PHPExcel_Shared_Font */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Font.php';
/** PHPExcel_Shared_String */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
/** PHPExcel_Shared_PasswordHasher */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PasswordHasher.php';
/** PHPExcel_ReferenceHelper */
require_once PHPEXCEL_ROOT . 'PHPExcel/ReferenceHelper.php';
/**
* PHPExcel_Worksheet
*
@@ -123,12 +39,19 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
const BREAK_NONE = 0;
const BREAK_ROW = 1;
const BREAK_COLUMN = 2;
/* Sheet state */
const SHEETSTATE_VISIBLE = 'visible';
const SHEETSTATE_HIDDEN = 'hidden';
const SHEETSTATE_VERYHIDDEN = 'veryHidden';
/**
* Invalid characters in sheet title
*
* @var array
*/
private static $_invalidCharacters = array('*', ':', '/', '\\', '?', '[', ']');
/**
* Parent spreadsheet
*
@@ -137,11 +60,11 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
private $_parent;
/**
* Collection of cells
* Cacheable collection of cells
*
* @var PHPExcel_Cell[]
* @var PHPExcel_CachedObjectStorage_xxx
*/
private $_cellCollection = array();
private $_cellCollection = null;
/**
* Collection of row dimensions
@@ -184,7 +107,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @var string
*/
private $_title;
/**
* Sheet state
*
@@ -297,6 +220,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
private $_printGridlines = false;
/**
* Show row and column headers?
*
* @var boolean
*/
private $_showRowColHeaders = true;
/**
* Show summary below? (Row/Column outline)
*
@@ -387,6 +317,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->setTitle($pTitle);
$this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE);
$this->_cellCollection = PHPExcel_CachedObjectStorageFactory::getInstance($this);
// Set page setup
$this->_pageSetup = new PHPExcel_Worksheet_PageSetup();
@@ -420,6 +352,35 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(null);
}
public function disconnectCells() {
$this->_cellCollection->unsetWorksheetCells();
$this->_cellCollection = null;
// detach ourself from the workbook, so that it can then delete this worksheet successfully
$this->_parent = null;
}
/**
* Return the cache controller for the cell collection
*
* @return PHPExcel_CachedObjectStorage_xxx
*/
public function getCellCacheController() {
return $this->_cellCollection;
} // function getCellCacheController()
/**
* Get array of invalid characters for sheet title
*
* @return array
*/
public static function getInvalidCharacters()
{
return self::$_invalidCharacters;
}
/**
* Check sheet title for valid Excel syntax
*
@@ -430,7 +391,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
private static function _checkSheetTitle($pValue)
{
// Some of the printable ASCII characters are invalid: * : / \ ? [ ]
if (preg_match('/(\\*|\\:|\\/|\\\\|\\?|\\[|\\])/', $pValue)) {
if (str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) {
throw new Exception('Invalid character found in sheet title');
}
@@ -455,7 +416,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->sortCellCollection();
}
return $this->_cellCollection;
if (is_null($this->_cellCollection)) {
return array();
}
return $this->_cellCollection->getCellList();
}
/**
@@ -466,29 +430,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function sortCellCollection()
{
if (!$this->_cellCollectionIsSorted) {
// Re-order cell collection
// uasort($this->_cellCollection, array('PHPExcel_Cell', 'compareCells')); <-- slow
$indexed = array();
foreach (array_keys($this->_cellCollection) as $index) {
$rowNum = $this->_cellCollection[$index]->getRow();
$colNum = PHPExcel_Cell::columnIndexFromString($this->_cellCollection[$index]->getColumn());
// Columns are limited to ZZZ (18278), so 20000 is plenty to assure no conflicts
$key = $rowNum * 20000 + $colNum;
$indexed[$key] = $index; // &$this->_cellCollection[$index];
if (!is_null($this->_cellCollection)) {
$this->_cellCollection->sortCellList();
}
ksort($indexed);
// Rebuild cellCollection from the sorted index
$newCellCollection = array();
foreach ($indexed as $index) {
$newCellCollection[$index] = $this->_cellCollection[$index];
}
$this->_cellCollection = $newCellCollection;
$this->_cellCollectionIsSorted = true;
}
return $this;
@@ -610,31 +554,38 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
}
// There is only something to do if there are some auto-size columns
if (count($autoSizes) > 0) {
// loop though all cells in sheet expand $autoSizes
foreach ($this->getCellCollection(false) as $cell) {
if (!empty($autoSizes)) {
// build list of cells references that participate in a merge
$isMergeCell = array();
foreach ($this->getMergeCells() as $cells) {
foreach (PHPExcel_Cell::extractAllCellReferencesInRange($cells) as $cellReference) {
$isMergeCell[$cellReference] = true;
}
}
// loop through all cells in the worksheet
foreach ($this->getCellCollection(false) as $cellID) {
$cell = $this->getCell($cellID);
if (isset($autoSizes[$cell->getColumn()])) {
// Calculated value
$cellValue = $cell->getCalculatedValue();
// Determine width if cell does not participate in a merge
if (!isset($isMergeCell[$cell->getCoordinate()])) {
// Calculated value
$cellValue = $cell->getCalculatedValue();
// To formatted string
$cellValue = PHPExcel_Style_NumberFormat::toFormattedString($cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode());
// To formatted string
$cellValue = PHPExcel_Style_NumberFormat::toFormattedString($cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode());
foreach ($this->getMergeCells() as $cells) {
if ($cell->isInRange($cells) && !$calculateMergeCells) {
$cellValue = ''; // do not calculate merge cells
}
$autoSizes[$cell->getColumn()] = max(
(float)$autoSizes[$cell->getColumn()],
(float)PHPExcel_Shared_Font::calculateColumnWidth(
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
$cellValue,
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
$this->getDefaultStyle()->getFont()
)
);
}
$autoSizes[$cell->getColumn()] = max(
(float)$autoSizes[$cell->getColumn()],
(float)PHPExcel_Shared_Font::calculateColumnWidth(
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
$cellValue,
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
$this->getDefaultStyle()->getFont()
)
);
}
}
@@ -730,7 +681,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
return $this;
}
/**
* Get sheet state
*
@@ -739,7 +690,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function getSheetState() {
return $this->_sheetState;
}
/**
* Set sheet state
*
@@ -750,7 +701,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->_sheetState = $value;
return $this;
}
/**
* Get page setup
*
@@ -906,7 +857,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 0, $pValue = null)
{
return $this->setCellValue(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow, $pValue);
return $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValue($pValue);
}
/**
@@ -935,7 +886,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 0, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
return $this->setCellValueExplicit(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow, $pValue, $pDataType);
return $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValueExplicit($pValue, $pDataType);
}
/**
@@ -948,8 +899,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function getCell($pCoordinate = 'A1')
{
// Check cell collection
if (isset($this->_cellCollection[$pCoordinate])) {
return $this->_cellCollection[$pCoordinate];
if ($this->_cellCollection->isDataSet($pCoordinate)) {
return $this->_cellCollection->getCacheData($pCoordinate);
}
// Worksheet reference?
@@ -964,16 +915,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
if (!is_null($namedRange)) {
$pCoordinate = $namedRange->getRange();
if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) {
if (!$namedRange->getLocalOnly()) {
return $namedRange->getWorksheet()->getCell($pCoordinate);
} else {
throw new Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle());
}
} else {
//Allow named ranges within the same sheet.
return $this->getCell($pCoordinate);
}
return $namedRange->getWorksheet()->getCell($pCoordinate);
}
}
@@ -990,7 +932,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Coordinates
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
$this->_cellCollection[$pCoordinate] = new PHPExcel_Cell($aCoordinates[0], $aCoordinates[1], null, PHPExcel_Cell_DataType::TYPE_NULL, $this);
$cell = $this->_cellCollection->addCacheData($pCoordinate,new PHPExcel_Cell($aCoordinates[0], $aCoordinates[1], null, PHPExcel_Cell_DataType::TYPE_NULL, $this));
$this->_cellCollectionIsSorted = false;
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
@@ -1005,18 +947,16 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if ( isset($rowDimensions[$aCoordinates[1]]) && $rowDimensions[$aCoordinates[1]]->getXfIndex() !== null ) {
// then there is a row dimension with explicit style, assign it to the cell
$this->_cellCollection[$pCoordinate]->setXfIndex($rowDimensions[$aCoordinates[1]]->getXfIndex());
$cell->setXfIndex($rowDimensions[$aCoordinates[1]]->getXfIndex());
} else if ( isset($columnDimensions[$aCoordinates[0]]) ) {
// then there is a column dimension, assign it to the cell
$this->_cellCollection[$pCoordinate]->setXfIndex($columnDimensions[$aCoordinates[0]]->getXfIndex());
$cell->setXfIndex($columnDimensions[$aCoordinates[0]]->getXfIndex());
} else {
// set to default index
$this->_cellCollection[$pCoordinate]->setXfIndex(0);
$cell->setXfIndex(0);
}
return $this->_cellCollection[$pCoordinate];
return $cell;
}
}
@@ -1029,22 +969,23 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function getCellByColumnAndRow($pColumn = 0, $pRow = 0)
{
$coordinate = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow;
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
$coordinate = $columnLetter . $pRow;
if (!isset($this->_cellCollection[$coordinate])) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
$this->_cellCollection[$coordinate] = new PHPExcel_Cell($columnLetter, $pRow, null, PHPExcel_Cell_DataType::TYPE_NULL, $this);
if (!$this->_cellCollection->isDataSet($coordinate)) {
$cell = $this->_cellCollection->addCacheData($coordinate, new PHPExcel_Cell($columnLetter, $pRow, null, PHPExcel_Cell_DataType::TYPE_NULL, $this));
$this->_cellCollectionIsSorted = false;
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn)
$this->_cachedHighestColumn = $pColumn;
$this->_cachedHighestColumn = $columnLetter;
if ($this->_cachedHighestRow < $pRow)
$this->_cachedHighestRow = $pRow;
return $cell;
}
return $this->_cellCollection[$coordinate];
return $this->_cellCollection->getCacheData($coordinate);
}
/**
@@ -1090,7 +1031,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
// Cell exists?
return isset($this->_cellCollection[$pCoordinate]);
return $this->_cellCollection->isDataSet($pCoordinate);
}
}
@@ -1455,6 +1396,24 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if (strpos($pRange,':') !== false) {
$this->_mergeCells[$pRange] = $pRange;
// make sure cells are created
// get the cells in the range
$aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
// create upper left cell if it does not already exist
$upperLeft = $aReferences[0];
if (!$this->cellExists($upperLeft)) {
$this->getCell($upperLeft)->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL);
}
// create or blank out the rest of the cells in the range
$count = count($aReferences);
for ($i = 1; $i < $count; $i++) {
$this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL);
}
} else {
throw new Exception('Merge must be set on a range of cells.');
}
@@ -1533,7 +1492,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* Set merge cells array for the entire sheet. Use instead mergeCells() to merge
* a single cell range.
*
* @param array
* @param array
*/
public function setMergeCells($pValue = array())
{
@@ -1877,6 +1836,26 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
return $this;
}
/**
* Show row and column headers?
*
* @return boolean
*/
public function getShowRowColHeaders() {
return $this->_showRowColHeaders;
}
/**
* Set show row and column headers
*
* @param boolean $pValue Show row and column headers (true/false)
* @return PHPExcel_Worksheet
*/
public function setShowRowColHeaders($pValue = false) {
$this->_showRowColHeaders = $pValue;
return $this;
}
/**
* Show summary below? (Row/Column outlining)
*
@@ -2083,7 +2062,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* Fill worksheet from values in array
*
* @param array $source Source array
* @param mixed $nullValue Value treated as "null"
* @param mixed $nullValue Value in source array that stands for blank cell
* @throws Exception
* @return PHPExcel_Worksheet
*/
@@ -2103,9 +2082,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
for ($i = 0; $i < $rowCount; ++$i) {
if ($rowData[$i] != $nullValue) {
// Set cell value
$this->setCellValue(
PHPExcel_Cell::stringFromColumnIndex($i + $startColumn) . $currentRow, $rowData[$i]
);
$this->getCell(PHPExcel_Cell::stringFromColumnIndex($i + $startColumn) . $currentRow)
->setValue($rowData[$i]);
}
}
}
@@ -2195,17 +2173,20 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$highestRow = 1;
// Find cells that can be cleaned
foreach ($this->_cellCollection as $coordinate => $cell) {
foreach ($this->_cellCollection->getCellList() as $coordinate) {
$cell = $this->getCell($coordinate);
// Can be cleaned?
$canBeCleaned = false;
// Empty value?
/* Excel doesn't remove such empty cells
// Empty value?
if (is_null($cell->getValue()) || (!is_object($cell->getValue()) && $cell->getValue() === '' && !$cell->hasHyperlink())) {
// default style ?
if ($cell->getXfIndex() == 0) {
$canBeCleaned = true;
}
}
*/
// Referenced in image?
if (isset($imageCoordinates[$coordinate]) && $imageCoordinates[$coordinate] === true) {
@@ -2215,7 +2196,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Clean?
if ($canBeCleaned) {
// Remove the cell
unset($this->_cellCollection[$coordinate]);
$this->_cellCollection->deleteCacheData($coordinate);
} else {
// Determine highest column and row
if ($highestColumn < PHPExcel_Cell::columnIndexFromString($cell->getColumn())) {
@@ -2319,8 +2300,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
}
// else create hyperlink
$cell = $this->getCell($pCellCoordinate);
$this->_hyperlinkCollection[$pCellCoordinate] = new PHPExcel_Cell_Hyperlink($cell);
$this->_hyperlinkCollection[$pCellCoordinate] = new PHPExcel_Cell_Hyperlink();
return $this->_hyperlinkCollection[$pCellCoordinate];
}
@@ -2337,7 +2317,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
unset($this->_hyperlinkCollection[$pCellCoordinate]);
} else {
$this->_hyperlinkCollection[$pCellCoordinate] = $pHyperlink;
$pHyperlink->setParent($this->getCell($pCellCoordinate));
}
return $this;
}
@@ -2376,8 +2355,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
}
// else create data validation
$cell = $this->getCell($pCellCoordinate);
$this->_dataValidationCollection[$pCellCoordinate] = new PHPExcel_Cell_DataValidation($cell);
$this->_dataValidationCollection[$pCellCoordinate] = new PHPExcel_Cell_DataValidation();
return $this->_dataValidationCollection[$pCellCoordinate];
}
@@ -2394,7 +2372,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
unset($this->_dataValidationCollection[$pCellCoordinate]);
} else {
$this->_dataValidationCollection[$pCellCoordinate] = $pDataValidation;
$pDataValidation->setParent($this->getCell($pCellCoordinate));
}
return $this;
}
@@ -2420,6 +2397,34 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
return $this->_dataValidationCollection;
}
/**
* Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet
*
* @param string $range
* @return string Adjusted range value
*/
public function shrinkRangeToFit($range) {
$maxCol = $this->getHighestColumn();
$maxRow = $this->getHighestRow();
$maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
$rangeBlocks = explode(' ',$range);
foreach ($rangeBlocks as &$rangeSet) {
$rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet);
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) { $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); }
if ($rangeBoundaries[0][1] > $maxRow) { $rangeBoundaries[0][1] = $maxRow; }
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) { $rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); }
if ($rangeBoundaries[1][1] > $maxRow) { $rangeBoundaries[1][1] = $maxRow; }
$rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1];
}
unset($rangeSet);
$stRange = implode(' ',$rangeBlocks);
return $stRange;
}
/**
* Get tab color
*

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,27 +22,10 @@
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Worksheet_Drawing_Shadow */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
/**
* PHPExcel_Worksheet_BaseDrawing
*
@@ -51,98 +34,98 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
{
{
/**
* Image counter
*
* @var int
*/
private static $_imageCounter = 0;
/**
* Image index
*
* @var int
*/
private $_imageIndex = 0;
/**
* Name
*
* @var string
*/
protected $_name;
/**
* Description
*
* @var string
*/
protected $_description;
/**
* Worksheet
*
* @var PHPExcel_Worksheet
*/
protected $_worksheet;
/**
* Coordinates
*
* @var string
*/
protected $_coordinates;
/**
* Offset X
*
* @var int
*/
protected $_offsetX;
/**
* Offset Y
*
* @var int
*/
protected $_offsetY;
/**
* Width
*
* @var int
*/
protected $_width;
/**
* Height
*
* @var int
*/
protected $_height;
/**
* Proportional resize
*
* @var boolean
*/
protected $_resizeProportional;
/**
* Rotation
*
* @var int
*/
protected $_rotation;
/**
* Shadow
*
* @var PHPExcel_Worksheet_Drawing_Shadow
*/
protected $_shadow;
protected $_shadow;
/**
* Create a new PHPExcel_Worksheet_BaseDrawing
*/
@@ -160,12 +143,12 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_resizeProportional = true;
$this->_rotation = 0;
$this->_shadow = new PHPExcel_Worksheet_Drawing_Shadow();
// Set image index
self::$_imageCounter++;
$this->_imageIndex = self::$_imageCounter;
}
/**
* Get image index
*
@@ -174,7 +157,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getImageIndex() {
return $this->_imageIndex;
}
/**
* Get Name
*
@@ -183,7 +166,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getName() {
return $this->_name;
}
/**
* Set Name
*
@@ -194,7 +177,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_name = $pValue;
return $this;
}
/**
* Get Description
*
@@ -203,7 +186,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getDescription() {
return $this->_description;
}
/**
* Set Description
*
@@ -223,7 +206,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getWorksheet() {
return $this->_worksheet;
}
/**
* Set Worksheet
*
@@ -242,7 +225,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
if ($pOverrideOld) {
// Remove drawing from old PHPExcel_Worksheet
$iterator = $this->_worksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) {
if ($iterator->current()->getHashCode() == $this->getHashCode()) {
$this->_worksheet->getDrawingCollection()->offsetUnset( $iterator->key() );
@@ -250,7 +233,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
break;
}
}
// Set new PHPExcel_Worksheet
$this->setWorksheet($pValue);
} else {
@@ -259,7 +242,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
}
return $this;
}
/**
* Get Coordinates
*
@@ -267,8 +250,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/
public function getCoordinates() {
return $this->_coordinates;
}
}
/**
* Set Coordinates
*
@@ -279,7 +262,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_coordinates = $pValue;
return $this;
}
/**
* Get OffsetX
*
@@ -288,7 +271,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getOffsetX() {
return $this->_offsetX;
}
/**
* Set OffsetX
*
@@ -299,7 +282,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_offsetX = $pValue;
return $this;
}
/**
* Get OffsetY
*
@@ -308,7 +291,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getOffsetY() {
return $this->_offsetY;
}
/**
* Set OffsetY
*
@@ -319,7 +302,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_offsetY = $pValue;
return $this;
}
/**
* Get Width
*
@@ -328,7 +311,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getWidth() {
return $this->_width;
}
/**
* Set Width
*
@@ -338,16 +321,16 @@ 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;
$this->_height = round($ratio * $pValue);
}
// Set width
$this->_width = $pValue;
return $this;
}
/**
* Get Height
*
@@ -356,7 +339,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getHeight() {
return $this->_height;
}
/**
* Set Height
*
@@ -366,16 +349,16 @@ 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;
$this->_width = round($ratio * $pValue);
}
// Set height
$this->_height = $pValue;
return $this;
}
/**
* Set width and height with proportional resize
* Example:
@@ -403,7 +386,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
}
return $this;
}
/**
* Get ResizeProportional
*
@@ -412,7 +395,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getResizeProportional() {
return $this->_resizeProportional;
}
/**
* Set ResizeProportional
*
@@ -423,7 +406,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_resizeProportional = $pValue;
return $this;
}
/**
* Get Rotation
*
@@ -432,7 +415,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getRotation() {
return $this->_rotation;
}
/**
* Set Rotation
*
@@ -443,7 +426,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_rotation = $pValue;
return $this;
}
/**
* Get Shadow
*
@@ -452,7 +435,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getShadow() {
return $this->_shadow;
}
/**
* Set Shadow
*
@@ -469,7 +452,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
return md5(
$this->_name
@@ -485,7 +468,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -22,38 +22,20 @@
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel */
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Cell */
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
/**
* PHPExcel_Worksheet_CellIterator
*
*
* Used to iterate rows in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_CellIterator extends IteratorIterator
class PHPExcel_Worksheet_CellIterator extends CachingIterator
{
/**
* PHPExcel_Worksheet to iterate
@@ -61,21 +43,21 @@ class PHPExcel_Worksheet_CellIterator extends IteratorIterator
* @var PHPExcel_Worksheet
*/
private $_subject;
/**
* Row index
*
* @var int
*/
private $_rowIndex;
/**
* Current iterator position
*
* @var int
*/
private $_position = 0;
/**
* Loop only existing cells
*
@@ -94,14 +76,14 @@ class PHPExcel_Worksheet_CellIterator extends IteratorIterator
$this->_subject = $subject;
$this->_rowIndex = $rowIndex;
}
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
/**
* Rewind iterator
*/
@@ -158,7 +140,7 @@ class PHPExcel_Worksheet_CellIterator extends IteratorIterator
return $this->_position < $columnCount;
}
/**
* Get loop only existing cells
*
@@ -167,7 +149,7 @@ class PHPExcel_Worksheet_CellIterator extends IteratorIterator
public function getIterateOnlyExistingCells() {
return $this->_onlyExistingCells;
}
/**
* Set loop only existing cells
*

View File

@@ -22,7 +22,7 @@
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,31 +22,10 @@
* @package PHPExcel_Worksheet_Drawing
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
}
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Worksheet_BaseDrawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/BaseDrawing.php';
/** PHPExcel_Worksheet_Drawing_Shadow */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
/**
* PHPExcel_Worksheet_Drawing
*
@@ -54,15 +33,15 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
* @package PHPExcel_Worksheet_Drawing
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
{
class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
{
/**
* Path
*
* @var string
*/
private $_path;
/**
* Create a new PHPExcel_Worksheet_Drawing
*/
@@ -70,11 +49,11 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
{
// Initialise values
$this->_path = '';
// Initialize parent
parent::__construct();
}
/**
* Get Filename
*
@@ -83,7 +62,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
public function getFilename() {
return basename($this->_path);
}
/**
* Get indexed filename (using image index)
*
@@ -94,7 +73,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
$fileName = str_replace(' ', '_', $fileName);
return str_replace('.' . $this->getExtension(), '', $fileName) . $this->getImageIndex() . '.' . $this->getExtension();
}
/**
* Get Extension
*
@@ -104,7 +83,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
$exploded = explode(".", basename($this->_path));
return $exploded[count($exploded) - 1];
}
/**
* Get Path
*
@@ -113,7 +92,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
public function getPath() {
return $this->_path;
}
/**
* Set Path
*
@@ -126,7 +105,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
if ($pVerifyFile) {
if (file_exists($pValue)) {
$this->_path = $pValue;
if ($this->_width == 0 && $this->_height == 0) {
// Get width/height
list($this->_width, $this->_height) = getimagesize($pValue);
@@ -144,7 +123,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
return md5(
$this->_path
@@ -152,7 +131,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

View File

@@ -8,12 +8,12 @@
* 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
@@ -22,27 +22,10 @@
* @package PHPExcel_Worksheet_Drawing
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.2, 2010-01-11
* @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
}
/** PHPExcel_IComparable */
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
/** PHPExcel_Worksheet */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
/** PHPExcel_Style_Color */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
/**
* PHPExcel_Worksheet_Drawing_Shadow
*
@@ -51,7 +34,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
{
{
/* Shadow alignment */
const SHADOW_BOTTOM = 'b';
const SHADOW_BOTTOM_LEFT = 'bl';
@@ -60,7 +43,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
const SHADOW_LEFT = 'l';
const SHADOW_TOP = 't';
const SHADOW_TOP_LEFT = 'tl';
const SHADOW_TOP_RIGHT = 'tr';
const SHADOW_TOP_RIGHT = 'tr';
/**
* Visible
@@ -68,7 +51,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
* @var boolean
*/
private $_visible;
/**
* Blur radius
*
@@ -77,7 +60,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
* @var int
*/
private $_blurRadius;
/**
* Shadow distance
*
@@ -86,35 +69,35 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
* @var int
*/
private $_distance;
/**
* Shadow direction (in degrees)
*
* @var int
*/
private $_direction;
/**
* Shadow alignment
*
* @var int
*/
private $_alignment;
/**
* Color
*
*
* @var PHPExcel_Style_Color
*/
private $_color;
/**
* Alpha
*
* @var int
*/
private $_alpha;
/**
* Create a new PHPExcel_Worksheet_Drawing_Shadow
*/
@@ -129,7 +112,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK);
$this->_alpha = 50;
}
/**
* Get Visible
*
@@ -138,7 +121,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getVisible() {
return $this->_visible;
}
/**
* Set Visible
*
@@ -149,7 +132,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_visible = $pValue;
return $this;
}
/**
* Get Blur radius
*
@@ -158,7 +141,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getBlurRadius() {
return $this->_blurRadius;
}
/**
* Set Blur radius
*
@@ -169,7 +152,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_blurRadius = $pValue;
return $this;
}
/**
* Get Shadow distance
*
@@ -178,7 +161,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getDistance() {
return $this->_distance;
}
/**
* Set Shadow distance
*
@@ -189,7 +172,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_distance = $pValue;
return $this;
}
/**
* Get Shadow direction (in degrees)
*
@@ -198,7 +181,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getDirection() {
return $this->_direction;
}
/**
* Set Shadow direction (in degrees)
*
@@ -209,7 +192,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_direction = $pValue;
return $this;
}
/**
* Get Shadow alignment
*
@@ -218,7 +201,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getAlignment() {
return $this->_alignment;
}
/**
* Set Shadow alignment
*
@@ -229,7 +212,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_alignment = $pValue;
return $this;
}
/**
* Get Color
*
@@ -238,7 +221,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getColor() {
return $this->_color;
}
/**
* Set Color
*
@@ -250,7 +233,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_color = $pValue;
return $this;
}
/**
* Get Alpha
*
@@ -259,7 +242,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getAlpha() {
return $this->_alpha;
}
/**
* Set Alpha
*
@@ -275,7 +258,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
*/
*/
public function getHashCode() {
return md5(
($this->_visible ? 't' : 'f')
@@ -288,7 +271,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
. __CLASS__
);
}
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/

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