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]);
}
}
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]);
}
}
if (is_null($pSheet)) {
if (isset($this->_namedRanges[$namedRange])) {
unset($this->_namedRanges[$namedRange]);
}
} 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
*

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

@@ -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
*
@@ -92,7 +65,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
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;
@@ -106,20 +79,43 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
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');
// 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 Excel date
$cell->setValueExplicit( PHPExcel_Shared_Date::PHPToExcel(strtotime($value)), PHPExcel_Cell_DataType::TYPE_NUMERIC);
// 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 );
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
// restore original value for timezone
date_default_timezone_set($saveTimeZone);
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
*

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

@@ -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
*
@@ -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

@@ -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

@@ -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
*

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

@@ -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
*

View File

@@ -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
*

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,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
*/
@@ -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_IWriter */
require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
/** PHPExcel_IReader */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
/**
* PHPExcel_IOFactory
*
@@ -57,6 +54,8 @@ class PHPExcel_IOFactory
* Search locations
*
* @var array
* @access private
* @static
*/
private static $_searchLocations = array(
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
@@ -67,6 +66,8 @@ class PHPExcel_IOFactory
* Autoresolve classes
*
* @var array
* @access private
* @static
*/
private static $_autoResolveClasses = array(
'Excel2007',
@@ -86,15 +87,19 @@ class PHPExcel_IOFactory
/**
* Get search locations
*
* @static
* @access public
* @return array
*/
public static function getSearchLocations() {
return self::$_searchLocations;
}
} // function getSearchLocations()
/**
* Set search locations
*
* @static
* @access public
* @param array $value
* @throws Exception
*/
@@ -104,25 +109,30 @@ class PHPExcel_IOFactory
} else {
throw new Exception('Invalid parameter passed.');
}
}
} // function setSearchLocations()
/**
* Add search location
*
* @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
*
* @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
*
* @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
*
* @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()
/**
* Identify file type using automatic PHPExcel_Reader_IReader resolution
*
* @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
*
@@ -62,6 +53,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
/**
* Input encoding
*
* @access private
* @var string
*/
private $_inputEncoding;
@@ -69,6 +61,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
/**
* Delimiter
*
* @access private
* @var string
*/
private $_delimiter;
@@ -76,6 +69,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
/**
* Enclosure
*
* @access private
* @var string
*/
private $_enclosure;
@@ -83,6 +77,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
/**
* Line ending
*
* @access private
* @var string
*/
private $_lineEnding;
@@ -90,6 +85,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
/**
* Sheet index to read
*
* @access private
* @var int
*/
private $_sheetIndex;
@@ -97,6 +93,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
/**
* PHPExcel_Reader_IReadFilter instance
*
* @access private
* @var PHPExcel_Reader_IReadFilter
*/
private $_readFilter = null;
@@ -111,13 +108,15 @@ 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?
*
* @access public
* @param string $pFileName
* @return boolean
* @throws Exception
*/
public function canRead($pFilename)
{
@@ -127,12 +126,14 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
}
return true;
}
} // function canRead()
/**
* Loads PHPExcel from file
*
* @access public
* @param string $pFilename
* @return PHPExcel
* @throws Exception
*/
public function load($pFilename)
@@ -142,51 +143,59 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
} // function load()
/**
* Read filter
*
* @access public
* @return PHPExcel_Reader_IReadFilter
*/
public function getReadFilter() {
return $this->_readFilter;
}
} // function getReadFilter()
/**
* Set read filter
*
* @access public
* @param PHPExcel_Reader_IReadFilter $pValue
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
$this->_readFilter = $pValue;
}
return $this;
} // function setReadFilter()
/**
* Set 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
*
* @access public
* @return string
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
}
} // function getInputEncoding()
/**
* Loads PHPExcel from file into PHPExcel instance
*
* @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;
}
@@ -238,9 +246,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
}
// Set cell value
$objPHPExcel->getActiveSheet()->setCellValue(
$columnLetter . $currentRow, $rowData[$i]
);
$objPHPExcel->getActiveSheet()->getCell($columnLetter . $currentRow)->setValue($rowData[$i]);
}
}
}
@@ -250,40 +256,44 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
// Return
return $objPHPExcel;
}
} // function loadIntoExisting()
/**
* Get delimiter
*
* @access public
* @return string
*/
public function getDelimiter() {
return $this->_delimiter;
}
} // function getDelimiter()
/**
* Set delimiter
*
* @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
*
* @access public
* @return string
*/
public function getEnclosure() {
return $this->_enclosure;
}
} // function getEnclosure()
/**
* Set enclosure
*
* @access public
* @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Reader_CSV
*/
@@ -293,45 +303,49 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
}
$this->_enclosure = $pValue;
return $this;
}
} // function setEnclosure()
/**
* Get line ending
*
* @access public
* @return string
*/
public function getLineEnding() {
return $this->_lineEnding;
}
} // function getLineEnding()
/**
* Set line ending
*
* @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
*
* @access public
* @return int
*/
public function getSheetIndex() {
return $this->_sheetIndex;
}
} // function getSheetIndex()
/**
* Set sheet index
*
* @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

@@ -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
*

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]);
}

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,63 +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_Style */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style.php';
/** PHPExcel_Style_Borders */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Borders.php';
/** PHPExcel_Style_Conditional */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Conditional.php';
/** PHPExcel_Style_Protection */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Protection.php';
/** PHPExcel_Style_NumberFormat */
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
/** PHPExcel_Worksheet_BaseDrawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/BaseDrawing.php';
/** PHPExcel_Worksheet_Drawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing.php';
/** PHPExcel_Shared_Drawing */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Drawing.php';
/** PHPExcel_Shared_Date */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
/** PHPExcel_Shared_File */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/File.php';
/** PHPExcel_Shared_String */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
/** PHPExcel_ReferenceHelper */
require_once PHPEXCEL_ROOT . 'PHPExcel/ReferenceHelper.php';
/** PHPExcel_Reader_IReadFilter */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReadFilter.php';
/** PHPExcel_Reader_DefaultReadFilter */
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
/**
* PHPExcel_Reader_Excel2007
*
@@ -556,6 +508,10 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docSheet->setShowGridLines((string)$xmlSheet->sheetViews->sheetView['showGridLines'] ? true : false);
}
if (isset($xmlSheet->sheetViews->sheetView['showRowColHeaders'])) {
$docSheet->setShowRowColHeaders((string)$xmlSheet->sheetViews->sheetView['showRowColHeaders'] ? true : false);
}
if (isset($xmlSheet->sheetViews->sheetView['rightToLeft'])) {
$docSheet->setRightToLeft((string)$xmlSheet->sheetViews->sheetView['rightToLeft'] ? true : false);
}
@@ -630,11 +586,11 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
if (isset($xmlSheet->cols) && !$this->_readDataOnly) {
foreach ($xmlSheet->cols->col as $col) {
for ($i = intval($col["min"]) - 1; $i < intval($col["max"]); ++$i) {
if ($col["style"]) {
if ($col["style"] && !$this->_readDataOnly) {
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"]));
}
if ($col["bestFit"]) {
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true);
//$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true);
}
if ($col["hidden"]) {
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false);
@@ -685,7 +641,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
if ($row["outlineLevel"] > 0) {
$docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"]));
}
if ($row["s"]) {
if ($row["s"] && !$this->_readDataOnly) {
$docSheet->getRowDimension(intval($row["r"]))->setXfIndex(intval($row["s"]));
}
@@ -779,27 +735,23 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$value = $value->getPlainText();
}
$cell = $docSheet->getCell($r);
// Assign value
if ($cellDataType != '') {
$docSheet->setCellValueExplicit($r, $value, $cellDataType);
$cell->setValueExplicit($value, $cellDataType);
} else {
$docSheet->setCellValue($r, $value);
$cell->setValue($value);
}
if (!is_null($calculatedValue)) {
$docSheet->getCell($r)->setCalculatedValue($calculatedValue);
$cell->setCalculatedValue($calculatedValue);
}
// Style information?
if ($c["s"] && !$this->_readDataOnly) {
// no style index means 0, it seems
$docSheet->getCell($r)->setXfIndex(isset($styles[intval($c["s"])]) ?
$cell->setXfIndex(isset($styles[intval($c["s"])]) ?
intval($c["s"]) : 0);
}
// Set rich text parent
if ($value instanceof PHPExcel_RichText && !$this->_readDataOnly) {
$value->setParent($docSheet->getCell($r));
}
}
}
}
@@ -812,7 +764,8 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
(
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_NONE ||
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CELLIS ||
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT ||
(string)$cfRule["type"] == PHPExcel_Style_Conditional::CONDITION_EXPRESSION
) && isset($dxfs[intval($cfRule["dxfId"])])
) {
$conditionals[(string) $conditional["sqref"]][intval($cfRule["priority"])] = $cfRule;
@@ -967,9 +920,12 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) {
// Uppercase coordinate
$range = strtoupper($dataValidation["sqref"]);
$rangeSet = explode(' ',$range);
foreach($rangeSet as $range) {
$stRange = $docSheet->shrinkRangeToFit($range);
// Extract all cell references in $range
$aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($range);
$aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($stRange);
foreach ($aReferences as $reference) {
// Create validation
$docValidation = $docSheet->getCell($reference)->getDataValidation();
@@ -989,6 +945,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
}
}
// Add hyperlinks
$hyperlinks = array();
@@ -1010,16 +967,17 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships');
foreach (PHPExcel_Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) {
$cell = $docSheet->getCell( $cellReference );
if (isset($linkRel['id'])) {
$docSheet->getCell( $cellReference )->getHyperlink()->setUrl( $hyperlinks[ (string)$linkRel['id'] ] );
$cell->getHyperlink()->setUrl( $hyperlinks[ (string)$linkRel['id'] ] );
}
if (isset($hyperlink['location'])) {
$docSheet->getCell( $cellReference )->getHyperlink()->setUrl( 'sheet://' . (string)$hyperlink['location'] );
$cell->getHyperlink()->setUrl( 'sheet://' . (string)$hyperlink['location'] );
}
// Tooltip
if (isset($hyperlink['tooltip'])) {
$docSheet->getCell( $cellReference )->getHyperlink()->setTooltip( (string)$hyperlink['tooltip'] );
$cell->getHyperlink()->setTooltip( (string)$hyperlink['tooltip'] );
}
}
}
@@ -1082,7 +1040,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$row = null;
$clientData = $shape->xpath('.//x:ClientData');
if (is_array($clientData)) {
if (is_array($clientData) && count($clientData) > 0) {
$clientData = $clientData[0];
if ( isset($clientData['ObjectType']) && (string)$clientData['ObjectType'] == 'Note' ) {
@@ -1298,31 +1256,18 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$extractedRange = explode(',', $extractedRange);
// Set print titles
if (isset($extractedRange[0])) {
$range = explode(':', $extractedRange[0]);
foreach ($extractedRange as $range) {
$matches = array();
if (PHPExcel_Worksheet::extractSheetTitle($range[0]) != '')
$range[0] = PHPExcel_Worksheet::extractSheetTitle($range[0]);
$range[0] = str_replace('$', '', $range[0]);
if (PHPExcel_Worksheet::extractSheetTitle($range[1]) != '')
$range[1] = PHPExcel_Worksheet::extractSheetTitle($range[1]);
$range[1] = str_replace('$', '', $range[1]);
$docSheet->getPageSetup()->setColumnsToRepeatAtLeft( $range );
// check for repeating columns, e g. 'A:A' or 'A:D'
if (preg_match('/^([A-Z]+)\:([A-Z]+)$/', $range, $matches)) {
$docSheet->getPageSetup()->setColumnsToRepeatAtLeft(array($matches[1], $matches[2]));
}
// check for repeating rows, e.g. '1:1' or '1:5'
elseif (preg_match('/^(\d+)\:(\d+)$/', $range, $matches)) {
$docSheet->getPageSetup()->setRowsToRepeatAtTop(array($matches[1], $matches[2]));
}
if (isset($extractedRange[1])) {
$range = explode(':', $extractedRange[1]);
if (PHPExcel_Worksheet::extractSheetTitle($range[0]) != '')
$range[0] = PHPExcel_Worksheet::extractSheetTitle($range[0]);
$range[0] = str_replace('$', '', $range[0]);
if (PHPExcel_Worksheet::extractSheetTitle($range[1]) != '')
$range[1] = PHPExcel_Worksheet::extractSheetTitle($range[1]);
$range[1] = str_replace('$', '', $range[1]);
$docSheet->getPageSetup()->setRowsToRepeatAtTop( $range );
}
break;
case '_xlnm.Print_Area':
@@ -1333,13 +1278,55 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
break;
default:
$range = explode('!', $extractedRange);
$extractedRange = isset($range[1]) ? $range[1] : $range[0];
$excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $docSheet, $extractedRange, true) );
break;
}
} else {
}
}
}
// Next sheet id
++$sheetId;
}
// Loop through definedNames
if ($xmlWorkbook->definedNames) {
foreach ($xmlWorkbook->definedNames->definedName as $definedName) {
// Extract range
$extractedRange = (string)$definedName;
$extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange);
$extractedRange = str_replace('$', '', $extractedRange);
// Valid range?
if (stripos((string)$definedName, '#REF!') !== false || $extractedRange == '') {
continue;
}
// Some definedNames are only applicable if we are on the same sheet...
if ((string)$definedName['localSheetId'] != '') {
// Local defined name
// Switch on type
switch ((string)$definedName['name']) {
case '_xlnm._FilterDatabase':
case '_xlnm.Print_Titles':
case '_xlnm.Print_Area':
break;
default:
$range = explode('!', (string)$definedName);
if (count($range) == 2) {
$range[0] = str_replace("''", "'", $range[0]);
$range[0] = str_replace("'", "", $range[0]);
if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) {
$extractedRange = str_replace('$', '', $range[1]);
$scope = $docSheet->getParent()->getSheet((string)$definedName['localSheetId']);
$excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope) );
}
}
break;
}
} else if (!isset($definedName['localSheetId'])) {
// "Global" definedNames
$locatedSheet = null;
$extractedSheetName = '';
@@ -1362,10 +1349,6 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
}
// Next sheet id
++$sheetId;
}
}
if (!$this->_readDataOnly) {
@@ -1410,13 +1393,13 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docStyle->getFont()->setName((string) $style->font->name["val"]);
$docStyle->getFont()->setSize((string) $style->font->sz["val"]);
if (isset($style->font->b)) {
$docStyle->getFont()->setBold(!isset($style->font->b["val"]) || $style->font->b["val"] == 'true');
$docStyle->getFont()->setBold(!isset($style->font->b["val"]) || $style->font->b["val"] == 'true' || $style->font->b["val"] == '1');
}
if (isset($style->font->i)) {
$docStyle->getFont()->setItalic(!isset($style->font->i["val"]) || $style->font->i["val"] == 'true');
$docStyle->getFont()->setItalic(!isset($style->font->i["val"]) || $style->font->i["val"] == 'true' || $style->font->i["val"] == '1');
}
if (isset($style->font->strike)) {
$docStyle->getFont()->setStrikethrough(!isset($style->font->strike["val"]) || $style->font->strike["val"] == 'true');
$docStyle->getFont()->setStrikethrough(!isset($style->font->strike["val"]) || $style->font->strike["val"] == 'true' || $style->font->strike["val"] == '1');
}
$docStyle->getFont()->getColor()->setARGB($this->_readColor($style->font->color));
@@ -1540,9 +1523,12 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) );
} else {
foreach ($is->r as $run) {
if (!isset($run->rPr)) {
$objText = $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) );
} else {
$objText = $value->createTextRun( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) );
if (isset($run->rPr)) {
if (isset($run->rPr->rFont["val"])) {
$objText->getFont()->setName((string) $run->rPr->rFont["val"]);
}

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
*

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
*

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('');
}
}
@@ -461,7 +425,8 @@ class PHPExcel_ReferenceHelper
}
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

@@ -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
*
@@ -71,13 +42,6 @@ class PHPExcel_RichText implements PHPExcel_IComparable
*/
private $_richTextElements;
/**
* Parent cell
*
* @var PHPExcel_Cell
*/
private $_parent;
/**
* Create a new PHPExcel_RichText instance
*
@@ -89,20 +53,17 @@ 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);
}
}
@@ -202,44 +163,6 @@ 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
*
@@ -263,8 +186,6 @@ class PHPExcel_RichText implements PHPExcel_IComparable
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

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

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

@@ -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
*
@@ -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
*

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,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
*
@@ -246,20 +234,25 @@ class PHPExcel_Shared_Font
*
* @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);

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

@@ -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,11 +483,46 @@ 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

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

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
*
@@ -245,7 +227,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
* @throws Exception
* @return PHPExcel_Style_NumberFormat
*/
public function applyFromArray($pStyles = null) {
public function applyFromArray($pStyles = null)
{
if (is_array($pStyles)) {
if ($this->_isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
@@ -265,7 +248,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
*
* @return string
*/
public function getFormatCode() {
public function getFormatCode()
{
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getFormatCode();
}
@@ -282,7 +266,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
* @param string $pValue
* @return PHPExcel_Style_NumberFormat
*/
public function setFormatCode($pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL) {
public function setFormatCode($pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL)
{
if ($pValue == '') {
$pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
}
@@ -301,7 +286,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
*
* @return int
*/
public function getBuiltInFormatCode() {
public function getBuiltInFormatCode()
{
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getBuiltInFormatCode();
}
@@ -314,7 +300,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
* @param int $pValue
* @return PHPExcel_Style_NumberFormat
*/
public function setBuiltInFormatCode($pValue = 0) {
public function setBuiltInFormatCode($pValue = 0)
{
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('code' => self::builtInFormatCode($pValue)));
@@ -397,7 +384,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
* @param int $pIndex
* @return string
*/
public static function builtInFormatCode($pIndex) {
public static function builtInFormatCode($pIndex)
{
// Clean parameter
$pIndex = intval($pIndex);
@@ -418,7 +406,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
* @param string $formatCode
* @return int|boolean
*/
public static function builtInFormatCodeIndex($formatCode) {
public static function builtInFormatCodeIndex($formatCode)
{
// Ensure built-in format codes are available
self::fillBuiltInFormatCodes();
@@ -435,7 +424,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
*
* @return string Hash code
*/
public function getHashCode() {
public function getHashCode()
{
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
}
@@ -449,7 +439,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
/**
* 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,7 +599,6 @@ 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);
@@ -620,17 +612,31 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
// 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
$useThousands = preg_match('/,/', $format);
// 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('/,/', '', $format);
$format = preg_replace('/0,0/', '00', $format);
$format = preg_replace('/#,#/', '##', $format);
}
if (preg_match('/0?.*\?\/\?/', $format, $m)) {
// 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]));
// 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,14 +656,27 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
$adjustedDecimalPart += $integerPart * $adjustedDecimalDivisor;
$value = "$sign$adjustedDecimalPart/$adjustedDecimalDivisor";
}
}
} else {
// Handle the number itself
$number_regex = "/(\d+)(\.?)(\d*)/";
// 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
@@ -667,15 +686,15 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
);
} else {
$sprintf_pattern = "%1." . strlen($right) . "f";
$sprintf_pattern = "%0$minWidth." . strlen($right) . "f";
$value = sprintf($sprintf_pattern, $value);
}
$value = preg_replace($number_regex, $value, $format);
}
}
}
}
}
// Additional formatting provided by callback function
if ($callBack !== null) {
@@ -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
*

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
*
@@ -129,6 +45,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
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
@@ -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,22 +554,28 @@ 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()])) {
// 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());
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(
@@ -637,6 +587,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
);
}
}
}
// adjust column widths
foreach ($autoSizes as $columnIndex => $width) {
@@ -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);
}
}
}
@@ -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;
if (!isset($this->_cellCollection[$coordinate])) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
$coordinate = $columnLetter . $pRow;
$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.');
}
@@ -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,10 +2173,12 @@ 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;
/* Excel doesn't remove such empty cells
// Empty value?
if (is_null($cell->getValue()) || (!is_object($cell->getValue()) && $cell->getValue() === '' && !$cell->hasHyperlink())) {
// default style ?
@@ -2206,6 +2186,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$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

@@ -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
*

View File

@@ -22,28 +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 */
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
*
@@ -53,7 +35,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
* @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

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

@@ -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
*

View File

@@ -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
*

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