diff --git a/ChangeLog b/ChangeLog
index ab9802ebe..4fe59e887 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/libraries/PHPExcel/PHPExcel.php b/libraries/PHPExcel/PHPExcel.php
index a7ff765de..bd469e1ee 100644
--- a/libraries/PHPExcel/PHPExcel.php
+++ b/libraries/PHPExcel/PHPExcel.php
@@ -22,36 +22,22 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
+ require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
+ PHPExcel_Autoloader::Register();
+ PHPExcel_Shared_ZipStreamWrapper::register();
+ // check mbstring.func_overload
+ if (ini_get('mbstring.func_overload') & 2) {
+ throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
+ }
}
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_DocumentProperties */
-require_once PHPEXCEL_ROOT . 'PHPExcel/DocumentProperties.php';
-
-/** PHPExcel_DocumentSecurity */
-require_once PHPEXCEL_ROOT . 'PHPExcel/DocumentSecurity.php';
-
-/** PHPExcel_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Shared_ZipStreamWrapper */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/ZipStreamWrapper.php';
-
-/** PHPExcel_NamedRange */
-require_once PHPEXCEL_ROOT . 'PHPExcel/NamedRange.php';
-
-/** PHPExcel_WorksheetIterator */
-require_once PHPEXCEL_ROOT . 'PHPExcel/WorksheetIterator.php';
-
/**
* PHPExcel
@@ -146,6 +132,16 @@ class PHPExcel
$this->addCellStyleXf(new PHPExcel_Style);
}
+
+ public function disconnectWorksheets() {
+ foreach($this->_workSheetCollection as $k => &$worksheet) {
+ $worksheet->disconnectCells();
+ $this->_workSheetCollection[$k] = null;
+ }
+ unset($worksheet);
+ $this->_workSheetCollection = array();
+ }
+
/**
* Get properties
*
@@ -379,6 +375,23 @@ class PHPExcel
return $this->getActiveSheet();
}
+ /**
+ * Set active sheet index by name
+ *
+ * @param string $pValue Sheet title
+ * @return PHPExcel_Worksheet
+ * @throws Exception
+ */
+ public function setActiveSheetIndexByName($pValue = '')
+ {
+ if (($worksheet = $this->getSheetByName($pValue)) instanceof PHPExcel_Worksheet) {
+ $this->setActiveSheetIndex($worksheet->getParent()->getIndex($worksheet));
+ return $worksheet;
+ }
+
+ throw new Exception('Workbook does not contain sheet:' . $pValue);
+ }
+
/**
* Get sheet names
*
@@ -420,7 +433,8 @@ class PHPExcel
$pSheet->rebindParent($this);
// update the cellXfs
- foreach ($pSheet->getCellCollection(false) as $cell) {
+ foreach ($pSheet->getCellCollection(false) as $cellID) {
+ $cell = $sheet->getCell($cellID);
$cell->setXfIndex( $cell->getXfIndex() + $countCellXfs );
}
@@ -443,7 +457,13 @@ class PHPExcel
* @return PHPExcel
*/
public function addNamedRange(PHPExcel_NamedRange $namedRange) {
- $this->_namedRanges[$namedRange->getWorksheet()->getTitle().'!'.$namedRange->getName()] = $namedRange;
+ if ($namedRange->getScope() == null) {
+ // global scope
+ $this->_namedRanges[$namedRange->getName()] = $namedRange;
+ } else {
+ // local scope
+ $this->_namedRanges[$namedRange->getScope()->getTitle().'!'.$namedRange->getName()] = $namedRange;
+ }
return true;
}
@@ -451,57 +471,42 @@ class PHPExcel
* Get named range
*
* @param string $namedRange
+ * @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
+ * @return PHPExcel_NamedRange|null
*/
public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
+ $returnValue = null;
+
if ($namedRange != '' && !is_null($namedRange)) {
- if (!is_null($pSheet)) {
- $key = $pSheet->getTitle().'!'.$namedRange;
- if (isset($this->_namedRanges[$key])) {
- return $this->_namedRanges[$key];
- }
+ // first look for global defined name
+ if (isset($this->_namedRanges[$namedRange])) {
+ $returnValue = $this->_namedRanges[$namedRange];
}
- $returnCount = 0;
- foreach($this->_namedRanges as $_namedRange) {
- if ($_namedRange->getName() == $namedRange) {
- if ((!is_null($pSheet)) && ($_namedRange->getWorksheet()->getTitle() == $pSheet->getTitle())) {
- return $_namedRange;
- } else {
- $returnCount++;
- $returnValue = $_namedRange;
- }
- }
- }
- if ($returnCount == 1) {
- return $returnValue;
+
+ // then look for local defined name (has priority over global defined name if both names exist)
+ if (!is_null($pSheet) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
+ $returnValue = $this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange];
}
}
- return null;
+ return $returnValue;
}
/**
* Remove named range
*
* @param string $namedRange
+ * @param PHPExcel_Worksheet|null $pSheet. Scope. Use null for global scope.
* @return PHPExcel
*/
public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
- if ($namedRange != '' && !is_null($namedRange)) {
- if (!is_null($pSheet)) {
- $key = $pSheet->getTitle().'!'.$namedRange;
- if (isset($this->_namedRanges[$key])) {
- unset($this->_namedRanges[$key]);
- }
+ if (is_null($pSheet)) {
+ if (isset($this->_namedRanges[$namedRange])) {
+ unset($this->_namedRanges[$namedRange]);
}
- foreach($this->_namedRanges as $_namedRange) {
- if ($_namedRange->getName() == $namedRange) {
- if ((!is_null($pSheet)) && ($_namedRange->getWorksheet()->getTitle() == $pSheet->getTitle())) {
- $key = $pSheet->getTitle().'!'.$namedRange;
- if (isset($this->_namedRanges[$key])) {
- unset($this->_namedRanges[$key]);
- }
- }
- }
+ } else {
+ if (isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
+ unset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange]);
}
}
return $this;
@@ -622,7 +627,8 @@ class PHPExcel
// then update cellXf indexes for cells
foreach ($this->_workSheetCollection as $worksheet) {
- foreach ($worksheet->getCellCollection(false) as $cell) {
+ foreach ($worksheet->getCellCollection(false) as $cellID) {
+ $cell = $sheet->getCell($cellID);
$xfIndex = $cell->getXfIndex();
if ($xfIndex > $pIndex ) {
// decrease xf index by 1
@@ -724,7 +730,8 @@ class PHPExcel
foreach ($this->getWorksheetIterator() as $sheet) {
// from cells
- foreach ($sheet->getCellCollection(false) as $cell) {
+ foreach ($sheet->getCellCollection(false) as $cellID) {
+ $cell = $sheet->getCell($cellID);
++$countReferencesCellXf[$cell->getXfIndex()];
}
@@ -756,7 +763,7 @@ class PHPExcel
// update the index for all cellXfs
foreach ($this->_cellXfCollection as $i => $cellXf) {
- echo $cellXf->setIndex($i);
+ $cellXf->setIndex($i);
}
// make sure there is always at least one cellXf (there should be)
@@ -768,7 +775,8 @@ class PHPExcel
foreach ($this->getWorksheetIterator() as $sheet) {
// for all cells
- foreach ($sheet->getCellCollection(false) as $cell) {
+ foreach ($sheet->getCellCollection(false) as $cellID) {
+ $cell = $sheet->getCell($cellID);
$cell->setXfIndex( $map[$cell->getXfIndex()] );
}
diff --git a/libraries/PHPExcel/PHPExcel/Autoloader.php b/libraries/PHPExcel/PHPExcel/Autoloader.php
new file mode 100644
index 000000000..ba667bbc2
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/Autoloader.php
@@ -0,0 +1,51 @@
+_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()
+
+}
diff --git a/libraries/PHPExcel/PHPExcel/CachedObjectStorage/CacheBase.php b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/CacheBase.php
new file mode 100644
index 000000000..100df63e2
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/CacheBase.php
@@ -0,0 +1,162 @@
+_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()
+
+}
diff --git a/libraries/PHPExcel/PHPExcel/CachedObjectStorage/DiscISAM.php b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/DiscISAM.php
new file mode 100644
index 000000000..b35f13831
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/DiscISAM.php
@@ -0,0 +1,143 @@
+_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()
+
+}
diff --git a/libraries/PHPExcel/PHPExcel/CachedObjectStorage/ICache.php b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/ICache.php
new file mode 100644
index 000000000..152167b3f
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/ICache.php
@@ -0,0 +1,97 @@
+_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()
+
+}
+
+
+?>
diff --git a/libraries/PHPExcel/PHPExcel/CachedObjectStorage/Memory.php b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/Memory.php
new file mode 100644
index 000000000..0472dac2c
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/Memory.php
@@ -0,0 +1,85 @@
+_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()
+
+}
diff --git a/libraries/PHPExcel/PHPExcel/CachedObjectStorage/MemoryGZip.php b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/MemoryGZip.php
new file mode 100644
index 000000000..dfacdcc2d
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/MemoryGZip.php
@@ -0,0 +1,107 @@
+_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()
+
+}
diff --git a/libraries/PHPExcel/PHPExcel/CachedObjectStorage/MemorySerialized.php b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/MemorySerialized.php
new file mode 100644
index 000000000..ae48ef55e
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/MemorySerialized.php
@@ -0,0 +1,107 @@
+_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()
+
+}
diff --git a/libraries/PHPExcel/PHPExcel/CachedObjectStorage/PHPTemp.php b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/PHPTemp.php
new file mode 100644
index 000000000..37676b1c2
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/PHPTemp.php
@@ -0,0 +1,137 @@
+_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()
+
+}
diff --git a/libraries/PHPExcel/PHPExcel/CachedObjectStorage/Wincache.php b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/Wincache.php
new file mode 100644
index 000000000..9b30e78ea
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/CachedObjectStorage/Wincache.php
@@ -0,0 +1,201 @@
+_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()
+
+}
+
+
+?>
\ No newline at end of file
diff --git a/libraries/PHPExcel/PHPExcel/CachedObjectStorageFactory.php b/libraries/PHPExcel/PHPExcel/CachedObjectStorageFactory.php
new file mode 100644
index 000000000..d4c947976
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/CachedObjectStorageFactory.php
@@ -0,0 +1,131 @@
+ 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()
+
+}
\ No newline at end of file
diff --git a/libraries/PHPExcel/PHPExcel/Calculation.php b/libraries/PHPExcel/PHPExcel/Calculation.php
index 793734f91..7fe4d9997 100644
--- a/libraries/PHPExcel/PHPExcel/Calculation.php
+++ b/libraries/PHPExcel/PHPExcel/Calculation.php
@@ -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
*/
@@ -32,17 +32,19 @@ 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).');
+ }
}
+
/** Matrix */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/Matrix.php';
-/** PHPExcel_Calculation_Function */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Function.php';
-
-/** PHPExcel_Calculation_Functions */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Functions.php';
-
/**
* PHPExcel_Calculation (Singleton)
@@ -64,20 +66,21 @@ class PHPExcel_Calculation {
// Function
const CALCULATION_REGEXP_FUNCTION = '@?([A-Z][A-Z0-9\.]*)[\s]*\(';
// Cell reference (cell or range of cells, with or without a sheet reference)
- const CALCULATION_REGEXP_CELLREF = '(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]+)\$?(\d+)';
+ const CALCULATION_REGEXP_CELLREF = '(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)';
// Named Range of cells
const CALCULATION_REGEXP_NAMEDRANGE = '(((\w*)|(\'.*\')|(\".*\"))!)?([_A-Z][_A-Z0-9]*)';
// Error
const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?';
- /** constants */
+ /** constants */
const RETURN_ARRAY_AS_ERROR = 'error';
const RETURN_ARRAY_AS_VALUE = 'value';
const RETURN_ARRAY_AS_ARRAY = 'array';
private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE;
+
/**
* Instance of this class
*
@@ -93,7 +96,7 @@ class PHPExcel_Calculation {
* @access private
* @var array
*/
- private $_calculationCache = array ();
+ private static $_calculationCache = array ();
/**
@@ -102,7 +105,7 @@ class PHPExcel_Calculation {
* @access private
* @var boolean
*/
- private $_calculationCacheEnabled = true;
+ private static $_calculationCacheEnabled = true;
/**
@@ -111,7 +114,7 @@ class PHPExcel_Calculation {
* @access private
* @var float
*/
- private $_calculationCacheExpirationTime = 2.5;
+ private static $_calculationCacheExpirationTime = 15;
/**
@@ -120,7 +123,7 @@ class PHPExcel_Calculation {
* @access private
* @var array
*/
- private $_operators = array('+', '-', '*', '/', '^', '&', '%', '~', '>', '<', '=', '>=', '<=', '<>', '|', ':');
+ private static $_operators = array('+', '-', '*', '/', '^', '&', '%', '~', '>', '<', '=', '>=', '<=', '<>', '|', ':');
/**
@@ -129,23 +132,80 @@ class PHPExcel_Calculation {
* @access private
* @var array
*/
- private $_binaryOperators = array('+', '-', '*', '/', '^', '&', '>', '<', '=', '>=', '<=', '<>', '|', ':');
+ private static $_binaryOperators = array('+', '-', '*', '/', '^', '&', '>', '<', '=', '>=', '<=', '<>', '|', ':');
+ /**
+ * Flag to determine how formula errors should be handled
+ * If true, then a user error will be triggered
+ * If false, then an exception will be thrown
+ *
+ * @access public
+ * @var boolean
+ *
+ */
public $suppressFormulaErrors = false;
+
+ /**
+ * Error message for any error that was raised/thrown by the calculation engine
+ *
+ * @access public
+ * @var string
+ *
+ */
public $formulaError = null;
+
+ /**
+ * Flag to determine whether a debug log should be generated by the calculation engine
+ * If true, then a debug log will be generated
+ * If false, then a debug log will not be generated
+ *
+ * @access public
+ * @var boolean
+ *
+ */
public $writeDebugLog = false;
+
+ /**
+ * An array of the nested cell references accessed by the calculation engine, used for the debug log
+ *
+ * @access private
+ * @var array of string
+ *
+ */
private $debugLogStack = array();
+
+ /**
+ * The debug log generated by the calculation engine
+ *
+ * @access public
+ * @var array of string
+ *
+ */
public $debugLog = array();
+ private $_cyclicFormulaCount = 0;
+ private $_cyclicFormulaCell = '';
+ public $cyclicFormulaCount = 0;
+
+
+ private static $_localeLanguage = 'en_us'; // US English (default locale)
+ private static $_validLocaleLanguages = array( 'en' // English (default language)
+ );
+ private static $_localeArgumentSeparator = ',';
+ private static $_localeFunctions = array();
+ private static $_localeBoolean = array( 'TRUE' => 'TRUE',
+ 'FALSE' => 'FALSE',
+ 'NULL' => 'NULL'
+ );
// Constant conversion from text name/value to actual (datatyped) value
- private $_ExcelConstants = array('TRUE' => True,
- 'FALSE' => False,
- 'NULL' => Null
- );
+ private static $_ExcelConstants = array('TRUE' => True,
+ 'FALSE' => False,
+ 'NULL' => Null
+ );
// PHPExcel functions
- private $_PHPExcelFunctions = array( // PHPExcel functions
+ private static $_PHPExcelFunctions = array( // PHPExcel functions
'ABS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
'functionCall' => 'abs',
'argumentCount' => '1'
@@ -372,19 +432,19 @@ class PHPExcel_Calculation {
'argumentCount' => '2'
),
'COUPDAYBS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
- 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
+ 'functionCall' => 'PHPExcel_Calculation_Functions::COUPDAYBS',
'argumentCount' => '3,4'
),
'COUPDAYS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
- 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
+ 'functionCall' => 'PHPExcel_Calculation_Functions::COUPDAYS',
'argumentCount' => '3,4'
),
'COUPDAYSNC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
- 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
+ 'functionCall' => 'PHPExcel_Calculation_Functions::COUPDAYSNC',
'argumentCount' => '3,4'
),
'COUPNCD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
- 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
+ 'functionCall' => 'PHPExcel_Calculation_Functions::COUPNCD',
'argumentCount' => '3,4'
),
'COUPNUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
@@ -392,7 +452,7 @@ class PHPExcel_Calculation {
'argumentCount' => '3,4'
),
'COUPPCD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
- 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
+ 'functionCall' => 'PHPExcel_Calculation_Functions::COUPPCD',
'argumentCount' => '3,4'
),
'COVAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
@@ -453,7 +513,7 @@ class PHPExcel_Calculation {
),
'DAVERAGE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'DAY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
'functionCall' => 'PHPExcel_Calculation_Functions::DAYOFMONTH',
@@ -469,11 +529,11 @@ class PHPExcel_Calculation {
),
'DCOUNT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'DCOUNTA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'DDB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
'functionCall' => 'PHPExcel_Calculation_Functions::DDB',
@@ -505,7 +565,7 @@ class PHPExcel_Calculation {
),
'DGET' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'DISC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
'functionCall' => 'PHPExcel_Calculation_Functions::DISC',
@@ -513,11 +573,11 @@ class PHPExcel_Calculation {
),
'DMAX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'DMIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'DOLLAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
'functionCall' => 'PHPExcel_Calculation_Functions::DOLLAR',
@@ -533,19 +593,19 @@ class PHPExcel_Calculation {
),
'DPRODUCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'DSTDEV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'DSTDEVP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'DSUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'DURATION' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
@@ -553,11 +613,11 @@ class PHPExcel_Calculation {
),
'DVAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'DVARP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '?'
+ 'argumentCount' => '3'
),
'EDATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
'functionCall' => 'PHPExcel_Calculation_Functions::EDATE',
@@ -720,8 +780,9 @@ class PHPExcel_Calculation {
'argumentCount' => '1'
),
'HYPERLINK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
- 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
- 'argumentCount' => '1,2'
+ 'functionCall' => 'PHPExcel_Calculation_Functions::HYPERLINK',
+ 'argumentCount' => '1,2',
+ 'passCellReference'=> true
),
'HYPGEOMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
'functionCall' => 'PHPExcel_Calculation_Functions::HYPGEOMDIST',
@@ -1041,7 +1102,7 @@ class PHPExcel_Calculation {
'argumentCount' => '1+'
),
'N' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
- 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
+ 'functionCall' => 'PHPExcel_Calculation_Functions::N',
'argumentCount' => '1'
),
'NA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
@@ -1175,7 +1236,7 @@ class PHPExcel_Calculation {
'argumentCount' => '4-6'
),
'PRICE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
- 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
+ 'functionCall' => 'PHPExcel_Calculation_Functions::PRICE',
'argumentCount' => '6,7'
),
'PRICEDISC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
@@ -1484,7 +1545,7 @@ class PHPExcel_Calculation {
'argumentCount' => '4'
),
'TYPE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
- 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
+ 'functionCall' => 'PHPExcel_Calculation_Functions::TYPE',
'argumentCount' => '1'
),
'UPPER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
@@ -1579,7 +1640,7 @@ class PHPExcel_Calculation {
// Internal functions used for special control purposes
- private $_controlFunctions = array(
+ private static $_controlFunctions = array(
'MKMATRIX' => array('argumentCount' => '*',
'functionCall' => 'self::_mkMatrix'
)
@@ -1588,6 +1649,17 @@ class PHPExcel_Calculation {
+ function __construct() {
+ $localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/';
+ foreach (glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) {
+ $filename = substr($filename,strlen($localeFileDirectory)+1);
+ if ($filename != 'en') {
+ self::$_validLocaleLanguages[] = $filename;
+ }
+ }
+ } // function __construct()
+
+
/**
* Get an instance of this class
*
@@ -1650,7 +1722,7 @@ class PHPExcel_Calculation {
* @return boolean
*/
public function getCalculationCacheEnabled() {
- return $this->_calculationCacheEnabled;
+ return self::$_calculationCacheEnabled;
} // function getCalculationCacheEnabled()
@@ -1661,7 +1733,7 @@ class PHPExcel_Calculation {
* @param boolean $pValue
*/
public function setCalculationCacheEnabled($pValue = true) {
- $this->_calculationCacheEnabled = $pValue;
+ self::$_calculationCacheEnabled = $pValue;
$this->clearCalculationCache();
} // function setCalculationCacheEnabled()
@@ -1686,7 +1758,7 @@ class PHPExcel_Calculation {
* Clear calculation cache
*/
public function clearCalculationCache() {
- $this->_calculationCache = array();
+ self::$_calculationCache = array();
} // function clearCalculationCache()
@@ -1696,7 +1768,7 @@ class PHPExcel_Calculation {
* @return float
*/
public function getCalculationCacheExpirationTime() {
- return $this->_calculationCacheExpirationTime;
+ return self::$_calculationCacheExpirationTime;
} // getCalculationCacheExpirationTime()
@@ -1706,12 +1778,218 @@ class PHPExcel_Calculation {
* @param float $pValue
*/
public function setCalculationCacheExpirationTime($pValue = 2.5) {
- $this->_calculationCacheExpirationTime = $pValue;
+ self::$_calculationCacheExpirationTime = $pValue;
} // function setCalculationCacheExpirationTime()
+ /**
+ * Get the currently defined locale code
+ *
+ * @return string
+ */
+ public function getLocale() {
+ return self::$_localeLanguage;
+ } // function getLocale()
+
+
+ /**
+ * Set the locale code
+ *
+ * @return boolean
+ */
+ public function setLocale($locale='en_us') {
+ // Identify our locale and language
+ $language = $locale = strtolower($locale);
+ if (strpos($locale,'_') !== false) {
+ list($language) = explode('_',$locale);
+ }
+
+ // Test whether we have any language data for this language (any locale)
+ if (in_array($language,self::$_validLocaleLanguages)) {
+ // initialise language/locale settings
+ self::$_localeFunctions = array();
+ self::$_localeArgumentSeparator = ',';
+ self::$_localeBoolean = array('TRUE' => 'TRUE', 'FALSE' => 'FALSE', 'NULL' => 'NULL');
+ // Default is English, if user isn't requesting english, then read the necessary data from the locale files
+ if ($locale != 'en_us') {
+ // Search for a file with a list of function names for locale
+ $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.str_replace('_','/',$locale).'/functions';
+ if (!file_exists($functionNamesFile)) {
+ // If there isn't a locale specific function file, look for a language specific function file
+ $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.$language.'/functions';
+ if (!file_exists($functionNamesFile)) {
+ return false;
+ }
+ }
+ // Retrieve the list of locale or language specific function names
+ $localeFunctions = file($functionNamesFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
+ foreach ($localeFunctions as $localeFunction) {
+ list($localeFunction) = explode('##',$localeFunction); // Strip out comments
+ if (strpos($localeFunction,'=') !== false) {
+ list($fName,$lfName) = explode('=',$localeFunction);
+ $fName = trim($fName);
+ $lfName = trim($lfName);
+ if ((isset(self::$_PHPExcelFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) {
+ self::$_localeFunctions[$fName] = $lfName;
+ }
+ }
+ }
+ // Default the TRUE and FALSE constants to the locale names of the TRUE() and FALSE() functions
+ if (isset(self::$_localeFunctions['TRUE'])) { self::$_localeBoolean['TRUE'] = self::$_localeFunctions['TRUE']; }
+ if (isset(self::$_localeFunctions['FALSE'])) { self::$_localeBoolean['FALSE'] = self::$_localeFunctions['FALSE']; }
+
+ $configFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.str_replace('_','/',$locale).'/config';
+ if (!file_exists($configFile)) {
+ $configFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.$language.'/config';
+ }
+ if (file_exists($configFile)) {
+ $localeSettings = file($configFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
+ foreach ($localeSettings as $localeSetting) {
+ list($localeSetting) = explode('##',$localeSetting); // Strip out comments
+ if (strpos($localeSetting,'=') !== false) {
+ list($settingName,$settingValue) = explode('=',$localeSetting);
+ $settingName = strtoupper(trim($settingName));
+ switch ($settingName) {
+ case 'ARGUMENTSEPARATOR' :
+ self::$_localeArgumentSeparator = trim($settingValue);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ self::$functionReplaceFromExcel = self::$functionReplaceToExcel =
+ self::$functionReplaceFromLocale = self::$functionReplaceToLocale = NULL;
+ self::$_localeLanguage = $locale;
+ return true;
+ }
+ return false;
+ } // function setLocale()
+
+
+
+ public static function _translateSeparator($fromSeparator,$toSeparator,$formula,&$inBraces) {
+ $strlen = mb_strlen($formula);
+ for ($i = 0; $i < $strlen; ++$i) {
+ $chr = mb_substr($formula,$i,1);
+ switch ($chr) {
+ case '{' : $inBraces = True;
+ break;
+ case '}' : $inBraces = False;
+ break;
+ case $fromSeparator :
+ if (!$inBraces) {
+ $formula = mb_substr($formula,0,$i).$toSeparator.mb_substr($formula,$i+1);
+ }
+ }
+ }
+ return $formula;
+ }
+
+ private static function _translateFormula($from,$to,$formula,$fromSeparator,$toSeparator) {
+ $inBraces = False;
+ // Convert any Excel function names to the required language
+ if (self::$_localeLanguage !== 'en_us') {
+ // If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
+ if (strpos($formula,'"') !== false) {
+ // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
+ // the formula
+ $temp = explode('"',$formula);
+ foreach($temp as $i => &$value) {
+ // Only count/replace in alternate array entries
+ if (($i % 2) == 0) {
+ $value = preg_replace($from,$to,$value);
+ $value = self::_translateSeparator($fromSeparator,$toSeparator,$value,$inBraces);
+ }
+ }
+ unset($value);
+ // Then rebuild the formula string
+ $formula = implode('"',$temp);
+ } else {
+ // If there's no quoted strings, then we do a simple count/replace
+ $formula = preg_replace($from,$to,$formula);
+ $formula = self::_translateSeparator($fromSeparator,$toSeparator,$formula);
+ }
+ }
+
+ return $formula;
+ }
+
+ private static $functionReplaceFromExcel = NULL;
+ private static $functionReplaceToLocale = NULL;
+
+ public function _translateFormulaToLocale($formula) {
+ if (is_null(self::$functionReplaceFromExcel)) {
+ self::$functionReplaceFromExcel = array();
+ foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
+ self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui';
+ }
+ foreach(array_keys(self::$_localeBoolean) as $excelBoolean) {
+ self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
+ }
+
+ }
+
+ if (is_null(self::$functionReplaceToLocale)) {
+ self::$functionReplaceToLocale = array();
+ foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
+ self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2';
+ }
+ foreach(array_values(self::$_localeBoolean) as $localeBoolean) {
+ self::$functionReplaceToLocale[] = '$1'.trim($localeBoolean).'$2';
+ }
+ }
+
+ return self::_translateFormula(self::$functionReplaceFromExcel,self::$functionReplaceToLocale,$formula,',',self::$_localeArgumentSeparator);
+ } // function _translateFormulaToLocale()
+
+
+ private static $functionReplaceFromLocale = NULL;
+ private static $functionReplaceToExcel = NULL;
+
+ public function _translateFormulaToEnglish($formula) {
+ if (is_null(self::$functionReplaceFromLocale)) {
+ self::$functionReplaceFromLocale = array();
+ foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
+ self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui';
+ }
+ foreach(array_values(self::$_localeBoolean) as $excelBoolean) {
+ self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
+ }
+ }
+
+ if (is_null(self::$functionReplaceToExcel)) {
+ self::$functionReplaceToExcel = array();
+ foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
+ self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2';
+ }
+ foreach(array_keys(self::$_localeBoolean) as $excelBoolean) {
+ self::$functionReplaceToExcel[] = '$1'.trim($excelBoolean).'$2';
+ }
+ }
+
+ return self::_translateFormula(self::$functionReplaceFromLocale,self::$functionReplaceToExcel,$formula,self::$_localeArgumentSeparator,',');
+ } // function _translateFormulaToEnglish()
+
+
+ public static function _localeFunc($function) {
+ if (self::$_localeLanguage !== 'en_us') {
+ $functionName = trim($function,'(');
+ if (isset(self::$_localeFunctions[$functionName])) {
+ $brace = ($functionName != $function);
+ $function = self::$_localeFunctions[$functionName];
+ if ($brace) { $function .= '('; }
+ }
+ }
+ return $function;
+ }
+
+
+
+
/**
* Wrap string values in quotes
*
@@ -1767,7 +2045,11 @@ class PHPExcel_Calculation {
* @throws Exception
*/
public function calculate(PHPExcel_Cell $pCell = null) {
- return $this->calculateCellValue($pCell);
+ try {
+ return $this->calculateCellValue($pCell);
+ } catch (Exception $e) {
+ throw(new Exception($e->getMessage()));
+ }
} // function calculate()
@@ -1785,6 +2067,7 @@ class PHPExcel_Calculation {
// Initialise the logging settings if requested
$this->formulaError = null;
$this->debugLog = $this->debugLogStack = array();
+ $this->_cyclicFormulaCount = 1;
$returnArrayAsType = self::$returnArrayAsType;
self::$returnArrayAsType = self::RETURN_ARRAY_AS_ARRAY;
@@ -1799,7 +2082,11 @@ class PHPExcel_Calculation {
self::$returnArrayAsType = $returnArrayAsType;
}
// Execute the calculation for the cell formula
- $result = self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell));
+ try {
+ $result = self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell));
+ } catch (Exception $e) {
+ throw(new Exception($e->getMessage()));
+ }
if ((is_array($result)) && (self::$returnArrayAsType != self::RETURN_ARRAY_AS_ARRAY)) {
$testResult = PHPExcel_Calculation_Functions::flattenArray($result);
@@ -1809,10 +2096,12 @@ class PHPExcel_Calculation {
// If there's only a single cell in the array, then we allow it
if (count($testResult) != 1) {
// If keys are numeric, then it's a matrix result rather than a cell range result, so we permit it
- $r = array_shift(array_keys($result));
+ $r = array_keys($result);
+ $r = array_shift($r);
if (!is_numeric($r)) { return PHPExcel_Calculation_Functions::VALUE(); }
if (is_array($result[$r])) {
- $c = array_shift(array_keys($result[$r]));
+ $c = array_keys($result[$r]);
+ $c = array_shift($c);
if (!is_numeric($c)) {
return PHPExcel_Calculation_Functions::VALUE();
}
@@ -1841,7 +2130,7 @@ class PHPExcel_Calculation {
// Basic validation that this is indeed a formula
// We return an empty array if not
$formula = trim($formula);
- if ($formula{0} != '=') return array();
+ if ((strlen($formula) == 0) || ($formula{0} != '=')) return array();
$formula = trim(substr($formula,1));
$formulaLength = strlen($formula);
if ($formulaLength < 1) return array();
@@ -1866,11 +2155,16 @@ class PHPExcel_Calculation {
// Disable calculation cacheing because it only applies to cell calculations, not straight formulae
// But don't actually flush any cache
$resetCache = $this->getCalculationCacheEnabled();
- $this->_calculationCacheEnabled = false;
+ self::$_calculationCacheEnabled = false;
// Execute the calculation
- $result = self::_unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell));
+ try {
+ $result = self::_unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell));
+ } catch (Exception $e) {
+ throw(new Exception($e->getMessage()));
+ }
+
// Reset calculation cacheing to its previous state
- $this->_calculationCacheEnabled = $resetCache;
+ self::$_calculationCacheEnabled = $resetCache;
return $result;
} // function calculateFormula()
@@ -1899,47 +2193,69 @@ class PHPExcel_Calculation {
$wsTitle = 'Wrk';
if (!is_null($pCell)) {
- $wsTitle = urlencode($pCell->getParent()->getTitle());
+ $pCellParent = $pCell->getParent();
+ if (!is_null($pCellParent)) {
+ $wsTitle = $pCellParent->getTitle();
+ }
}
// Is calculation cacheing enabled?
if (!is_null($cellID)) {
- if ($this->_calculationCacheEnabled) {
+ if (self::$_calculationCacheEnabled) {
// Is the value present in calculation cache?
// echo 'Testing cache value
';
- if (isset($this->_calculationCache[$wsTitle][$cellID])) {
+ if (isset(self::$_calculationCache[$wsTitle][$cellID])) {
// echo 'Value is in cache
';
$this->_writeDebug('Testing cache value for cell '.$cellID);
// Is cache still valid?
- if ((time() + microtime(true)) - $this->_calculationCache[$wsTitle][$cellID]['time'] < $this->_calculationCacheExpirationTime) {
+ if ((time() + microtime(true)) - self::$_calculationCache[$wsTitle][$cellID]['time'] < self::$_calculationCacheExpirationTime) {
// echo 'Cache time is still valid
';
$this->_writeDebug('Retrieving value for '.$cellID.' from cache');
// Return the cached result
- $returnValue = $this->_calculationCache[$wsTitle][$cellID]['data'];
+ $returnValue = self::$_calculationCache[$wsTitle][$cellID]['data'];
// echo 'Retrieving data value of '.$returnValue.' for '.$cellID.' from cache
';
if (is_array($returnValue)) {
- return array_shift(PHPExcel_Calculation_Functions::flattenArray($returnValue));
+ $returnValue = PHPExcel_Calculation_Functions::flattenArray($returnValue);
+ return array_shift($returnValue);
}
return $returnValue;
} else {
// echo 'Cache has expired
';
$this->_writeDebug('Cache value for '.$cellID.' has expired');
// Clear the cache if it's no longer valid
- unset($this->_calculationCache[$wsTitle][$cellID]);
+ unset(self::$_calculationCache[$wsTitle][$cellID]);
}
}
}
}
- $this->debugLogStack[] = $cellID;
+ if ((in_array($wsTitle.'!'.$cellID,$this->debugLogStack)) && ($wsTitle != 'Wrk')) {
+ if ($this->cyclicFormulaCount <= 0) {
+ return $this->_raiseFormulaError('Cyclic Reference in Formula');
+ } elseif (($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) &&
+ ($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID)) {
+ return $cellValue;
+ } elseif ($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID) {
+ $this->_cyclicFormulaCount++;
+ if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
+ return $cellValue;
+ }
+ } elseif ($this->_cyclicFormulaCell == '') {
+ $this->_cyclicFormulaCell = $wsTitle.'!'.$cellID;
+ if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
+ return $cellValue;
+ }
+ }
+ }
+ $this->debugLogStack[] = $wsTitle.'!'.$cellID;
// Parse the formula onto the token stack and calculate the value
$cellValue = $this->_processTokenStack($this->_parseFormula($formula), $cellID, $pCell);
array_pop($this->debugLogStack);
// Save to calculation cache
if (!is_null($cellID)) {
- if ($this->_calculationCacheEnabled) {
- $this->_calculationCache[$wsTitle][$cellID]['time'] = (time() + microtime(true));
- $this->_calculationCache[$wsTitle][$cellID]['data'] = $cellValue;
+ if (self::$_calculationCacheEnabled) {
+ self::$_calculationCache[$wsTitle][$cellID]['time'] = (time() + microtime(true));
+ self::$_calculationCache[$wsTitle][$cellID]['data'] = $cellValue;
}
}
@@ -2003,7 +2319,11 @@ class PHPExcel_Calculation {
if ($colCount > $matrixColumns) {
$matrixColumns = $colCount;
}
- $matrix[$rowKey] = array_values($rowValue);
+ if (!is_array($rowValue)) {
+ $matrix[$rowKey] = array($rowValue);
+ } else {
+ $matrix[$rowKey] = array_values($rowValue);
+ }
}
$matrix = array_values($matrix);
return array($matrixRows,$matrixColumns);
@@ -2105,6 +2425,11 @@ class PHPExcel_Calculation {
* @return mixed
*/
private static function _showValue($value) {
+ $testArray = PHPExcel_Calculation_Functions::flattenArray($value);
+ if (count($testArray) == 1) {
+ $value = array_pop($testArray);
+ }
+
if (is_array($value)) {
$returnMatrix = array();
$pad = $rpad = ', ';
@@ -2118,7 +2443,7 @@ class PHPExcel_Calculation {
}
return '{ '.implode($rpad,$returnMatrix).' }';
} elseif(is_bool($value)) {
- return ($value) ? 'TRUE' : 'FALSE';
+ return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
}
return $value;
@@ -2132,6 +2457,11 @@ class PHPExcel_Calculation {
* @return mixed
*/
private static function _showTypeDetails($value) {
+ $testArray = PHPExcel_Calculation_Functions::flattenArray($value);
+ if (count($testArray) == 1) {
+ $value = array_pop($testArray);
+ }
+
switch (gettype($value)) {
case 'double' :
case 'float' :
@@ -2297,11 +2627,11 @@ class PHPExcel_Calculation {
} elseif (($opCharacter == '~') && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde, because it's legal
return $this->_raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression
- } elseif ((in_array($opCharacter, $this->_operators) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack?
+ } elseif ((in_array($opCharacter, self::$_operators) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack?
// echo 'Element with value '.$opCharacter.' is an Operator
';
while($stack->count() > 0 &&
($o2 = $stack->last()) &&
- in_array($o2['value'], $this->_operators) &&
+ in_array($o2['value'], self::$_operators) &&
@($operatorAssociativity[$opCharacter] ? $operatorPrecedence[$opCharacter] < $operatorPrecedence[$o2['value']] : $operatorPrecedence[$opCharacter] <= $operatorPrecedence[$o2['value']])) {
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
}
@@ -2331,14 +2661,14 @@ class PHPExcel_Calculation {
// }
$output[] = $d; // Dump the argument count on the output
$output[] = $stack->pop(); // Pop the function and push onto the output
- if (array_key_exists($functionName, $this->_controlFunctions)) {
+ if (array_key_exists($functionName, self::$_controlFunctions)) {
// echo 'Built-in function '.$functionName.'
';
- $expectedArgumentCount = $this->_controlFunctions[$functionName]['argumentCount'];
- $functionCall = $this->_controlFunctions[$functionName]['functionCall'];
- } elseif (array_key_exists($functionName, $this->_PHPExcelFunctions)) {
+ $expectedArgumentCount = self::$_controlFunctions[$functionName]['argumentCount'];
+ $functionCall = self::$_controlFunctions[$functionName]['functionCall'];
+ } elseif (array_key_exists($functionName, self::$_PHPExcelFunctions)) {
// echo 'PHPExcel function '.$functionName.'
';
- $expectedArgumentCount = $this->_PHPExcelFunctions[$functionName]['argumentCount'];
- $functionCall = $this->_PHPExcelFunctions[$functionName]['functionCall'];
+ $expectedArgumentCount = self::$_PHPExcelFunctions[$functionName]['argumentCount'];
+ $functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
} else { // did we somehow push a non-function on the stack? this should never happen
return $this->_raiseFormulaError("Formula Error: Internal error, non-function on stack");
}
@@ -2389,21 +2719,21 @@ class PHPExcel_Calculation {
}
++$index;
- } elseif ($opCharacter == ',') { // Is this the comma separator for function arguments?
+ } elseif ($opCharacter == ',') { // Is this the separator for function arguments?
// echo 'Element is a Function argument separator
';
while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last (
- if (is_null($o2)) return $this->_raiseFormulaError("Formula Error: Unexpected ','");
+ if (is_null($o2)) return $this->_raiseFormulaError("Formula Error: Unexpected ,");
else $output[] = $o2; // pop the argument expression stuff and push onto the output
}
// If we've a comma when we're expecting an operand, then what we actually have is a null operand;
// so push a null onto the stack
if (($expectingOperand) || (!$expectingOperator)) {
- $output[] = array('type' => 'NULL Value', 'value' => $this->_ExcelConstants['NULL'], 'reference' => NULL);
+ $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => NULL);
}
// make sure there was a function
$d = $stack->last(2);
if (!preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches))
- return $this->_raiseFormulaError("Formula Error: Unexpected ','");
+ return $this->_raiseFormulaError("Formula Error: Unexpected ,");
$d = $stack->pop();
$stack->push($d['type'],++$d['value'],$d['reference']); // increment the argument count
$stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again
@@ -2426,14 +2756,14 @@ class PHPExcel_Calculation {
if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) {
$val = preg_replace('/\s/','',$val);
// echo 'Element '.$val.' is a Function
';
- if (array_key_exists(strtoupper($matches[1]), $this->_PHPExcelFunctions) || array_key_exists(strtoupper($matches[1]), $this->_controlFunctions)) { // it's a func
+ if (array_key_exists(strtoupper($matches[1]), self::$_PHPExcelFunctions) || array_key_exists(strtoupper($matches[1]), self::$_controlFunctions)) { // it's a func
$stack->push('Function', strtoupper($val));
$ax = preg_match('/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch);
if ($ax) {
- $stack->push('Operand Count for Function '.strtoupper($val).')', 0);
+ $stack->push('Operand Count for Function '.self::_localeFunc(strtoupper($val)).')', 0);
$expectingOperator = true;
} else {
- $stack->push('Operand Count for Function '.strtoupper($val).')', 1);
+ $stack->push('Operand Count for Function '.self::_localeFunc(strtoupper($val)).')', 1);
$expectingOperator = false;
}
$stack->push('Brace', '(');
@@ -2450,9 +2780,11 @@ class PHPExcel_Calculation {
// $expectingOperator = false;
} else { // it's a variable, constant, string, number or boolean
// echo 'Element is a Variable, Constant, String, Number or Boolean
';
+ $localeConstant = false;
if ($opCharacter == '"') {
// echo 'Element is a String
';
- $val = str_replace('""','"',$val);
+ // UnEscape any quotes within the string
+ $val = self::_wrapResult(str_replace('""','"',self::_unwrapResult($val)));
} elseif (is_numeric($val)) {
// echo 'Element is a Number
';
if ((strpos($val,'.') !== False) || (stripos($val,'e') !== False) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) {
@@ -2462,24 +2794,29 @@ class PHPExcel_Calculation {
// echo 'Casting '.$val.' to integer
';
$val = (integer) $val;
}
- } elseif (array_key_exists(trim(strtoupper($val)), $this->_ExcelConstants)) {
+ } elseif (array_key_exists(trim(strtoupper($val)), self::$_ExcelConstants)) {
$excelConstant = trim(strtoupper($val));
// echo 'Element '.$excelConstant.' is an Excel Constant
';
- $val = $this->_ExcelConstants[$excelConstant];
+ $val = self::$_ExcelConstants[$excelConstant];
+ } elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$_localeBoolean)) !== false) {
+// echo 'Element '.$localeConstant.' is an Excel Constant
';
+ $val = self::$_ExcelConstants[$localeConstant];
}
- $output[] = array('type' => 'Value', 'value' => $val, 'reference' => NULL);
+ $details = array('type' => 'Value', 'value' => $val, 'reference' => NULL);
+ if ($localeConstant) { $details['localeValue'] = $localeConstant; }
+ $output[] = $details;
}
$index += $length;
} elseif ($opCharacter == ')') { // miscellaneous error checking
if ($expectingOperand) {
- $output[] = array('type' => 'Null Value', 'value' => $this->_ExcelConstants['NULL'], 'reference' => NULL);
+ $output[] = array('type' => 'Null Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => NULL);
$expectingOperand = false;
$expectingOperator = True;
} else {
return $this->_raiseFormulaError("Formula Error: Unexpected ')'");
}
- } elseif (in_array($opCharacter, $this->_operators) && !$expectingOperator) {
+ } elseif (in_array($opCharacter, self::$_operators) && !$expectingOperator) {
return $this->_raiseFormulaError("Formula Error: Unexpected operator '$opCharacter'");
} else { // I don't even want to know what you did to get here
return $this->_raiseFormulaError("Formula Error: An unexpected error occured");
@@ -2488,7 +2825,7 @@ class PHPExcel_Calculation {
if ($index == strlen($formula)) {
// Did we end with an operator?.
// Only valid for the % unary operator
- if ((in_array($opCharacter, $this->_operators)) && ($opCharacter != '%')) {
+ if ((in_array($opCharacter, self::$_operators)) && ($opCharacter != '%')) {
return $this->_raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands");
} else {
break;
@@ -2510,7 +2847,7 @@ class PHPExcel_Calculation {
// echo 'Element is an Intersect Operator
';
while($stack->count() > 0 &&
($o2 = $stack->last()) &&
- in_array($o2['value'], $this->_operators) &&
+ in_array($o2['value'], self::$_operators) &&
@($operatorAssociativity[$opCharacter] ? $operatorPrecedence[$opCharacter] < $operatorPrecedence[$o2['value']] : $operatorPrecedence[$opCharacter] <= $operatorPrecedence[$o2['value']])) {
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
}
@@ -2529,9 +2866,12 @@ class PHPExcel_Calculation {
// evaluate postfix notation
- private function _processTokenStack($tokens, $cellID=null, PHPExcel_Cell $pCell = null) {
+ private function _processTokenStack($tokens, $cellID = null, PHPExcel_Cell $pCell = null) {
if ($tokens == false) return false;
+ // If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent worksheet),
+ // so we store the parent worksheet so that we can re-attach it when necessary
+ $pCellParent = (!is_null($pCell)) ? $pCell->getParent() : null;
$stack = new PHPExcel_Token_Stack;
// Loop through each token in turn
@@ -2541,7 +2881,7 @@ class PHPExcel_Calculation {
$token = $tokenData['value'];
// echo 'Token is '.$token.'
';
// if the token is a binary operator, pop the top two values off the stack, do the operation, and push the result back on the stack
- if (in_array($token, $this->_binaryOperators, true)) {
+ if (in_array($token, self::$_binaryOperators, true)) {
// echo 'Token is a binary operator
';
// We must have two operands, error if we don't
if (is_null($operand2Data = $stack->pop())) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
@@ -2571,7 +2911,7 @@ class PHPExcel_Calculation {
if (strpos($operand1Data['reference'],'!') !== false) {
list($sheet1,$operand1Data['reference']) = explode('!',$operand1Data['reference']);
} else {
- $sheet1 = $pCell->getParent()->getTitle();
+ $sheet1 = (!is_null($pCellParent)) ? $pCellParent->getTitle() : '';
}
if (strpos($operand2Data['reference'],'!') !== false) {
list($sheet2,$operand2Data['reference']) = explode('!',$operand2Data['reference']);
@@ -2606,7 +2946,11 @@ class PHPExcel_Calculation {
$oRow[] = $oCR[1];
}
$cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
- $cellValue = $this->extractCellRange($cellRef, $pCell->getParent()->getParent()->getSheetByName($sheet1), false);
+ if (!is_null($pCellParent)) {
+ $cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($sheet1), false);
+ } else {
+ return $this->_raiseFormulaError('Unable to access Cell Reference');
+ }
$stack->push('Cell Reference',$cellValue,$cellRef);
} else {
$stack->push('Error',PHPExcel_Calculation_Functions::REF(),NULL);
@@ -2633,10 +2977,10 @@ class PHPExcel_Calculation {
// (converting the other operand to a matrix if need be); then perform the required
// matrix operation
if (is_bool($operand1)) {
- $operand1 = ($operand1) ? 'TRUE' : 'FALSE';
+ $operand1 = ($operand1) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
}
if (is_bool($operand2)) {
- $operand2 = ($operand2) ? 'TRUE' : 'FALSE';
+ $operand2 = ($operand2) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
}
if ((is_array($operand1)) || (is_array($operand2))) {
// Ensure that both operands are arrays/matrices
@@ -2717,12 +3061,21 @@ class PHPExcel_Calculation {
$matches[2] = trim($matches[2],"\"'");
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'
';
$this->_writeDebug('Evaluating Cell Range '.$cellRef.' in worksheet '.$matches[2]);
- $cellValue = $this->extractCellRange($cellRef, $pCell->getParent()->getParent()->getSheetByName($matches[2]), false);
+ if (!is_null($pCellParent)) {
+ $cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($matches[2]), false);
+ } else {
+ return $this->_raiseFormulaError('Unable to access Cell Reference');
+ }
$this->_writeDebug('Evaluation Result for cells '.$cellRef.' in worksheet '.$matches[2].' is '.self::_showTypeDetails($cellValue));
+ $cellRef = $matches[2].'!'.$cellRef;
} else {
// echo '$cellRef='.$cellRef.' in current worksheet
';
$this->_writeDebug('Evaluating Cell Range '.$cellRef.' in current worksheet');
- $cellValue = $this->extractCellRange($cellRef, $pCell->getParent(), false);
+ if (!is_null($pCellParent)) {
+ $cellValue = $this->extractCellRange($cellRef, $pCellParent, false);
+ } else {
+ return $this->_raiseFormulaError('Unable to access Cell Reference');
+ }
$this->_writeDebug('Evaluation Result for cells '.$cellRef.' is '.self::_showTypeDetails($cellValue));
}
}
@@ -2737,17 +3090,22 @@ class PHPExcel_Calculation {
$matches[2] = trim($matches[2],"\"'");
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'
';
$this->_writeDebug('Evaluating Cell '.$cellRef.' in worksheet '.$matches[2]);
- if ($pCell->getParent()->getParent()->getSheetByName($matches[2])->cellExists($cellRef)) {
- $cellValue = $this->extractCellRange($cellRef, $pCell->getParent()->getParent()->getSheetByName($matches[2]), false);
+ if (!is_null($pCellParent)) {
+ if ($pCellParent->getParent()->getSheetByName($matches[2])->cellExists($cellRef)) {
+ $cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($matches[2]), false);
+ } else {
+ $cellValue = PHPExcel_Calculation_Functions::REF();
+ }
} else {
- $cellValue = PHPExcel_Calculation_Functions::REF();
+ return $this->_raiseFormulaError('Unable to access Cell Reference');
}
$this->_writeDebug('Evaluation Result for cell '.$cellRef.' in worksheet '.$matches[2].' is '.self::_showTypeDetails($cellValue));
+ $cellRef = $matches[2].'!'.$cellRef;
} else {
// echo '$cellRef='.$cellRef.' in current worksheet
';
$this->_writeDebug('Evaluating Cell '.$cellRef.' in current worksheet');
- if ($pCell->getParent()->cellExists($cellRef)) {
- $cellValue = $this->extractCellRange($cellRef, $pCell->getParent(), false);
+ if ($pCellParent->cellExists($cellRef)) {
+ $cellValue = $this->extractCellRange($cellRef, $pCellParent, false);
} else {
$cellValue = NULL;
}
@@ -2764,17 +3122,17 @@ class PHPExcel_Calculation {
$argCount = $stack->pop();
$argCount = $argCount['value'];
if ($functionName != 'MKMATRIX') {
- $this->_writeDebug('Evaluating Function '.$functionName.'() with '.(($argCount == 0) ? 'no' : $argCount).' argument'.(($argCount == 1) ? '' : 's'));
+ $this->_writeDebug('Evaluating Function '.self::_localeFunc($functionName).'() with '.(($argCount == 0) ? 'no' : $argCount).' argument'.(($argCount == 1) ? '' : 's'));
}
- if ((array_key_exists($functionName, $this->_PHPExcelFunctions)) || (array_key_exists($functionName, $this->_controlFunctions))) { // function
- if (array_key_exists($functionName, $this->_PHPExcelFunctions)) {
- $functionCall = $this->_PHPExcelFunctions[$functionName]['functionCall'];
- $passByReference = isset($this->_PHPExcelFunctions[$functionName]['passByReference']);
- $passCellReference = isset($this->_PHPExcelFunctions[$functionName]['passCellReference']);
- } elseif (array_key_exists($functionName, $this->_controlFunctions)) {
- $functionCall = $this->_controlFunctions[$functionName]['functionCall'];
- $passByReference = isset($this->_controlFunctions[$functionName]['passByReference']);
- $passCellReference = isset($this->_controlFunctions[$functionName]['passCellReference']);
+ if ((array_key_exists($functionName, self::$_PHPExcelFunctions)) || (array_key_exists($functionName, self::$_controlFunctions))) { // function
+ if (array_key_exists($functionName, self::$_PHPExcelFunctions)) {
+ $functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
+ $passByReference = isset(self::$_PHPExcelFunctions[$functionName]['passByReference']);
+ $passCellReference = isset(self::$_PHPExcelFunctions[$functionName]['passCellReference']);
+ } elseif (array_key_exists($functionName, self::$_controlFunctions)) {
+ $functionCall = self::$_controlFunctions[$functionName]['functionCall'];
+ $passByReference = isset(self::$_controlFunctions[$functionName]['passByReference']);
+ $passCellReference = isset(self::$_controlFunctions[$functionName]['passCellReference']);
}
// get the arguments for this function
// echo 'Function '.$functionName.' expects '.$argCount.' arguments
';
@@ -2783,8 +3141,8 @@ class PHPExcel_Calculation {
$arg = $stack->pop();
$a = $argCount - $i - 1;
if (($passByReference) &&
- (isset($this->_PHPExcelFunctions[$functionName]['passByReference'][$a])) &&
- ($this->_PHPExcelFunctions[$functionName]['passByReference'][$a])) {
+ (isset(self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) &&
+ (self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) {
if (is_null($arg['reference'])) {
$args[] = $cellID;
if ($functionName != 'MKMATRIX') { $argArrayVals[] = self::_showValue($cellID); }
@@ -2808,7 +3166,7 @@ class PHPExcel_Calculation {
// echo '
';
if ($functionName != 'MKMATRIX') {
krsort($argArrayVals);
- $this->_writeDebug('Evaluating '. $functionName.'( '.implode(', ',$argArrayVals).' )');
+ $this->_writeDebug('Evaluating '. self::_localeFunc($functionName).'( '.implode(self::$_localeArgumentSeparator.' ',$argArrayVals).' )');
}
// Process each argument in turn, building the return value as an array
// if (($argCount == 1) && (is_array($args[1])) && ($functionName != 'MKMATRIX')) {
@@ -2819,16 +3177,16 @@ class PHPExcel_Calculation {
// foreach($operand1 as $args) {
// if (is_array($args)) {
// foreach($args as $arg) {
-// $this->_writeDebug('Evaluating '. $functionName.'( '.self::_showValue($arg).' )');
+// $this->_writeDebug('Evaluating '.self::_localeFunc($functionName).'( '.self::_showValue($arg).' )');
// $r = call_user_func_array($functionCall,$arg);
-// $this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($r));
+// $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.self::_showTypeDetails($r));
// $result[$row][] = $r;
// }
// ++$row;
// } else {
-// $this->_writeDebug('Evaluating '. $functionName.'( '.self::_showValue($args).' )');
+// $this->_writeDebug('Evaluating '.self::_localeFunc($functionName).'( '.self::_showValue($args).' )');
// $r = call_user_func_array($functionCall,$args);
-// $this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($r));
+// $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.self::_showTypeDetails($r));
// $result[] = $r;
// }
// }
@@ -2848,18 +3206,18 @@ class PHPExcel_Calculation {
}
// }
if ($functionName != 'MKMATRIX') {
- $this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($result));
+ $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.self::_showTypeDetails($result));
}
$stack->push('Value',self::_wrapResult($result));
}
} else {
// if the token is a number, boolean, string or an Excel error, push it onto the stack
- if (array_key_exists(strtoupper($token), $this->_ExcelConstants)) {
+ if (array_key_exists(strtoupper($token), self::$_ExcelConstants)) {
$excelConstant = strtoupper($token);
// echo 'Token is a PHPExcel constant: '.$excelConstant.'
';
- $stack->push('Constant Value',$this->_ExcelConstants[$excelConstant]);
- $this->_writeDebug('Evaluating Constant '.$excelConstant.' as '.self::_showTypeDetails($this->_ExcelConstants[$excelConstant]));
+ $stack->push('Constant Value',self::$_ExcelConstants[$excelConstant]);
+ $this->_writeDebug('Evaluating Constant '.$excelConstant.' as '.self::_showTypeDetails(self::$_ExcelConstants[$excelConstant]));
} elseif ((is_numeric($token)) || (is_bool($token)) || (is_null($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
// echo 'Token is a number, boolean, string, null or an Excel error
';
$stack->push('Value',$token);
@@ -2869,7 +3227,7 @@ class PHPExcel_Calculation {
$namedRange = $matches[6];
// echo 'Named Range is '.$namedRange.'
';
$this->_writeDebug('Evaluating Named Range '.$namedRange);
- $cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCell->getParent() : null), false);
+ $cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellParent : null), false);
$this->_writeDebug('Evaluation Result for named range '.$namedRange.' is '.self::_showTypeDetails($cellValue));
$stack->push('Named Range',$cellValue,$namedRange);
} else {
@@ -3061,9 +3419,8 @@ class PHPExcel_Calculation {
// trigger an error, but nicely, if need be
- private function _raiseFormulaError($errorMessage) {
+ protected function _raiseFormulaError($errorMessage) {
$this->formulaError = $errorMessage;
- echo '_raiseFormulaError message is '.$errorMessage.'
';
if (!$this->suppressFormulaErrors) throw new Exception($errorMessage);
trigger_error($errorMessage, E_USER_ERROR);
} // function _raiseFormulaError()
@@ -3152,16 +3509,17 @@ class PHPExcel_Calculation {
// Named range?
$namedRange = PHPExcel_NamedRange::resolveRange($pRange, $pSheet);
if (!is_null($namedRange)) {
-// echo 'Named Range '.$pRange.' (';
+ $pSheet = $namedRange->getWorksheet();
+//// echo 'Named Range '.$pRange.' (';
$pRange = $namedRange->getRange();
-// echo $pRange.') is in sheet '.$namedRange->getWorksheet()->getTitle().'
';
- if ($pSheet->getTitle() != $namedRange->getWorksheet()->getTitle()) {
- if (!$namedRange->getLocalOnly()) {
- $pSheet = $namedRange->getWorksheet();
- } else {
- return $returnValue;
- }
- }
+//// echo $pRange.') is in sheet '.$namedRange->getWorksheet()->getTitle().'
';
+// if ($pSheet->getTitle() != $namedRange->getWorksheet()->getTitle()) {
+// if (!$namedRange->getLocalOnly()) {
+// $pSheet = $namedRange->getWorksheet();
+// } else {
+// return $returnValue;
+// }
+// }
} else {
return PHPExcel_Calculation_Functions::REF();
}
@@ -3205,8 +3563,8 @@ class PHPExcel_Calculation {
*/
public function isImplemented($pFunction = '') {
$pFunction = strtoupper ($pFunction);
- if (isset($this->_PHPExcelFunctions[$pFunction])) {
- return ($this->_PHPExcelFunctions[$pFunction]['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY');
+ if (isset(self::$_PHPExcelFunctions[$pFunction])) {
+ return (self::$_PHPExcelFunctions[$pFunction]['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY');
} else {
return false;
}
@@ -3222,7 +3580,7 @@ class PHPExcel_Calculation {
// Return value
$returnValue = array();
// Loop functions
- foreach($this->_PHPExcelFunctions as $functionName => $function) {
+ foreach(self::$_PHPExcelFunctions as $functionName => $function) {
if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
$returnValue[$functionName] = new PHPExcel_Calculation_Function($function['category'],
$functionName,
@@ -3242,7 +3600,7 @@ class PHPExcel_Calculation {
* @return array
*/
public function listFunctionNames() {
- return array_keys($this->_PHPExcelFunctions);
+ return array_keys(self::$_PHPExcelFunctions);
} // function listFunctionNames()
} // class PHPExcel_Calculation
@@ -3267,6 +3625,12 @@ class PHPExcel_Token_Stack {
'value' => $value,
'reference' => $reference
);
+ if ($type == 'Function') {
+ $localeFunction = PHPExcel_Calculation::_localeFunc($value);
+ if ($localeFunction != $value) {
+ $this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction;
+ }
+ }
} // function push()
diff --git a/libraries/PHPExcel/PHPExcel/Calculation/Exception.php b/libraries/PHPExcel/PHPExcel/Calculation/Exception.php
index 84cf09d79..a113e9ec6 100644
--- a/libraries/PHPExcel/PHPExcel/Calculation/Exception.php
+++ b/libraries/PHPExcel/PHPExcel/Calculation/Exception.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Calculation/ExceptionHandler.php b/libraries/PHPExcel/PHPExcel/Calculation/ExceptionHandler.php
index 48475df5c..81f3fbac3 100644
--- a/libraries/PHPExcel/PHPExcel/Calculation/ExceptionHandler.php
+++ b/libraries/PHPExcel/PHPExcel/Calculation/ExceptionHandler.php
@@ -22,20 +22,9 @@
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Calculation_Exception */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Exception.php';
-
/**
* PHPExcel_Calculation_ExceptionHandler
*
@@ -43,14 +32,14 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Exception.php';
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
-class PHPExcel_Calculation_ExceptionHandler {
+class PHPExcel_Calculation_ExceptionHandler {
/**
* Register errorhandler
*/
public function __construct() {
- set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
+ set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
}
-
+
/**
* Unregister errorhandler
*/
diff --git a/libraries/PHPExcel/PHPExcel/Calculation/FormulaParser.php b/libraries/PHPExcel/PHPExcel/Calculation/FormulaParser.php
index d6bf785ad..5565217d3 100644
--- a/libraries/PHPExcel/PHPExcel/Calculation/FormulaParser.php
+++ b/libraries/PHPExcel/PHPExcel/Calculation/FormulaParser.php
@@ -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
*
diff --git a/libraries/PHPExcel/PHPExcel/Calculation/FormulaToken.php b/libraries/PHPExcel/PHPExcel/Calculation/FormulaToken.php
index 091e69d0b..6f55208f2 100644
--- a/libraries/PHPExcel/PHPExcel/Calculation/FormulaToken.php
+++ b/libraries/PHPExcel/PHPExcel/Calculation/FormulaToken.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Calculation/Function.php b/libraries/PHPExcel/PHPExcel/Calculation/Function.php
index 6ea8aea10..7da6732fe 100644
--- a/libraries/PHPExcel/PHPExcel/Calculation/Function.php
+++ b/libraries/PHPExcel/PHPExcel/Calculation/Function.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Calculation/Functions.php b/libraries/PHPExcel/PHPExcel/Calculation/Functions.php
index 2ba67fd77..7f1cc18e6 100644
--- a/libraries/PHPExcel/PHPExcel/Calculation/Functions.php
+++ b/libraries/PHPExcel/PHPExcel/Calculation/Functions.php
@@ -22,10 +22,26 @@
* @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__) . '/../../');
+ 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).');
+ }
+}
+
+
/** EPS */
define('EPS', 2.22e-16);
@@ -63,29 +79,6 @@ if ($savedPrecision < 16) {
}
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Calculation */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation.php';
-
-/** PHPExcel_Cell_DataType */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
-
-/** PHPExcel_Style_NumberFormat */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
-
-/** PHPExcel_Shared_Date */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
-
/** Matrix */
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/Matrix.php';
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/trendClass.php';
@@ -122,7 +115,7 @@ class PHPExcel_Calculation_Functions {
* Data Type to use when returning date values
*
* @access private
- * @var integer
+ * @var string
*/
private static $ReturnDateType = self::RETURNDATE_EXCEL;
@@ -236,8 +229,14 @@ class PHPExcel_Calculation_Functions {
/**
* NA
*
+ * Excel Function:
+ * =NA()
+ *
+ * Returns the error value #N/A
+ * #N/A is the error value that means "no value is available."
+ *
* @access public
- * @category Error Returns
+ * @category Logical Functions
* @return string #N/A!
*/
public static function NA() {
@@ -248,6 +247,8 @@ class PHPExcel_Calculation_Functions {
/**
* NAN
*
+ * Returns the error value #NUM!
+ *
* @access public
* @category Error Returns
* @return string #NUM!
@@ -260,9 +261,11 @@ class PHPExcel_Calculation_Functions {
/**
* NAME
*
+ * Returns the error value #NAME?
+ *
* @access public
* @category Error Returns
- * @return string #NAME!
+ * @return string #NAME?
*/
public static function NAME() {
return self::$_errorCodes['name'];
@@ -272,6 +275,8 @@ class PHPExcel_Calculation_Functions {
/**
* REF
*
+ * Returns the error value #REF!
+ *
* @access public
* @category Error Returns
* @return string #REF!
@@ -284,6 +289,8 @@ class PHPExcel_Calculation_Functions {
/**
* VALUE
*
+ * Returns the error value #VALUE!
+ *
* @access public
* @category Error Returns
* @return string #VALUE!
@@ -552,6 +559,39 @@ class PHPExcel_Calculation_Functions {
} // function STATEMENT_IFERROR()
+ /**
+ * HYPERLINK
+ *
+ * Excel Function:
+ * =HYPERLINK(linkURL,displayName)
+ *
+ * @access public
+ * @category Logical Functions
+ * @param string $linkURL Value to check, is also the value returned when no error
+ * @param string $displayName Value to return when testValue is an error condition
+ * @return mixed The value of errorpart or testValue determined by error condition
+ */
+ public static function HYPERLINK($linkURL = '', $displayName = null, PHPExcel_Cell $pCell = null) {
+ $args = func_get_args();
+ $pCell = array_pop($args);
+
+ $linkURL = (is_null($linkURL)) ? '' : self::flattenSingleValue($linkURL);
+ $displayName = (is_null($displayName)) ? '' : self::flattenSingleValue($displayName);
+
+ if ((!is_object($pCell)) || (trim($linkURL) == '')) {
+ return self::$_errorCodes['reference'];
+ }
+
+ if ((is_object($displayName)) || trim($displayName) == '') {
+ $displayName = $linkURL;
+ }
+
+ $pCell->getHyperlink()->setUrl($linkURL);
+
+ return $displayName;
+ } // function HYPERLINK()
+
+
/**
* ATAN2
*
@@ -826,6 +866,46 @@ class PHPExcel_Calculation_Functions {
} // function MINA()
+ /**
+ * MINIF
+ *
+ * Returns the minimum value within a range of cells that contain numbers within the list of arguments
+ *
+ * Excel Function:
+ * MINIF(value1[,value2[, ...]],condition)
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @param string $condition The criteria that defines which cells will be checked.
+ * @return float
+ */
+ public static function MINIF($aArgs,$condition,$sumArgs = array()) {
+ // Return value
+ $returnValue = null;
+
+ $aArgs = self::flattenArray($aArgs);
+ $sumArgs = self::flattenArray($sumArgs);
+ if (count($sumArgs) == 0) {
+ $sumArgs = $aArgs;
+ }
+ $condition = self::_ifCondition($condition);
+ // Loop through arguments
+ foreach ($aArgs as $key => $arg) {
+ if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); }
+ $testCondition = '='.$arg.$condition;
+ if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
+ if ((is_null($returnValue)) || ($arg < $returnValue)) {
+ $returnValue = $arg;
+ }
+ }
+ }
+
+ // Return
+ return $returnValue;
+ } // function MINIF()
+
+
/**
* SMALL
*
@@ -945,6 +1025,59 @@ class PHPExcel_Calculation_Functions {
} // function MAXA()
+ private static function _ifCondition($condition) {
+ $condition = self::flattenSingleValue($condition);
+ if (!in_array($condition{0},array('>', '<', '='))) {
+ if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); }
+ return '='.$condition;
+ } else {
+ preg_match('/([<>=]+)(.*)/',$condition,$matches);
+ list(,$operator,$operand) = $matches;
+ if (!is_numeric($operand)) { $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand)); }
+ return $operator.$operand;
+ }
+ } // function _ifCondition()
+
+ /**
+ * MAXIF
+ *
+ * Counts the maximum value within a range of cells that contain numbers within the list of arguments
+ *
+ * Excel Function:
+ * MAXIF(value1[,value2[, ...]],condition)
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @param string $condition The criteria that defines which cells will be checked.
+ * @return float
+ */
+ public static function MAXIF($aArgs,$condition,$sumArgs = array()) {
+ // Return value
+ $returnValue = null;
+
+ $aArgs = self::flattenArray($aArgs);
+ $sumArgs = self::flattenArray($sumArgs);
+ if (count($sumArgs) == 0) {
+ $sumArgs = $aArgs;
+ }
+ $condition = self::_ifCondition($condition);
+ // Loop through arguments
+ foreach ($aArgs as $key => $arg) {
+ if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); }
+ $testCondition = '='.$arg.$condition;
+ if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
+ if ((is_null($returnValue)) || ($arg > $returnValue)) {
+ $returnValue = $arg;
+ }
+ }
+ }
+
+ // Return
+ return $returnValue;
+ } // function MAXIF()
+
+
/**
* LARGE
*
@@ -1184,16 +1317,7 @@ class PHPExcel_Calculation_Functions {
$returnValue = 0;
$aArgs = self::flattenArray($aArgs);
- $condition = self::flattenSingleValue($condition);
- if (!in_array($condition{0},array('>', '<', '='))) {
- if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); }
- $condition = '='.$condition;
- } else {
- preg_match('/([<>=]+)(.*)/',$condition,$matches);
- list(,$operator,$operand) = $matches;
- if (!is_numeric($operand)) { $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand)); }
- $condition = $operator.$operand;
- }
+ $condition = self::_ifCondition($condition);
// Loop through arguments
foreach ($aArgs as $arg) {
if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); }
@@ -1232,15 +1356,7 @@ class PHPExcel_Calculation_Functions {
if (count($sumArgs) == 0) {
$sumArgs = $aArgs;
}
- if (!in_array($condition{0},array('>', '<', '='))) {
- if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); }
- $condition = '='.$condition;
- } else {
- preg_match('/([<>=]+)(.*)/',$condition,$matches);
- list(,$operator,$operand) = $matches;
- if (!is_numeric($operand)) { $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand)); }
- $condition = $operator.$operand;
- }
+ $condition = self::_ifCondition($condition);
// Loop through arguments
foreach ($aArgs as $key => $arg) {
if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); }
@@ -1348,6 +1464,52 @@ class PHPExcel_Calculation_Functions {
} // function AVERAGEA()
+ /**
+ * AVERAGEIF
+ *
+ * Returns the average value from a range of cells that contain numbers within the list of arguments
+ *
+ * Excel Function:
+ * AVERAGEIF(value1[,value2[, ...]],condition)
+ *
+ * @access public
+ * @category Mathematical and Trigonometric Functions
+ * @param mixed $arg,... Data values
+ * @param string $condition The criteria that defines which cells will be checked.
+ * @return float
+ */
+ public static function AVERAGEIF($aArgs,$condition,$averageArgs = array()) {
+ // Return value
+ $returnValue = 0;
+
+ $aArgs = self::flattenArray($aArgs);
+ $averageArgs = self::flattenArray($averageArgs);
+ if (count($averageArgs) == 0) {
+ $averageArgs = $aArgs;
+ }
+ $condition = self::_ifCondition($condition);
+ // Loop through arguments
+ $aCount = 0;
+ foreach ($aArgs as $key => $arg) {
+ if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); }
+ $testCondition = '='.$arg.$condition;
+ if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
+ if ((is_null($returnValue)) || ($arg > $returnValue)) {
+ $returnValue += $arg;
+ ++$aCount;
+ }
+ }
+ }
+
+ // Return
+ if ($aCount > 0) {
+ return $returnValue / $aCount;
+ } else {
+ return self::$_errorCodes['divisionbyzero'];
+ }
+ } // function AVERAGEIF()
+
+
/**
* MEDIAN
*
@@ -5529,7 +5691,7 @@ class PHPExcel_Calculation_Functions {
* @return string Version information
*/
public static function VERSION() {
- return 'PHPExcel 1.7.2, 2010-01-11';
+ return 'PHPExcel 1.7.3, 2010-05-17';
} // function VERSION()
@@ -5675,22 +5837,37 @@ class PHPExcel_Calculation_Functions {
* depending on the value of the ReturnDateType flag
*/
public static function DATEVALUE($dateValue = 1) {
- $dateValue = str_replace(array('/','.',' '),array('-','-','-'),trim(self::flattenSingleValue($dateValue),'"'));
+ $dateValue = trim(self::flattenSingleValue($dateValue),'"');
+ // Strip any ordinals because they're allowed in Excel (English only)
+ $dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui','$1$3',$dateValue);
+ // Convert separators (/ . or space) to hyphens (should also handle dot used for ordinals in some countries, e.g. Denmark, Germany)
+ $dateValue = str_replace(array('/','.','-',' '),array(' ',' ',' ',' '),$dateValue);
$yearFound = false;
- $t1 = explode('-',$dateValue);
+ $t1 = explode(' ',$dateValue);
foreach($t1 as &$t) {
- if ((is_numeric($t)) && (($t > 31) && ($t < 100))) {
+ if ((is_numeric($t)) && ($t > 31)) {
if ($yearFound) {
return self::$_errorCodes['value'];
} else {
- $t += 1900;
+ if ($t < 100) { $t += 1900; }
$yearFound = true;
}
}
}
+ if ((count($t1) == 1) && (strpos($t,':') != false)) {
+ // We've been fed a time value without any date
+ return 0.0;
+ } elseif (count($t1) == 2) {
+ // We only have two parts of the date: either day/month or month/year
+ if ($yearFound) {
+ array_unshift($t1,1);
+ } else {
+ array_push($t1,date('Y'));
+ }
+ }
unset($t);
- $dateValue = implode('-',$t1);
+ $dateValue = implode(' ',$t1);
$PHPDateArray = date_parse($dateValue);
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
@@ -5769,9 +5946,11 @@ class PHPExcel_Calculation_Functions {
* depending on the value of the ReturnDateType flag
*/
public static function TIMEVALUE($timeValue) {
- $timeValue = self::flattenSingleValue($timeValue);
+ $timeValue = trim(self::flattenSingleValue($timeValue),'"');
+ $timeValue = str_replace(array('/','.'),array('-','-'),$timeValue);
- if ((($PHPDateArray = date_parse($timeValue)) !== False) && ($PHPDateArray['error_count'] == 0)) {
+ $PHPDateArray = date_parse($timeValue);
+ if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) {
if (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE) {
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']);
} else {
@@ -6042,19 +6221,55 @@ class PHPExcel_Calculation_Functions {
return self::$_errorCodes['value'];
}
- if ((is_numeric($method)) && (!is_string($method))) {
+ if (((is_numeric($method)) && (!is_string($method))) || ($method == '')) {
switch($method) {
case 0 :
return self::DAYS360($startDate,$endDate) / 360;
break;
case 1 :
+ $days = self::DATEDIF($startDate,$endDate);
$startYear = self::YEAR($startDate);
$endYear = self::YEAR($endDate);
- $leapDay = 0;
- if (self::_isLeapYear($startYear) || self::_isLeapYear($endYear)) {
- $leapDay = 1;
+ $years = $endYear - $startYear + 1;
+ $leapDays = 0;
+ if ($years == 1) {
+ if (self::_isLeapYear($endYear)) {
+ $startMonth = self::MONTHOFYEAR($startDate);
+ $endMonth = self::MONTHOFYEAR($endDate);
+ $endDay = self::DAYOFMONTH($endDate);
+ if (($startMonth < 3) ||
+ (($endMonth * 100 + $endDay) >= (2 * 100 + 29))) {
+ $leapDays += 1;
+ }
+ }
+ } else {
+ for($year = $startYear; $year <= $endYear; ++$year) {
+ if ($year == $startYear) {
+ $startMonth = self::MONTHOFYEAR($startDate);
+ $startDay = self::DAYOFMONTH($startDate);
+ if ($startMonth < 3) {
+ $leapDays += (self::_isLeapYear($year)) ? 1 : 0;
+ }
+ } elseif($year == $endYear) {
+ $endMonth = self::MONTHOFYEAR($endDate);
+ $endDay = self::DAYOFMONTH($endDate);
+ if (($endMonth * 100 + $endDay) >= (2 * 100 + 29)) {
+ $leapDays += (self::_isLeapYear($year)) ? 1 : 0;
+ }
+ } else {
+ $leapDays += (self::_isLeapYear($year)) ? 1 : 0;
+ }
+ }
+ if ($years == 2) {
+ if (($leapDays == 0) && (self::_isLeapYear($startYear)) && ($days > 365)) {
+ $leapDays = 1;
+ } elseif ($days < 366) {
+ $years = 1;
+ }
+ }
+ $leapDays /= $years;
}
- return self::DATEDIF($startDate,$endDate) / (365 + $leapDay);
+ return $days / (365 + $leapDays);
break;
case 2 :
return self::DATEDIF($startDate,$endDate) / 360;
@@ -6080,7 +6295,10 @@ class PHPExcel_Calculation_Functions {
* @return long Interval between the dates
*/
public static function NETWORKDAYS($startDate,$endDate) {
- // Flush the mandatory start and end date that are referenced in the function definition
+ // Retrieve the mandatory start and end date that are referenced in the function definition
+ $startDate = self::flattenSingleValue($startDate);
+ $endDate = self::flattenSingleValue($endDate);
+ // Flush the mandatory start and end date that are referenced in the function definition, and get the optional days
$dateArgs = self::flattenArray(func_get_args());
array_shift($dateArgs);
array_shift($dateArgs);
@@ -6089,9 +6307,11 @@ class PHPExcel_Calculation_Functions {
if (is_string($startDate = $sDate = self::_getDateValue($startDate))) {
return self::$_errorCodes['value'];
}
+ $startDate = (float) floor($startDate);
if (is_string($endDate = $eDate = self::_getDateValue($endDate))) {
return self::$_errorCodes['value'];
}
+ $endDate = (float) floor($endDate);
if ($sDate > $eDate) {
$startDate = $eDate;
@@ -6140,69 +6360,80 @@ class PHPExcel_Calculation_Functions {
* @return long Interval between the dates
*/
public static function WORKDAY($startDate,$endDays) {
+ // Retrieve the mandatory start date and days that are referenced in the function definition
+ $startDate = self::flattenSingleValue($startDate);
+ $endDays = (int) self::flattenSingleValue($endDays);
+ // Flush the mandatory start date and days that are referenced in the function definition, and get the optional days
$dateArgs = self::flattenArray(func_get_args());
-
array_shift($dateArgs);
array_shift($dateArgs);
- if (is_string($startDate = self::_getDateValue($startDate))) {
+ if ((is_string($startDate = self::_getDateValue($startDate))) || (!is_numeric($endDays))) {
return self::$_errorCodes['value'];
}
- if (!is_numeric($endDays)) {
- return self::$_errorCodes['value'];
- }
- $endDate = (float) $startDate + (floor($endDays / 5) * 7) + ($endDays % 5);
- if ($endDays < 0) {
- $endDate += 7;
+ $startDate = (float) floor($startDate);
+ // If endDays is 0, we always return startDate
+ if ($endDays == 0) { return $startDate; }
+
+ $decrementing = ($endDays < 0) ? True : False;
+
+ // Adjust the start date if it falls over a weekend
+
+ $startDoW = self::DAYOFWEEK($startDate,3);
+ if (self::DAYOFWEEK($startDate,3) >= 5) {
+ $startDate += ($decrementing) ? -$startDoW + 4: 7 - $startDoW;
+ ($decrementing) ? $endDays++ : $endDays--;
}
+ // Add endDays
+ $endDate = (float) $startDate + (intval($endDays / 5) * 7) + ($endDays % 5);
+
+ // Adjust the calculated end date if it falls over a weekend
$endDoW = self::DAYOFWEEK($endDate,3);
if ($endDoW >= 5) {
- if ($endDays >= 0) {
- $endDate += (7 - $endDoW);
- } else {
- $endDate -= ($endDoW - 5);
- }
+ $endDate += ($decrementing) ? -$endDoW + 4: 7 - $endDoW;
}
// Test any extra holiday parameters
if (count($dateArgs) > 0) {
$holidayCountedArray = $holidayDates = array();
foreach ($dateArgs as $holidayDate) {
- if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
- return self::$_errorCodes['value'];
+ if ((!is_null($holidayDate)) && (trim($holidayDate) > '')) {
+ if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
+ return self::$_errorCodes['value'];
+ }
+ if (self::DAYOFWEEK($holidayDate,3) < 5) {
+ $holidayDates[] = $holidayDate;
+ }
}
- $holidayDates[] = $holidayDate;
}
- if ($endDays >= 0) {
- sort($holidayDates, SORT_NUMERIC);
- } else {
+ if ($decrementing) {
rsort($holidayDates, SORT_NUMERIC);
+ } else {
+ sort($holidayDates, SORT_NUMERIC);
}
foreach ($holidayDates as $holidayDate) {
- if ($endDays >= 0) {
- if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
- if ((self::DAYOFWEEK($holidayDate,2) < 6) && (!in_array($holidayDate,$holidayCountedArray))) {
- ++$endDate;
- $holidayCountedArray[] = $holidayDate;
- }
- }
- } else {
+ if ($decrementing) {
if (($holidayDate <= $startDate) && ($holidayDate >= $endDate)) {
- if ((self::DAYOFWEEK($holidayDate,2) < 6) && (!in_array($holidayDate,$holidayCountedArray))) {
+ if (!in_array($holidayDate,$holidayCountedArray)) {
--$endDate;
$holidayCountedArray[] = $holidayDate;
}
}
- }
- $endDoW = self::DAYOFWEEK($endDate,3);
- if ($endDoW >= 5) {
- if ($endDays >= 0) {
- $endDate += (7 - $endDoW);
- } else {
- $endDate -= ($endDoW - 5);
+ } else {
+ if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
+ if (!in_array($holidayDate,$holidayCountedArray)) {
+ ++$endDate;
+ $holidayCountedArray[] = $holidayDate;
+ }
}
}
+ // Adjust the calculated end date if it falls over a weekend
+ $endDoW = self::DAYOFWEEK($endDate,3);
+ if ($endDoW >= 5) {
+ $endDate += ($decrementing) ? -$endDoW + 4: 7 - $endDoW;
+ }
+
}
}
@@ -7064,12 +7295,13 @@ class PHPExcel_Calculation_Functions {
* @return string
*/
public static function COMPLEX($realNumber=0.0, $imaginary=0.0, $suffix='i') {
- $realNumber = self::flattenSingleValue($realNumber);
- $imaginary = self::flattenSingleValue($imaginary);
- $suffix = self::flattenSingleValue($suffix);
+ $realNumber = (is_null($realNumber)) ? 0.0 : (float) self::flattenSingleValue($realNumber);
+ $imaginary = (is_null($imaginary)) ? 0.0 : (float) self::flattenSingleValue($imaginary);
+ $suffix = (is_null($suffix)) ? 'i' : self::flattenSingleValue($suffix);
if (((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
(($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))) {
+ if ($suffix == '') $suffix = 'i';
if ($realNumber == 0.0) {
if ($imaginary == 0.0) {
return (string) '0';
@@ -8371,14 +8603,15 @@ class PHPExcel_Calculation_Functions {
* @return int
*/
public static function BESSELI($x, $n) {
- $x = self::flattenSingleValue($x);
- $n = floor(self::flattenSingleValue($n));
+ $x = (is_null($x)) ? 0.0 : self::flattenSingleValue($x);
+ $n = (is_null($n)) ? 0.0 : self::flattenSingleValue($n);
if ((is_numeric($x)) && (is_numeric($n))) {
+ $n = floor($n);
if ($n < 0) {
return self::$_errorCodes['num'];
}
- $f_2_PI = 2 * pi();
+ $f_2_PI = 2 * M_PI;
if (abs($x) <= 30) {
$fTerm = pow($x / 2, $n) / self::FACT($n);
@@ -8413,10 +8646,11 @@ class PHPExcel_Calculation_Functions {
* @return int
*/
public static function BESSELJ($x, $n) {
- $x = self::flattenSingleValue($x);
- $n = floor(self::flattenSingleValue($n));
+ $x = (is_null($x)) ? 0.0 : self::flattenSingleValue($x);
+ $n = (is_null($n)) ? 0.0 : self::flattenSingleValue($n);
if ((is_numeric($x)) && (is_numeric($n))) {
+ $n = floor($n);
if ($n < 0) {
return self::$_errorCodes['num'];
}
@@ -8491,15 +8725,15 @@ class PHPExcel_Calculation_Functions {
* @return float
*/
public static function BESSELK($x, $ord) {
- $x = self::flattenSingleValue($x);
- $ord = floor(self::flattenSingleValue($ord));
+ $x = (is_null($x)) ? 0.0 : self::flattenSingleValue($x);
+ $ord = (is_null($ord)) ? 0.0 : self::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) {
- if ($ord < 0) {
+ if (($ord < 0) || ($x == 0.0)) {
return self::$_errorCodes['num'];
}
- switch($ord) {
+ switch(floor($ord)) {
case 0 : return self::_Besselk0($x);
break;
case 1 : return self::_Besselk1($x);
@@ -8569,15 +8803,15 @@ class PHPExcel_Calculation_Functions {
* @return int
*/
public static function BESSELY($x, $ord) {
- $x = self::flattenSingleValue($x);
- $ord = floor(self::flattenSingleValue($ord));
+ $x = (is_null($x)) ? 0.0 : self::flattenSingleValue($x);
+ $ord = (is_null($ord)) ? 0.0 : self::flattenSingleValue($ord);
if ((is_numeric($x)) && (is_numeric($ord))) {
- if ($ord < 0) {
+ if (($ord < 0) || ($x == 0.0)) {
return self::$_errorCodes['num'];
}
- switch($ord) {
+ switch(floor($ord)) {
case 0 : return self::_Bessely0($x);
break;
case 1 : return self::_Bessely1($x);
@@ -9631,7 +9865,7 @@ class PHPExcel_Calculation_Functions {
$daysPerYear = 365;
break;
case 1 :
- if (self::_isLeapYear(self::YEAR($year))) {
+ if (self::_isLeapYear($year)) {
$daysPerYear = 366;
} else {
$daysPerYear = 365;
@@ -9680,13 +9914,8 @@ class PHPExcel_Calculation_Functions {
if (!is_numeric($daysBetweenIssueAndSettlement)) {
return $daysBetweenIssueAndSettlement;
}
- $daysPerYear = self::_daysPerYear(self::YEAR($issue),$basis);
- if (!is_numeric($daysPerYear)) {
- return $daysPerYear;
- }
- $daysBetweenIssueAndSettlement *= $daysPerYear;
- return $par * $rate * ($daysBetweenIssueAndSettlement / $daysPerYear);
+ return $par * $rate * $daysBetweenIssueAndSettlement;
}
return self::$_errorCodes['value'];
} // function ACCRINT()
@@ -9725,13 +9954,7 @@ class PHPExcel_Calculation_Functions {
if (!is_numeric($daysBetweenIssueAndSettlement)) {
return $daysBetweenIssueAndSettlement;
}
- $daysPerYear = self::_daysPerYear(self::YEAR($issue),$basis);
- if (!is_numeric($daysPerYear)) {
- return $daysPerYear;
- }
- $daysBetweenIssueAndSettlement *= $daysPerYear;
-
- return $par * $rate * ($daysBetweenIssueAndSettlement / $daysPerYear);
+ return $par * $rate * $daysBetweenIssueAndSettlement;
}
return self::$_errorCodes['value'];
} // function ACCRINTM()
@@ -9744,7 +9967,7 @@ class PHPExcel_Calculation_Functions {
$salvage = self::flattenSingleValue($salvage);
$period = floor(self::flattenSingleValue($period));
$rate = self::flattenSingleValue($rate);
- $basis = floor(self::flattenSingleValue($basis));
+ $basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
$fUsePer = 1.0 / $rate;
@@ -9759,18 +9982,22 @@ class PHPExcel_Calculation_Functions {
}
$rate *= $amortiseCoeff;
- $fNRate = floor((self::YEARFRAC($purchased, $firstPeriod, $basis) * $rate * $cost) + 0.5);
+// $fNRate = floor((self::YEARFRAC($purchased, $firstPeriod, $basis) * $rate * $cost) + 0.5);
+ $fNRate = round(self::YEARFRAC($purchased, $firstPeriod, $basis) * $rate * $cost,0);
$cost -= $fNRate;
$fRest = $cost - $salvage;
for ($n = 0; $n < $period; ++$n) {
- $fNRate = floor(($rate * $cost) + 0.5);
+// $fNRate = floor(($rate * $cost) + 0.5);
+ $fNRate = round($rate * $cost,0);
$fRest -= $fNRate;
if ($fRest < 0.0) {
switch ($period - $n) {
case 0 :
- case 1 : return floor(($cost * 0.5) + 0.5);
+ case 1 :
+// return floor(($cost * 0.5) + 0.5);
+ return round($cost * 0.5,0);
break;
default : return 0.0;
break;
@@ -9789,11 +10016,17 @@ class PHPExcel_Calculation_Functions {
$salvage = self::flattenSingleValue($salvage);
$period = self::flattenSingleValue($period);
$rate = self::flattenSingleValue($rate);
- $basis = self::flattenSingleValue($basis);
+ $basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
$fOneRate = $cost * $rate;
$fCostDelta = $cost - $salvage;
- $f0Rate = self::YEARFRAC($purchased, $firstPeriod, $basis) * $rate * $cost;
+ // Note, quirky variation for leap years on the YEARFRAC for this function
+ $purchasedYear = self::YEAR($purchased);
+ $yearFrac = self::YEARFRAC($purchased, $firstPeriod, $basis);
+ if (($basis == 1) && ($yearFrac < 1) && (self::_isLeapYear($purchasedYear))) {
+ $yearFrac *= 365 / 366;
+ }
+ $f0Rate = $yearFrac * $rate * $cost;
$nNumOfFullPeriods = intval(($cost - $salvage - $f0Rate) / $fOneRate);
if ($period == 0) {
@@ -9808,12 +10041,205 @@ class PHPExcel_Calculation_Functions {
} // function AMORLINC()
+ private static function _lastDayOfMonth($testDate) {
+ $date = clone $testDate;
+ $date->modify('+1 day');
+ return ($date->format('d') == 1);
+ } // function _lastDayOfMonth()
+
+ private static function _firstDayOfMonth($testDate) {
+ $date = clone $testDate;
+ return ($date->format('d') == 1);
+ } // function _lastDayOfMonth()
+
+ private static function _coupFirstPeriodDate($settlement, $maturity, $frequency, $next) {
+ $months = 12 / $frequency;
+
+ $result = PHPExcel_Shared_Date::ExcelToPHPObject($maturity);
+ $eom = self::_lastDayOfMonth($result);
+
+ while ($settlement < PHPExcel_Shared_Date::PHPToExcel($result)) {
+ $result->modify('-'.$months.' months');
+ }
+ if ($next) {
+ $result->modify('+'.$months.' months');
+ }
+
+ if ($eom) {
+ $result->modify('-1 day');
+ }
+
+ return PHPExcel_Shared_Date::PHPToExcel($result);
+ } // function _coupFirstPeriodDate()
+
+
+ private static function _validFrequency($frequency) {
+ if (($frequency == 1) || ($frequency == 2) || ($frequency == 4)) {
+ return true;
+ }
+ if ((self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC) &&
+ (($frequency == 6) || ($frequency == 12))) {
+ return true;
+ }
+ return false;
+ } // function _validFrequency()
+
+ public static function COUPDAYS($settlement, $maturity, $frequency, $basis=0) {
+ $settlement = self::flattenSingleValue($settlement);
+ $maturity = self::flattenSingleValue($maturity);
+ $frequency = (int) self::flattenSingleValue($frequency);
+ $basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
+
+ if (is_string($settlement = self::_getDateValue($settlement))) {
+ return self::$_errorCodes['value'];
+ }
+ if (is_string($maturity = self::_getDateValue($maturity))) {
+ return self::$_errorCodes['value'];
+ }
+
+ if (($settlement > $maturity) ||
+ (!self::_validFrequency($frequency)) ||
+ (($basis < 0) || ($basis > 4))) {
+ return self::$_errorCodes['num'];
+ }
+
+ switch ($basis) {
+ case 3: // Actual/365
+ return 365 / $frequency;
+ case 1: // Actual/actual
+ if ($frequency == 1) {
+ $daysPerYear = self::_daysPerYear(self::YEAR($maturity),$basis);
+ return ($daysPerYear / $frequency);
+ } else {
+ $prev = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, False);
+ $next = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, True);
+ return ($next - $prev);
+ }
+ default: // US (NASD) 30/360, Actual/360 or European 30/360
+ return 360 / $frequency;
+ }
+ return self::$_errorCodes['value'];
+ } // function COUPDAYS()
+
+
+ public static function COUPDAYBS($settlement, $maturity, $frequency, $basis=0) {
+ $settlement = self::flattenSingleValue($settlement);
+ $maturity = self::flattenSingleValue($maturity);
+ $frequency = (int) self::flattenSingleValue($frequency);
+ $basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
+
+ if (is_string($settlement = self::_getDateValue($settlement))) {
+ return self::$_errorCodes['value'];
+ }
+ if (is_string($maturity = self::_getDateValue($maturity))) {
+ return self::$_errorCodes['value'];
+ }
+
+ if (($settlement > $maturity) ||
+ (!self::_validFrequency($frequency)) ||
+ (($basis < 0) || ($basis > 4))) {
+ return self::$_errorCodes['num'];
+ }
+
+ $daysPerYear = self::_daysPerYear(self::YEAR($settlement),$basis);
+ $prev = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, False);
+
+ return self::YEARFRAC($prev, $settlement, $basis) * $daysPerYear;
+ } // function COUPDAYBS()
+
+
+ public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis=0) {
+ $settlement = self::flattenSingleValue($settlement);
+ $maturity = self::flattenSingleValue($maturity);
+ $frequency = (int) self::flattenSingleValue($frequency);
+ $basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
+
+ if (is_string($settlement = self::_getDateValue($settlement))) {
+ return self::$_errorCodes['value'];
+ }
+ if (is_string($maturity = self::_getDateValue($maturity))) {
+ return self::$_errorCodes['value'];
+ }
+
+ if (($settlement > $maturity) ||
+ (!self::_validFrequency($frequency)) ||
+ (($basis < 0) || ($basis > 4))) {
+ return self::$_errorCodes['num'];
+ }
+
+ $daysPerYear = self::_daysPerYear(self::YEAR($settlement),$basis);
+ $next = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, True);
+
+ return self::YEARFRAC($settlement, $next, $basis) * $daysPerYear;
+ } // function COUPDAYSNC()
+
+
+ public static function COUPNCD($settlement, $maturity, $frequency, $basis=0) {
+ $settlement = self::flattenSingleValue($settlement);
+ $maturity = self::flattenSingleValue($maturity);
+ $frequency = (int) self::flattenSingleValue($frequency);
+ $basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
+
+ if (is_string($settlement = self::_getDateValue($settlement))) {
+ return self::$_errorCodes['value'];
+ }
+ if (is_string($maturity = self::_getDateValue($maturity))) {
+ return self::$_errorCodes['value'];
+ }
+
+ if (($settlement > $maturity) ||
+ (!self::_validFrequency($frequency)) ||
+ (($basis < 0) || ($basis > 4))) {
+ return self::$_errorCodes['num'];
+ }
+
+ return self::_coupFirstPeriodDate($settlement, $maturity, $frequency, True);
+ } // function COUPNCD()
+
+
+ public static function COUPPCD($settlement, $maturity, $frequency, $basis=0) {
+ $settlement = self::flattenSingleValue($settlement);
+ $maturity = self::flattenSingleValue($maturity);
+ $frequency = (int) self::flattenSingleValue($frequency);
+ $basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
+
+ if (is_string($settlement = self::_getDateValue($settlement))) {
+ return self::$_errorCodes['value'];
+ }
+ if (is_string($maturity = self::_getDateValue($maturity))) {
+ return self::$_errorCodes['value'];
+ }
+
+ if (($settlement > $maturity) ||
+ (!self::_validFrequency($frequency)) ||
+ (($basis < 0) || ($basis > 4))) {
+ return self::$_errorCodes['num'];
+ }
+
+ return self::_coupFirstPeriodDate($settlement, $maturity, $frequency, False);
+ } // function COUPPCD()
+
+
public static function COUPNUM($settlement, $maturity, $frequency, $basis=0) {
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
- $frequency = self::flattenSingleValue($frequency);
- $basis = self::flattenSingleValue($basis);
+ $frequency = (int) self::flattenSingleValue($frequency);
+ $basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
+ if (is_string($settlement = self::_getDateValue($settlement))) {
+ return self::$_errorCodes['value'];
+ }
+ if (is_string($maturity = self::_getDateValue($maturity))) {
+ return self::$_errorCodes['value'];
+ }
+
+ if (($settlement > $maturity) ||
+ (!self::_validFrequency($frequency)) ||
+ (($basis < 0) || ($basis > 4))) {
+ return self::$_errorCodes['num'];
+ }
+
+ $settlement = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, True);
$daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity, $basis) * 365;
switch ($frequency) {
@@ -9823,29 +10249,54 @@ class PHPExcel_Calculation_Functions {
return ceil($daysBetweenSettlementAndMaturity / 180);
case 4: // quarterly
return ceil($daysBetweenSettlementAndMaturity / 90);
+ case 6: // bimonthly
+ return ceil($daysBetweenSettlementAndMaturity / 60);
+ case 12: // monthly
+ return ceil($daysBetweenSettlementAndMaturity / 30);
}
return self::$_errorCodes['value'];
} // function COUPNUM()
- public static function COUPDAYBS($settlement, $maturity, $frequency, $basis=0) {
+ public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis=0) {
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
- $frequency = self::flattenSingleValue($frequency);
- $basis = self::flattenSingleValue($basis);
+ $rate = (float) self::flattenSingleValue($rate);
+ $yield = (float) self::flattenSingleValue($yield);
+ $redemption = (float) self::flattenSingleValue($redemption);
+ $frequency = (int) self::flattenSingleValue($frequency);
+ $basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
- $daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity, $basis) * 365;
-
- switch ($frequency) {
- case 1: // annual payments
- return 365 - ($daysBetweenSettlementAndMaturity % 360);
- case 2: // half-yearly
- return 365 - ($daysBetweenSettlementAndMaturity % 360);
- case 4: // quarterly
- return self::DATEDIF($maturity, $settlement);
+ if (is_string($settlement = self::_getDateValue($settlement))) {
+ return self::$_errorCodes['value'];
}
- return self::$_errorCodes['value'];
- } // function COUPDAYBS()
+ if (is_string($maturity = self::_getDateValue($maturity))) {
+ return self::$_errorCodes['value'];
+ }
+
+ if (($settlement > $maturity) ||
+ (!self::_validFrequency($frequency)) ||
+ (($basis < 0) || ($basis > 4))) {
+ return self::$_errorCodes['num'];
+ }
+
+ $dsc = self::COUPDAYSNC($settlement, $maturity, $frequency, $basis);
+ $e = self::COUPDAYS($settlement, $maturity, $frequency, $basis);
+ $n = self::COUPNUM($settlement, $maturity, $frequency, $basis);
+ $a = self::COUPDAYBS($settlement, $maturity, $frequency, $basis);
+
+ $baseYF = 1.0 + ($yield / $frequency);
+ $rfp = 100 * ($rate / $frequency);
+ $de = $dsc / $e;
+
+ $result = $redemption / pow($baseYF, (--$n + $de));
+ for($k = 0; $k <= $n; ++$k) {
+ $result += $rfp / (pow($baseYF, ($k + $de)));
+ }
+ $result -= $rfp * ($a / $e);
+
+ return $result;
+ } // function PRICE()
/**
@@ -10444,7 +10895,9 @@ class PHPExcel_Calculation_Functions {
return self::$_errorCodes['value'];
}
- $isMatrix = (is_numeric(array_shift(array_keys($cellAddress))));
+ $x = array_keys($cellAddress);
+ $x = array_shift($x);
+ $isMatrix = (is_numeric($x));
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) {
@@ -10511,7 +10964,8 @@ class PHPExcel_Calculation_Functions {
return self::$_errorCodes['value'];
}
- $isMatrix = (is_numeric(array_shift(array_keys($cellAddress))));
+ $i = array_keys($cellAddress);
+ $isMatrix = (is_numeric(array_shift($i)));
list($columns,$rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress);
if ($isMatrix) {
@@ -10581,11 +11035,16 @@ class PHPExcel_Calculation_Functions {
* @return string A reference to a cell or range of cells
*/
public static function OFFSET($cellAddress=Null,$rows=0,$columns=0,$height=null,$width=null) {
+ $rows = self::flattenSingleValue($rows);
+ $columns = self::flattenSingleValue($columns);
+ $height = self::flattenSingleValue($height);
+ $width = self::flattenSingleValue($width);
if ($cellAddress == Null) {
return 0;
}
- $pCell = array_pop(func_get_args());
+ $args = func_get_args();
+ $pCell = array_pop($args);
if (!is_object($pCell)) {
return self::$_errorCodes['reference'];
}
@@ -10791,6 +11250,8 @@ class PHPExcel_Calculation_Functions {
/**
+ * INDEX
+ *
* Uses an index to choose a value from a reference or array
* implemented: Return the value of a specified cell or array of cells Array form
* not implemented: Return a reference to specified cells Reference form
@@ -10805,6 +11266,10 @@ class PHPExcel_Calculation_Functions {
return self::$_errorCodes['value'];
}
+ if (!is_array($arrayValues)) {
+ return self::$_errorCodes['reference'];
+ }
+
$rowKeys = array_keys($arrayValues);
$columnKeys = @array_keys($arrayValues[$rowKeys[0]]);
@@ -10841,6 +11306,102 @@ class PHPExcel_Calculation_Functions {
} // function INDEX()
+ /**
+ * N
+ *
+ * Returns a value converted to a number
+ *
+ * @param value The value you want converted
+ * @return number N converts values listed in the following table
+ * If value is or refers to N returns
+ * A number That number
+ * A date The serial number of that date
+ * TRUE 1
+ * FALSE 0
+ * An error value The error value
+ * Anything else 0
+ */
+ public static function N($value) {
+ while (is_array($value)) {
+ $value = array_shift($value);
+ }
+
+ switch (gettype($value)) {
+ case 'double' :
+ case 'float' :
+ case 'integer' :
+ return $value;
+ break;
+ case 'boolean' :
+ return (integer) $value;
+ break;
+ case 'string' :
+ // Errors
+ if ((strlen($value) > 0) && ($value{0} == '#')) {
+ return $value;
+ }
+ break;
+ }
+ return 0;
+ } // function N()
+
+
+ /**
+ * TYPE
+ *
+ * Returns a number that identifies the type of a value
+ *
+ * @param value The value you want tested
+ * @return number N converts values listed in the following table
+ * If value is or refers to N returns
+ * A number 1
+ * Text 2
+ * Logical Value 4
+ * An error value 16
+ * Array or Matrix 64
+ */
+ public static function TYPE($value) {
+ $value = self::flattenArrayIndexed($value);
+ if (is_array($value) && (count($value) > 1)) {
+ $a = array_keys($value);
+ $a = array_pop($a);
+ // Range of cells is an error
+ if (self::isCellValue($a)) {
+ return 16;
+ // Test for Matrix
+ } elseif (self::isMatrixValue($a)) {
+ return 64;
+ }
+ } elseif(count($value) == 0) {
+ // Empty Cell
+ return 1;
+ }
+ $value = self::flattenSingleValue($value);
+
+ switch (gettype($value)) {
+ case 'double' :
+ case 'float' :
+ case 'integer' :
+ return 1;
+ break;
+ case 'boolean' :
+ return 4;
+ break;
+ case 'array' :
+ return 64;
+ break;
+ case 'string' :
+ // Errors
+ if ((strlen($value) > 0) && ($value{0} == '#')) {
+ return 16;
+ }
+ return 2;
+ break;
+ }
+ return 0;
+ } // function TYPE()
+
+
/**
* SYD
*
@@ -11132,7 +11693,8 @@ class PHPExcel_Calculation_Functions {
private static function _vlookupSort($a,$b) {
- $firstColumn = array_shift(array_keys($a));
+ $f = array_keys($a);
+ $firstColumn = array_shift($f);
if (strtolower($a[$firstColumn]) == strtolower($b[$firstColumn])) {
return 0;
}
@@ -11150,6 +11712,10 @@ class PHPExcel_Calculation_Functions {
* @return mixed The value of the found cell
*/
public static function VLOOKUP($lookup_value, $lookup_array, $index_number, $not_exact_match=true) {
+ $lookup_value = self::flattenSingleValue($lookup_value);
+ $index_number = self::flattenSingleValue($index_number);
+ $not_exact_match = self::flattenSingleValue($not_exact_match);
+
// index_number must be greater than or equal to 1
if ($index_number < 1) {
return self::$_errorCodes['value'];
@@ -11159,7 +11725,8 @@ class PHPExcel_Calculation_Functions {
if ((!is_array($lookup_array)) || (count($lookup_array) < 1)) {
return self::$_errorCodes['reference'];
} else {
- $firstRow = array_pop(array_keys($lookup_array));
+ $f = array_keys($lookup_array);
+ $firstRow = array_pop($f);
if ((!is_array($lookup_array[$firstRow])) || ($index_number > count($lookup_array[$firstRow]))) {
return self::$_errorCodes['reference'];
} else {
@@ -11211,22 +11778,28 @@ class PHPExcel_Calculation_Functions {
return self::$_errorCodes['na'];
}
$lookupRows = count($lookup_vector);
- $lookupColumns = count($lookup_vector[array_shift(array_keys($lookup_vector))]);
+ $l = array_keys($lookup_vector);
+ $l = array_shift($l);
+ $lookupColumns = count($lookup_vector[$l]);
if ((($lookupRows == 1) && ($lookupColumns > 1)) || (($lookupRows == 2) && ($lookupColumns != 2))) {
$lookup_vector = self::TRANSPOSE($lookup_vector);
$lookupRows = count($lookup_vector);
- $lookupColumns = count($lookup_vector[array_shift(array_keys($lookup_vector))]);
+ $l = array_keys($lookup_vector);
+ $lookupColumns = count($lookup_vector[array_shift($l)]);
}
if (is_null($result_vector)) {
$result_vector = $lookup_vector;
}
$resultRows = count($result_vector);
- $resultColumns = count($result_vector[array_shift(array_keys($result_vector))]);
+ $l = array_keys($result_vector);
+ $l = array_shift($l);
+ $resultColumns = count($result_vector[$l]);
if ((($resultRows == 1) && ($resultColumns > 1)) || (($resultRows == 2) && ($resultColumns != 2))) {
$result_vector = self::TRANSPOSE($result_vector);
$resultRows = count($result_vector);
- $resultColumns = count($result_vector[array_shift(array_keys($result_vector))]);
+ $r = array_keys($result_vector);
+ $resultColumns = count($result_vector[array_shift($r)]);
}
if ($lookupRows == 2) {
@@ -11236,7 +11809,8 @@ class PHPExcel_Calculation_Functions {
if ($lookupColumns != 2) {
foreach($lookup_vector as &$value) {
if (is_array($value)) {
- $key1 = $key2 = array_shift(array_keys($value));
+ $k = array_keys($value);
+ $key1 = $key2 = array_shift($k);
$key2++;
$dataValue1 = $value[$key1];
} else {
@@ -11328,9 +11902,10 @@ class PHPExcel_Calculation_Functions {
* @return mixed
*/
public static function flattenSingleValue($value = '') {
- if (is_array($value)) {
- return self::flattenSingleValue(array_pop($value));
+ while (is_array($value)) {
+ $value = array_pop($value);
}
+
return $value;
} // function flattenSingleValue()
diff --git a/libraries/PHPExcel/PHPExcel/Cell.php b/libraries/PHPExcel/PHPExcel/Cell.php
index c0603ac16..8855f19d9 100644
--- a/libraries/PHPExcel/PHPExcel/Cell.php
+++ b/libraries/PHPExcel/PHPExcel/Cell.php
@@ -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
';
$result = PHPExcel_Calculation::getInstance()->calculateCellValue($this,$resetLog);
+// echo $this->getCoordinate().' calculation result is '.$result.'
';
} catch ( Exception $ex ) {
// echo 'Calculation Exception: '.$ex->getMessage().'
';
$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;
}
diff --git a/libraries/PHPExcel/PHPExcel/Cell/AdvancedValueBinder.php b/libraries/PHPExcel/PHPExcel/Cell/AdvancedValueBinder.php
index d8e25645c..02193ed64 100644
--- a/libraries/PHPExcel/PHPExcel/Cell/AdvancedValueBinder.php
+++ b/libraries/PHPExcel/PHPExcel/Cell/AdvancedValueBinder.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,37 +22,10 @@
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Cell_IValueBinder */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/IValueBinder.php';
-
-/** PHPExcel_Cell_DefaultValueBinder */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DefaultValueBinder.php';
-
-/** PHPExcel_Style_NumberFormat */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
-
-/** PHPExcel_Shared_Date */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
-
-/** PHPExcel_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-
/**
* PHPExcel_Cell_AdvancedValueBinder
*
@@ -78,49 +51,72 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Find out data type
$dataType = parent::dataTypeForValue($value);
-
+
// Style logic - strings
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
// Check for percentage
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
// Convert value to number
$cell->setValueExplicit( (float)str_replace('%', '', $value) / 100, PHPExcel_Cell_DataType::TYPE_NUMERIC);
-
+
// Set style
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE );
-
+
return true;
}
-
- // Check for time e.g. '9:45', '09:45'
+
+ // Check for time without seconds e.g. '9:45', '09:45'
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
list($h, $m) = explode(':', $value);
$days = $h / 24 + $m / 1440;
-
+
// Convert value to number
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
-
+
// Set style
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
-
+
return true;
}
-
- // Check for date
- if (strtotime($value) !== false) {
- // make sure we have UTC for the sake of strtotime
- $saveTimeZone = date_default_timezone_get();
- date_default_timezone_set('UTC');
-
- // Convert value to Excel date
- $cell->setValueExplicit( PHPExcel_Shared_Date::PHPToExcel(strtotime($value)), PHPExcel_Cell_DataType::TYPE_NUMERIC);
-
+
+ // Check for time with seconds '9:45:59', '09:45:59'
+ if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) {
+ list($h, $m, $s) = explode(':', $value);
+ $days = $h / 24 + $m / 1440 + $s / 86400;
+
+ // Convert value to number
+ $cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+
// Set style
- $cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2 );
-
- // restore original value for timezone
- date_default_timezone_set($saveTimeZone);
-
+ $cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
+
+ return true;
+ }
+
+ // Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10'
+ if (($v = PHPExcel_Shared_Date::stringToExcel($value)) !== false) {
+ // Convert value to Excel date
+ $cell->setValueExplicit($v, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+
+ // Set style. Either there is a time part or not. Look for ':'
+ if (strpos($value, ':') !== false) {
+ $formatCode = 'yyyy-mm-dd h:mm';
+ } else {
+ $formatCode = 'yyyy-mm-dd';
+ }
+ $cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode($formatCode);
+
+ return true;
+ }
+
+ // Check for newline character "\n"
+ if (strpos($value, "\n") !== false) {
+ $value = PHPExcel_Shared_String::SanitizeUTF8($value);
+ $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
+
+ // Set style
+ $cell->getParent()->getStyle( $cell->getCoordinate() )->getAlignment()->setWrapText(true);
+
return true;
}
}
diff --git a/libraries/PHPExcel/PHPExcel/Cell/DataType.php b/libraries/PHPExcel/PHPExcel/Cell/DataType.php
index add1bec8b..20e4ff8c3 100644
--- a/libraries/PHPExcel/PHPExcel/Cell/DataType.php
+++ b/libraries/PHPExcel/PHPExcel/Cell/DataType.php
@@ -22,22 +22,10 @@
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Cell_DefaultValueBinder */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DefaultValueBinder.php';
-
-
/**
* PHPExcel_Cell_DataType
*
@@ -71,7 +59,7 @@ class PHPExcel_Cell_DataType
public static function getErrorCodes() {
return self::$_errorCodes;
}
-
+
/**
* DataType for value
*
diff --git a/libraries/PHPExcel/PHPExcel/Cell/DataValidation.php b/libraries/PHPExcel/PHPExcel/Cell/DataValidation.php
index 8d7f29329..f0b939105 100644
--- a/libraries/PHPExcel/PHPExcel/Cell/DataValidation.php
+++ b/libraries/PHPExcel/PHPExcel/Cell/DataValidation.php
@@ -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;
diff --git a/libraries/PHPExcel/PHPExcel/Cell/DefaultValueBinder.php b/libraries/PHPExcel/PHPExcel/Cell/DefaultValueBinder.php
index 2b8bef72e..9476d9ead 100644
--- a/libraries/PHPExcel/PHPExcel/Cell/DefaultValueBinder.php
+++ b/libraries/PHPExcel/PHPExcel/Cell/DefaultValueBinder.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,31 +22,10 @@
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Cell_IValueBinder */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/IValueBinder.php';
-
-/** PHPExcel_Cell_DataType */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
-
-/** PHPExcel_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-
/**
* PHPExcel_Cell_DefaultValueBinder
*
@@ -72,11 +51,11 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
// Set value explicit
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::dataTypeForValue($value) );
-
+
// Done!
return true;
}
-
+
/**
* DataType for value
*
@@ -94,7 +73,7 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
} elseif ($pValue instanceof PHPExcel_RichText) {
return PHPExcel_Cell_DataType::TYPE_STRING;
- } elseif ($pValue{0} === '=') {
+ } elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
return PHPExcel_Cell_DataType::TYPE_FORMULA;
} elseif (is_bool($pValue)) {
diff --git a/libraries/PHPExcel/PHPExcel/Cell/Hyperlink.php b/libraries/PHPExcel/PHPExcel/Cell/Hyperlink.php
index a4f3758f4..f6af8adab 100644
--- a/libraries/PHPExcel/PHPExcel/Cell/Hyperlink.php
+++ b/libraries/PHPExcel/PHPExcel/Cell/Hyperlink.php
@@ -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__
);
}
diff --git a/libraries/PHPExcel/PHPExcel/Cell/IValueBinder.php b/libraries/PHPExcel/PHPExcel/Cell/IValueBinder.php
index 3a4186ccf..39a9e9321 100644
--- a/libraries/PHPExcel/PHPExcel/Cell/IValueBinder.php
+++ b/libraries/PHPExcel/PHPExcel/Cell/IValueBinder.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,22 +22,10 @@
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-
/**
* PHPExcel_Cell_IValueBinder
*
diff --git a/libraries/PHPExcel/PHPExcel/Comment.php b/libraries/PHPExcel/PHPExcel/Comment.php
index ee7254ac0..97f93da88 100644
--- a/libraries/PHPExcel/PHPExcel/Comment.php
+++ b/libraries/PHPExcel/PHPExcel/Comment.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,28 +22,10 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
-}
-
-/** PHPExcel_RichText */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText.php';
-
-/** PHPExcel_Style_Color */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-
/**
* PHPExcel_Comment
*
@@ -59,59 +41,59 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @var string
*/
private $_author;
-
+
/**
* Rich text comment
*
* @var PHPExcel_RichText
*/
private $_text;
-
+
/**
* Comment width (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_width = '96pt';
-
+
/**
* Left margin (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_marginLeft = '59.25pt';
-
+
/**
* Top margin (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_marginTop = '1.5pt';
-
+
/**
* Visible
*
* @var boolean
*/
private $_visible = false;
-
+
/**
* Comment height (CSS style, i.e. XXpx or YYpt)
*
* @var string
*/
private $_height = '55.5pt';
-
+
/**
* Comment fill color
*
* @var PHPExcel_Style_Color
*/
private $_fillColor;
-
+
/**
* Create a new PHPExcel_Comment
- *
+ *
* @throws Exception
*/
public function __construct()
@@ -121,7 +103,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_text = new PHPExcel_RichText();
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
}
-
+
/**
* Get Author
*
@@ -130,7 +112,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getAuthor() {
return $this->_author;
}
-
+
/**
* Set Author
*
@@ -141,7 +123,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_author = $pValue;
return $this;
}
-
+
/**
* Get Rich text comment
*
@@ -150,7 +132,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getText() {
return $this->_text;
}
-
+
/**
* Set Rich text comment
*
@@ -161,7 +143,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_text = $pValue;
return $this;
}
-
+
/**
* Get comment width (CSS style, i.e. XXpx or YYpt)
*
@@ -170,7 +152,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getWidth() {
return $this->_width;
}
-
+
/**
* Set comment width (CSS style, i.e. XXpx or YYpt)
*
@@ -181,7 +163,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_width = $value;
return $this;
}
-
+
/**
* Get comment height (CSS style, i.e. XXpx or YYpt)
*
@@ -190,7 +172,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getHeight() {
return $this->_height;
}
-
+
/**
* Set comment height (CSS style, i.e. XXpx or YYpt)
*
@@ -201,7 +183,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_height = $value;
return $this;
}
-
+
/**
* Get left margin (CSS style, i.e. XXpx or YYpt)
*
@@ -210,7 +192,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getMarginLeft() {
return $this->_marginLeft;
}
-
+
/**
* Set left margin (CSS style, i.e. XXpx or YYpt)
*
@@ -221,7 +203,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_marginLeft = $value;
return $this;
}
-
+
/**
* Get top margin (CSS style, i.e. XXpx or YYpt)
*
@@ -230,7 +212,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getMarginTop() {
return $this->_marginTop;
}
-
+
/**
* Set top margin (CSS style, i.e. XXpx or YYpt)
*
@@ -241,7 +223,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
$this->_marginTop = $value;
return $this;
}
-
+
/**
* Is the comment visible by default?
*
@@ -250,7 +232,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getVisible() {
return $this->_visible;
}
-
+
/**
* Set comment default visibility
*
@@ -258,10 +240,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable
* @return PHPExcel_Comment
*/
public function setVisible($value = false) {
- $this->_visible = $value;
+ $this->_visible = $value;
return $this;
}
-
+
/**
* Get fill color
*
@@ -270,12 +252,12 @@ class PHPExcel_Comment implements PHPExcel_IComparable
public function getFillColor() {
return $this->_fillColor;
}
-
+
/**
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
return md5(
$this->_author
@@ -289,7 +271,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/DocumentProperties.php b/libraries/PHPExcel/PHPExcel/DocumentProperties.php
index 41fe1fb7d..ee8160c6f 100644
--- a/libraries/PHPExcel/PHPExcel/DocumentProperties.php
+++ b/libraries/PHPExcel/PHPExcel/DocumentProperties.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/DocumentSecurity.php b/libraries/PHPExcel/PHPExcel/DocumentSecurity.php
index 6344d40e3..2c5543866 100644
--- a/libraries/PHPExcel/PHPExcel/DocumentSecurity.php
+++ b/libraries/PHPExcel/PHPExcel/DocumentSecurity.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,22 +22,10 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
-}
-
-/** PHPExcel_Shared_PasswordHasher */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PasswordHasher.php';
-
-
/**
* PHPExcel_DocumentSecurity
*
@@ -53,35 +41,35 @@ class PHPExcel_DocumentSecurity
* @var boolean
*/
private $_lockRevision;
-
+
/**
* LockStructure
*
* @var boolean
*/
private $_lockStructure;
-
+
/**
* LockWindows
*
* @var boolean
*/
private $_lockWindows;
-
+
/**
* RevisionsPassword
*
* @var string
*/
private $_revisionsPassword;
-
+
/**
* WorkbookPassword
*
* @var string
*/
private $_workbookPassword;
-
+
/**
* Create a new PHPExcel_DocumentSecurity
*/
@@ -94,7 +82,7 @@ class PHPExcel_DocumentSecurity
$this->_revisionsPassword = '';
$this->_workbookPassword = '';
}
-
+
/**
* Is some sort of dcument security enabled?
*
@@ -105,7 +93,7 @@ class PHPExcel_DocumentSecurity
$this->_lockStructure ||
$this->_lockWindows;
}
-
+
/**
* Get LockRevision
*
@@ -114,7 +102,7 @@ class PHPExcel_DocumentSecurity
function getLockRevision() {
return $this->_lockRevision;
}
-
+
/**
* Set LockRevision
*
@@ -125,7 +113,7 @@ class PHPExcel_DocumentSecurity
$this->_lockRevision = $pValue;
return $this;
}
-
+
/**
* Get LockStructure
*
@@ -134,7 +122,7 @@ class PHPExcel_DocumentSecurity
function getLockStructure() {
return $this->_lockStructure;
}
-
+
/**
* Set LockStructure
*
@@ -145,7 +133,7 @@ class PHPExcel_DocumentSecurity
$this->_lockStructure = $pValue;
return $this;
}
-
+
/**
* Get LockWindows
*
@@ -154,7 +142,7 @@ class PHPExcel_DocumentSecurity
function getLockWindows() {
return $this->_lockWindows;
}
-
+
/**
* Set LockWindows
*
@@ -165,7 +153,7 @@ class PHPExcel_DocumentSecurity
$this->_lockWindows = $pValue;
return $this;
}
-
+
/**
* Get RevisionsPassword (hashed)
*
@@ -174,7 +162,7 @@ class PHPExcel_DocumentSecurity
function getRevisionsPassword() {
return $this->_revisionsPassword;
}
-
+
/**
* Set RevisionsPassword
*
@@ -189,7 +177,7 @@ class PHPExcel_DocumentSecurity
$this->_revisionsPassword = $pValue;
return $this;
}
-
+
/**
* Get WorkbookPassword (hashed)
*
diff --git a/libraries/PHPExcel/PHPExcel/HashTable.php b/libraries/PHPExcel/PHPExcel/HashTable.php
index afbced953..795d538eb 100644
--- a/libraries/PHPExcel/PHPExcel/HashTable.php
+++ b/libraries/PHPExcel/PHPExcel/HashTable.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,22 +22,10 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
-}
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-
/**
* PHPExcel_HashTable
*
@@ -53,14 +41,14 @@ class PHPExcel_HashTable
* @var array
*/
public $_items = array();
-
+
/**
* HashTable key map
*
* @var array
*/
public $_keyMap = array();
-
+
/**
* Create a new PHPExcel_HashTable
*
@@ -74,7 +62,7 @@ class PHPExcel_HashTable
$this->addFromSource($pSource);
}
}
-
+
/**
* Add HashTable items from source
*
@@ -88,7 +76,7 @@ class PHPExcel_HashTable
} else if (!is_array($pSource)) {
throw new Exception('Invalid array parameter passed.');
}
-
+
foreach ($pSource as $item) {
$this->add($item);
}
@@ -106,7 +94,7 @@ class PHPExcel_HashTable
$this->_keyMap[ count($this->_items) - 1 ] = $pSource->getHashCode();
}
}
-
+
/**
* Remove HashTable item
*
@@ -116,21 +104,21 @@ class PHPExcel_HashTable
public function remove(PHPExcel_IComparable $pSource = null) {
if (isset($this->_items[ $pSource->getHashCode() ])) {
unset($this->_items[ $pSource->getHashCode() ]);
-
+
$deleteKey = -1;
- foreach ($this->_keyMap as $key => $value) {
+ foreach ($this->_keyMap as $key => $value) {
if ($deleteKey >= 0) {
$this->_keyMap[$key - 1] = $value;
}
-
+
if ($value == $pSource->getHashCode()) {
$deleteKey = $key;
}
}
- unset($this->_keyMap[ count($this->_keyMap) - 1 ]);
- }
+ unset($this->_keyMap[ count($this->_keyMap) - 1 ]);
+ }
}
-
+
/**
* Clear HashTable
*
@@ -139,7 +127,7 @@ class PHPExcel_HashTable
$this->_items = array();
$this->_keyMap = array();
}
-
+
/**
* Count
*
@@ -148,7 +136,7 @@ class PHPExcel_HashTable
public function count() {
return count($this->_items);
}
-
+
/**
* Get index for hash code
*
@@ -158,7 +146,7 @@ class PHPExcel_HashTable
public function getIndexForHashCode($pHashCode = '') {
return array_search($pHashCode, $this->_keyMap);
}
-
+
/**
* Get by index
*
@@ -170,10 +158,10 @@ class PHPExcel_HashTable
if (isset($this->_keyMap[$pIndex])) {
return $this->getByHashCode( $this->_keyMap[$pIndex] );
}
-
+
return null;
}
-
+
/**
* Get by hashcode
*
@@ -185,10 +173,10 @@ class PHPExcel_HashTable
if (isset($this->_items[$pHashCode])) {
return $this->_items[$pHashCode];
}
-
+
return null;
}
-
+
/**
* HashTable to array
*
@@ -197,7 +185,7 @@ class PHPExcel_HashTable
public function toArray() {
return $this->_items;
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/IComparable.php b/libraries/PHPExcel/PHPExcel/IComparable.php
index 1a3a689ea..a389325cb 100644
--- a/libraries/PHPExcel/PHPExcel/IComparable.php
+++ b/libraries/PHPExcel/PHPExcel/IComparable.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/IOFactory.php b/libraries/PHPExcel/PHPExcel/IOFactory.php
index f116bc012..7182c073a 100644
--- a/libraries/PHPExcel/PHPExcel/IOFactory.php
+++ b/libraries/PHPExcel/PHPExcel/IOFactory.php
@@ -22,28 +22,25 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
+/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
- * @ignore
+ * @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
+ require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
+ PHPExcel_Autoloader::Register();
+ PHPExcel_Shared_ZipStreamWrapper::register();
+ // check mbstring.func_overload
+ if (ini_get('mbstring.func_overload') & 2) {
+ throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
+ }
}
-/** PHPExcel */
-require_once PHPEXCEL_ROOT . 'PHPExcel.php';
-
-/** PHPExcel_IWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
-
-/** PHPExcel_IReader */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
-
-
/**
* PHPExcel_IOFactory
*
@@ -54,9 +51,11 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
class PHPExcel_IOFactory
{
/**
- * Search locations
+ * Search locations
*
- * @var array
+ * @var array
+ * @access private
+ * @static
*/
private static $_searchLocations = array(
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
@@ -64,9 +63,11 @@ class PHPExcel_IOFactory
);
/**
- * Autoresolve classes
+ * Autoresolve classes
*
- * @var array
+ * @var array
+ * @access private
+ * @static
*/
private static $_autoResolveClasses = array(
'Excel2007',
@@ -79,24 +80,28 @@ class PHPExcel_IOFactory
);
/**
- * Private constructor for PHPExcel_IOFactory
+ * Private constructor for PHPExcel_IOFactory
*/
private function __construct() { }
/**
- * Get search locations
+ * Get search locations
*
- * @return array
+ * @static
+ * @access public
+ * @return array
*/
public static function getSearchLocations() {
return self::$_searchLocations;
- }
+ } // function getSearchLocations()
/**
- * Set search locations
+ * Set search locations
*
- * @param array $value
- * @throws Exception
+ * @static
+ * @access public
+ * @param array $value
+ * @throws Exception
*/
public static function setSearchLocations($value) {
if (is_array($value)) {
@@ -104,25 +109,30 @@ class PHPExcel_IOFactory
} else {
throw new Exception('Invalid parameter passed.');
}
- }
+ } // function setSearchLocations()
/**
- * Add search location
+ * Add search location
*
- * @param string $type Example: IWriter
- * @param string $location Example: PHPExcel/Writer/{0}.php
- * @param string $classname Example: PHPExcel_Writer_{0}
+ * @static
+ * @access public
+ * @param string $type Example: IWriter
+ * @param string $location Example: PHPExcel/Writer/{0}.php
+ * @param string $classname Example: PHPExcel_Writer_{0}
*/
public static function addSearchLocation($type = '', $location = '', $classname = '') {
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
- }
+ } // function addSearchLocation()
/**
- * Create PHPExcel_Writer_IWriter
+ * Create PHPExcel_Writer_IWriter
*
- * @param PHPExcel $phpExcel
- * @param string $writerType Example: Excel2007
- * @return PHPExcel_Writer_IWriter
+ * @static
+ * @access public
+ * @param PHPExcel $phpExcel
+ * @param string $writerType Example: Excel2007
+ * @return PHPExcel_Writer_IWriter
+ * @throws Exception
*/
public static function createWriter(PHPExcel $phpExcel, $writerType = '') {
// Search type
@@ -134,10 +144,6 @@ class PHPExcel_IOFactory
$className = str_replace('{0}', $writerType, $searchLocation['class']);
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
- if (!class_exists($className)) {
- require_once PHPEXCEL_ROOT . $classFile;
- }
-
$instance = new $className($phpExcel);
if (!is_null($instance)) {
return $instance;
@@ -147,13 +153,16 @@ class PHPExcel_IOFactory
// Nothing found...
throw new Exception("No $searchType found for type $writerType");
- }
+ } // function createWriter()
/**
- * Create PHPExcel_Reader_IReader
+ * Create PHPExcel_Reader_IReader
*
- * @param string $readerType Example: Excel2007
- * @return PHPExcel_Reader_IReader
+ * @static
+ * @access public
+ * @param string $readerType Example: Excel2007
+ * @return PHPExcel_Reader_IReader
+ * @throws Exception
*/
public static function createReader($readerType = '') {
// Search type
@@ -165,10 +174,6 @@ class PHPExcel_IOFactory
$className = str_replace('{0}', $readerType, $searchLocation['class']);
$classFile = str_replace('{0}', $readerType, $searchLocation['path']);
- if (!class_exists($className)) {
- require_once PHPEXCEL_ROOT . $classFile;
- }
-
$instance = new $className();
if (!is_null($instance)) {
return $instance;
@@ -178,24 +183,47 @@ class PHPExcel_IOFactory
// Nothing found...
throw new Exception("No $searchType found for type $readerType");
- }
+ } // function createReader()
/**
- * Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
+ * Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
*
- * @param string $pFileName
- * @return PHPExcel
+ * @static
+ * @access public
+ * @param string $pFileName
+ * @return PHPExcel
+ * @throws Exception
*/
public static function load($pFilename) {
$reader = self::createReaderForFile($pFilename);
return $reader->load($pFilename);
- }
+ } // function load()
/**
- * Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
+ * Identify file type using automatic PHPExcel_Reader_IReader resolution
*
- * @param string $pFileName
- * @return PHPExcel_Reader_IReader
+ * @static
+ * @access public
+ * @param string $pFileName
+ * @return string
+ * @throws Exception
+ */
+ public static function identify($pFilename) {
+ $reader = self::createReaderForFile($pFilename);
+ $className = get_class($reader);
+ $classType = explode('_',$className);
+ unset($reader);
+ return array_pop($classType);
+ } // function identify()
+
+ /**
+ * Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
+ *
+ * @static
+ * @access public
+ * @param string $pFileName
+ * @return PHPExcel_Reader_IReader
+ * @throws Exception
*/
public static function createReaderForFile($pFilename) {
@@ -203,41 +231,33 @@ class PHPExcel_IOFactory
$pathinfo = pathinfo($pFilename);
if (isset($pathinfo['extension'])) {
-
switch (strtolower($pathinfo['extension'])) {
case 'xlsx':
$reader = self::createReader('Excel2007');
break;
-
case 'xls':
$reader = self::createReader('Excel5');
break;
-
case 'ods':
$reader = self::createReader('OOCalc');
break;
-
case 'slk':
$reader = self::createReader('SYLK');
break;
-
case 'xml':
$reader = self::createReader('Excel2003XML');
break;
-
case 'csv':
// Do nothing
// We must not try to use CSV reader since it loads
// all files including Excel files etc.
break;
-
default:
break;
-
}
// Let's see if we are lucky
- if ($reader->canRead($pFilename)) {
+ if (isset($reader) && $reader->canRead($pFilename)) {
return $reader;
}
@@ -253,5 +273,5 @@ class PHPExcel_IOFactory
}
}
- }
+ } // function createReaderForFile()
}
diff --git a/libraries/PHPExcel/PHPExcel/NamedRange.php b/libraries/PHPExcel/PHPExcel/NamedRange.php
index 87054a5f8..af5777b1a 100644
--- a/libraries/PHPExcel/PHPExcel/NamedRange.php
+++ b/libraries/PHPExcel/PHPExcel/NamedRange.php
@@ -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) {
diff --git a/libraries/PHPExcel/PHPExcel/Reader/CSV.php b/libraries/PHPExcel/PHPExcel/Reader/CSV.php
index 8758112fb..5ad6760d0 100644
--- a/libraries/PHPExcel/PHPExcel/Reader/CSV.php
+++ b/libraries/PHPExcel/PHPExcel/Reader/CSV.php
@@ -22,7 +22,7 @@
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
@@ -32,24 +32,15 @@ if (!defined('PHPEXCEL_ROOT')) {
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
+ require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
+ PHPExcel_Autoloader::Register();
+ PHPExcel_Shared_ZipStreamWrapper::register();
+ // check mbstring.func_overload
+ if (ini_get('mbstring.func_overload') & 2) {
+ throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
+ }
}
-/** PHPExcel */
-require_once PHPEXCEL_ROOT . 'PHPExcel.php';
-
-/** PHPExcel_Reader_IReader */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
-
-/** PHPExcel_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
- /** PHPExcel_Reader_DefaultReadFilter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
-
-
/**
* PHPExcel_Reader_CSV
*
@@ -60,49 +51,55 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
{
/**
- * Input encoding
+ * Input encoding
*
- * @var string
+ * @access private
+ * @var string
*/
private $_inputEncoding;
/**
- * Delimiter
+ * Delimiter
*
- * @var string
+ * @access private
+ * @var string
*/
private $_delimiter;
/**
- * Enclosure
+ * Enclosure
*
- * @var string
+ * @access private
+ * @var string
*/
private $_enclosure;
/**
- * Line ending
+ * Line ending
*
- * @var string
+ * @access private
+ * @var string
*/
private $_lineEnding;
/**
- * Sheet index to read
+ * Sheet index to read
*
- * @var int
+ * @access private
+ * @var int
*/
private $_sheetIndex;
/**
- * PHPExcel_Reader_IReadFilter instance
+ * PHPExcel_Reader_IReadFilter instance
*
- * @var PHPExcel_Reader_IReadFilter
+ * @access private
+ * @var PHPExcel_Reader_IReadFilter
*/
private $_readFilter = null;
/**
- * Create a new PHPExcel_Reader_CSV
+ * Create a new PHPExcel_Reader_CSV
*/
public function __construct() {
$this->_inputEncoding = 'UTF-8';
@@ -111,15 +108,17 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
$this->_lineEnding = PHP_EOL;
$this->_sheetIndex = 0;
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
- }
-
+ } // function __construct()
+
/**
- * Can the current PHPExcel_Reader_IReader read the file?
+ * Can the current PHPExcel_Reader_IReader read the file?
*
- * @param string $pFileName
- * @return boolean
- */
- public function canRead($pFilename)
+ * @access public
+ * @param string $pFileName
+ * @return boolean
+ * @throws Exception
+ */
+ public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
@@ -127,13 +126,15 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
}
return true;
- }
+ } // function canRead()
/**
- * Loads PHPExcel from file
+ * Loads PHPExcel from file
*
- * @param string $pFilename
- * @throws Exception
+ * @access public
+ * @param string $pFilename
+ * @return PHPExcel
+ * @throws Exception
*/
public function load($pFilename)
{
@@ -142,52 +143,60 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
// Load into this instance
return $this->loadIntoExisting($pFilename, $objPHPExcel);
- }
+ } // function load()
/**
- * Read filter
+ * Read filter
*
- * @return PHPExcel_Reader_IReadFilter
+ * @access public
+ * @return PHPExcel_Reader_IReadFilter
*/
public function getReadFilter() {
return $this->_readFilter;
- }
+ } // function getReadFilter()
/**
- * Set read filter
+ * Set read filter
*
- * @param PHPExcel_Reader_IReadFilter $pValue
+ * @access public
+ * @param PHPExcel_Reader_IReadFilter $pValue
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
$this->_readFilter = $pValue;
- }
+ return $this;
+ } // function setReadFilter()
/**
- * Set input encoding
+ * Set input encoding
*
- * @param string $pValue Input encoding
+ * @access public
+ * @param string $pValue Input encoding
*/
public function setInputEncoding($pValue = 'UTF-8')
{
$this->_inputEncoding = $pValue;
- }
+ return $this;
+ } // function setInputEncoding()
/**
- * Get input encoding
+ * Get input encoding
*
- * @return string
+ * @access public
+ * @return string
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
- }
+ } // function getInputEncoding()
/**
- * Loads PHPExcel from file into PHPExcel instance
+ * Loads PHPExcel from file into PHPExcel instance
*
- * @param string $pFilename
- * @param PHPExcel $objPHPExcel
- * @throws Exception
+ * @access public
+ * @param string $pFilename
+ * @param PHPExcel $objPHPExcel
+ * @return PHPExcel
+ * @throws Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
@@ -214,7 +223,6 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
fgets($fileHandle, 4) == "\xEF\xBB\xBF" ?
fseek($fileHandle, 3) : fseek($fileHandle, 0);
break;
-
default:
break;
}
@@ -231,16 +239,14 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
// Unescape enclosures
$rowData[$i] = str_replace("\\" . $this->_enclosure, $this->_enclosure, $rowData[$i]);
$rowData[$i] = str_replace($this->_enclosure . $this->_enclosure, $this->_enclosure, $rowData[$i]);
-
+
// Convert encoding if necessary
if ($this->_inputEncoding !== 'UTF-8') {
$rowData[$i] = PHPExcel_Shared_String::ConvertEncoding($rowData[$i], 'UTF-8', $this->_inputEncoding);
}
// Set cell value
- $objPHPExcel->getActiveSheet()->setCellValue(
- $columnLetter . $currentRow, $rowData[$i]
- );
+ $objPHPExcel->getActiveSheet()->getCell($columnLetter . $currentRow)->setValue($rowData[$i]);
}
}
}
@@ -250,42 +256,46 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
// Return
return $objPHPExcel;
- }
+ } // function loadIntoExisting()
/**
- * Get delimiter
+ * Get delimiter
*
- * @return string
+ * @access public
+ * @return string
*/
public function getDelimiter() {
return $this->_delimiter;
- }
+ } // function getDelimiter()
/**
- * Set delimiter
+ * Set delimiter
*
- * @param string $pValue Delimiter, defaults to ,
- * @return PHPExcel_Reader_CSV
+ * @access public
+ * @param string $pValue Delimiter, defaults to ,
+ * @return PHPExcel_Reader_CSV
*/
public function setDelimiter($pValue = ',') {
$this->_delimiter = $pValue;
return $this;
- }
+ } // function setDelimiter()
/**
- * Get enclosure
+ * Get enclosure
*
- * @return string
+ * @access public
+ * @return string
*/
public function getEnclosure() {
return $this->_enclosure;
- }
+ } // function getEnclosure()
/**
- * Set enclosure
+ * Set enclosure
*
- * @param string $pValue Enclosure, defaults to "
- * @return PHPExcel_Reader_CSV
+ * @access public
+ * @param string $pValue Enclosure, defaults to "
+ * @return PHPExcel_Reader_CSV
*/
public function setEnclosure($pValue = '"') {
if ($pValue == '') {
@@ -293,45 +303,49 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
}
$this->_enclosure = $pValue;
return $this;
- }
+ } // function setEnclosure()
/**
- * Get line ending
+ * Get line ending
*
- * @return string
+ * @access public
+ * @return string
*/
public function getLineEnding() {
return $this->_lineEnding;
- }
+ } // function getLineEnding()
/**
- * Set line ending
+ * Set line ending
*
- * @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
- * @return PHPExcel_Reader_CSV
+ * @access public
+ * @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
+ * @return PHPExcel_Reader_CSV
*/
public function setLineEnding($pValue = PHP_EOL) {
$this->_lineEnding = $pValue;
return $this;
- }
+ } // function setLineEnding()
/**
- * Get sheet index
+ * Get sheet index
*
- * @return int
+ * @access public
+ * @return int
*/
public function getSheetIndex() {
return $this->_sheetIndex;
- }
+ } // function getSheetIndex()
/**
- * Set sheet index
+ * Set sheet index
*
- * @param int $pValue Sheet index
- * @return PHPExcel_Reader_CSV
+ * @access public
+ * @param int $pValue Sheet index
+ * @return PHPExcel_Reader_CSV
*/
public function setSheetIndex($pValue = 0) {
$this->_sheetIndex = $pValue;
return $this;
- }
+ } // function setSheetIndex()
}
diff --git a/libraries/PHPExcel/PHPExcel/Reader/DefaultReadFilter.php b/libraries/PHPExcel/PHPExcel/Reader/DefaultReadFilter.php
index 63c5ae3cc..bfb6af596 100644
--- a/libraries/PHPExcel/PHPExcel/Reader/DefaultReadFilter.php
+++ b/libraries/PHPExcel/PHPExcel/Reader/DefaultReadFilter.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,7 +22,7 @@
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
@@ -32,12 +32,15 @@ if (!defined('PHPEXCEL_ROOT')) {
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
+ require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
+ PHPExcel_Autoloader::Register();
+ PHPExcel_Shared_ZipStreamWrapper::register();
+ // check mbstring.func_overload
+ if (ini_get('mbstring.func_overload') & 2) {
+ throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
+ }
}
-/** PHPExcel_Reader_IReadFilter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReadFilter.php';
-
-
/**
* PHPExcel_Reader_DefaultReadFilter
*
@@ -54,7 +57,7 @@ class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
* @param $row Row index
* @param $worksheetName Optional worksheet name
* @return boolean
- */
+ */
public function readCell($column, $row, $worksheetName = '') {
return true;
}
diff --git a/libraries/PHPExcel/PHPExcel/Reader/Excel2003XML.php b/libraries/PHPExcel/PHPExcel/Reader/Excel2003XML.php
index 89d5a83c3..ee22d7cbf 100644
--- a/libraries/PHPExcel/PHPExcel/Reader/Excel2003XML.php
+++ b/libraries/PHPExcel/PHPExcel/Reader/Excel2003XML.php
@@ -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 '
';
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]);
}
diff --git a/libraries/PHPExcel/PHPExcel/Reader/Excel2007.php b/libraries/PHPExcel/PHPExcel/Reader/Excel2007.php
index 6cbc89372..6d3922cc1 100644
--- a/libraries/PHPExcel/PHPExcel/Reader/Excel2007.php
+++ b/libraries/PHPExcel/PHPExcel/Reader/Excel2007.php
@@ -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
*
@@ -298,7 +250,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
}
-
+
public function _getFromZipArchive(ZipArchive $archive, $fileName = '')
{
// Root-relative paths
@@ -307,14 +259,14 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$fileName = substr($fileName, strpos($fileName, '//') + 1);
}
$fileName = PHPExcel_Shared_File::realpath($fileName);
-
+
// Apache POI fixes
$contents = $archive->getFromName($fileName);
if ($contents === false)
{
$contents = $archive->getFromName(substr($fileName, 1));
}
-
+
/*
if (strpos($contents, '_readStyle($style, $cellStyles[intval($cellStyle['xfId'])]);
-
+
// normal style, currently not using it for anything
}
}
@@ -498,7 +450,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
$xmlWorkbook = simplexml_load_string($this->_getFromZipArchive($zip, "{$rel['Target']}")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
-
+
// Set base date
if ($xmlWorkbook->workbookPr) {
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900);
@@ -519,66 +471,70 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
{
foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
++$oldSheetId;
-
+
// Check if sheet should be skipped
if (isset($this->_loadSheetsOnly) && !in_array((string) $eleSheet["name"], $this->_loadSheetsOnly)) {
++$countSkippedSheets;
$mapSheetId[$oldSheetId] = null;
continue;
}
-
+
// Map old sheet id in original workbook to new sheet id.
// They will differ if loadSheetsOnly() is being used
$mapSheetId[$oldSheetId] = $oldSheetId - $countSkippedSheets;
-
+
// Load sheet
$docSheet = $excel->createSheet();
$docSheet->setTitle((string) $eleSheet["name"]);
$fileWorksheet = $worksheets[(string) self::array_item($eleSheet->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$xmlSheet = simplexml_load_string($this->_getFromZipArchive($zip, "$dir/$fileWorksheet")); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main");
-
+
$sharedFormulas = array();
-
+
if (isset($eleSheet["state"]) && (string) $eleSheet["state"] != '') {
$docSheet->setSheetState( (string) $eleSheet["state"] );
}
-
+
if (isset($xmlSheet->sheetViews) && isset($xmlSheet->sheetViews->sheetView)) {
if (isset($xmlSheet->sheetViews->sheetView['zoomScale'])) {
$docSheet->getSheetView()->setZoomScale( intval($xmlSheet->sheetViews->sheetView['zoomScale']) );
}
-
+
if (isset($xmlSheet->sheetViews->sheetView['zoomScaleNormal'])) {
$docSheet->getSheetView()->setZoomScaleNormal( intval($xmlSheet->sheetViews->sheetView['zoomScaleNormal']) );
}
-
+
if (isset($xmlSheet->sheetViews->sheetView['showGridLines'])) {
$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);
}
-
+
if (isset($xmlSheet->sheetViews->sheetView->pane)) {
if (isset($xmlSheet->sheetViews->sheetView->pane['topLeftCell'])) {
$docSheet->freezePane( (string)$xmlSheet->sheetViews->sheetView->pane['topLeftCell'] );
} else {
$xSplit = 0;
$ySplit = 0;
-
+
if (isset($xmlSheet->sheetViews->sheetView->pane['xSplit'])) {
$xSplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane['xSplit']);
}
-
+
if (isset($xmlSheet->sheetViews->sheetView->pane['ySplit'])) {
$ySplit = 1 + intval($xmlSheet->sheetViews->sheetView->pane['ySplit']);
}
-
+
$docSheet->freezePaneByColumnAndRow($xSplit, $ySplit);
}
}
-
+
if (isset($xmlSheet->sheetViews->sheetView->selection)) {
if (isset($xmlSheet->sheetViews->sheetView->selection['sqref'])) {
$sqref = (string)$xmlSheet->sheetViews->sheetView->selection['sqref'];
@@ -587,29 +543,29 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docSheet->setSelectedCells($sqref);
}
}
-
+
}
-
+
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->tabColor)) {
if (isset($xmlSheet->sheetPr->tabColor['rgb'])) {
$docSheet->getTabColor()->setARGB( (string)$xmlSheet->sheetPr->tabColor['rgb'] );
}
}
-
+
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && $xmlSheet->sheetPr->outlinePr['summaryRight'] == false) {
$docSheet->setShowSummaryRight(false);
} else {
$docSheet->setShowSummaryRight(true);
}
-
+
if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && $xmlSheet->sheetPr->outlinePr['summaryBelow'] == false) {
$docSheet->setShowSummaryBelow(false);
} else {
$docSheet->setShowSummaryBelow(true);
}
}
-
+
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) {
if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && $xmlSheet->sheetPr->pageSetUpPr['fitToPage'] == false) {
$docSheet->getPageSetup()->setFitToPage(false);
@@ -617,7 +573,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docSheet->getPageSetup()->setFitToPage(true);
}
}
-
+
if (isset($xmlSheet->sheetFormatPr)) {
if (isset($xmlSheet->sheetFormatPr['customHeight']) && ((string)$xmlSheet->sheetFormatPr['customHeight'] == '1' || strtolower((string)$xmlSheet->sheetFormatPr['customHeight']) == 'true') && isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) {
$docSheet->getDefaultRowDimension()->setRowHeight( (float)$xmlSheet->sheetFormatPr['defaultRowHeight'] );
@@ -626,15 +582,15 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docSheet->getDefaultColumnDimension()->setWidth( (float)$xmlSheet->sheetFormatPr['defaultColWidth'] );
}
}
-
+
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);
@@ -646,23 +602,23 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"]));
}
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setWidth(floatval($col["width"]));
-
+
if (intval($col["max"]) == 16384) {
break;
}
}
}
}
-
+
if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) {
if ($xmlSheet->printOptions['gridLinesSet'] == 'true' && $xmlSheet->printOptions['gridLinesSet'] == '1') {
$docSheet->setShowGridlines(true);
}
-
+
if ($xmlSheet->printOptions['gridLines'] == 'true' || $xmlSheet->printOptions['gridLines'] == '1') {
$docSheet->setPrintGridlines(true);
}
-
+
if ($xmlSheet->printOptions['horizontalCentered']) {
$docSheet->getPageSetup()->setHorizontalCentered(true);
}
@@ -670,7 +626,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docSheet->getPageSetup()->setVerticalCentered(true);
}
}
-
+
if ($xmlSheet && $xmlSheet->sheetData && $xmlSheet->sheetData->row) {
foreach ($xmlSheet->sheetData->row as $row) {
if ($row["ht"] && !$this->_readDataOnly) {
@@ -685,25 +641,25 @@ 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"]));
}
-
+
foreach ($row->c as $c) {
$r = (string) $c["r"];
$cellDataType = (string) $c["t"];
$value = null;
$calculatedValue = null;
-
+
// Read cell?
if (!is_null($this->getReadFilter())) {
$coordinates = PHPExcel_Cell::coordinateFromString($r);
-
+
if (!$this->getReadFilter()->readCell($coordinates[0], $coordinates[1], $docSheet->getTitle())) {
continue;
}
}
-
+
// echo 'Reading cell '.$coordinates[0].$coordinates[1].'
';
// print_r($c);
// echo '
';
@@ -715,14 +671,14 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
// echo 'String
';
if ((string)$c->v != '') {
$value = $sharedStrings[intval($c->v)];
-
+
if ($value instanceof PHPExcel_RichText) {
$value = clone $value;
}
} else {
$value = '';
}
-
+
break;
case "b":
// echo 'Boolean
';
@@ -737,7 +693,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
case "inlineStr":
// echo 'Inline String
';
$value = $this->_parseRichText($c->is);
-
+
break;
case "e":
// echo 'Error
';
@@ -748,9 +704,9 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToError');
// echo '$calculatedValue = '.$calculatedValue.'
';
}
-
+
break;
-
+
default:
// echo 'Default
';
if (!isset($c->f)) {
@@ -762,48 +718,44 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToString');
// echo '$calculatedValue = '.$calculatedValue.'
';
}
-
+
break;
}
// echo 'Value is '.$value.'
';
-
+
// Check for numeric values
if (is_numeric($value) && $cellDataType != 's') {
if ($value == (int)$value) $value = (int)$value;
elseif ($value == (float)$value) $value = (float)$value;
elseif ($value == (double)$value) $value = (double)$value;
}
-
+
// Rich text?
if ($value instanceof PHPExcel_RichText && $this->_readDataOnly) {
$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));
- }
}
}
}
-
+
$conditionals = array();
if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->conditionalFormatting) {
foreach ($xmlSheet->conditionalFormatting as $conditional) {
@@ -812,14 +764,15 @@ 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;
}
}
}
-
+
foreach ($conditionals as $ref => $cfRules) {
ksort($cfRules);
$conditionalStyles = array();
@@ -827,11 +780,11 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$objConditional = new PHPExcel_Style_Conditional();
$objConditional->setConditionType((string)$cfRule["type"]);
$objConditional->setOperatorType((string)$cfRule["operator"]);
-
+
if ((string)$cfRule["text"] != '') {
$objConditional->setText((string)$cfRule["text"]);
}
-
+
if (count($cfRule->formula) > 1) {
foreach ($cfRule->formula as $formula) {
$objConditional->addCondition((string)$formula);
@@ -842,7 +795,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$objConditional->setStyle(clone $dxfs[intval($cfRule["dxfId"])]);
$conditionalStyles[] = $objConditional;
}
-
+
// Extract all cell references in $ref
$aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($ref);
foreach ($aReferences as $reference) {
@@ -850,7 +803,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
}
-
+
$aKeys = array("sheet", "objects", "scenarios", "formatCells", "formatColumns", "formatRows", "insertColumns", "insertRows", "insertHyperlinks", "deleteColumns", "deleteRows", "selectLockedCells", "sort", "autoFilter", "pivotTables", "selectUnlockedCells");
if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
foreach ($aKeys as $key) {
@@ -858,7 +811,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docSheet->getProtection()->$method($xmlSheet->sheetProtection[$key] == "true");
}
}
-
+
if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
$docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], true);
if ($xmlSheet->protectedRanges->protectedRange) {
@@ -867,17 +820,17 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
}
-
+
if ($xmlSheet && $xmlSheet->autoFilter && !$this->_readDataOnly) {
$docSheet->setAutoFilter((string) $xmlSheet->autoFilter["ref"]);
}
-
+
if ($xmlSheet && $xmlSheet->mergeCells && $xmlSheet->mergeCells->mergeCell && !$this->_readDataOnly) {
foreach ($xmlSheet->mergeCells->mergeCell as $mergeCell) {
$docSheet->mergeCells((string) $mergeCell["ref"]);
}
}
-
+
if ($xmlSheet && $xmlSheet->pageMargins && !$this->_readDataOnly) {
$docPageMargins = $docSheet->getPageMargins();
$docPageMargins->setLeft(floatval($xmlSheet->pageMargins["left"]));
@@ -887,10 +840,10 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docPageMargins->setHeader(floatval($xmlSheet->pageMargins["header"]));
$docPageMargins->setFooter(floatval($xmlSheet->pageMargins["footer"]));
}
-
+
if ($xmlSheet && $xmlSheet->pageSetup && !$this->_readDataOnly) {
$docPageSetup = $docSheet->getPageSetup();
-
+
if (isset($xmlSheet->pageSetup["orientation"])) {
$docPageSetup->setOrientation((string) $xmlSheet->pageSetup["orientation"]);
}
@@ -911,10 +864,10 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docPageSetup->setFirstPageNumber(intval($xmlSheet->pageSetup["firstPageNumber"]));
}
}
-
+
if ($xmlSheet && $xmlSheet->headerFooter && !$this->_readDataOnly) {
$docHeaderFooter = $docSheet->getHeaderFooter();
-
+
if (isset($xmlSheet->headerFooter["differentOddEven"]) &&
((string)$xmlSheet->headerFooter["differentOddEven"] == 'true' || (string)$xmlSheet->headerFooter["differentOddEven"] == '1')) {
$docHeaderFooter->setDifferentOddEven(true);
@@ -939,7 +892,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
} else {
$docHeaderFooter->setAlignWithMargins(true);
}
-
+
$docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader);
$docHeaderFooter->setOddFooter((string) $xmlSheet->headerFooter->oddFooter);
$docHeaderFooter->setEvenHeader((string) $xmlSheet->headerFooter->evenHeader);
@@ -947,7 +900,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$docHeaderFooter->setFirstHeader((string) $xmlSheet->headerFooter->firstHeader);
$docHeaderFooter->setFirstFooter((string) $xmlSheet->headerFooter->firstFooter);
}
-
+
if ($xmlSheet && $xmlSheet->rowBreaks && $xmlSheet->rowBreaks->brk && !$this->_readDataOnly) {
foreach ($xmlSheet->rowBreaks->brk as $brk) {
if ($brk["man"]) {
@@ -962,34 +915,38 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
}
-
+
if ($xmlSheet && $xmlSheet->dataValidations && !$this->_readDataOnly) {
foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) {
// Uppercase coordinate
$range = strtoupper($dataValidation["sqref"]);
-
- // Extract all cell references in $range
- $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($range);
- foreach ($aReferences as $reference) {
- // Create validation
- $docValidation = $docSheet->getCell($reference)->getDataValidation();
- $docValidation->setType((string) $dataValidation["type"]);
- $docValidation->setErrorStyle((string) $dataValidation["errorStyle"]);
- $docValidation->setOperator((string) $dataValidation["operator"]);
- $docValidation->setAllowBlank($dataValidation["allowBlank"] != 0);
- $docValidation->setShowDropDown($dataValidation["showDropDown"] == 0);
- $docValidation->setShowInputMessage($dataValidation["showInputMessage"] != 0);
- $docValidation->setShowErrorMessage($dataValidation["showErrorMessage"] != 0);
- $docValidation->setErrorTitle((string) $dataValidation["errorTitle"]);
- $docValidation->setError((string) $dataValidation["error"]);
- $docValidation->setPromptTitle((string) $dataValidation["promptTitle"]);
- $docValidation->setPrompt((string) $dataValidation["prompt"]);
- $docValidation->setFormula1((string) $dataValidation->formula1);
- $docValidation->setFormula2((string) $dataValidation->formula2);
+ $rangeSet = explode(' ',$range);
+ foreach($rangeSet as $range) {
+ $stRange = $docSheet->shrinkRangeToFit($range);
+
+ // Extract all cell references in $range
+ $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($stRange);
+ foreach ($aReferences as $reference) {
+ // Create validation
+ $docValidation = $docSheet->getCell($reference)->getDataValidation();
+ $docValidation->setType((string) $dataValidation["type"]);
+ $docValidation->setErrorStyle((string) $dataValidation["errorStyle"]);
+ $docValidation->setOperator((string) $dataValidation["operator"]);
+ $docValidation->setAllowBlank($dataValidation["allowBlank"] != 0);
+ $docValidation->setShowDropDown($dataValidation["showDropDown"] == 0);
+ $docValidation->setShowInputMessage($dataValidation["showInputMessage"] != 0);
+ $docValidation->setShowErrorMessage($dataValidation["showErrorMessage"] != 0);
+ $docValidation->setErrorTitle((string) $dataValidation["errorTitle"]);
+ $docValidation->setError((string) $dataValidation["error"]);
+ $docValidation->setPromptTitle((string) $dataValidation["promptTitle"]);
+ $docValidation->setPrompt((string) $dataValidation["prompt"]);
+ $docValidation->setFormula1((string) $dataValidation->formula1);
+ $docValidation->setFormula2((string) $dataValidation->formula2);
+ }
}
}
}
-
+
// Add hyperlinks
$hyperlinks = array();
if (!$this->_readDataOnly) {
@@ -1002,30 +959,31 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
}
-
+
// Loop through hyperlinks
if ($xmlSheet && $xmlSheet->hyperlinks) {
foreach ($xmlSheet->hyperlinks->hyperlink as $hyperlink) {
// Link url
$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'] );
}
}
}
}
}
-
+
// Add comments
$comments = array();
$vmlComments = array();
@@ -1042,92 +1000,92 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
}
-
+
// Loop through comments
foreach ($comments as $relName => $relPath) {
// Load comments file
$relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath);
$commentsFile = simplexml_load_string($this->_getFromZipArchive($zip, $relPath) );
-
+
// Utility variables
$authors = array();
-
+
// Loop through authors
foreach ($commentsFile->authors->author as $author) {
$authors[] = (string)$author;
}
-
+
// Loop through contents
foreach ($commentsFile->commentList->comment as $comment) {
$docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] );
$docSheet->getComment( (string)$comment['ref'] )->setText( $this->_parseRichText($comment->text) );
}
}
-
+
// Loop through VML comments
foreach ($vmlComments as $relName => $relPath) {
// Load VML comments file
$relPath = PHPExcel_Shared_File::realpath(dirname("$dir/$fileWorksheet") . "/" . $relPath);
$vmlCommentsFile = simplexml_load_string( $this->_getFromZipArchive($zip, $relPath) );
$vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
-
+
$shapes = $vmlCommentsFile->xpath('//v:shape');
foreach ($shapes as $shape) {
$shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
-
+
if (isset($shape['style'])) {
$style = (string)$shape['style'];
$fillColor = strtoupper( substr( (string)$shape['fillcolor'], 1 ) );
$column = null;
$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' ) {
$temp = $clientData->xpath('.//x:Row');
if (is_array($temp)) $row = $temp[0];
-
+
$temp = $clientData->xpath('.//x:Column');
if (is_array($temp)) $column = $temp[0];
}
}
-
+
if (!is_null($column) && !is_null($row)) {
// Set comment properties
$comment = $docSheet->getCommentByColumnAndRow($column, $row + 1);
$comment->getFillColor()->setRGB( $fillColor );
-
+
// Parse style
$styleArray = explode(';', str_replace(' ', '', $style));
foreach ($styleArray as $stylePair) {
$stylePair = explode(':', $stylePair);
-
+
if ($stylePair[0] == 'margin-left') $comment->setMarginLeft($stylePair[1]);
if ($stylePair[0] == 'margin-top') $comment->setMarginTop($stylePair[1]);
if ($stylePair[0] == 'width') $comment->setWidth($stylePair[1]);
if ($stylePair[0] == 'height') $comment->setHeight($stylePair[1]);
if ($stylePair[0] == 'visibility') $comment->setVisible( $stylePair[1] == 'visible' );
-
+
}
}
}
}
}
-
+
// Header/footer images
if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->_readDataOnly) {
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$vmlRelationship = '';
-
+
foreach ($relsWorksheet->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing") {
$vmlRelationship = self::dir_add("$dir/$fileWorksheet", $ele["Target"]);
}
}
-
+
if ($vmlRelationship != '') {
// Fetch linked images
$relsVML = simplexml_load_string($this->_getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels' )); //~ http://schemas.openxmlformats.org/package/2006/relationships");
@@ -1137,27 +1095,27 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$drawings[(string) $ele["Id"]] = self::dir_add($vmlRelationship, $ele["Target"]);
}
}
-
+
// Fetch VML document
$vmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $vmlRelationship));
$vmlDrawing->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
-
+
$hfImages = array();
-
+
$shapes = $vmlDrawing->xpath('//v:shape');
foreach ($shapes as $shape) {
$shape->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml');
$imageData = $shape->xpath('//v:imagedata');
$imageData = $imageData[0];
-
+
$imageData = $imageData->attributes('urn:schemas-microsoft-com:office:office');
$style = self::toCSSArray( (string)$shape['style'] );
-
+
$hfImages[ (string)$shape['id'] ] = new PHPExcel_Worksheet_HeaderFooterDrawing();
if (isset($imageData['title'])) {
$hfImages[ (string)$shape['id'] ]->setName( (string)$imageData['title'] );
}
-
+
$hfImages[ (string)$shape['id'] ]->setPath("zip://$pFilename#" . $drawings[(string)$imageData['relid']], false);
$hfImages[ (string)$shape['id'] ]->setResizeProportional(false);
$hfImages[ (string)$shape['id'] ]->setWidth($style['width']);
@@ -1166,14 +1124,14 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$hfImages[ (string)$shape['id'] ]->setOffsetY($style['margin-top']);
$hfImages[ (string)$shape['id'] ]->setResizeProportional(true);
}
-
+
$docSheet->getHeaderFooter()->setImages($hfImages);
}
}
}
-
+
}
-
+
// TODO: Make sure drawings and graph are loaded differently!
if ($zip->locateName(dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels")) {
$relsWorksheet = simplexml_load_string($this->_getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . "/_rels/" . basename($fileWorksheet) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
@@ -1188,7 +1146,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$fileDrawing = $drawings[(string) self::array_item($drawing->attributes("http://schemas.openxmlformats.org/officeDocument/2006/relationships"), "id")];
$relsDrawing = simplexml_load_string($this->_getFromZipArchive($zip, dirname($fileDrawing) . "/_rels/" . basename($fileDrawing) . ".rels") ); //~ http://schemas.openxmlformats.org/package/2006/relationships");
$images = array();
-
+
if ($relsDrawing && $relsDrawing->Relationship) {
foreach ($relsDrawing->Relationship as $ele) {
if ($ele["Type"] == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image") {
@@ -1197,7 +1155,7 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
$xmlDrawing = simplexml_load_string($this->_getFromZipArchive($zip, $fileDrawing))->children("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
-
+
if ($xmlDrawing->oneCellAnchor) {
foreach ($xmlDrawing->oneCellAnchor as $oneCellAnchor) {
if ($oneCellAnchor->pic->blipFill) {
@@ -1245,10 +1203,10 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$objDrawing->setOffsetX(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff));
$objDrawing->setOffsetY(PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff));
$objDrawing->setResizeProportional(false);
-
+
$objDrawing->setWidth(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cx")));
$objDrawing->setHeight(PHPExcel_Shared_Drawing::EMUToPixels(self::array_item($xfrm->ext->attributes(), "cy")));
-
+
if ($xfrm) {
$objDrawing->setRotation(PHPExcel_Shared_Drawing::angleToDegrees(self::array_item($xfrm->attributes(), "rot")));
}
@@ -1266,11 +1224,11 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
}
}
}
-
+
}
}
}
-
+
// Loop through definedNames
if ($xmlWorkbook->definedNames) {
foreach ($xmlWorkbook->definedNames->definedName as $definedName) {
@@ -1278,94 +1236,119 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
$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'] != '' && (string)$definedName['localSheetId'] == $sheetId) {
// Switch on type
switch ((string)$definedName['name']) {
-
+
case '_xlnm._FilterDatabase':
$docSheet->setAutoFilter($extractedRange);
break;
-
+
case '_xlnm.Print_Titles':
// Split $extractedRange
$extractedRange = explode(',', $extractedRange);
-
+
// Set print titles
- if (isset($extractedRange[0])) {
- $range = explode(':', $extractedRange[0]);
-
- 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 );
+ foreach ($extractedRange as $range) {
+ $matches = array();
+
+ // 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':
$range = explode('!', $extractedRange);
$extractedRange = isset($range[1]) ? $range[1] : $range[0];
-
+
$docSheet->getPageSetup()->setPrintArea($extractedRange);
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 {
- // "Global" definedNames
- $locatedSheet = null;
- $extractedSheetName = '';
- if (strpos( (string)$definedName, '!' ) !== false) {
- // Extract sheet name
- $extractedSheetName = PHPExcel_Worksheet::extractSheetTitle( (string)$definedName, true );
- $extractedSheetName = $extractedSheetName[0];
-
- // Locate sheet
- $locatedSheet = $excel->getSheetByName($extractedSheetName);
-
- // Modify range
- $range = explode('!', $extractedRange);
- $extractedRange = isset($range[1]) ? $range[1] : $range[0];
- }
-
- if (!is_null($locatedSheet)) {
- $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false) );
- }
}
}
}
-
+
// 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 = '';
+ if (strpos( (string)$definedName, '!' ) !== false) {
+ // Extract sheet name
+ $extractedSheetName = PHPExcel_Worksheet::extractSheetTitle( (string)$definedName, true );
+ $extractedSheetName = $extractedSheetName[0];
+
+ // Locate sheet
+ $locatedSheet = $excel->getSheetByName($extractedSheetName);
+
+ // Modify range
+ $range = explode('!', $extractedRange);
+ $extractedRange = isset($range[1]) ? $range[1] : $range[0];
+ }
+
+ if (!is_null($locatedSheet)) {
+ $excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $locatedSheet, $extractedRange, false) );
+ }
+ }
+ }
+ }
}
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) {
- $objText = $value->createTextRun( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) );
+ 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"]);
}
diff --git a/libraries/PHPExcel/PHPExcel/Reader/Excel5.php b/libraries/PHPExcel/PHPExcel/Reader/Excel5.php
index 8509b0801..1002749b9 100644
--- a/libraries/PHPExcel/PHPExcel/Reader/Excel5.php
+++ b/libraries/PHPExcel/PHPExcel/Reader/Excel5.php
@@ -22,7 +22,7 @@
* @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
*/
// Original file header of ParseXL (used as the base for this class):
@@ -63,54 +63,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_Reader_Excel5_Escher */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/Excel5/Escher.php';
-
-/** PHPExcel_Shared_Date */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
-
-/** PHPExcel_Shared_Excel5 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Excel5.php';
-
-/** PHPExcel_Shared_Escher */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher.php';
-
-/** PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php';
-
-/** PHPExcel_Shared_OLERead */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLERead.php';
-
-/** PHPExcel_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_NamedRange */
-require_once PHPEXCEL_ROOT . 'PHPExcel/NamedRange.php';
-
-/** PHPExcel_Reader_IReadFilter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReadFilter.php';
-
-/** PHPExcel_Reader_DefaultReadFilter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
-
-/** PHPExcel_Worksheet_MemoryDrawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/MemoryDrawing.php';
-
-/** PHPExcel_Style_Borders */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Borders.php';
-
-
/**
* PHPExcel_Reader_Excel5
*
@@ -144,6 +105,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
const XLS_Type_NOTE = 0x001c;
const XLS_Type_SELECTION = 0x001d;
const XLS_Type_DATEMODE = 0x0022;
+ const XLS_Type_EXTERNNAME = 0x0023;
const XLS_Type_LEFTMARGIN = 0x0026;
const XLS_Type_RIGHTMARGIN = 0x0027;
const XLS_Type_TOPMARGIN = 0x0028;
@@ -176,8 +138,10 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
const XLS_Type_LABELSST = 0x00fd;
const XLS_Type_EXTSST = 0x00ff;
const XLS_Type_EXTERNALBOOK = 0x01ae;
+ const XLS_Type_DATAVALIDATIONS = 0x01b2;
const XLS_Type_TXO = 0x01b6;
const XLS_Type_HYPERLINK = 0x01b8;
+ const XLS_Type_DATAVALIDATION = 0x01be;
const XLS_Type_DIMENSION = 0x0200;
const XLS_Type_BLANK = 0x0201;
const XLS_Type_NUMBER = 0x0203;
@@ -222,14 +186,14 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
private $_readFilter = null;
/**
- * OLE reader
+ * Summary Information stream data.
*
- * @var PHPExcel_Shared_OLERead
+ * @var string
*/
- private $_ole;
+ private $_summaryInformation;
/**
- * Stream data that is read. Includes workbook globals substream as well as sheet substreams
+ * Workbook stream data. (Includes workbook globals substream as well as sheet substreams)
*
* @var string
*/
@@ -320,6 +284,13 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
*/
private $_ref;
+ /**
+ * External names
+ *
+ * @var array
+ */
+ private $_externalNames;
+
/**
* Defined names
*
@@ -503,10 +474,10 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
try {
// Use ParseXL for the hard work.
- $this->_ole = new PHPExcel_Shared_OLERead();
+ $ole = new PHPExcel_Shared_OLERead();
// get excel data
- $res = $this->_ole->read($pFilename);
+ $res = $ole->read($pFilename);
return true;
} catch (Exception $e) {
@@ -518,10 +489,14 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
* Loads PHPExcel from file
*
* @param string $pFilename
+ * @return PHPExcel
* @throws Exception
*/
public function load($pFilename)
{
+ // Read the OLE file
+ $this->_loadOLE($pFilename);
+
// Initialisations
$this->_phpExcel = new PHPExcel;
$this->_phpExcel->removeSheetByIndex(0); // remove 1st sheet
@@ -530,12 +505,8 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_phpExcel->removeCellXfByIndex(0); // remove the default style
}
- // Use ParseXL for the hard work.
- $this->_ole = new PHPExcel_Shared_OLERead();
-
- // get excel data
- $res = $this->_ole->read($pFilename);
- $this->_data = $this->_ole->getWorkBook();
+ // Read the summary information stream (containing meta data)
+ $this->_readSummaryInformation();
// total byte size of Excel data (workbook global substream + sheet substreams)
$this->_dataSize = strlen($this->_data);
@@ -561,26 +532,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$code = $this->_GetInt2d($this->_data, $this->_pos);
switch ($code) {
- case self::XLS_Type_BOF:
- $pos = $this->_pos;
- $length = $this->_GetInt2d($this->_data, $pos + 2);
- $recordData = substr($this->_data, $pos + 4, $length);
-
- // offset: 0; size: 2; BIFF version
- $this->_version = $this->_GetInt2d($this->_data, $pos + 4);
-
- if (($this->_version != self::XLS_BIFF8) && ($this->_version != self::XLS_BIFF7)) {
- return false;
- }
-
- // offset: 2; size: 2; type of stream
- $substreamType = $this->_GetInt2d($this->_data, $pos + 6);
- if ($substreamType != self::XLS_WorkbookGlobals) {
- return false;
- }
- $this->_pos += 4 + $length;
- break;
-
+ case self::XLS_Type_BOF: $this->_readBof(); break;
case self::XLS_Type_FILEPASS: $this->_readFilepass(); break;
case self::XLS_Type_CODEPAGE: $this->_readCodepage(); break;
case self::XLS_Type_DATEMODE: $this->_readDateMode(); break;
@@ -592,6 +544,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
case self::XLS_Type_PALETTE: $this->_readPalette(); break;
case self::XLS_Type_SHEET: $this->_readSheet(); break;
case self::XLS_Type_EXTERNALBOOK: $this->_readExternalBook(); break;
+ case self::XLS_Type_EXTERNNAME: $this->_readExternName(); break;
case self::XLS_Type_EXTERNSHEET: $this->_readExternSheet(); break;
case self::XLS_Type_DEFINEDNAME: $this->_readDefinedName(); break;
case self::XLS_Type_MSODRAWINGGROUP: $this->_readMsoDrawingGroup(); break;
@@ -673,6 +626,11 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// Parse the individual sheets
foreach ($this->_sheets as $sheet) {
+ if ($sheet['sheetType'] != 0x00) {
+ // 0x00: Worksheet, 0x02: Chart, 0x06: Visual Basic module
+ continue;
+ }
+
// check if sheet should be skipped
if (isset($this->_loadSheetsOnly) && !in_array($sheet['name'], $this->_loadSheetsOnly)) {
continue;
@@ -700,27 +658,11 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// Initialize shared formulas
$this->_sharedFormulas = array();
- while ($this->_pos < $this->_dataSize) {
+ while ($this->_pos <= $this->_dataSize - 4) {
$code = $this->_GetInt2d($this->_data, $this->_pos);
switch ($code) {
- case self::XLS_Type_BOF:
- $length = $this->_GetInt2d($this->_data, $this->_pos + 2);
- $recordData = substr($this->_data, $this->_pos + 4, $length);
-
- // move stream pointer to next record
- $this->_pos += 4 + $length;
-
- // do not use this version information for anything
- // it is unreliable (OpenOffice doc, 5.8), use only version information from the global stream
-
- // offset: 2; size: 2; type of the following data
- $substreamType = $this->_GetInt2d($recordData, 2);
- if ($substreamType != self::XLS_Worksheet) {
- break 2;
- }
- break;
-
+ case self::XLS_Type_BOF: $this->_readBof(); break;
case self::XLS_Type_PRINTGRIDLINES: $this->_readPrintGridlines(); break;
case self::XLS_Type_DEFAULTROWHEIGHT: $this->_readDefaultRowHeight(); break;
case self::XLS_Type_SHEETPR: $this->_readSheetPr(); break;
@@ -762,6 +704,8 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
case self::XLS_Type_SELECTION: $this->_readSelection(); break;
case self::XLS_Type_MERGEDCELLS: $this->_readMergedCells(); break;
case self::XLS_Type_HYPERLINK: $this->_readHyperLink(); break;
+ case self::XLS_Type_DATAVALIDATIONS: $this->_readDataValidations(); break;
+ case self::XLS_Type_DATAVALIDATION: $this->_readDataValidation(); break;
case self::XLS_Type_SHEETLAYOUT: $this->_readSheetLayout(); break;
case self::XLS_Type_SHEETPROTECTION: $this->_readSheetProtection(); break;
case self::XLS_Type_RANGEPROTECTION: $this->_readRangeProtection(); break;
@@ -957,7 +901,11 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$extractedRange = $explodes[1];
$extractedRange = str_replace('$', '', $extractedRange);
- $this->_phpExcel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $docSheet, $extractedRange, false) );
+ $localOnly = ($definedName['scope'] == 0) ? false : true;
+ $scope = ($definedName['scope'] == 0) ?
+ null : $this->_phpExcel->getSheetByName($this->_sheets[$definedName['scope'] - 1]['name']);
+
+ $this->_phpExcel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $docSheet, $extractedRange, $localOnly, $scope) );
}
}
}
@@ -966,6 +914,148 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
return $this->_phpExcel;
}
+ /**
+ * Use OLE reader to extract the relevant data streams from the OLE file
+ *
+ * @param string $pFilename
+ */
+ private function _loadOLE($pFilename)
+ {
+ // OLE reader
+ $ole = new PHPExcel_Shared_OLERead();
+
+ // get excel data
+ $res = $ole->read($pFilename);
+ $this->_data = $ole->getWorkBook();
+
+ // Get summary information data
+ $this->_summaryInformation = $ole->getSummaryInformation();
+ }
+
+ /**
+ * Read summary information
+ */
+ private function _readSummaryInformation()
+ {
+ if (!isset($this->_summaryInformation)) {
+ return;
+ }
+
+ // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
+ // offset: 2; size: 2;
+ // offset: 4; size: 2; OS version
+ // offset: 6; size: 2; OS indicator
+ // offset: 8; size: 16
+ // offset: 24; size: 4; section count
+
+ // offset: 28; size: 16; first section's class id: e0 85 9f f2 f9 4f 68 10 ab 91 08 00 2b 27 b3 d9
+ // offset: 44; size: 4
+
+ // section header
+ // offset: 48; size: 4; section length
+ $secLength = $this->_GetInt4d($this->_summaryInformation, 48);
+
+ // offset: 52; size: 4; property count
+ $countProperties = $this->_GetInt4d($this->_summaryInformation, 52);
+
+ // initialize code page (used to resolve string values)
+ $codePage = 'CP1252';
+
+ // offset: 56; size: var
+ // loop through property decarations and properties
+ for ($i = 0; $i < $countProperties; ++$i) {
+
+ // offset: 56 + 8 * $i; size: 4; property ID
+ $id = $this->_GetInt4d($this->_summaryInformation, 56 + 8 * $i);
+
+ // offset: 60 + 8 * $i; size: 4; offset from beginning of section (48)
+ $offset = $this->_GetInt4d($this->_summaryInformation, 60 + 8 * $i);
+
+ $type = $this->_GetInt4d($this->_summaryInformation, 48 + $offset);
+
+ // initialize property value
+ $value = null;
+
+ // extract property value based on property type
+ switch ($type) {
+ case 0x02: // 2 byte signed integer
+ $value = $this->_GetInt2d($this->_summaryInformation, 52 + $offset);
+ break;
+
+ case 0x03: // 4 byte signed integer
+ $value = $this->_GetInt4d($this->_summaryInformation, 52 + $offset);
+ break;
+
+ case 0x13: // 4 byte unsigned integer
+ // not needed yet, fix later if necessary
+ break;
+
+ case 0x1E: // null-terminated string prepended by dword string length
+ $byteLength = $this->_GetInt4d($this->_summaryInformation, 52 + $offset);
+ $value = substr($this->_summaryInformation, 56 + $offset, $byteLength);
+ $value = PHPExcel_Shared_String::ConvertEncoding($value, 'UTF-8', $codePage);
+ $value = rtrim($value);
+ break;
+
+ case 0x40: // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
+ // PHP-time
+ $value = PHPExcel_Shared_OLE::OLE2LocalDate(substr($this->_summaryInformation, 52 + $offset, 8));
+ break;
+
+ case 0x47: // Clipboard format
+ // not needed yet, fix later if necessary
+ break;
+ }
+
+ // Use value of property id as appropriate
+ switch ($id) {
+ case 0x01: // Code Page
+ $codePage = PHPExcel_Shared_CodePage::NumberToName($value);
+ break;
+
+ case 0x02: // Title
+ $this->_phpExcel->getProperties()->setTitle($value);
+ break;
+
+ case 0x03: // Subject
+ $this->_phpExcel->getProperties()->setSubject($value);
+ break;
+
+ case 0x04: // Author (Creator)
+ $this->_phpExcel->getProperties()->setCreator($value);
+ break;
+
+ case 0x05: // Keywords
+ $this->_phpExcel->getProperties()->setKeywords($value);
+ break;
+
+ case 0x06: // Comments (Description)
+ $this->_phpExcel->getProperties()->setDescription($value);
+ break;
+
+ case 0x08: // Last Saved By (LastModifiedBy)
+ $this->_phpExcel->getProperties()->setLastModifiedBy($value);
+ break;
+
+ case 0x09: // Revision
+ // not supported by PHPExcel
+ break;
+
+ case 0x0C: // Created
+ $this->_phpExcel->getProperties()->setCreated($value);
+ break;
+
+ case 0x0D: // Modified
+ $this->_phpExcel->getProperties()->setModified($value);
+ break;
+
+ case 0x12: // Name of creating application
+ // not supported by PHPExcel
+ break;
+ }
+ }
+ }
+
/**
* Reads a general type of BIFF record. Does nothing except for moving stream pointer forward to next record.
*/
@@ -978,6 +1068,45 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_pos += 4 + $length;
}
+ /**
+ * Read BOF
+ */
+ private function _readBof()
+ {
+ $length = $this->_GetInt2d($this->_data, $this->_pos + 2);
+ $recordData = substr($this->_data, $this->_pos + 4, $length);
+
+ // move stream pointer to next record
+ $this->_pos += 4 + $length;
+
+ // offset: 2; size: 2; type of the following data
+ $substreamType = $this->_GetInt2d($recordData, 2);
+
+ switch ($substreamType) {
+ case self::XLS_WorkbookGlobals:
+ $version = $this->_GetInt2d($recordData, 0);
+ if (($version != self::XLS_BIFF8) && ($version != self::XLS_BIFF7)) {
+ throw new Exception('Cannot read this Excel file. Version is too old.');
+ }
+ $this->_version = $version;
+ break;
+
+ case self::XLS_Worksheet:
+ // do not use this version information for anything
+ // it is unreliable (OpenOffice doc, 5.8), use only version information from the global stream
+ break;
+
+ default:
+ // substream, e.g. chart
+ // just skip the entire substream
+ do {
+ $code = $this->_GetInt2d($this->_data, $this->_pos);
+ $this->_readDefault();
+ } while ($code != self::XLS_Type_EOF && $this->_pos < $this->_dataSize);
+ break;
+ }
+ }
+
/**
* FILEPASS
*
@@ -1020,159 +1149,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 0; size: 2; code page identifier
$codepage = $this->_GetInt2d($recordData, 0);
- switch ($codepage) {
-
- case 367: // ASCII
- $this->_codepage ="ASCII";
- break;
-
- case 437: //OEM US
- $this->_codepage ="CP437";
- break;
-
- case 720: //OEM Arabic
- // currently not supported by libiconv
- $this->_codepage = "";
- break;
-
- case 737: //OEM Greek
- $this->_codepage ="CP737";
- break;
-
- case 775: //OEM Baltic
- $this->_codepage ="CP775";
- break;
-
- case 850: //OEM Latin I
- $this->_codepage ="CP850";
- break;
-
- case 852: //OEM Latin II (Central European)
- $this->_codepage ="CP852";
- break;
-
- case 855: //OEM Cyrillic
- $this->_codepage ="CP855";
- break;
-
- case 857: //OEM Turkish
- $this->_codepage ="CP857";
- break;
-
- case 858: //OEM Multilingual Latin I with Euro
- $this->_codepage ="CP858";
- break;
-
- case 860: //OEM Portugese
- $this->_codepage ="CP860";
- break;
-
- case 861: //OEM Icelandic
- $this->_codepage ="CP861";
- break;
-
- case 862: //OEM Hebrew
- $this->_codepage ="CP862";
- break;
-
- case 863: //OEM Canadian (French)
- $this->_codepage ="CP863";
- break;
-
- case 864: //OEM Arabic
- $this->_codepage ="CP864";
- break;
-
- case 865: //OEM Nordic
- $this->_codepage ="CP865";
- break;
-
- case 866: //OEM Cyrillic (Russian)
- $this->_codepage ="CP866";
- break;
-
- case 869: //OEM Greek (Modern)
- $this->_codepage ="CP869";
- break;
-
- case 874: //ANSI Thai
- $this->_codepage ="CP874";
- break;
-
- case 932: //ANSI Japanese Shift-JIS
- $this->_codepage ="CP932";
- break;
-
- case 936: //ANSI Chinese Simplified GBK
- $this->_codepage ="CP936";
- break;
-
- case 949: //ANSI Korean (Wansung)
- $this->_codepage ="CP949";
- break;
-
- case 950: //ANSI Chinese Traditional BIG5
- $this->_codepage ="CP950";
- break;
-
- case 1200: //UTF-16 (BIFF8)
- $this->_codepage ="UTF-16LE";
- break;
-
- case 1250:// ANSI Latin II (Central European)
- $this->_codepage ="CP1250";
- break;
-
- case 1251: //ANSI Cyrillic
- $this->_codepage ="CP1251";
- break;
-
- case 1252: //ANSI Latin I (BIFF4-BIFF7)
- $this->_codepage ="CP1252";
- break;
-
- case 1253: //ANSI Greek
- $this->_codepage ="CP1253";
- break;
-
- case 1254: //ANSI Turkish
- $this->_codepage ="CP1254";
- break;
-
- case 1255: //ANSI Hebrew
- $this->_codepage ="CP1255";
- break;
-
- case 1256: //ANSI Arabic
- $this->_codepage ="CP1256";
- break;
-
- case 1257: //ANSI Baltic
- $this->_codepage ="CP1257";
- break;
-
- case 1258: //ANSI Vietnamese
- $this->_codepage ="CP1258";
- break;
-
- case 1361: //ANSI Korean (Johab)
- $this->_codepage ="CP1361";
- break;
-
- case 10000: //Apple Roman
- $this->_codepage = 'MAC';
- break;
-
- case 32768: //Apple Roman
- $this->_codepage = 'MAC';
- break;
-
- case 32769: //ANSI Latin I (BIFF2-BIFF3)
- // currently not supported by libiconv
- $this->_codepage = "";
- break;
-
- }
+ $this->_codepage = PHPExcel_Shared_CodePage::NumberToName($codepage);
}
/**
@@ -1633,7 +1610,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 0; size: 2; 0x087D = repeated header
// offset: 2; size: 2
-
+
// offset: 4; size: 8; not used
// offset: 12; size: 2; record version
@@ -1645,19 +1622,19 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 18; size: 2; number of extension properties that follow
$cexts = $this->_GetInt2d($recordData, 18);
-
+
// start reading the actual extension data
$offset = 20;
while ($offset < $length) {
// extension type
$extType = $this->_GetInt2d($recordData, $offset);
-
+
// extension length
$cb = $this->_GetInt2d($recordData, $offset + 2);
-
+
// extension data
$extData = substr($recordData, $offset + 4, $cb);
-
+
switch ($extType) {
case 4: // fill start color
$xclfType = $this->_GetInt2d($extData, 0); // color type
@@ -1793,7 +1770,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
-
+
/**
* Read STYLE record
*/
@@ -1881,7 +1858,6 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$rec_offset = $this->_GetInt4d($recordData, 0);
// offset: 4; size: 1; sheet state
- $rec_typeFlag = ord($recordData{4});
switch (ord($recordData{4})) {
case 0x00: $sheetState = PHPExcel_Worksheet::SHEETSTATE_VISIBLE; break;
case 0x01: $sheetState = PHPExcel_Worksheet::SHEETSTATE_HIDDEN; break;
@@ -1890,7 +1866,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
// offset: 5; size: 1; sheet type
- $rec_visibilityFlag = ord($recordData{5});
+ $sheetType = ord($recordData{5});
// offset: 6; size: var; sheet name
if ($this->_version == self::XLS_BIFF8) {
@@ -1900,10 +1876,12 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$string = $this->_readByteStringShort(substr($recordData, 6));
$rec_name = $string['value'];
}
+
$this->_sheets[] = array(
'name' => $rec_name,
'offset' => $rec_offset,
'sheetState' => $sheetState,
+ 'sheetType' => $sheetType,
);
}
@@ -1954,13 +1932,13 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$this->_externalBooks[] = array(
'type' => 'internal',
);
- } elseif (substr($recordData, 0, 4) == pack('VCC', 0x0001, 0x01, 0x3A)) {
+ } elseif (substr($recordData, 0, 4) == pack('vCC', 0x0001, 0x01, 0x3A)) {
// add-in function
// offset: 0; size: 2; 0x0001
$this->_externalBooks[] = array(
'type' => 'addInFunction',
);
- } elseif (substr($recordData, 0, 2) == pack('V', 0x0000)) {
+ } elseif (substr($recordData, 0, 2) == pack('v', 0x0000)) {
// DDE links, OLE links
// offset: 0; size: 2; 0x0000
// offset: 2; size: var; encoded source document name
@@ -1970,6 +1948,40 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+ /**
+ * Read EXTERNNAME record.
+ */
+ private function _readExternName()
+ {
+ $length = $this->_GetInt2d($this->_data, $this->_pos + 2);
+ $recordData = substr($this->_data, $this->_pos + 4, $length);
+
+ // move stream pointer to next record
+ $this->_pos += 4 + $length;
+
+ // external sheet references provided for named cells
+ if ($this->_version == self::XLS_BIFF8) {
+ // offset: 0; size: 2; options
+ $options = $this->_GetInt2d($recordData, 0);
+
+ // offset: 2; size: 2;
+
+ // offset: 4; size: 2; not used
+
+ // offset: 6; size: var
+ $nameString = $this->_readUnicodeStringShort(substr($recordData, 6));
+
+ // offset: var; size: var; formula data
+ $offset = 6 + $nameString['size'];
+ $formula = $this->_getFormulaFromStructure(substr($recordData, $offset));
+
+ $this->_externalNames[] = array(
+ 'name' => $nameString['value'],
+ 'formula' => $formula,
+ );
+ }
+ }
+
/**
* Read EXTERNSHEET record
*/
@@ -2035,6 +2047,9 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// note: there can also be additional data, this is not included in $flen
$flen = $this->_GetInt2d($recordData, 4);
+ // offset: 8; size: 2; 0=Global name, otherwise index to sheet (1-based)
+ $scope = $this->_GetInt2d($recordData, 8);
+
// offset: 14; size: var; Name (Unicode string without length field)
$string = $this->_readUnicodeString(substr($recordData, 14), $nlen);
@@ -2052,6 +2067,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
'isBuiltInName' => $isBuiltInName,
'name' => $string['value'],
'formula' => $formula,
+ 'scope' => $scope,
);
}
}
@@ -2851,13 +2867,14 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$rknum = $this->_GetInt4d($recordData, 6);
$numValue = $this->_GetIEEE754($rknum);
- // add style information
+ $cell = $this->_phpSheet->getCell($columnString . ($row + 1));
if (!$this->_readDataOnly) {
- $this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
+ // add style information
+ $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
// add cell
- $this->_phpSheet->setCellValueExplicit($columnString . ($row + 1), $numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+ $cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC);
}
}
@@ -2896,17 +2913,17 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// add cell
if (($fmtRuns = $this->_sst[$index]['fmtRuns']) && !$this->_readDataOnly) {
// then we should treat as rich text
- $richText = new PHPExcel_RichText($this->_phpSheet->getCell($columnString . ($row + 1)));
+ $richText = new PHPExcel_RichText();
$charPos = 0;
for ($i = 0; $i <= count($this->_sst[$index]['fmtRuns']); ++$i) {
if (isset($fmtRuns[$i])) {
- $text = mb_substr($this->_sst[$index]['value'], $charPos, $fmtRuns[$i]['charPos'] - $charPos, 'UTF-8');
+ $text = PHPExcel_Shared_String::Substring($this->_sst[$index]['value'], $charPos, $fmtRuns[$i]['charPos'] - $charPos);
$charPos = $fmtRuns[$i]['charPos'];
} else {
- $text = mb_substr($this->_sst[$index]['value'], $charPos, mb_strlen($this->_sst[$index]['value']), 'UTF-8');
+ $text = PHPExcel_Shared_String::Substring($this->_sst[$index]['value'], $charPos, PHPExcel_Shared_String::CountCharacters($this->_sst[$index]['value']));
}
- if (mb_strlen($text) > 0) {
+ if (PHPExcel_Shared_String::CountCharacters($text) > 0) {
if ($i == 0) { // first text run, no style
$richText->createText($text);
} else {
@@ -2924,13 +2941,16 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
}
+ $cell = $this->_phpSheet->getCell($columnString . ($row + 1));
+ $cell->setValueExplicit($richText, PHPExcel_Cell_DataType::TYPE_STRING);
} else {
- $this->_phpSheet->setCellValueExplicit($columnString . ($row + 1), $this->_sst[$index]['value'], PHPExcel_Cell_DataType::TYPE_STRING);
+ $cell = $this->_phpSheet->getCell($columnString . ($row + 1));
+ $cell->setValueExplicit($this->_sst[$index]['value'], PHPExcel_Cell_DataType::TYPE_STRING);
}
- // add style information
if (!$this->_readDataOnly) {
- $this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
+ // add style information
+ $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
}
}
@@ -2975,13 +2995,14 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: var; size: 4; RK value
$numValue = $this->_GetIEEE754($this->_GetInt4d($recordData, $offset + 2));
+ $cell = $this->_phpSheet->getCell($columnString . ($row + 1));
if (!$this->_readDataOnly) {
// add style
- $this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
+ $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
// add cell value
- $this->_phpSheet->setCellValueExplicit($columnString . ($row + 1), $numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+ $cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC);
}
$offset += 6;
@@ -3018,13 +3039,14 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$numValue = $this->_extractNumber(substr($recordData, 6, 8));
- // add cell style
+ $cell = $this->_phpSheet->getCell($columnString . ($row + 1));
if (!$this->_readDataOnly) {
- $this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
+ // add cell style
+ $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
// add cell value
- $this->_phpSheet->setCellValueExplicit($columnString . ($row + 1), $numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+ $cell->setValueExplicit($numValue, PHPExcel_Cell_DataType::TYPE_NUMERIC);
}
}
@@ -3051,33 +3073,35 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$column = $this->_GetInt2d($recordData, 2);
$columnString = PHPExcel_Cell::stringFromColumnIndex($column);
+ // offset: 20: size: variable; formula structure
+ $formulaStructure = substr($recordData, 20);
+
+ // offset: 14: size: 2; option flags, recalculate always, recalculate on open etc.
+ $options = $this->_GetInt2d($recordData, 14);
+
+ // bit: 0; mask: 0x0001; 1 = recalculate always
+ // bit: 1; mask: 0x0002; 1 = calculate on open
+ // bit: 2; mask: 0x0008; 1 = part of a shared formula
+ $isPartOfSharedFormula = (bool) (0x0008 & $options);
+
+ // WARNING:
+ // We can apparently not rely on $isPartOfSharedFormula. Even when $isPartOfSharedFormula = true
+ // the formula data may be ordinary formula data, therefore we need to check
+ // explicitly for the tExp token (0x01)
+ $isPartOfSharedFormula = $isPartOfSharedFormula && ord($formulaStructure{2}) == 0x01;
+
+ if ($isPartOfSharedFormula) {
+ // part of shared formula which means there will be a formula with a tExp token and nothing else
+ // get the base cell, grab tExp token
+ $baseRow = $this->_GetInt2d($formulaStructure, 3);
+ $baseCol = $this->_GetInt2d($formulaStructure, 5);
+ $this->_baseCell = PHPExcel_Cell::stringFromColumnIndex($baseCol). ($baseRow + 1);
+ }
+
// Read cell?
if ( !is_null($this->getReadFilter()) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->_phpSheet->getTitle()) ) {
- // offset: 20: size: variable; formula structure
- $formulaStructure = substr($recordData, 20);
-
- // offset: 14: size: 2; option flags, recalculate always, recalculate on open etc.
- $options = $this->_GetInt2d($recordData, 14);
-
- // bit: 0; mask: 0x0001; 1 = recalculate always
- // bit: 1; mask: 0x0002; 1 = calculate on open
- // bit: 2; mask: 0x0008; 1 = part of a shared formula
- $isPartOfSharedFormula = (bool) (0x0008 & $options);
-
- // WARNING:
- // We can apparently not rely on $isPartOfSharedFormula. Even when $isPartOfSharedFormula = true
- // the formula data may be ordinary formula data, therefore we need to check
- // explicitly for the tExp token (0x01)
- $isPartOfSharedFormula = $isPartOfSharedFormula && ord($formulaStructure{2}) == 0x01;
-
if ($isPartOfSharedFormula) {
- // part of shared formula which means there will be a formula with a tExp token and nothing else
- // get the base cell, grab tExp token
- $baseRow = $this->_GetInt2d($formulaStructure, 3);
- $baseCol = $this->_GetInt2d($formulaStructure, 5);
- $this->_baseCell = PHPExcel_Cell::stringFromColumnIndex($baseCol). ($baseRow + 1);
-
// formula is added to this cell after the sheet has been read
$this->_sharedFormulaParts[$columnString . ($row + 1)] = $this->_baseCell;
}
@@ -3136,9 +3160,10 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
- // add cell style
+ $cell = $this->_phpSheet->getCell($columnString . ($row + 1));
if (!$this->_readDataOnly) {
- $this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
+ // add cell style
+ $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
// store the formula
@@ -3150,21 +3175,21 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
throw new Exception('Not BIFF8. Can only read BIFF8 formulas');
}
$formula = $this->_getFormulaFromStructure($formulaStructure); // get formula in human language
- $this->_phpSheet->getCell($columnString . ($row + 1))->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
+ $cell->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
} catch (Exception $e) {
- $this->_phpSheet->setCellValueExplicit($columnString . ($row + 1), $value, $dataType);
+ $cell->setValueExplicit($value, $dataType);
}
} else {
if ($this->_version == self::XLS_BIFF8) {
// do nothing at this point, formula id added later in the code
} else {
- $this->_phpSheet->setCellValueExplicit($columnString . ($row + 1), $value, $dataType);
+ $cell->setValueExplicit($value, $dataType);
}
}
// store the cached calculated value
- $this->_phpSheet->getCell($columnString . ($row + 1))->setCalculatedValue($value);
+ $cell->setCalculatedValue($value);
}
}
@@ -3258,25 +3283,26 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 7; size: 1; 0=boolean; 1=error
$isError = ord($recordData{7});
+ $cell = $this->_phpSheet->getCell($columnString . ($row + 1));
switch ($isError) {
- case 0: // boolean
- $value = (bool) $boolErr;
+ case 0: // boolean
+ $value = (bool) $boolErr;
- // add cell value
- $this->_phpSheet->getCell($columnString . ($row + 1))->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_BOOL);
- break;
+ // add cell value
+ $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_BOOL);
+ break;
- case 1: // error type
- $value = $this->_mapErrorCode($boolErr);
+ case 1: // error type
+ $value = $this->_mapErrorCode($boolErr);
- // add cell value
- $this->_phpSheet->getCell($columnString . ($row + 1))->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_ERROR);
- break;
+ // add cell value
+ $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_ERROR);
+ break;
}
- // add cell style
if (!$this->_readDataOnly) {
- $this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
+ // add cell style
+ $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
}
}
@@ -3359,11 +3385,12 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$string = $this->_readByteStringLong(substr($recordData, 6));
$value = $string['value'];
}
- $this->_phpSheet->setCellValueExplicit($columnString . ($row + 1), $value, PHPExcel_Cell_DataType::TYPE_STRING);
+ $cell = $this->_phpSheet->getCell($columnString . ($row + 1));
+ $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
- // add cell style
if (!$this->_readDataOnly) {
- $this->_phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
+ // add cell style
+ $cell->setXfIndex($this->_mapCellXfIndex[$xfIndex]);
}
}
}
@@ -3405,10 +3432,10 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
private function _readMsoDrawing()
{
$length = $this->_GetInt2d($this->_data, $this->_pos + 2);
- $recordData = substr($this->_data, $this->_pos + 4, $length);
- // move stream pointer to next record
- $this->_pos += 4 + $length;
+ // get spliced record data
+ $splicedRecordData = $this->_getSplicedRecordData();
+ $recordData = $splicedRecordData['recordData'];
$this->_drawingData .= $recordData;
}
@@ -3459,6 +3486,10 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$showGridlines = (bool) ((0x0002 & $options) >> 1);
$this->_phpSheet->setShowGridlines($showGridlines);
+ // bit: 2; mask: 0x0004; 0 = do not show headers, 1 = show headers
+ $showRowColHeaders = (bool) ((0x0004 & $options) >> 2);
+ $this->_phpSheet->setShowRowColHeaders($showRowColHeaders);
+
// bit: 3; mask: 0x0008; 0 = panes are not frozen, 1 = panes are frozen
$this->_frozen = (bool) ((0x0008 & $options) >> 3);
@@ -3550,7 +3581,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$cellRangeAddressList = $this->_readBIFF5CellRangeAddressList($data); // note: also BIFF8 uses BIFF5 syntax
$selectedCells = $cellRangeAddressList['cellRangeAddresses'][0];
-
+
// first row '1' + last row '16384' indicates that full column is selected (apparently also in BIFF8!)
if (preg_match('/^([A-Z]+1\:[A-Z]+)16384$/', $selectedCells)) {
$selectedCells = preg_replace('/^([A-Z]+1\:[A-Z]+)16384$/', '${1}1048576', $selectedCells);
@@ -3713,16 +3744,16 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: var; size: 4; size of the following file link field including string lenth mark
$sz = $this->_GetInt4d($recordData, $offset);
$offset += 4;
-
+
// only present if $sz > 0
if ($sz > 0) {
// offset: var; size: 4; size of the character array of the extended file path and name
$xl = $this->_GetInt4d($recordData, $offset);
$offset += 4;
-
+
// offset: var; size 2; unknown
$offset += 2;
-
+
// offset: var; size $xl; character array of the extended file path and name.
$extendedFilePath = substr($recordData, $offset, $xl);
$extendedFilePath = $this->_encodeUTF16($extendedFilePath, false);
@@ -3770,6 +3801,177 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
}
+ /**
+ * Read DATAVALIDATIONS record
+ */
+ private function _readDataValidations()
+ {
+ $length = $this->_GetInt2d($this->_data, $this->_pos + 2);
+ $recordData = substr($this->_data, $this->_pos + 4, $length);
+
+ // move stream pointer forward to next record
+ $this->_pos += 4 + $length;
+ }
+
+ /**
+ * Read DATAVALIDATION record
+ */
+ private function _readDataValidation()
+ {
+ $length = $this->_GetInt2d($this->_data, $this->_pos + 2);
+ $recordData = substr($this->_data, $this->_pos + 4, $length);
+
+ // move stream pointer forward to next record
+ $this->_pos += 4 + $length;
+
+ if ($this->_readDataOnly) {
+ return;
+ }
+
+ // offset: 0; size: 4; Options
+ $options = $this->_GetInt4d($recordData, 0);
+
+ // bit: 0-3; mask: 0x0000000F; type
+ $type = (0x0000000F & $options) >> 0;
+ switch ($type) {
+ case 0x00: $type = PHPExcel_Cell_DataValidation::TYPE_NONE; break;
+ case 0x01: $type = PHPExcel_Cell_DataValidation::TYPE_WHOLE; break;
+ case 0x02: $type = PHPExcel_Cell_DataValidation::TYPE_DECIMAL; break;
+ case 0x03: $type = PHPExcel_Cell_DataValidation::TYPE_LIST; break;
+ case 0x04: $type = PHPExcel_Cell_DataValidation::TYPE_DATE; break;
+ case 0x05: $type = PHPExcel_Cell_DataValidation::TYPE_TIME; break;
+ case 0x06: $type = PHPExcel_Cell_DataValidation::TYPE_TEXTLENGTH; break;
+ case 0x07: $type = PHPExcel_Cell_DataValidation::TYPE_CUSTOM; break;
+ }
+
+ // bit: 4-6; mask: 0x00000070; error type
+ $errorStyle = (0x00000070 & $options) >> 4;
+ switch ($errorStyle) {
+ case 0x00: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; break;
+ case 0x01: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_WARNING; break;
+ case 0x02: $errorStyle = PHPExcel_Cell_DataValidation::STYLE_INFORMATION; break;
+ }
+
+ // bit: 7; mask: 0x00000080; 1= formula is explicit (only applies to list)
+ // I have only seen cases where this is 1
+ $explicitFormula = (0x00000080 & $options) >> 7;
+
+ // bit: 8; mask: 0x00000100; 1= empty cells allowed
+ $allowBlank = (0x00000100 & $options) >> 8;
+
+ // bit: 9; mask: 0x00000200; 1= suppress drop down arrow in list type validity
+ $suppressDropDown = (0x00000200 & $options) >> 9;
+
+ // bit: 18; mask: 0x00040000; 1= show prompt box if cell selected
+ $showInputMessage = (0x00040000 & $options) >> 18;
+
+ // bit: 19; mask: 0x00080000; 1= show error box if invalid values entered
+ $showErrorMessage = (0x00080000 & $options) >> 19;
+
+ // bit: 20-23; mask: 0x00F00000; condition operator
+ $operator = (0x00F00000 & $options) >> 20;
+ switch ($operator) {
+ case 0x00: $operator = PHPExcel_Cell_DataValidation::OPERATOR_BETWEEN ; break;
+ case 0x01: $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTBETWEEN ; break;
+ case 0x02: $operator = PHPExcel_Cell_DataValidation::OPERATOR_EQUAL ; break;
+ case 0x03: $operator = PHPExcel_Cell_DataValidation::OPERATOR_NOTEQUAL ; break;
+ case 0x04: $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHAN ; break;
+ case 0x05: $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHAN ; break;
+ case 0x06: $operator = PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHANOREQUAL; break;
+ case 0x07: $operator = PHPExcel_Cell_DataValidation::OPERATOR_LESSTHANOREQUAL ; break;
+ }
+
+ // offset: 4; size: var; title of the prompt box
+ $offset = 4;
+ $string = $this->_readUnicodeStringLong(substr($recordData, $offset));
+ $promptTitle = $string['value'] !== chr(0) ?
+ $string['value'] : '';
+ $offset += $string['size'];
+
+ // offset: var; size: var; title of the error box
+ $string = $this->_readUnicodeStringLong(substr($recordData, $offset));
+ $errorTitle = $string['value'] !== chr(0) ?
+ $string['value'] : '';
+ $offset += $string['size'];
+
+ // offset: var; size: var; text of the prompt box
+ $string = $this->_readUnicodeStringLong(substr($recordData, $offset));
+ $prompt = $string['value'] !== chr(0) ?
+ $string['value'] : '';
+ $offset += $string['size'];
+
+ // offset: var; size: var; text of the error box
+ $string = $this->_readUnicodeStringLong(substr($recordData, $offset));
+ $error = $string['value'] !== chr(0) ?
+ $string['value'] : '';
+ $offset += $string['size'];
+
+ // offset: var; size: 2; size of the formula data for the first condition
+ $sz1 = $this->_GetInt2d($recordData, $offset);
+ $offset += 2;
+
+ // offset: var; size: 2; not used
+ $offset += 2;
+
+ // offset: var; size: $sz1; formula data for first condition (without size field)
+ $formula1 = substr($recordData, $offset, $sz1);
+ $formula1 = pack('v', $sz1) . $formula1; // prepend the length
+ try {
+ $formula1 = $this->_getFormulaFromStructure($formula1);
+
+ // in list type validity, null characters are used as item separators
+ if ($type == PHPExcel_Cell_DataValidation::TYPE_LIST) {
+ $formula1 = str_replace(chr(0), ',', $formula1);
+ }
+ } catch (Exception $e) {
+ return;
+ }
+ $offset += $sz1;
+
+ // offset: var; size: 2; size of the formula data for the first condition
+ $sz2 = $this->_GetInt2d($recordData, $offset);
+ $offset += 2;
+
+ // offset: var; size: 2; not used
+ $offset += 2;
+
+ // offset: var; size: $sz2; formula data for second condition (without size field)
+ $formula2 = substr($recordData, $offset, $sz2);
+ $formula2 = pack('v', $sz2) . $formula2; // prepend the length
+ try {
+ $formula2 = $this->_getFormulaFromStructure($formula2);
+ } catch (Exception $e) {
+ return;
+ }
+ $offset += $sz2;
+
+ // offset: var; size: var; cell range address list with
+ $cellRangeAddressList = $this->_readBIFF8CellRangeAddressList(substr($recordData, $offset));
+ $cellRangeAddresses = $cellRangeAddressList['cellRangeAddresses'];
+
+ foreach ($cellRangeAddresses as $cellRange) {
+ $stRange = $this->_phpSheet->shrinkRangeToFit($cellRange);
+ $stRange = PHPExcel_Cell::extractAllCellReferencesInRange($stRange);
+ foreach ($stRange as $coordinate) {
+ $objValidation = $this->_phpSheet->getCell($coordinate)->getDataValidation();
+ $objValidation->setType($type);
+ $objValidation->setErrorStyle($errorStyle);
+ $objValidation->setAllowBlank((bool)$allowBlank);
+ $objValidation->setShowInputMessage((bool)$showInputMessage);
+ $objValidation->setShowErrorMessage((bool)$showErrorMessage);
+ $objValidation->setShowDropDown(!$suppressDropDown);
+ $objValidation->setOperator($operator);
+ $objValidation->setErrorTitle($errorTitle);
+ $objValidation->setError($error);
+ $objValidation->setPromptTitle($promptTitle);
+ $objValidation->setPrompt($prompt);
+ $objValidation->setFormula1($formula1);
+ $objValidation->setFormula2($formula2);
+ }
+ }
+
+ }
+
/**
* Read SHEETLAYOUT record. Stores sheet tab color information.
*/
@@ -3810,7 +4012,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
}
/**
- * Read SHEETPROTECTION record
+ * Read SHEETPROTECTION record (FEATHEADR)
*/
private function _readSheetProtection()
{
@@ -3826,10 +4028,21 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 0; size: 2; repeated record header
- // offset: 2; size: 9; not used
+ // offset: 2; size: 2; FRT cell reference flag (=0 currently)
- // offset: 11; size: 8; unknown data
+ // offset: 4; size: 8; Currently not used and set to 0
+ // offset: 12; size: 2; Shared feature type index (2=Enhanced Protetion, 4=SmartTag)
+ $isf = $this->_GetInt2d($recordData, 12);
+ if ($isf != 2) {
+ return;
+ }
+
+ // offset: 14; size: 1; =1 since this is a feat header
+
+ // offset: 15; size: 4; size of rgbHdrSData
+
+ // rgbHdrSData, assume "Enhanced Protection"
// offset: 19; size: 2; option flags
$options = $this->_GetInt2d($recordData, 19);
@@ -3895,7 +4108,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 21; size: 2; not used
}
-
+
/**
* Read RANGEPROTECTION record
* Reading of this record is based on Microsoft Office Excel 97-2000 Binary File Format Specification,
@@ -4048,17 +4261,20 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$length = $this->_GetInt2d($this->_data, $this->_pos + 2);
$recordData = substr($this->_data, $this->_pos + 4, $length);
- // move stream pointer to next record
- $this->_pos += 4 + $length;
-
// check if we are reading drawing data
// this is in case a free CONTINUE record occurs in other circumstances we are unaware of
if ($this->_drawingData == '') {
+ // move stream pointer to next record
+ $this->_pos += 4 + $length;
+
return;
}
// check if record data is at least 4 bytes long, otherwise there is no chance this is MSODRAWING data
- if (strlen($recordData) < 4) {
+ if ($length < 4) {
+ // move stream pointer to next record
+ $this->_pos += 4 + $length;
+
return;
}
@@ -4072,8 +4288,16 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$splitPoint = $this->_GetInt2d($recordData, 2);
if (in_array($splitPoint, $validSplitPoints)) {
- $this->_drawingData .= $recordData;
+ // get spliced record data (and move pointer to next record)
+ $splicedRecordData = $this->_getSplicedRecordData();
+ $this->_drawingData .= $splicedRecordData['recordData'];
+
+ return;
}
+
+ // move stream pointer to next record
+ $this->_pos += 4 + $length;
+
}
@@ -4276,13 +4500,26 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
break;
case 'tFunc': // function with fixed number of arguments
case 'tFuncV': // function with variable number of arguments
- $ops = array(); // array of operators
- for ($i = 0; $i < $token['data']['args']; ++$i) {
- $ops[] = array_pop($formulaStrings);
+ if ($token['data']['function'] != '') {
+ // normal function
+ $ops = array(); // array of operators
+ for ($i = 0; $i < $token['data']['args']; ++$i) {
+ $ops[] = array_pop($formulaStrings);
+ }
+ $ops = array_reverse($ops);
+ $formulaStrings[] = "$space1$space0{$token['data']['function']}(" . implode(',', $ops) . ")";
+ unset($space0, $space1);
+ } else {
+ // add-in function
+ $ops = array(); // array of operators
+ for ($i = 0; $i < $token['data']['args'] - 1; ++$i) {
+ $ops[] = array_pop($formulaStrings);
+ }
+ $ops = array_reverse($ops);
+ $function = array_pop($formulaStrings);
+ $formulaStrings[] = "$space1$space0$function(" . implode(',', $ops) . ")";
+ unset($space0, $space1);
}
- $ops = array_reverse($ops);
- $formulaStrings[] = "$space1$space0{$token['data']['function']}(" . implode(',', $ops) . ")";
- unset($space0, $space1);
break;
case 'tParen': // parenthesis
$expression = array_pop($formulaStrings);
@@ -4310,6 +4547,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
case 'tMemFunc':
case 'tMissArg':
case 'tName':
+ case 'tNameX':
case 'tNum': // number
case 'tRef': // single cell reference
case 'tRef3d': // 3d cell reference
@@ -4661,7 +4899,8 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 1; size: 1; number of arguments
$args = ord($formulaData[1]);
// offset: 2: size: 2; index to built-in sheet function
- switch ($this->_GetInt2d($formulaData, 2)) {
+ $index = $this->_GetInt2d($formulaData, 2);
+ switch ($index) {
case 0: $function = 'COUNT'; break;
case 1: $function = 'IF'; break;
case 4: $function = 'SUM'; break;
@@ -4723,6 +4962,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
case 227: $function = 'MEDIAN'; break;
case 228: $function = 'SUMPRODUCT'; break;
case 247: $function = 'DB'; break;
+ case 255: $function = ''; break;
case 269: $function = 'AVEDEV'; break;
case 270: $function = 'BETADIST'; break;
case 272: $function = 'BETAINV'; break;
@@ -4803,7 +5043,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$size = 3 + $subSize;
$data = $this->_getFormulaFromData(substr($formulaData, 3, $subSize));
break;
-
+
case 0x2C: // Relative reference, used in shared formulas and some other places
case 0x4C:
case 0x6C:
@@ -4811,7 +5051,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$size = 5;
$data = $this->_readBIFF8CellAddressB(substr($formulaData, 1, 4), $baseCell);
break;
-
+
case 0x2D:
case 0x4D:
case 0x6D:
@@ -4820,28 +5060,56 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$data = $this->_readBIFF8CellRangeAddressB(substr($formulaData, 1, 8), $baseCell);
break;
+ case 0x39:
+ case 0x59:
+ case 0x79:
+ $name = 'tNameX';
+ $size = 7;
+ // offset: 1; size: 2; index to REF entry in EXTERNSHEET record
+ // offset: 3; size: 2; one-based index to DEFINEDNAME or EXTERNNAME record
+ $index = $this->_GetInt2d($formulaData, 3);
+ // assume index is to EXTERNNAME record
+ $data = $this->_externalNames[$index - 1]['name'];
+ // offset: 5; size: 2; not used
+ break;
+
case 0x3A: // 3d reference to cell
case 0x5A:
$name = 'tRef3d';
$size = 7;
- // offset: 1; size: 2; index to REF entry
- $sheetRange = $this->_readSheetRangeByRefIndex($this->_GetInt2d($formulaData, 1));
- // offset: 3; size: 4; cell address
- $cellAddress = $this->_readBIFF8CellAddress(substr($formulaData, 3, 4));
- $data = "$sheetRange!$cellAddress";
+ try {
+ // offset: 1; size: 2; index to REF entry
+ $sheetRange = $this->_readSheetRangeByRefIndex($this->_GetInt2d($formulaData, 1));
+ // offset: 3; size: 4; cell address
+ $cellAddress = $this->_readBIFF8CellAddress(substr($formulaData, 3, 4));
+
+ $data = "$sheetRange!$cellAddress";
+
+ } catch (Exception $e) {
+ // deleted sheet reference
+ $data = '#REF!';
+ }
break;
case 0x3B: // 3d reference to cell range
case 0x5B:
$name = 'tArea3d';
$size = 11;
- // offset: 1; size: 2; index to REF entry
- $sheetRange = $this->_readSheetRangeByRefIndex($this->_GetInt2d($formulaData, 1));
- // offset: 3; size: 8; cell address
- $cellRangeAddress = $this->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8));
- $data = "$sheetRange!$cellRangeAddress";
+ try {
+ // offset: 1; size: 2; index to REF entry
+ $sheetRange = $this->_readSheetRangeByRefIndex($this->_GetInt2d($formulaData, 1));
+ // offset: 3; size: 8; cell address
+ $cellRangeAddress = $this->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8));
+
+ $data = "$sheetRange!$cellRangeAddress";
+
+ } catch (Exception $e) {
+ // deleted sheet reference
+ $data = '#REF!';
+
+ }
break;
// case 0x39: // don't know how to deal with
@@ -4900,7 +5168,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
{
list($baseCol, $baseRow) = PHPExcel_Cell::coordinateFromString($baseCell);
$baseCol = PHPExcel_Cell::columnIndexFromString($baseCol) - 1;
-
+
// offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767))
$rowIndex = $this->_GetInt2d($cellAddressStructure, 0);
$row = $this->_GetInt2d($cellAddressStructure, 0) + 1;
@@ -5209,7 +5477,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
if (isset($this->_ref[$index])) {
$type = $this->_externalBooks[$this->_ref[$index]['externalBookIndex']]['type'];
-
+
switch ($type) {
case 'internal':
// check if we have a deleted 3d reference
diff --git a/libraries/PHPExcel/PHPExcel/Reader/Excel5/Escher.php b/libraries/PHPExcel/PHPExcel/Reader/Excel5/Escher.php
index fd9f138ed..e0a975e22 100644
--- a/libraries/PHPExcel/PHPExcel/Reader/Excel5/Escher.php
+++ b/libraries/PHPExcel/PHPExcel/Reader/Excel5/Escher.php
@@ -22,41 +22,9 @@
* @package PHPExcel_Reader_Excel5
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
-}
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Shared_Escher_DggContainer */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer.php';
-
-/** PHPExcel_Shared_Escher_DggContainer_BstoreContainer */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php';
-
-/** PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php';
-
-/** PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php';
-
-/** PHPExcel_Shared_Escher_DgContainer */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DgContainer.php';
-
-/** PHPExcel_Shared_Escher_DgContainer_SpgrContainer */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php';
-
-/** PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php';
-
/**
* PHPExcel_Reader_Excel5_Escher
*
@@ -122,7 +90,7 @@ class PHPExcel_Reader_Excel5_Escher
{
$this->_object = $object;
}
-
+
/**
* Load Escher stream data. May be a partial Escher stream.
*
@@ -136,14 +104,14 @@ class PHPExcel_Reader_Excel5_Escher
$this->_dataSize = strlen($this->_data);
$this->_pos = 0;
-
+
// Parse Escher stream
while ($this->_pos < $this->_dataSize) {
-
-
+
+
// offset: 2; size: 2: Record Type
$fbt = $this->_GetInt2d($this->_data, $this->_pos + 2);
-
+
switch ($fbt) {
case self::DGGCONTAINER: $this->_readDggContainer(); break;
case self::DGG: $this->_readDgg(); break;
@@ -166,7 +134,7 @@ class PHPExcel_Reader_Excel5_Escher
default: $this->_readDefault(); break;
}
}
-
+
return $this->_object;
}
@@ -177,16 +145,16 @@ class PHPExcel_Reader_Excel5_Escher
{
// offset 0; size: 2; recVer and recInstance
$verInstance = $this->_GetInt2d($this->_data, $this->_pos);
-
+
// offset: 2; size: 2: Record Type
$fbt = $this->_GetInt2d($this->_data, $this->_pos + 2);
// bit: 0-3; mask: 0x000F; recVer
$recVer = (0x000F & $verInstance) >> 0;
-
+
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
-
+
// move stream pointer to next record
$this->_pos += 8 + $length;
}
@@ -216,7 +184,7 @@ class PHPExcel_Reader_Excel5_Escher
{
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
-
+
// move stream pointer to next record
$this->_pos += 8 + $length;
}
@@ -245,22 +213,22 @@ class PHPExcel_Reader_Excel5_Escher
private function _readBSE()
{
// offset: 0; size: 2; recVer and recInstance
-
+
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
-
+
// move stream pointer to next record
$this->_pos += 8 + $length;
-
+
// add BSE to BstoreContainer
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
$this->_object->addBSE($BSE);
$BSE->setBLIPType($recInstance);
-
+
// offset: 0; size: 1; btWin32 (MSOBLIPTYPE)
$btWin32 = ord($recordData[0]);
@@ -311,38 +279,38 @@ class PHPExcel_Reader_Excel5_Escher
private function _readBlipJPEG()
{
// offset: 0; size: 2; recVer and recInstance
-
+
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
-
+
// move stream pointer to next record
$this->_pos += 8 + $length;
-
+
$pos = 0;
-
+
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
$rgbUid1 = substr($recordData, 0, 16);
$pos += 16;
-
+
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
if (in_array($recInstance, array(0x046B, 0x06E3))) {
$rgbUid2 = substr($recordData, 16, 16);
$pos += 16;
}
-
+
// offset: var; size: 1; tag
$tag = ord($recordData{$pos});
$pos += 1;
-
+
// offset: var; size: var; the raw image data
$data = substr($recordData, $pos);
-
+
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($data);
-
+
$this->_object->setBlip($blip);
}
@@ -352,38 +320,38 @@ class PHPExcel_Reader_Excel5_Escher
private function _readBlipPNG()
{
// offset: 0; size: 2; recVer and recInstance
-
+
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
-
+
// move stream pointer to next record
$this->_pos += 8 + $length;
-
+
$pos = 0;
-
+
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
$rgbUid1 = substr($recordData, 0, 16);
$pos += 16;
-
+
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
if ($recInstance == 0x06E1) {
$rgbUid2 = substr($recordData, 16, 16);
$pos += 16;
}
-
+
// offset: var; size: 1; tag
$tag = ord($recordData{$pos});
$pos += 1;
-
+
// offset: var; size: var; the raw image data
$data = substr($recordData, $pos);
-
+
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
$blip->setData($data);
-
+
$this->_object->setBlip($blip);
}
@@ -393,13 +361,13 @@ class PHPExcel_Reader_Excel5_Escher
private function _readOPT()
{
// offset: 0; size: 2; recVer and recInstance
-
+
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
-
+
// move stream pointer to next record
$this->_pos += 8 + $length;
@@ -412,7 +380,7 @@ class PHPExcel_Reader_Excel5_Escher
private function _readTertiaryOPT()
{
// offset: 0; size: 2; recVer and recInstance
-
+
// bit: 4-15; mask: 0xFFF0; recInstance
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
@@ -566,10 +534,10 @@ class PHPExcel_Reader_Excel5_Escher
{
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
$recordData = substr($this->_data, $this->_pos + 8, $length);
-
+
// move stream pointer to next record
$this->_pos += 8 + $length;
-
+
// offset: 2; size: 2; upper-left corner column index (0-based)
$c1 = $this->_GetInt2d($recordData, 2);
diff --git a/libraries/PHPExcel/PHPExcel/Reader/IReadFilter.php b/libraries/PHPExcel/PHPExcel/Reader/IReadFilter.php
index c81297176..6d8ee6d92 100644
--- a/libraries/PHPExcel/PHPExcel/Reader/IReadFilter.php
+++ b/libraries/PHPExcel/PHPExcel/Reader/IReadFilter.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Reader/IReader.php b/libraries/PHPExcel/PHPExcel/Reader/IReader.php
index 52e0c2e89..e1a5b9865 100644
--- a/libraries/PHPExcel/PHPExcel/Reader/IReader.php
+++ b/libraries/PHPExcel/PHPExcel/Reader/IReader.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Reader/OOCalc.php b/libraries/PHPExcel/PHPExcel/Reader/OOCalc.php
index 618a1f2d4..38f9eaea1 100644
--- a/libraries/PHPExcel/PHPExcel/Reader/OOCalc.php
+++ b/libraries/PHPExcel/PHPExcel/Reader/OOCalc.php
@@ -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);
diff --git a/libraries/PHPExcel/PHPExcel/Reader/SYLK.php b/libraries/PHPExcel/PHPExcel/Reader/SYLK.php
index a9bd64717..d93cb379c 100644
--- a/libraries/PHPExcel/PHPExcel/Reader/SYLK.php
+++ b/libraries/PHPExcel/PHPExcel/Reader/SYLK.php
@@ -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('¤',';',str_replace(';',"\t",str_replace(';;','¤',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;
}
+
}
diff --git a/libraries/PHPExcel/PHPExcel/Reader/Serialized.php b/libraries/PHPExcel/PHPExcel/Reader/Serialized.php
index 120a6781c..fd4df9f64 100644
--- a/libraries/PHPExcel/PHPExcel/Reader/Serialized.php
+++ b/libraries/PHPExcel/PHPExcel/Reader/Serialized.php
@@ -22,7 +22,7 @@
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
@@ -32,18 +32,15 @@ if (!defined('PHPEXCEL_ROOT')) {
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
+ require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
+ PHPExcel_Autoloader::Register();
+ PHPExcel_Shared_ZipStreamWrapper::register();
+ // check mbstring.func_overload
+ if (ini_get('mbstring.func_overload') & 2) {
+ throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
+ }
}
-/** PHPExcel */
-require_once PHPEXCEL_ROOT . 'PHPExcel.php';
-
-/** PHPExcel_Reader_IReader */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
-
-/** PHPExcel_Shared_File */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/File.php';
-
-
/**
* PHPExcel_Reader_Serialized
*
@@ -58,17 +55,17 @@ class PHPExcel_Reader_Serialized implements PHPExcel_Reader_IReader
*
* @param string $pFileName
* @return boolean
- */
- public function canRead($pFilename)
+ */
+ public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
-
+
return $this->fileSupportsUnserializePHPExcel($pFilename);
}
-
+
/**
* Loads PHPExcel Serialized file
*
diff --git a/libraries/PHPExcel/PHPExcel/ReferenceHelper.php b/libraries/PHPExcel/PHPExcel/ReferenceHelper.php
index 175bba122..da288c5d0 100644
--- a/libraries/PHPExcel/PHPExcel/ReferenceHelper.php
+++ b/libraries/PHPExcel/PHPExcel/ReferenceHelper.php
@@ -22,40 +22,10 @@
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
-}
-
-/** PHPExcel_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Cell_DataType */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
-
-/** PHPExcel_Style */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style.php';
-
-/** PHPExcel_Worksheet_Drawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing.php';
-
-/** PHPExcel_Calculation_FormulaParser */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/FormulaParser.php';
-
-/** PHPExcel_Calculation_FormulaToken */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/FormulaToken.php';
-
-
/**
* PHPExcel_ReferenceHelper (Singleton)
*
@@ -100,12 +70,6 @@ class PHPExcel_ReferenceHelper
* @throws Exception
*/
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null) {
- // Get a copy of the cell collection
- /*$aTemp = $pSheet->getCellCollection();
- $aCellCollection = array();
- foreach ($aTemp as $key => $value) {
- $aCellCollection[$key] = clone $value;
- }*/
$aCellCollection = $pSheet->getCellCollection();
// Get coordinates of $pBefore
@@ -148,7 +112,9 @@ class PHPExcel_ReferenceHelper
// Loop through cells, bottom-up, and change cell coordinates
- while ( ($cell = ($pNumCols < 0 || $pNumRows < 0) ? array_shift($aCellCollection) : array_pop($aCellCollection)) ) {
+ while (($cellID = ($pNumCols < 0 || $pNumRows < 0) ? array_shift($aCellCollection) : array_pop($aCellCollection))) {
+ $cell = $pSheet->getCell($cellID);
+
// New coordinates
$newCoordinates = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1 + $pNumCols ) . ($cell->getRow() + $pNumRows);
@@ -165,17 +131,15 @@ class PHPExcel_ReferenceHelper
// Insert this cell at its new location
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
// Formula should be adjusted
- $pSheet->setCellValue(
- $newCoordinates
- , $this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows)
- );
+ $pSheet->getCell($newCoordinates)
+ ->setValue($this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows));
} else {
// Formula should not be adjusted
- $pSheet->setCellValue($newCoordinates, $cell->getValue());
+ $pSheet->getCell($newCoordinates)->setValue($cell->getValue());
}
// Clear the original cell
- $pSheet->setCellValue($cell->getCoordinate(), '');
+ $pSheet->getCell($cell->getCoordinate())->setValue('');
}
}
@@ -459,9 +423,10 @@ class PHPExcel_ReferenceHelper
if ($oldName == '') {
return;
}
-
+
foreach ($pPhpExcel->getWorksheetIterator() as $sheet) {
- foreach ($sheet->getCellCollection(false) as $cell) {
+ foreach ($sheet->getCellCollection(false) as $cellID) {
+ $cell = $sheet->getCell($cellID);
if (!is_null($cell) && $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
$formula = $cell->getValue();
if (strpos($formula, $oldName) !== false) {
diff --git a/libraries/PHPExcel/PHPExcel/RichText.php b/libraries/PHPExcel/PHPExcel/RichText.php
index aca7796ea..cd43573f8 100644
--- a/libraries/PHPExcel/PHPExcel/RichText.php
+++ b/libraries/PHPExcel/PHPExcel/RichText.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,39 +22,10 @@
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
-}
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Cell_DataType */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
-
-/** PHPExcel_RichText_ITextElement */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/ITextElement.php';
-
-/** PHPExcel_RichText_TextElement */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/TextElement.php';
-
-/** PHPExcel_RichText_Run */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/Run.php';
-
-/** PHPExcel_Style_Font */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
-
/**
* PHPExcel_RichText
*
@@ -70,14 +41,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
* @var PHPExcel_RichText_ITextElement[]
*/
private $_richTextElements;
-
- /**
- * Parent cell
- *
- * @var PHPExcel_Cell
- */
- private $_parent;
-
+
/**
* Create a new PHPExcel_RichText instance
*
@@ -88,24 +52,21 @@ class PHPExcel_RichText implements PHPExcel_IComparable
{
// Initialise variables
$this->_richTextElements = array();
-
- // Set parent?
+
+ // Rich-Text string attached to cell?
if (!is_null($pCell)) {
- // Set parent cell
- $this->_parent = $pCell;
-
// Add cell text and style
- if ($this->_parent->getValue() != "") {
- $objRun = new PHPExcel_RichText_Run($this->_parent->getValue());
- $objRun->setFont(clone $this->_parent->getParent()->getStyle($this->_parent->getCoordinate())->getFont());
+ if ($pCell->getValue() != "") {
+ $objRun = new PHPExcel_RichText_Run($pCell->getValue());
+ $objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont());
$this->addText($objRun);
}
-
+
// Set parent value
- $this->_parent->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
+ $pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
}
}
-
+
/**
* Add text
*
@@ -118,7 +79,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
$this->_richTextElements[] = $pText;
return $this;
}
-
+
/**
* Create text
*
@@ -132,7 +93,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
$this->addText($objText);
return $objText;
}
-
+
/**
* Create text run
*
@@ -146,7 +107,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
$this->addText($objText);
return $objText;
}
-
+
/**
* Get plain text
*
@@ -156,16 +117,16 @@ class PHPExcel_RichText implements PHPExcel_IComparable
{
// Return value
$returnValue = '';
-
+
// Loop through all PHPExcel_RichText_ITextElement
foreach ($this->_richTextElements as $text) {
$returnValue .= $text->getText();
}
-
+
// Return
return $returnValue;
}
-
+
/**
* Convert to string
*
@@ -174,7 +135,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
public function __toString() {
return $this->getPlainText();
}
-
+
/**
* Get Rich Text elements
*
@@ -184,7 +145,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
{
return $this->_richTextElements;
}
-
+
/**
* Set Rich Text elements
*
@@ -201,70 +162,30 @@ class PHPExcel_RichText implements PHPExcel_IComparable
}
return $this;
}
-
- /**
- * Get parent
- *
- * @return PHPExcel_Cell
- */
- public function getParent() {
- return $this->_parent;
- }
-
- /**
- * Set parent
- *
- * @param PHPExcel_Cell $value
- * @return PHPExcel_RichText
- */
- public function setParent(PHPExcel_Cell $value) {
- // Set parent
- $this->_parent = $value;
-
- // Set parent value
- $this->_parent->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
-
- // Verify style information
- $sheet = $this->_parent->getParent();
- $cellFont = $sheet->getStyle($this->_parent->getCoordinate())->getFont()->getSharedComponent();
- foreach ($this->getRichTextElements() as $element) {
- if (!($element instanceof PHPExcel_RichText_Run)) continue;
-
- if ($element->getFont()->getHashCode() == $sheet->getDefaultStyle()->getFont()->getHashCode()) {
- if ($element->getFont()->getHashCode() != $cellFont->getHashCode()) {
- $element->setFont(clone $cellFont);
- }
- }
- }
- return $this;
- }
-
/**
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
$hashElements = '';
foreach ($this->_richTextElements as $element) {
$hashElements .= $element->getHashCode();
}
-
+
return md5(
$hashElements
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
- if ($key == '_parent') continue;
-
if (is_object($value)) {
$this->$key = clone $value;
} else {
diff --git a/libraries/PHPExcel/PHPExcel/RichText/ITextElement.php b/libraries/PHPExcel/PHPExcel/RichText/ITextElement.php
index 713a522c0..001361edd 100644
--- a/libraries/PHPExcel/PHPExcel/RichText/ITextElement.php
+++ b/libraries/PHPExcel/PHPExcel/RichText/ITextElement.php
@@ -6,12 +6,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -20,22 +20,10 @@
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Style_Font */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
-
-
/**
* PHPExcel_RichText_ITextElement
*
@@ -49,28 +37,28 @@ interface PHPExcel_RichText_ITextElement
* Get text
*
* @return string Text
- */
+ */
public function getText();
-
+
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
- */
+ */
public function setText($pText = '');
-
+
/**
* Get font
*
* @return PHPExcel_Style_Font
- */
+ */
public function getFont();
-
+
/**
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode();
}
diff --git a/libraries/PHPExcel/PHPExcel/RichText/Run.php b/libraries/PHPExcel/PHPExcel/RichText/Run.php
index 82aff89c8..29a291b73 100644
--- a/libraries/PHPExcel/PHPExcel/RichText/Run.php
+++ b/libraries/PHPExcel/PHPExcel/RichText/Run.php
@@ -6,12 +6,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -20,28 +20,10 @@
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_RichText_ITextElement */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/ITextElement.php';
-
-/** PHPExcel_RichText_TextElement */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/TextElement.php';
-
-/** PHPExcel_Style_Font */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
-
-
/**
* PHPExcel_RichText_Run
*
@@ -50,14 +32,14 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
-{
+{
/**
* Font
*
* @var PHPExcel_Style_Font
*/
private $_font;
-
+
/**
* Create a new PHPExcel_RichText_Run instance
*
@@ -69,33 +51,33 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
$this->setText($pText);
$this->_font = new PHPExcel_Style_Font();
}
-
+
/**
* Get font
*
* @return PHPExcel_Style_Font
- */
+ */
public function getFont() {
return $this->_font;
}
-
+
/**
* Set font
*
* @param PHPExcel_Style_Font $pFont Font
* @throws Exception
* @return PHPExcel_RichText_ITextElement
- */
+ */
public function setFont(PHPExcel_Style_Font $pFont = null) {
$this->_font = $pFont;
return $this;
}
-
+
/**
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
return md5(
$this->getText()
@@ -103,7 +85,7 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/RichText/TextElement.php b/libraries/PHPExcel/PHPExcel/RichText/TextElement.php
index d16a92995..5598d4feb 100644
--- a/libraries/PHPExcel/PHPExcel/RichText/TextElement.php
+++ b/libraries/PHPExcel/PHPExcel/RichText/TextElement.php
@@ -6,12 +6,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -20,25 +20,10 @@
* @package PHPExcel_RichText
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_RichText_ITextElement */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/ITextElement.php';
-
-/** PHPExcel_Style_Font */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
-
-
/**
* PHPExcel_RichText_TextElement
*
@@ -54,7 +39,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
* @var string
*/
private $_text;
-
+
/**
* Create a new PHPExcel_RichText_TextElement instance
*
@@ -65,48 +50,48 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
// Initialise variables
$this->_text = $pText;
}
-
+
/**
* Get text
*
* @return string Text
- */
+ */
public function getText() {
return $this->_text;
}
-
+
/**
* Set text
*
* @param $pText string Text
* @return PHPExcel_RichText_ITextElement
- */
+ */
public function setText($pText = '') {
$this->_text = $pText;
return $this;
}
-
+
/**
* Get font
*
* @return PHPExcel_Style_Font
- */
+ */
public function getFont() {
return null;
}
-
+
/**
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
return md5(
$this->_text
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Settings.php b/libraries/PHPExcel/PHPExcel/Settings.php
new file mode 100644
index 000000000..27e39f953
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/Settings.php
@@ -0,0 +1,65 @@
+setLocale($locale);
+ } // function setLocale()
+
+}
\ No newline at end of file
diff --git a/libraries/PHPExcel/PHPExcel/Shared/CodePage.php b/libraries/PHPExcel/PHPExcel/Shared/CodePage.php
new file mode 100644
index 000000000..23f28d003
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/Shared/CodePage.php
@@ -0,0 +1,94 @@
+""))
+ $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;
+ }
+
}
diff --git a/libraries/PHPExcel/PHPExcel/Shared/Escher.php b/libraries/PHPExcel/PHPExcel/Shared/Escher.php
index 4ed04b384..7c4edcdd4 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/Escher.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/Escher.php
@@ -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
*/
/**
diff --git a/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer.php b/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer.php
index 243dab350..55df1acfd 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer.php
@@ -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
*/
/**
diff --git a/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php b/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php
index 8f07e52ae..f0c6933e8 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php
@@ -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
*/
/**
diff --git a/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php
index 952685307..914235f53 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php
@@ -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
*/
/**
diff --git a/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer.php b/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer.php
index 5883ae26b..e7b4d46bd 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer.php
@@ -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
*/
/**
diff --git a/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php b/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php
index c15995a63..070fdb8be 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php
@@ -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
*/
/**
diff --git a/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php b/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php
index 0ae494851..b753d45fb 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php
@@ -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
*/
/**
diff --git a/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php b/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php
index 87609cca7..47fcb75e6 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php
@@ -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
*/
/**
diff --git a/libraries/PHPExcel/PHPExcel/Shared/Excel5.php b/libraries/PHPExcel/PHPExcel/Shared/Excel5.php
index f9b3f818a..8d3fb3601 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/Excel5.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/Excel5.php
@@ -22,26 +22,9 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Shared_Drawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Drawing.php';
-
-/** PHPExcel_Shared_Font */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Font.php';
-
/**
* PHPExcel_Shared_Excel5
*
@@ -264,7 +247,7 @@ class PHPExcel_Shared_Excel5
list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinates);
$col_start = PHPExcel_Cell::columnIndexFromString($column) - 1;
$row_start = $row - 1;
-
+
$x1 = $offsetX;
$y1 = $offsetY;
diff --git a/libraries/PHPExcel/PHPExcel/Shared/File.php b/libraries/PHPExcel/PHPExcel/Shared/File.php
index a742d152f..94445052f 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/File.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/File.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Shared/Font.php b/libraries/PHPExcel/PHPExcel/Shared/Font.php
index 8bf67d5b3..5ca6501b2 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/Font.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/Font.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,22 +22,10 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-
/**
* PHPExcel_Shared_Font
*
@@ -71,7 +59,7 @@ class PHPExcel_Shared_Font
const CHARSET_ANSI_THAI = 0xDE;
const CHARSET_ANSI_LATIN_II = 0xEE;
const CHARSET_OEM_LATIN_I = 0xFF;
-
+
// XXX: Constants created!
/** Font filenames */
const ARIAL = 'arial.ttf';
@@ -230,7 +218,7 @@ class PHPExcel_Shared_Font
{
self::$trueTypeFontPath = $pValue;
}
-
+
/**
* Get the path to the folder containing .ttf files.
*
@@ -240,26 +228,31 @@ class PHPExcel_Shared_Font
{
return self::$trueTypeFontPath;
}
-
+
/**
* Calculate an (approximate) OpenXML column width, based on font size and text contained
*
* @param int $fontSize Font size (in pixels or points)
* @param bool $fontSizeInPixels Is the font size specified in pixels (true) or in points (false) ?
- * @param string $columnText Text to calculate width
+ * @param string $cellText Text to calculate width
* @param int $rotation Rotation angle
* @return int Column width
*/
- public static function calculateColumnWidth(PHPExcel_Style_Font $font, $columnText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) {
+ public static function calculateColumnWidth(PHPExcel_Style_Font $font, $cellText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) {
// If it is rich text, use plain text
- if ($columnText instanceof PHPExcel_RichText) {
- $columnText = $columnText->getPlainText();
+ if ($cellText instanceof PHPExcel_RichText) {
+ $cellText = $cellText->getPlainText();
}
- // Only measure the part before the first newline character (is always "\n")
- if (strpos($columnText, "\n") !== false) {
- $columnText = substr($columnText, 0, strpos($columnText, "\n"));
+ // Special case if there are one or more newline characters ("\n")
+ if (strpos($cellText, "\n") !== false) {
+ $lineTexts = explode("\n", $cellText);
+ $lineWitdhs = array();
+ foreach ($lineTexts as $lineText) {
+ $lineWidths[] = self::calculateColumnWidth($font, $lineText, $rotation = 0, $defaultFont);
+ }
+ return max($lineWidths); // width of longest line in cell
}
// Try to get the exact text width in pixels
@@ -270,14 +263,14 @@ class PHPExcel_Shared_Font
}
// Width of text in pixels excl. padding
- $columnWidth = self::getTextWidthPixelsExact($columnText, $font, $rotation);
+ $columnWidth = self::getTextWidthPixelsExact($cellText, $font, $rotation);
// Excel adds some padding, use 1.07 of the width of an 'n' glyph
$columnWidth += ceil(self::getTextWidthPixelsExact('0', $font, 0) * 1.07); // pixels incl. padding
} catch (Exception $e) {
// Width of text in pixels excl. padding, approximation
- $columnWidth = self::getTextWidthPixelsApprox($columnText, $font, $rotation);
+ $columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation);
// Excel adds some padding, just use approx width of 'n' glyph
$columnWidth += self::getTextWidthPixelsApprox('n', $font, 0);
@@ -318,7 +311,7 @@ class PHPExcel_Shared_Font
$upperRightCornerY = $textBox[5];
$upperLeftCornerX = $textBox[6];
$upperLeftCornerY = $textBox[7];
-
+
// Consider the rotation when calculating the width
$textWidth = max($lowerRightCornerX - $upperLeftCornerX, $upperRightCornerX - $lowerLeftCornerX);
@@ -391,7 +384,7 @@ class PHPExcel_Shared_Font
public static function fontSizeToPixels($fontSizeInPoints = 11) {
return (int) ((4 / 3) * $fontSizeInPoints);
}
-
+
/**
* Calculate an (approximate) pixel size, based on inch size
*
@@ -401,7 +394,7 @@ class PHPExcel_Shared_Font
public static function inchSizeToPixels($sizeInInch = 1) {
return ($sizeInInch * 96);
}
-
+
/**
* Calculate an (approximate) pixel size, based on centimeter size
*
@@ -431,34 +424,34 @@ class PHPExcel_Shared_Font
switch ($name) {
case 'Arial':
$fontFile = (
- $bold ? ($italic ? self::ARIAL_BOLD_ITALIC : self::ARIAL_BOLD)
+ $bold ? ($italic ? self::ARIAL_BOLD_ITALIC : self::ARIAL_BOLD)
: ($italic ? self::ARIAL_ITALIC : self::ARIAL)
);
break;
case 'Calibri':
$fontFile = (
- $bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
+ $bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
: ($italic ? self::CALIBRI_ITALIC : self::CALIBRI)
);
break;
case 'Courier New':
$fontFile = (
- $bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
+ $bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
: ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW)
);
break;
case 'Comic Sans MS':
$fontFile = (
- $bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
+ $bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
);
break;
case 'Georgia':
$fontFile = (
- $bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
+ $bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
: ($italic ? self::GEORGIA_ITALIC : self::GEORGIA)
);
break;
@@ -469,7 +462,7 @@ class PHPExcel_Shared_Font
case 'Liberation Sans':
$fontFile = (
- $bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
+ $bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
: ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS)
);
break;
@@ -488,7 +481,7 @@ class PHPExcel_Shared_Font
case 'Palatino Linotype':
$fontFile = (
- $bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
+ $bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
: ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE)
);
break;
@@ -499,27 +492,27 @@ class PHPExcel_Shared_Font
case 'Tahoma':
$fontFile = (
- $bold ? self::TAHOMA_BOLD : self::TAHOMA
+ $bold ? self::TAHOMA_BOLD : self::TAHOMA
);
break;
case 'Times New Roman':
$fontFile = (
- $bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
+ $bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
: ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN)
);
break;
case 'Trebuchet MS':
$fontFile = (
- $bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
+ $bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
: ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS)
);
break;
case 'Verdana':
$fontFile = (
- $bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
+ $bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
: ($italic ? self::VERDANA_ITALIC : self::VERDANA)
);
break;
@@ -589,7 +582,7 @@ class PHPExcel_Shared_Font
return $columnWidth;
}
-
+
/**
* Get the effective row height for rows without a row dimension or rows with height -1
* For example, for Calibri 11 this is 15 points
diff --git a/libraries/PHPExcel/PHPExcel/Shared/JAMA/Matrix.php b/libraries/PHPExcel/PHPExcel/Shared/JAMA/Matrix.php
index 49659d03c..c168567a3 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/JAMA/Matrix.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/JAMA/Matrix.php
@@ -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);
}
diff --git a/libraries/PHPExcel/PHPExcel/Shared/OLE.php b/libraries/PHPExcel/PHPExcel/Shared/OLE.php
index f65c24fad..a7cc9c3d8 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/OLE.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/OLE.php
@@ -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;
diff --git a/libraries/PHPExcel/PHPExcel/Shared/OLE/ChainedBlockStream.php b/libraries/PHPExcel/PHPExcel/Shared/OLE/ChainedBlockStream.php
index df96995c8..0da02c955 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/OLE/ChainedBlockStream.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/OLE/ChainedBlockStream.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,19 +22,9 @@
* @package PHPExcel_Shared_OLE
* @copyright Copyright (c) 2006 - 2007 Christian Schmidt
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
-}
-
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE.php';
-
/**
* PHPExcel_Shared_OLE_ChainedBlockStream
*
diff --git a/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS.php b/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS.php
new file mode 100644
index 000000000..aa1a4265c
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS.php
@@ -0,0 +1,218 @@
+ |
+// | 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
+* @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;
+ }
+ }
diff --git a/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS/File.php b/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS/File.php
new file mode 100644
index 000000000..f061f568c
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS/File.php
@@ -0,0 +1,84 @@
+ |
+// | 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
+* @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);
+ }
+}
diff --git a/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS/Root.php b/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS/Root.php
new file mode 100644
index 000000000..a7f003509
--- /dev/null
+++ b/libraries/PHPExcel/PHPExcel/Shared/OLE/PPS/Root.php
@@ -0,0 +1,447 @@
+ |
+// | 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
+* @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));
+ }
+ }
+ }
diff --git a/libraries/PHPExcel/PHPExcel/Shared/OLERead.php b/libraries/PHPExcel/PHPExcel/Shared/OLERead.php
index 46cb5ade3..609fe4ba7 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/OLERead.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/OLERead.php
@@ -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;
}
diff --git a/libraries/PHPExcel/PHPExcel/Shared/PasswordHasher.php b/libraries/PHPExcel/PHPExcel/Shared/PasswordHasher.php
index 1a5c11a33..441a4e105 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/PasswordHasher.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/PasswordHasher.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Shared/String.php b/libraries/PHPExcel/PHPExcel/Shared/String.php
index e165fdd63..c3761fe95 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/String.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/String.php
@@ -22,7 +22,7 @@
* @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
@@ -48,6 +48,13 @@ class PHPExcel_Shared_String
*/
private static $_controlCharacters = array();
+ /**
+ * SYLK Characters array
+ *
+ * $var array
+ */
+ private static $_SYLKCharacters = array();
+
/**
* Decimal separator
*
@@ -89,6 +96,171 @@ class PHPExcel_Shared_String
}
}
+ /**
+ * Build SYLK characters array
+ */
+ private static function _buildSYLKCharacters()
+ {
+ self::$_SYLKCharacters = array(
+ "\x1B 0" => chr(0),
+ "\x1B 1" => chr(1),
+ "\x1B 2" => chr(2),
+ "\x1B 3" => chr(3),
+ "\x1B 4" => chr(4),
+ "\x1B 5" => chr(5),
+ "\x1B 6" => chr(6),
+ "\x1B 7" => chr(7),
+ "\x1B 8" => chr(8),
+ "\x1B 9" => chr(9),
+ "\x1B :" => chr(10),
+ "\x1B ;" => chr(11),
+ "\x1B <" => chr(12),
+ "\x1B :" => chr(13),
+ "\x1B >" => chr(14),
+ "\x1B ?" => chr(15),
+ "\x1B!0" => chr(16),
+ "\x1B!1" => chr(17),
+ "\x1B!2" => chr(18),
+ "\x1B!3" => chr(19),
+ "\x1B!4" => chr(20),
+ "\x1B!5" => chr(21),
+ "\x1B!6" => chr(22),
+ "\x1B!7" => chr(23),
+ "\x1B!8" => chr(24),
+ "\x1B!9" => chr(25),
+ "\x1B!:" => chr(26),
+ "\x1B!;" => chr(27),
+ "\x1B!<" => chr(28),
+ "\x1B!=" => chr(29),
+ "\x1B!>" => chr(30),
+ "\x1B!?" => chr(31),
+ "\x1B'?" => chr(127),
+ "\x1B(0" => '€', // 128 in CP1252
+ "\x1B(2" => '‚', // 130 in CP1252
+ "\x1B(3" => 'Æ’', // 131 in CP1252
+ "\x1B(4" => '„', // 132 in CP1252
+ "\x1B(5" => '…', // 133 in CP1252
+ "\x1B(6" => '†', // 134 in CP1252
+ "\x1B(7" => '‡', // 135 in CP1252
+ "\x1B(8" => 'ˆ', // 136 in CP1252
+ "\x1B(9" => '‰', // 137 in CP1252
+ "\x1B(:" => 'Å ', // 138 in CP1252
+ "\x1B(;" => '‹', // 139 in CP1252
+ "\x1BNj" => 'Å’', // 140 in CP1252
+ "\x1B(>" => 'Ž', // 142 in CP1252
+ "\x1B)1" => '‘', // 145 in CP1252
+ "\x1B)2" => '’', // 146 in CP1252
+ "\x1B)3" => '“', // 147 in CP1252
+ "\x1B)4" => 'â€', // 148 in CP1252
+ "\x1B)5" => '•', // 149 in CP1252
+ "\x1B)6" => '–', // 150 in CP1252
+ "\x1B)7" => '—', // 151 in CP1252
+ "\x1B)8" => '˜', // 152 in CP1252
+ "\x1B)9" => 'â„¢', // 153 in CP1252
+ "\x1B):" => 'Å¡', // 154 in CP1252
+ "\x1B);" => '›', // 155 in CP1252
+ "\x1BNz" => 'Å“', // 156 in CP1252
+ "\x1B)>" => 'ž', // 158 in CP1252
+ "\x1B)?" => 'Ÿ', // 159 in CP1252
+ "\x1B*0" => 'Â ', // 160 in CP1252
+ "\x1BN!" => '¡', // 161 in CP1252
+ "\x1BN\"" => '¢', // 162 in CP1252
+ "\x1BN#" => '£', // 163 in CP1252
+ "\x1BN(" => '¤', // 164 in CP1252
+ "\x1BN%" => 'Â¥', // 165 in CP1252
+ "\x1B*6" => '¦', // 166 in CP1252
+ "\x1BN'" => '§', // 167 in CP1252
+ "\x1BNH " => '¨', // 168 in CP1252
+ "\x1BNS" => '©', // 169 in CP1252
+ "\x1BNc" => 'ª', // 170 in CP1252
+ "\x1BN+" => '«', // 171 in CP1252
+ "\x1B*<" => '¬', // 172 in CP1252
+ "\x1B*=" => 'Â', // 173 in CP1252
+ "\x1BNR" => '®', // 174 in CP1252
+ "\x1B*?" => '¯', // 175 in CP1252
+ "\x1BN0" => '°', // 176 in CP1252
+ "\x1BN1" => '±', // 177 in CP1252
+ "\x1BN2" => '²', // 178 in CP1252
+ "\x1BN3" => '³', // 179 in CP1252
+ "\x1BNB " => '´', // 180 in CP1252
+ "\x1BN5" => 'µ', // 181 in CP1252
+ "\x1BN6" => '¶', // 182 in CP1252
+ "\x1BN7" => '·', // 183 in CP1252
+ "\x1B+8" => '¸', // 184 in CP1252
+ "\x1BNQ" => '¹', // 185 in CP1252
+ "\x1BNk" => 'º', // 186 in CP1252
+ "\x1BN;" => '»', // 187 in CP1252
+ "\x1BN<" => '¼', // 188 in CP1252
+ "\x1BN=" => '½', // 189 in CP1252
+ "\x1BN>" => '¾', // 190 in CP1252
+ "\x1BN?" => '¿', // 191 in CP1252
+ "\x1BNAA" => 'À', // 192 in CP1252
+ "\x1BNBA" => 'Ã', // 193 in CP1252
+ "\x1BNCA" => 'Â', // 194 in CP1252
+ "\x1BNDA" => 'Ã', // 195 in CP1252
+ "\x1BNHA" => 'Ä', // 196 in CP1252
+ "\x1BNJA" => 'Ã…', // 197 in CP1252
+ "\x1BNa" => 'Æ', // 198 in CP1252
+ "\x1BNKC" => 'Ç', // 199 in CP1252
+ "\x1BNAE" => 'È', // 200 in CP1252
+ "\x1BNBE" => 'É', // 201 in CP1252
+ "\x1BNCE" => 'Ê', // 202 in CP1252
+ "\x1BNHE" => 'Ë', // 203 in CP1252
+ "\x1BNAI" => 'Ì', // 204 in CP1252
+ "\x1BNBI" => 'Ã', // 205 in CP1252
+ "\x1BNCI" => 'ÃŽ', // 206 in CP1252
+ "\x1BNHI" => 'Ã', // 207 in CP1252
+ "\x1BNb" => 'Ã', // 208 in CP1252
+ "\x1BNDN" => 'Ñ', // 209 in CP1252
+ "\x1BNAO" => 'Ã’', // 210 in CP1252
+ "\x1BNBO" => 'Ó', // 211 in CP1252
+ "\x1BNCO" => 'Ô', // 212 in CP1252
+ "\x1BNDO" => 'Õ', // 213 in CP1252
+ "\x1BNHO" => 'Ö', // 214 in CP1252
+ "\x1B-7" => '×', // 215 in CP1252
+ "\x1BNi" => 'Ø', // 216 in CP1252
+ "\x1BNAU" => 'Ù', // 217 in CP1252
+ "\x1BNBU" => 'Ú', // 218 in CP1252
+ "\x1BNCU" => 'Û', // 219 in CP1252
+ "\x1BNHU" => 'Ü', // 220 in CP1252
+ "\x1B-=" => 'Ã', // 221 in CP1252
+ "\x1BNl" => 'Þ', // 222 in CP1252
+ "\x1BN{" => 'ß', // 223 in CP1252
+ "\x1BNAa" => 'Ã ', // 224 in CP1252
+ "\x1BNBa" => 'á', // 225 in CP1252
+ "\x1BNCa" => 'â', // 226 in CP1252
+ "\x1BNDa" => 'ã', // 227 in CP1252
+ "\x1BNHa" => 'ä', // 228 in CP1252
+ "\x1BNJa" => 'Ã¥', // 229 in CP1252
+ "\x1BNq" => 'æ', // 230 in CP1252
+ "\x1BNKc" => 'ç', // 231 in CP1252
+ "\x1BNAe" => 'è', // 232 in CP1252
+ "\x1BNBe" => 'é', // 233 in CP1252
+ "\x1BNCe" => 'ê', // 234 in CP1252
+ "\x1BNHe" => 'ë', // 235 in CP1252
+ "\x1BNAi" => 'ì', // 236 in CP1252
+ "\x1BNBi" => 'Ã', // 237 in CP1252
+ "\x1BNCi" => 'î', // 238 in CP1252
+ "\x1BNHi" => 'ï', // 239 in CP1252
+ "\x1BNs" => 'ð', // 240 in CP1252
+ "\x1BNDn" => 'ñ', // 241 in CP1252
+ "\x1BNAo" => 'ò', // 242 in CP1252
+ "\x1BNBo" => 'ó', // 243 in CP1252
+ "\x1BNCo" => 'ô', // 244 in CP1252
+ "\x1BNDo" => 'õ', // 245 in CP1252
+ "\x1BNHo" => 'ö', // 246 in CP1252
+ "\x1B/7" => '÷', // 247 in CP1252
+ "\x1BNy" => 'ø', // 248 in CP1252
+ "\x1BNAu" => 'ù', // 249 in CP1252
+ "\x1BNBu" => 'ú', // 250 in CP1252
+ "\x1BNCu" => 'û', // 251 in CP1252
+ "\x1BNHu" => 'ü', // 252 in CP1252
+ "\x1B/=" => 'ý', // 253 in CP1252
+ "\x1BN|" => 'þ', // 254 in CP1252
+ "\x1BNHy" => 'ÿ', // 255 in CP1252
+ );
+ }
+
/**
* Get whether mbstring extension is available
*
@@ -117,21 +289,37 @@ class PHPExcel_Shared_String
return self::$_isIconvEnabled;
}
- // Check that iconv exists
- // Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
- // we cannot use iconv when that happens
- // Also, sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0
- // we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773)
- if (function_exists('iconv')
- && @iconv('UTF-8', 'UTF-16LE', 'x')
- && @iconv_substr('A', 0, 1, 'UTF-8') ) {
-
- self::$_isIconvEnabled = true;
- } else {
+ // Fail if iconv doesn't exist
+ if (!function_exists('iconv')) {
self::$_isIconvEnabled = false;
+ return false;
}
- return self::$_isIconvEnabled;
+ // Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
+ if (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
+ self::$_isIconvEnabled = false;
+ return false;
+ }
+
+ // Sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0
+ // we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773)
+ if (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
+ self::$_isIconvEnabled = false;
+ return false;
+ }
+
+ // CUSTOM: IBM AIX iconv() does not work
+ if ( defined('PHP_OS') && @stristr(PHP_OS, 'AIX')
+ && defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0)
+ && defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0) )
+ {
+ self::$_isIconvEnabled = false;
+ return false;
+ }
+
+ // If we reach here no problems were detected with iconv
+ self::$_isIconvEnabled = true;
+ return true;
}
/**
@@ -277,7 +465,7 @@ class PHPExcel_Shared_String
}
/**
- * Convert string from one encoding to another. First try mbstring, then iconv, or no convertion
+ * Convert string from one encoding to another. First try iconv, then mbstring, or no convertion
*
* @param string $value
* @param string $to Encoding to convert to, e.g. 'UTF-8'
@@ -295,10 +483,45 @@ class PHPExcel_Shared_String
$value = mb_convert_encoding($value, $to, $from);
return $value;
}
-
+ if($from == 'UTF-16LE'){
+ return self::utf16_decode($value, false);
+ }else if($from == 'UTF-16BE'){
+ return self::utf16_decode($value);
+ }
// else, no conversion
return $value;
}
+
+ /**
+ * Decode UTF-16 encoded strings.
+ *
+ * Can handle both BOM'ed data and un-BOM'ed data.
+ * Assumes Big-Endian byte order if no BOM is available.
+ * This function was taken from http://php.net/manual/en/function.utf8-decode.php
+ * and $bom_be parameter added.
+ *
+ * @param string $str UTF-16 encoded data to decode.
+ * @return string UTF-8 / ISO encoded data.
+ * @access public
+ * @version 0.2 / 2010-05-13
+ * @author Rasmus Andersson {@link http://rasmusandersson.se/}
+ * @author vadik56
+ */
+ function utf16_decode( $str, $bom_be=true ) {
+ if( strlen($str) < 2 ) return $str;
+ $c0 = ord($str{0});
+ $c1 = ord($str{1});
+ if( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); }
+ elseif( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; }
+ $len = strlen($str);
+ $newstr = '';
+ for($i=0;$i<$len;$i+=2) {
+ if( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); }
+ else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); }
+ $newstr .= ($val == 0x228) ? "\n" : chr($val);
+ }
+ return $newstr;
+ }
/**
* Get character count. First try mbstring, then iconv, finally strlen
@@ -427,4 +650,28 @@ class PHPExcel_Shared_String
self::$_thousandsSeparator = $pValue;
}
+ /**
+ * Convert SYLK encoded string to UTF-8
+ *
+ * @param string $pValue
+ * @return string UTF-8 encoded string
+ */
+ public static function SYLKtoUTF8($pValue = '')
+ {
+ // If there is no escape character in the string there is nothing to do
+ if (strpos($pValue, '') === false) {
+ return $pValue;
+ }
+
+ if(empty(self::$_SYLKCharacters)) {
+ self::_buildSYLKCharacters();
+ }
+
+ foreach (self::$_SYLKCharacters as $k => $v) {
+ $pValue = str_replace($k, $v, $pValue);
+ }
+
+ return $pValue;
+ }
+
}
diff --git a/libraries/PHPExcel/PHPExcel/Shared/XMLWriter.php b/libraries/PHPExcel/PHPExcel/Shared/XMLWriter.php
index 4cd3d726a..9d43211da 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/XMLWriter.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/XMLWriter.php
@@ -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')) {
diff --git a/libraries/PHPExcel/PHPExcel/Shared/ZipStreamWrapper.php b/libraries/PHPExcel/PHPExcel/Shared/ZipStreamWrapper.php
index b5bc1cb02..1c41ec69e 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/ZipStreamWrapper.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/ZipStreamWrapper.php
@@ -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();
diff --git a/libraries/PHPExcel/PHPExcel/Shared/trend/bestFitClass.php b/libraries/PHPExcel/PHPExcel/Shared/trend/bestFitClass.php
index bd96d5827..7f9d01e3f 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/trend/bestFitClass.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/trend/bestFitClass.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Shared/trend/exponentialBestFitClass.php b/libraries/PHPExcel/PHPExcel/Shared/trend/exponentialBestFitClass.php
index 1d7212d9d..efc19987d 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/trend/exponentialBestFitClass.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/trend/exponentialBestFitClass.php
@@ -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');
diff --git a/libraries/PHPExcel/PHPExcel/Shared/trend/linearBestFitClass.php b/libraries/PHPExcel/PHPExcel/Shared/trend/linearBestFitClass.php
index 265048196..63222cb2c 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/trend/linearBestFitClass.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/trend/linearBestFitClass.php
@@ -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');
diff --git a/libraries/PHPExcel/PHPExcel/Shared/trend/logarithmicBestFitClass.php b/libraries/PHPExcel/PHPExcel/Shared/trend/logarithmicBestFitClass.php
index 115c78d0d..56d6ca9bd 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/trend/logarithmicBestFitClass.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/trend/logarithmicBestFitClass.php
@@ -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');
diff --git a/libraries/PHPExcel/PHPExcel/Shared/trend/polynomialBestFitClass.php b/libraries/PHPExcel/PHPExcel/Shared/trend/polynomialBestFitClass.php
index dca14ff3c..e5e57c5b3 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/trend/polynomialBestFitClass.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/trend/polynomialBestFitClass.php
@@ -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';
diff --git a/libraries/PHPExcel/PHPExcel/Shared/trend/powerBestFitClass.php b/libraries/PHPExcel/PHPExcel/Shared/trend/powerBestFitClass.php
index 651aec2fe..c3b98d313 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/trend/powerBestFitClass.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/trend/powerBestFitClass.php
@@ -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';
diff --git a/libraries/PHPExcel/PHPExcel/Shared/trend/trendClass.php b/libraries/PHPExcel/PHPExcel/Shared/trend/trendClass.php
index 12ae7c6ac..f987831cd 100644
--- a/libraries/PHPExcel/PHPExcel/Shared/trend/trendClass.php
+++ b/libraries/PHPExcel/PHPExcel/Shared/trend/trendClass.php
@@ -1,13 +1,5 @@
_parent = $parent;
return $this;
}
-
+
/**
* Is this a supervisor or a real style component?
*
@@ -258,7 +223,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
/**
* Apply styles from array
- *
+ *
*
* $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray(
* array(
@@ -289,9 +254,9 @@ class PHPExcel_Style implements PHPExcel_IComparable
* )
* );
*
- *
+ *
* @param array $pStyles Array containing style information
- * @param boolean $pAdvanced Advanced mode for setting borders.
+ * @param boolean $pAdvanced Advanced mode for setting borders.
* @throws Exception
* @return PHPExcel_Style
*/
@@ -373,7 +338,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
// loop through up to 3 x 3 = 9 regions
for ($x = 1; $x <= $xMax; ++$x) {
// start column index for region
- $colStart = ($x == 3) ?
+ $colStart = ($x == 3) ?
PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0])
: PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $x - 1);
@@ -417,7 +382,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
// build range for region
$range = $colStart . $rowStart . ':' . $colEnd . $rowEnd;
-
+
// retrieve relevant style array for region
$regionStyles = $pStyles;
unset($regionStyles['borders']['inside']);
@@ -503,7 +468,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
$style = $workbook->getCellXfByIndex($oldXfIndex);
$newStyle = clone $style;
$newStyle->applyFromArray($pStyles);
-
+
if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) {
// there is already such cell Xf in our collection
$newXfIndexes[$oldXfIndex] = $existingStyle->getIndex();
@@ -579,7 +544,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getFill() {
return $this->_fill;
}
-
+
/**
* Get Font
*
@@ -609,7 +574,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getBorders() {
return $this->_borders;
}
-
+
/**
* Get Alignment
*
@@ -618,7 +583,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getAlignment() {
return $this->_alignment;
}
-
+
/**
* Get Number Format
*
@@ -627,7 +592,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getNumberFormat() {
return $this->_numberFormat;
}
-
+
/**
* Get Conditional Styles. Only used on supervisor.
*
@@ -636,7 +601,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getConditionalStyles() {
return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell());
}
-
+
/**
* Set Conditional Styles. Only used on supervisor.
*
@@ -651,7 +616,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Protection
*
@@ -660,18 +625,18 @@ class PHPExcel_Style implements PHPExcel_IComparable
public function getProtection() {
return $this->_protection;
}
-
+
/**
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
$hashConditionals = '';
foreach ($this->_conditionalStyles as $conditional) {
$hashConditionals .= $conditional->getHashCode();
}
-
+
return md5(
$this->getFill()->getHashCode()
. $this->getFont()->getHashCode()
@@ -683,7 +648,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Get own index in style collection
*
diff --git a/libraries/PHPExcel/PHPExcel/Style/Alignment.php b/libraries/PHPExcel/PHPExcel/Style/Alignment.php
index fa52e0869..c248433d5 100644
--- a/libraries/PHPExcel/PHPExcel/Style/Alignment.php
+++ b/libraries/PHPExcel/PHPExcel/Style/Alignment.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,22 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-
/**
* PHPExcel_Style_Alignment
*
@@ -46,7 +34,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Style_Alignment implements PHPExcel_IComparable
-{
+{
/* Horizontal alignment styles */
const HORIZONTAL_GENERAL = 'general';
const HORIZONTAL_LEFT = 'left';
@@ -54,55 +42,55 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
const HORIZONTAL_CENTER = 'center';
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous';
const HORIZONTAL_JUSTIFY = 'justify';
-
+
/* Vertical alignment styles */
const VERTICAL_BOTTOM = 'bottom';
const VERTICAL_TOP = 'top';
const VERTICAL_CENTER = 'center';
const VERTICAL_JUSTIFY = 'justify';
-
+
/**
* Horizontal
*
* @var string
*/
private $_horizontal;
-
+
/**
* Vertical
*
* @var string
*/
private $_vertical;
-
+
/**
* Text rotation
*
* @var int
*/
private $_textRotation;
-
+
/**
* Wrap text
*
* @var boolean
*/
private $_wrapText;
-
+
/**
* Shrink to fit
*
* @var boolean
*/
private $_shrinkToFit;
-
+
/**
* Indent - only possible with horizontal alignment left and right
*
* @var int
*/
private $_indent;
-
+
/**
* Parent Borders
*
@@ -219,7 +207,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
/**
* Apply styles from array
- *
+ *
*
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray(
* array(
@@ -230,7 +218,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
* )
* );
*
- *
+ *
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Alignment
@@ -264,7 +252,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Horizontal
*
@@ -276,7 +264,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_horizontal;
}
-
+
/**
* Set Horizontal
*
@@ -287,7 +275,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
}
-
+
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('horizontal' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -297,7 +285,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Vertical
*
@@ -309,7 +297,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_vertical;
}
-
+
/**
* Set Vertical
*
@@ -320,7 +308,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
if ($pValue == '') {
$pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
}
-
+
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('vertical' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -329,7 +317,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get TextRotation
*
@@ -341,7 +329,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_textRotation;
}
-
+
/**
* Set TextRotation
*
@@ -366,10 +354,10 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
} else {
throw new Exception("Text rotation should be a value between -90 and 90.");
}
-
+
return $this;
}
-
+
/**
* Get Wrap Text
*
@@ -381,7 +369,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_wrapText;
}
-
+
/**
* Set Wrap Text
*
@@ -400,7 +388,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Shrink to fit
*
@@ -412,7 +400,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_shrinkToFit;
}
-
+
/**
* Set Shrink to fit
*
@@ -443,7 +431,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this->_indent;
}
-
+
/**
* Set indent
*
@@ -464,12 +452,12 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
@@ -484,7 +472,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Style/Border.php b/libraries/PHPExcel/PHPExcel/Style/Border.php
index edaeaf301..b0335906c 100644
--- a/libraries/PHPExcel/PHPExcel/Style/Border.php
+++ b/libraries/PHPExcel/PHPExcel/Style/Border.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,25 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Style_Color */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-
/**
* PHPExcel_Style_Border
*
@@ -65,17 +50,17 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
const BORDER_SLANTDASHDOT = 'slantDashDot';
const BORDER_THICK = 'thick';
const BORDER_THIN = 'thin';
-
+
/**
* Border style
*
* @var string
*/
private $_borderStyle;
-
+
/**
* Border color
- *
+ *
* @var PHPExcel_Style_Color
*/
private $_color;
@@ -132,7 +117,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
$this->_parentPropertyName = $parentPropertyName;
return $this;
}
-
+
/**
* Is this a supervisor or a real style component?
*
@@ -270,7 +255,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
/**
* Apply styles from array
- *
+ *
*
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->applyFromArray(
* array(
@@ -281,7 +266,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
* )
* );
*
- *
+ *
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Border
@@ -303,7 +288,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Border style
*
@@ -315,7 +300,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
}
return $this->_borderStyle;
}
-
+
/**
* Set Border style
*
@@ -323,7 +308,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
* @return PHPExcel_Style_Border
*/
public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) {
-
+
if ($pValue == '') {
$pValue = PHPExcel_Style_Border::BORDER_NONE;
}
@@ -335,7 +320,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Border Color
*
@@ -344,7 +329,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
public function getColor() {
return $this->_color;
}
-
+
/**
* Set Border Color
*
@@ -355,7 +340,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
public function setColor(PHPExcel_Style_Color $pValue = null) {
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
-
+
if ($this->_isSupervisor) {
$styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -364,12 +349,12 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
@@ -380,7 +365,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Style/Borders.php b/libraries/PHPExcel/PHPExcel/Style/Borders.php
index 4a6b3460b..d7a259a71 100644
--- a/libraries/PHPExcel/PHPExcel/Style/Borders.php
+++ b/libraries/PHPExcel/PHPExcel/Style/Borders.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,25 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Style_Border */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Border.php';
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-
/**
* PHPExcel_Style_Borders
*
@@ -55,84 +40,84 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
const DIAGONAL_UP = 1;
const DIAGONAL_DOWN = 2;
const DIAGONAL_BOTH = 3;
-
+
/**
* Left
*
* @var PHPExcel_Style_Border
*/
private $_left;
-
+
/**
* Right
*
* @var PHPExcel_Style_Border
*/
private $_right;
-
+
/**
* Top
*
* @var PHPExcel_Style_Border
*/
private $_top;
-
+
/**
* Bottom
*
* @var PHPExcel_Style_Border
*/
private $_bottom;
-
+
/**
* Diagonal
*
* @var PHPExcel_Style_Border
*/
private $_diagonal;
-
+
/**
* DiagonalDirection
*
* @var int
*/
private $_diagonalDirection;
-
+
/**
* All borders psedo-border. Only applies to supervisor.
*
* @var PHPExcel_Style_Border
*/
private $_allBorders;
-
+
/**
* Outline psedo-border. Only applies to supervisor.
*
* @var PHPExcel_Style_Border
*/
private $_outline;
-
+
/**
* Inside psedo-border. Only applies to supervisor.
*
* @var PHPExcel_Style_Border
*/
private $_inside;
-
+
/**
* Vertical pseudo-border. Only applies to supervisor.
*
* @var PHPExcel_Style_Border
*/
private $_vertical;
-
+
/**
* Horizontal pseudo-border. Only applies to supervisor.
*
* @var PHPExcel_Style_Border
*/
private $_horizontal;
-
+
/**
* Parent Borders
*
@@ -271,7 +256,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
/**
* Apply styles from array
- *
+ *
*
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray(
* array(
@@ -302,7 +287,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
* )
* );
*
- *
+ *
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Borders
@@ -336,7 +321,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Left
*
@@ -345,7 +330,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
public function getLeft() {
return $this->_left;
}
-
+
/**
* Get Right
*
@@ -354,7 +339,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
public function getRight() {
return $this->_right;
}
-
+
/**
* Get Top
*
@@ -363,7 +348,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
public function getTop() {
return $this->_top;
}
-
+
/**
* Get Bottom
*
@@ -381,7 +366,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
public function getDiagonal() {
return $this->_diagonal;
}
-
+
/**
* Get AllBorders (pseudo-border). Only applies to supervisor.
*
@@ -394,7 +379,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_allBorders;
}
-
+
/**
* Get Outline (pseudo-border). Only applies to supervisor.
*
@@ -407,7 +392,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_outline;
}
-
+
/**
* Get Inside (pseudo-border). Only applies to supervisor.
*
@@ -420,7 +405,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_inside;
}
-
+
/**
* Get Vertical (pseudo-border). Only applies to supervisor.
*
@@ -433,7 +418,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_vertical;
}
-
+
/**
* Get Horizontal (pseudo-border). Only applies to supervisor.
*
@@ -446,7 +431,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_horizontal;
}
-
+
/**
* Get DiagonalDirection
*
@@ -458,7 +443,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this->_diagonalDirection;
}
-
+
/**
* Set DiagonalDirection
*
@@ -477,12 +462,12 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashcode();
@@ -497,7 +482,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Style/Color.php b/libraries/PHPExcel/PHPExcel/Style/Color.php
index e17595c0d..e48d4a6f2 100644
--- a/libraries/PHPExcel/PHPExcel/Style/Color.php
+++ b/libraries/PHPExcel/PHPExcel/Style/Color.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,22 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-
/**
* PHPExcel_Style_Color
*
@@ -58,14 +46,14 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
const COLOR_DARKGREEN = 'FF008000';
const COLOR_YELLOW = 'FFFFFF00';
const COLOR_DARKYELLOW = 'FF808000';
-
+
/**
* Indexed colors array
*
* @var array
*/
private static $_indexedColors;
-
+
/**
* ARGB - Alpha RGB
*
@@ -96,7 +84,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
/**
* Create a new PHPExcel_Style_Color
- *
+ *
* @param string $pARGB
*/
public function __construct($pARGB = PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor = false)
@@ -107,7 +95,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
// Initialise values
$this->_argb = $pARGB;
}
-
+
/**
* Bind parent. Only used for supervisor
*
@@ -214,11 +202,11 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
/**
* Apply styles from array
- *
+ *
*
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->getColor()->applyFromArray( array('rgb' => '808080') );
*
- *
+ *
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Color
@@ -240,7 +228,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get ARGB
*
@@ -252,7 +240,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
}
return $this->_argb;
}
-
+
/**
* Set ARGB
*
@@ -271,7 +259,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get RGB
*
@@ -283,7 +271,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
}
return substr($this->_argb, 2);
}
-
+
/**
* Set RGB
*
@@ -302,17 +290,17 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get indexed color
- *
+ *
* @param int $pIndex
* @return PHPExcel_Style_Color
*/
public static function indexedColor($pIndex) {
// Clean parameter
$pIndex = intval($pIndex);
-
+
// Indexed colors
if (is_null(self::$_indexedColors)) {
self::$_indexedColors = array();
@@ -381,11 +369,11 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
self::$_indexedColors[] = '00333399';
self::$_indexedColors[] = '00333333';
}
-
+
if (array_key_exists($pIndex, self::$_indexedColors)) {
return new PHPExcel_Style_Color(self::$_indexedColors[$pIndex]);
}
-
+
return new PHPExcel_Style_Color();
}
@@ -393,7 +381,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
@@ -403,7 +391,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Style/Conditional.php b/libraries/PHPExcel/PHPExcel/Style/Conditional.php
index e0520c8ec..83ab52b71 100644
--- a/libraries/PHPExcel/PHPExcel/Style/Conditional.php
+++ b/libraries/PHPExcel/PHPExcel/Style/Conditional.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,25 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Style */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style.php';
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-
/**
* PHPExcel_Style_Conditional
*
@@ -55,7 +40,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
const CONDITION_CELLIS = 'cellIs';
const CONDITION_CONTAINSTEXT = 'containsText';
const CONDITION_EXPRESSION = 'expression';
-
+
/* Operator types */
const OPERATOR_NONE = '';
const OPERATOR_BEGINSWITH = 'beginsWith';
@@ -69,42 +54,42 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
const OPERATOR_CONTAINSTEXT = 'containsText';
const OPERATOR_NOTCONTAINS = 'notContains';
const OPERATOR_BETWEEN = 'between';
-
+
/**
* Condition type
*
* @var int
*/
private $_conditionType;
-
+
/**
* Operator type
*
* @var int
*/
private $_operatorType;
-
+
/**
* Text
*
* @var string
*/
private $_text;
-
+
/**
* Condition
*
* @var string[]
*/
private $_condition = array();
-
+
/**
* Style
- *
+ *
* @var PHPExcel_Style
*/
private $_style;
-
+
/**
* Create a new PHPExcel_Style_Conditional
*/
@@ -117,7 +102,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
$this->_condition = array();
$this->_style = new PHPExcel_Style();
}
-
+
/**
* Get Condition type
*
@@ -126,7 +111,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function getConditionType() {
return $this->_conditionType;
}
-
+
/**
* Set Condition type
*
@@ -137,7 +122,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
$this->_conditionType = $pValue;
return $this;
}
-
+
/**
* Get Operator type
*
@@ -146,7 +131,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function getOperatorType() {
return $this->_operatorType;
}
-
+
/**
* Set Operator type
*
@@ -157,7 +142,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
$this->_operatorType = $pValue;
return $this;
}
-
+
/**
* Get text
*
@@ -166,7 +151,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function getText() {
return $this->_text;
}
-
+
/**
* Set text
*
@@ -177,7 +162,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
$this->_text = $value;
return $this;
}
-
+
/**
* Get Condition
*
@@ -188,10 +173,10 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
if (isset($this->_condition[0])) {
return $this->_condition[0];
}
-
+
return '';
}
-
+
/**
* Set Condition
*
@@ -202,10 +187,10 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function setCondition($pValue = '') {
if (!is_array($pValue))
$pValue = array($pValue);
-
+
return $this->setConditions($pValue);
}
-
+
/**
* Get Conditions
*
@@ -214,7 +199,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function getConditions() {
return $this->_condition;
}
-
+
/**
* Set Conditions
*
@@ -224,11 +209,11 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function setConditions($pValue) {
if (!is_array($pValue))
$pValue = array($pValue);
-
+
$this->_condition = $pValue;
return $this;
}
-
+
/**
* Add Condition
*
@@ -239,7 +224,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
$this->_condition[] = $pValue;
return $this;
}
-
+
/**
* Get Style
*
@@ -248,7 +233,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
public function getStyle() {
return $this->_style;
}
-
+
/**
* Set Style
*
@@ -265,7 +250,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
return md5(
$this->_conditionType
@@ -275,7 +260,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Style/Fill.php b/libraries/PHPExcel/PHPExcel/Style/Fill.php
index 2d5fbe102..ac8c75213 100644
--- a/libraries/PHPExcel/PHPExcel/Style/Fill.php
+++ b/libraries/PHPExcel/PHPExcel/Style/Fill.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,25 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Style_Color */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-
/**
* PHPExcel_Style_Fill
*
@@ -79,28 +64,28 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
* @var string
*/
private $_fillType;
-
+
/**
* Rotation
*
* @var double
*/
private $_rotation;
-
+
/**
* Start color
- *
+ *
* @var PHPExcel_Style_Color
*/
private $_startColor;
-
+
/**
* End color
- *
+ *
* @var PHPExcel_Style_Color
*/
private $_endColor;
-
+
/**
* Parent Borders
*
@@ -221,7 +206,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
/**
* Apply styles from array
- *
+ *
*
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFill()->applyFromArray(
* array(
@@ -236,7 +221,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
* )
* );
*
- *
+ *
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Fill
@@ -267,7 +252,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Fill Type
*
@@ -279,7 +264,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this->_fillType;
}
-
+
/**
* Set Fill Type
*
@@ -295,7 +280,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Rotation
*
@@ -307,7 +292,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this->_rotation;
}
-
+
/**
* Set Rotation
*
@@ -323,7 +308,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Start Color
*
@@ -332,7 +317,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
public function getStartColor() {
return $this->_startColor;
}
-
+
/**
* Set Start Color
*
@@ -343,7 +328,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
public function setStartColor(PHPExcel_Style_Color $pValue = null) {
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
-
+
if ($this->_isSupervisor) {
$styleArray = $this->getStartColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -352,7 +337,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get End Color
*
@@ -361,7 +346,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
public function getEndColor() {
return $this->_endColor;
}
-
+
/**
* Set End Color
*
@@ -372,7 +357,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
public function setEndColor(PHPExcel_Style_Color $pValue = null) {
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
-
+
if ($this->_isSupervisor) {
$styleArray = $this->getEndColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -386,7 +371,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
@@ -399,7 +384,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Style/Font.php b/libraries/PHPExcel/PHPExcel/Style/Font.php
index 2adaff11c..c415226e1 100644
--- a/libraries/PHPExcel/PHPExcel/Style/Font.php
+++ b/libraries/PHPExcel/PHPExcel/Style/Font.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,25 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_Style_Color */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-
/**
* PHPExcel_Style_Font
*
@@ -56,63 +41,63 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
const UNDERLINE_DOUBLEACCOUNTING = 'doubleAccounting';
const UNDERLINE_SINGLE = 'single';
const UNDERLINE_SINGLEACCOUNTING = 'singleAccounting';
-
+
/**
* Name
*
* @var string
*/
private $_name;
-
+
/**
* Bold
*
* @var boolean
*/
private $_bold;
-
+
/**
* Italic
*
* @var boolean
*/
private $_italic;
-
+
/**
* Superscript
*
* @var boolean
*/
private $_superScript;
-
+
/**
* Subscript
*
* @var boolean
*/
private $_subScript;
-
+
/**
* Underline
*
* @var string
*/
private $_underline;
-
+
/**
* Strikethrough
*
* @var boolean
*/
private $_strikethrough;
-
+
/**
* Foreground color
- *
+ *
* @var PHPExcel_Style_Color
*/
- private $_color;
-
+ private $_color;
+
/**
* Parent Borders
*
@@ -179,7 +164,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
{
return $this->_isSupervisor;
}
-
+
/**
* Get the shared style component for the currently active cell in currently active sheet.
* Only used for style supervisor
@@ -236,7 +221,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
/**
* Apply styles from array
- *
+ *
*
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray(
* array(
@@ -251,7 +236,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
* )
* );
*
- *
+ *
* @param array $pStyles Array containing style information
* @throws Exception
* @return PHPExcel_Style_Font
@@ -294,7 +279,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Name
*
@@ -306,7 +291,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_name;
}
-
+
/**
* Set Name
*
@@ -325,7 +310,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Size
*
@@ -337,7 +322,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_size;
}
-
+
/**
* Set Size
*
@@ -356,7 +341,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Bold
*
@@ -368,7 +353,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_bold;
}
-
+
/**
* Set Bold
*
@@ -387,7 +372,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Italic
*
@@ -399,7 +384,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_italic;
}
-
+
/**
* Set Italic
*
@@ -418,7 +403,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get SuperScript
*
@@ -430,7 +415,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_superScript;
}
-
+
/**
* Set SuperScript
*
@@ -450,7 +435,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get SubScript
*
@@ -462,7 +447,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_subScript;
}
-
+
/**
* Set SubScript
*
@@ -482,7 +467,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Underline
*
@@ -494,7 +479,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_underline;
}
-
+
/**
* Set Underline
*
@@ -513,7 +498,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Striketrough
*
@@ -523,7 +508,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
public function getStriketrough() {
return $this->getStrikethrough();
}
-
+
/**
* Set Striketrough
*
@@ -534,7 +519,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
public function setStriketrough($pValue = false) {
return $this->setStrikethrough($pValue);
}
-
+
/**
* Get Strikethrough
*
@@ -546,7 +531,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
}
return $this->_strikethrough;
}
-
+
/**
* Set Strikethrough
*
@@ -574,7 +559,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
public function getColor() {
return $this->_color;
}
-
+
/**
* Set Color
*
@@ -585,7 +570,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
public function setColor(PHPExcel_Style_Color $pValue = null) {
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
-
+
if ($this->_isSupervisor) {
$styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB()));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -599,7 +584,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
@@ -617,7 +602,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Style/NumberFormat.php b/libraries/PHPExcel/PHPExcel/Style/NumberFormat.php
index 83a8fc967..f6a406d61 100644
--- a/libraries/PHPExcel/PHPExcel/Style/NumberFormat.php
+++ b/libraries/PHPExcel/PHPExcel/Style/NumberFormat.php
@@ -22,28 +22,10 @@
* @package PHPExcel_Style
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-/** PHPExcel_Shared_Date */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
-
-/** PHPExcel_Calculation_Functions */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Functions.php';
-
-
/**
* PHPExcel_Style_NumberFormat
*
@@ -143,17 +125,17 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
private $_parent;
/**
- * Create a new PHPExcel_Style_NumberFormat
- */
- public function __construct($isSupervisor = false)
- {
- // Supervisor?
+ * Create a new PHPExcel_Style_NumberFormat
+ */
+ public function __construct($isSupervisor = false)
+ {
+ // Supervisor?
$this->_isSupervisor = $isSupervisor;
- // Initialise values
- $this->_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
- $this->_builtInFormatCode = 0;
- }
+ // Initialise values
+ $this->_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
+ $this->_builtInFormatCode = 0;
+ }
/**
* Bind parent. Only used for supervisor
@@ -230,22 +212,23 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
return array('numberformat' => $array);
}
- /**
- * Apply styles from array
- *
- *
- * $objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray(
- * array(
- * 'code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE
- * )
- * );
- *
- *
- * @param array $pStyles Array containing style information
- * @throws Exception
- * @return PHPExcel_Style_NumberFormat
- */
- public function applyFromArray($pStyles = null) {
+ /**
+ * Apply styles from array
+ *
+ *
+ * $objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray(
+ * array(
+ * 'code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE
+ * )
+ * );
+ *
+ *
+ * @param array $pStyles Array containing style information
+ * @throws Exception
+ * @return PHPExcel_Style_NumberFormat
+ */
+ public function applyFromArray($pStyles = null)
+ {
if (is_array($pStyles)) {
if ($this->_isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
@@ -260,32 +243,34 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
return $this;
}
- /**
- * Get Format Code
- *
- * @return string
- */
- public function getFormatCode() {
+ /**
+ * Get Format Code
+ *
+ * @return string
+ */
+ public function getFormatCode()
+ {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getFormatCode();
}
- if ($this->_builtInFormatCode !== false)
- {
- return self::builtInFormatCode($this->_builtInFormatCode);
- }
- return $this->_formatCode;
- }
+ if ($this->_builtInFormatCode !== false)
+ {
+ return self::builtInFormatCode($this->_builtInFormatCode);
+ }
+ return $this->_formatCode;
+ }
- /**
- * Set Format Code
- *
- * @param string $pValue
- * @return PHPExcel_Style_NumberFormat
- */
- public function setFormatCode($pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL) {
- if ($pValue == '') {
- $pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
- }
+ /**
+ * Set Format Code
+ *
+ * @param string $pValue
+ * @return PHPExcel_Style_NumberFormat
+ */
+ public function setFormatCode($pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL)
+ {
+ if ($pValue == '') {
+ $pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
+ }
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('code' => $pValue));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
@@ -294,27 +279,29 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
$this->_builtInFormatCode = self::builtInFormatCodeIndex($pValue);
}
return $this;
- }
+ }
/**
- * Get Built-In Format Code
- *
- * @return int
- */
- public function getBuiltInFormatCode() {
+ * Get Built-In Format Code
+ *
+ * @return int
+ */
+ public function getBuiltInFormatCode()
+ {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getBuiltInFormatCode();
}
- return $this->_builtInFormatCode;
- }
+ return $this->_builtInFormatCode;
+ }
- /**
- * Set Built-In Format Code
- *
- * @param int $pValue
- * @return PHPExcel_Style_NumberFormat
- */
- public function setBuiltInFormatCode($pValue = 0) {
+ /**
+ * Set Built-In Format Code
+ *
+ * @param int $pValue
+ * @return PHPExcel_Style_NumberFormat
+ */
+ public function setBuiltInFormatCode($pValue = 0)
+ {
if ($this->_isSupervisor) {
$styleArray = $this->getStyleArray(array('code' => self::builtInFormatCode($pValue)));
@@ -324,15 +311,15 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
$this->_formatCode = self::builtInFormatCode($pValue);
}
return $this;
- }
+ }
- /**
- * Fill built-in format codes
- */
- private static function fillBuiltInFormatCodes()
- {
- // Built-in format codes
- if (is_null(self::$_builtInFormats)) {
+ /**
+ * Fill built-in format codes
+ */
+ private static function fillBuiltInFormatCodes()
+ {
+ // Built-in format codes
+ if (is_null(self::$_builtInFormats)) {
self::$_builtInFormats = array();
// General
@@ -388,68 +375,72 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
// Flip array (for faster lookups)
self::$_flippedBuiltInFormats = array_flip(self::$_builtInFormats);
- }
- }
+ }
+ }
- /**
- * Get built-in format code
- *
- * @param int $pIndex
- * @return string
- */
- public static function builtInFormatCode($pIndex) {
- // Clean parameter
+ /**
+ * Get built-in format code
+ *
+ * @param int $pIndex
+ * @return string
+ */
+ public static function builtInFormatCode($pIndex)
+ {
+ // Clean parameter
$pIndex = intval($pIndex);
// Ensure built-in format codes are available
- self::fillBuiltInFormatCodes();
+ self::fillBuiltInFormatCodes();
// Lookup format code
if (array_key_exists($pIndex, self::$_builtInFormats)) {
return self::$_builtInFormats[$pIndex];
}
- return '';
- }
+ return '';
+ }
- /**
- * Get built-in format code index
- *
- * @param string $formatCode
- * @return int|boolean
- */
- public static function builtInFormatCodeIndex($formatCode) {
- // Ensure built-in format codes are available
- self::fillBuiltInFormatCodes();
+ /**
+ * Get built-in format code index
+ *
+ * @param string $formatCode
+ * @return int|boolean
+ */
+ public static function builtInFormatCodeIndex($formatCode)
+ {
+ // Ensure built-in format codes are available
+ self::fillBuiltInFormatCodes();
// Lookup format code
if (array_key_exists($formatCode, self::$_flippedBuiltInFormats)) {
return self::$_flippedBuiltInFormats[$formatCode];
}
- return false;
- }
+ return false;
+ }
/**
* Get hash code
*
* @return string Hash code
*/
- public function getHashCode() {
+ public function getHashCode()
+ {
if ($this->_isSupervisor) {
return $this->getSharedComponent()->getHashCode();
}
- return md5(
- $this->_formatCode
- . $this->_builtInFormatCode
- . __CLASS__
- );
- }
+ return md5(
+ $this->_formatCode
+ . $this->_builtInFormatCode
+ . __CLASS__
+ );
+ }
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
- public function __clone() {
+ public function __clone()
+ {
$vars = get_object_vars($this);
foreach ($vars as $key => $value) {
if (is_object($value)) {
@@ -511,7 +502,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
* @param array $callBack Callback function for additional formatting of string
* @return string Formatted string
*/
- public static function toFormattedString($value = '', $format = '', $callBack = null) {
+ public static function toFormattedString($value = '', $format = '', $callBack = null)
+ {
// For now we do not treat strings although section 4 of a format code affects strings
if (!is_numeric($value)) return $value;
@@ -587,7 +579,8 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
$format = strtr($format,self::$_dateFormatReplacements12);
}
- $value = gmdate($format, PHPExcel_Shared_Date::ExcelToPHP($value));
+ $dateObj = PHPExcel_Shared_Date::ExcelToPHPObject($value);
+ $value = $dateObj->format($format);
} else if (preg_match('/%$/', $format)) { // % number format
if ($format === self::FORMAT_PERCENTAGE) {
@@ -606,31 +599,44 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
}
} else {
- if (preg_match ("/^([0-9.,-]+)$/", $value)) {
- if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) {
- $value = 'EUR ' . sprintf('%1.2f', $value);
+ if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) {
+ $value = 'EUR ' . sprintf('%1.2f', $value);
- } else {
- // In Excel formats, "_" is used to add spacing, which we can't do in HTML
- $format = preg_replace('/_./', '', $format);
+ } else {
+ // In Excel formats, "_" is used to add spacing, which we can't do in HTML
+ $format = preg_replace('/_./', '', $format);
- // Some non-number characters are escaped with \, which we don't need
- $format = preg_replace("/\\\\/", '', $format);
+ // Some non-number characters are escaped with \, which we don't need
+ $format = preg_replace("/\\\\/", '', $format);
- // Some non-number strings are quoted, so we'll get rid of the quotes
- $format = preg_replace('/"/', '', $format);
+ // Some non-number strings are quoted, so we'll get rid of the quotes
+ $format = preg_replace('/"/', '', $format);
- // TEMPORARY - Convert # to 0
- $format = preg_replace('/\\#/', '0', $format);
+ // Find out if we need thousands separator
+ // This is indicated by a comma enclosed by a digit placeholder:
+ // #,# or 0,0
+ $useThousands = preg_match('/(#,#|0,0)/', $format);
+ if ($useThousands) {
+ $format = preg_replace('/0,0/', '00', $format);
+ $format = preg_replace('/#,#/', '##', $format);
+ }
- // Find out if we need thousands separator
- $useThousands = preg_match('/,/', $format);
- if ($useThousands) {
- $format = preg_replace('/,/', '', $format);
- }
+ // Scale thousands, millions,...
+ // This is indicated by a number of commas after a digit placeholder:
+ // #, or 0.0,,
+ $scale = 1; // same as no scale
+ $matches = array();
+ if (preg_match('/(#|0)(,+)/', $format, $matches)) {
+ $scale = pow(1000, strlen($matches[2]));
- if (preg_match('/0?.*\?\/\?/', $format, $m)) {
- //echo 'Format mask is fractional '.$format.'
';
+ // strip the commas
+ $format = preg_replace('/0,+/', '0', $format);
+ $format = preg_replace('/#,+/', '#', $format);
+ }
+
+ if (preg_match('/#?.*\?\/\?/', $format, $m)) {
+ //echo 'Format mask is fractional '.$format.'
';
+ if ($value != (int)$value) {
$sign = ($value < 0) ? '-' : '';
$integerPart = floor(abs($value));
@@ -650,28 +656,41 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
$adjustedDecimalPart += $integerPart * $adjustedDecimalDivisor;
$value = "$sign$adjustedDecimalPart/$adjustedDecimalDivisor";
}
+ }
- } else {
- // Handle the number itself
- $number_regex = "/(\d+)(\.?)(\d*)/";
- if (preg_match($number_regex, $format, $matches)) {
- $left = $matches[1];
- $dec = $matches[2];
- $right = $matches[3];
- if ($useThousands) {
- $value = number_format(
- $value
- , strlen($right)
- , PHPExcel_Shared_String::getDecimalSeparator()
- , PHPExcel_Shared_String::getThousandsSeparator()
- );
+ } else {
+ // Handle the number itself
- } else {
- $sprintf_pattern = "%1." . strlen($right) . "f";
- $value = sprintf($sprintf_pattern, $value);
- }
- $value = preg_replace($number_regex, $value, $format);
+ // scale number
+ $value = $value / $scale;
+
+ // Strip #
+ $format = preg_replace('/\\#/', '', $format);
+
+ $number_regex = "/(0+)(\.?)(0*)/";
+ $matches = array();
+ if (preg_match($number_regex, $format, $matches)) {
+ $left = $matches[1];
+ $dec = $matches[2];
+ $right = $matches[3];
+
+ // minimun width of formatted number (including dot)
+ $minWidth = strlen($left) + strlen($dec) + strlen($right);
+
+ if ($useThousands) {
+ $value = number_format(
+ $value
+ , strlen($right)
+ , PHPExcel_Shared_String::getDecimalSeparator()
+ , PHPExcel_Shared_String::getThousandsSeparator()
+ );
+
+ } else {
+ $sprintf_pattern = "%0$minWidth." . strlen($right) . "f";
+ $value = sprintf($sprintf_pattern, $value);
}
+
+ $value = preg_replace($number_regex, $value, $format);
}
}
}
@@ -685,4 +704,5 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
return $value;
}
+
}
diff --git a/libraries/PHPExcel/PHPExcel/Style/Protection.php b/libraries/PHPExcel/PHPExcel/Style/Protection.php
index 12611d13b..1c7070200 100644
--- a/libraries/PHPExcel/PHPExcel/Style/Protection.php
+++ b/libraries/PHPExcel/PHPExcel/Style/Protection.php
@@ -26,18 +26,6 @@
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-
/**
* PHPExcel_Style_Protection
*
@@ -276,7 +264,7 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet.php b/libraries/PHPExcel/PHPExcel/Worksheet.php
index 74bd65266..74b70b756 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet.php
@@ -22,94 +22,10 @@
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
-}
-
-/** PHPExcel */
-require_once PHPEXCEL_ROOT . 'PHPExcel.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Cell_DataType */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
-
-/** PHPExcel_Worksheet_RowDimension */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/RowDimension.php';
-
-/** PHPExcel_Worksheet_ColumnDimension */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/ColumnDimension.php';
-
-/** PHPExcel_Worksheet_PageSetup */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/PageSetup.php';
-
-/** PHPExcel_Worksheet_PageMargins */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/PageMargins.php';
-
-/** PHPExcel_Worksheet_HeaderFooter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/HeaderFooter.php';
-
-/** PHPExcel_Worksheet_BaseDrawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/BaseDrawing.php';
-
-/** PHPExcel_Worksheet_Drawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing.php';
-
-/** PHPExcel_Worksheet_MemoryDrawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/MemoryDrawing.php';
-
-/** PHPExcel_Worksheet_HeaderFooterDrawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/HeaderFooterDrawing.php';
-
-/** PHPExcel_Worksheet_SheetView */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/SheetView.php';
-
-/** PHPExcel_Worksheet_Protection */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Protection.php';
-
-/** PHPExcel_Worksheet_RowIterator */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/RowIterator.php';
-
-/** PHPExcel_Comment */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Comment.php';
-
-/** PHPExcel_Style */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style.php';
-
-/** PHPExcel_Style_Fill */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Fill.php';
-
-/** PHPExcel_Style_Color */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
-
-/** PHPExcel_Style_NumberFormat */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-/** PHPExcel_Shared_Font */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Font.php';
-
-/** PHPExcel_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-/** PHPExcel_Shared_PasswordHasher */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PasswordHasher.php';
-
-/** PHPExcel_ReferenceHelper */
-require_once PHPEXCEL_ROOT . 'PHPExcel/ReferenceHelper.php';
-
-
/**
* PHPExcel_Worksheet
*
@@ -123,12 +39,19 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
const BREAK_NONE = 0;
const BREAK_ROW = 1;
const BREAK_COLUMN = 2;
-
+
/* Sheet state */
const SHEETSTATE_VISIBLE = 'visible';
const SHEETSTATE_HIDDEN = 'hidden';
const SHEETSTATE_VERYHIDDEN = 'veryHidden';
+ /**
+ * Invalid characters in sheet title
+ *
+ * @var array
+ */
+ private static $_invalidCharacters = array('*', ':', '/', '\\', '?', '[', ']');
+
/**
* Parent spreadsheet
*
@@ -137,11 +60,11 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
private $_parent;
/**
- * Collection of cells
+ * Cacheable collection of cells
*
- * @var PHPExcel_Cell[]
+ * @var PHPExcel_CachedObjectStorage_xxx
*/
- private $_cellCollection = array();
+ private $_cellCollection = null;
/**
* Collection of row dimensions
@@ -184,7 +107,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @var string
*/
private $_title;
-
+
/**
* Sheet state
*
@@ -297,6 +220,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
private $_printGridlines = false;
+ /**
+ * Show row and column headers?
+ *
+ * @var boolean
+ */
+ private $_showRowColHeaders = true;
+
/**
* Show summary below? (Row/Column outline)
*
@@ -387,6 +317,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->setTitle($pTitle);
$this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE);
+ $this->_cellCollection = PHPExcel_CachedObjectStorageFactory::getInstance($this);
+
// Set page setup
$this->_pageSetup = new PHPExcel_Worksheet_PageSetup();
@@ -420,6 +352,35 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(null);
}
+
+ public function disconnectCells() {
+ $this->_cellCollection->unsetWorksheetCells();
+ $this->_cellCollection = null;
+
+ // detach ourself from the workbook, so that it can then delete this worksheet successfully
+ $this->_parent = null;
+ }
+
+ /**
+ * Return the cache controller for the cell collection
+ *
+ * @return PHPExcel_CachedObjectStorage_xxx
+ */
+ public function getCellCacheController() {
+ return $this->_cellCollection;
+ } // function getCellCacheController()
+
+
+ /**
+ * Get array of invalid characters for sheet title
+ *
+ * @return array
+ */
+ public static function getInvalidCharacters()
+ {
+ return self::$_invalidCharacters;
+ }
+
/**
* Check sheet title for valid Excel syntax
*
@@ -430,7 +391,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
private static function _checkSheetTitle($pValue)
{
// Some of the printable ASCII characters are invalid: * : / \ ? [ ]
- if (preg_match('/(\\*|\\:|\\/|\\\\|\\?|\\[|\\])/', $pValue)) {
+ if (str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) {
throw new Exception('Invalid character found in sheet title');
}
@@ -455,7 +416,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->sortCellCollection();
}
- return $this->_cellCollection;
+ if (is_null($this->_cellCollection)) {
+ return array();
+ }
+ return $this->_cellCollection->getCellList();
}
/**
@@ -466,29 +430,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function sortCellCollection()
{
if (!$this->_cellCollectionIsSorted) {
- // Re-order cell collection
- // uasort($this->_cellCollection, array('PHPExcel_Cell', 'compareCells')); <-- slow
-
- $indexed = array();
- foreach (array_keys($this->_cellCollection) as $index) {
- $rowNum = $this->_cellCollection[$index]->getRow();
- $colNum = PHPExcel_Cell::columnIndexFromString($this->_cellCollection[$index]->getColumn());
-
- // Columns are limited to ZZZ (18278), so 20000 is plenty to assure no conflicts
- $key = $rowNum * 20000 + $colNum;
-
- $indexed[$key] = $index; // &$this->_cellCollection[$index];
+ if (!is_null($this->_cellCollection)) {
+ $this->_cellCollection->sortCellList();
}
- ksort($indexed);
-
- // Rebuild cellCollection from the sorted index
- $newCellCollection = array();
- foreach ($indexed as $index) {
- $newCellCollection[$index] = $this->_cellCollection[$index];
- }
-
- $this->_cellCollection = $newCellCollection;
-
$this->_cellCollectionIsSorted = true;
}
return $this;
@@ -610,31 +554,38 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
}
// There is only something to do if there are some auto-size columns
- if (count($autoSizes) > 0) {
- // loop though all cells in sheet expand $autoSizes
- foreach ($this->getCellCollection(false) as $cell) {
+ if (!empty($autoSizes)) {
+
+ // build list of cells references that participate in a merge
+ $isMergeCell = array();
+ foreach ($this->getMergeCells() as $cells) {
+ foreach (PHPExcel_Cell::extractAllCellReferencesInRange($cells) as $cellReference) {
+ $isMergeCell[$cellReference] = true;
+ }
+ }
+
+ // loop through all cells in the worksheet
+ foreach ($this->getCellCollection(false) as $cellID) {
+ $cell = $this->getCell($cellID);
if (isset($autoSizes[$cell->getColumn()])) {
- // Calculated value
- $cellValue = $cell->getCalculatedValue();
+ // Determine width if cell does not participate in a merge
+ if (!isset($isMergeCell[$cell->getCoordinate()])) {
+ // Calculated value
+ $cellValue = $cell->getCalculatedValue();
- // To formatted string
- $cellValue = PHPExcel_Style_NumberFormat::toFormattedString($cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode());
+ // To formatted string
+ $cellValue = PHPExcel_Style_NumberFormat::toFormattedString($cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode());
- foreach ($this->getMergeCells() as $cells) {
- if ($cell->isInRange($cells) && !$calculateMergeCells) {
- $cellValue = ''; // do not calculate merge cells
- }
+ $autoSizes[$cell->getColumn()] = max(
+ (float)$autoSizes[$cell->getColumn()],
+ (float)PHPExcel_Shared_Font::calculateColumnWidth(
+ $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
+ $cellValue,
+ $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
+ $this->getDefaultStyle()->getFont()
+ )
+ );
}
-
- $autoSizes[$cell->getColumn()] = max(
- (float)$autoSizes[$cell->getColumn()],
- (float)PHPExcel_Shared_Font::calculateColumnWidth(
- $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
- $cellValue,
- $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
- $this->getDefaultStyle()->getFont()
- )
- );
}
}
@@ -730,7 +681,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
return $this;
}
-
+
/**
* Get sheet state
*
@@ -739,7 +690,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function getSheetState() {
return $this->_sheetState;
}
-
+
/**
* Set sheet state
*
@@ -750,7 +701,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->_sheetState = $value;
return $this;
}
-
+
/**
* Get page setup
*
@@ -906,7 +857,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 0, $pValue = null)
{
- return $this->setCellValue(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow, $pValue);
+ return $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValue($pValue);
}
/**
@@ -935,7 +886,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 0, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{
- return $this->setCellValueExplicit(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow, $pValue, $pDataType);
+ return $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValueExplicit($pValue, $pDataType);
}
/**
@@ -948,8 +899,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function getCell($pCoordinate = 'A1')
{
// Check cell collection
- if (isset($this->_cellCollection[$pCoordinate])) {
- return $this->_cellCollection[$pCoordinate];
+ if ($this->_cellCollection->isDataSet($pCoordinate)) {
+ return $this->_cellCollection->getCacheData($pCoordinate);
}
// Worksheet reference?
@@ -964,16 +915,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
if (!is_null($namedRange)) {
$pCoordinate = $namedRange->getRange();
- if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) {
- if (!$namedRange->getLocalOnly()) {
- return $namedRange->getWorksheet()->getCell($pCoordinate);
- } else {
- throw new Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle());
- }
- } else {
- //Allow named ranges within the same sheet.
- return $this->getCell($pCoordinate);
- }
+ return $namedRange->getWorksheet()->getCell($pCoordinate);
}
}
@@ -990,7 +932,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Coordinates
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
- $this->_cellCollection[$pCoordinate] = new PHPExcel_Cell($aCoordinates[0], $aCoordinates[1], null, PHPExcel_Cell_DataType::TYPE_NULL, $this);
+ $cell = $this->_cellCollection->addCacheData($pCoordinate,new PHPExcel_Cell($aCoordinates[0], $aCoordinates[1], null, PHPExcel_Cell_DataType::TYPE_NULL, $this));
$this->_cellCollectionIsSorted = false;
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
@@ -1005,18 +947,16 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if ( isset($rowDimensions[$aCoordinates[1]]) && $rowDimensions[$aCoordinates[1]]->getXfIndex() !== null ) {
// then there is a row dimension with explicit style, assign it to the cell
- $this->_cellCollection[$pCoordinate]->setXfIndex($rowDimensions[$aCoordinates[1]]->getXfIndex());
-
+ $cell->setXfIndex($rowDimensions[$aCoordinates[1]]->getXfIndex());
} else if ( isset($columnDimensions[$aCoordinates[0]]) ) {
// then there is a column dimension, assign it to the cell
- $this->_cellCollection[$pCoordinate]->setXfIndex($columnDimensions[$aCoordinates[0]]->getXfIndex());
-
+ $cell->setXfIndex($columnDimensions[$aCoordinates[0]]->getXfIndex());
} else {
// set to default index
- $this->_cellCollection[$pCoordinate]->setXfIndex(0);
+ $cell->setXfIndex(0);
}
- return $this->_cellCollection[$pCoordinate];
+ return $cell;
}
}
@@ -1029,22 +969,23 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function getCellByColumnAndRow($pColumn = 0, $pRow = 0)
{
- $coordinate = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow;
+ $columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
+ $coordinate = $columnLetter . $pRow;
- if (!isset($this->_cellCollection[$coordinate])) {
- $columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
-
- $this->_cellCollection[$coordinate] = new PHPExcel_Cell($columnLetter, $pRow, null, PHPExcel_Cell_DataType::TYPE_NULL, $this);
+ if (!$this->_cellCollection->isDataSet($coordinate)) {
+ $cell = $this->_cellCollection->addCacheData($coordinate, new PHPExcel_Cell($columnLetter, $pRow, null, PHPExcel_Cell_DataType::TYPE_NULL, $this));
$this->_cellCollectionIsSorted = false;
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn)
- $this->_cachedHighestColumn = $pColumn;
+ $this->_cachedHighestColumn = $columnLetter;
if ($this->_cachedHighestRow < $pRow)
$this->_cachedHighestRow = $pRow;
+
+ return $cell;
}
- return $this->_cellCollection[$coordinate];
+ return $this->_cellCollection->getCacheData($coordinate);
}
/**
@@ -1090,7 +1031,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
// Cell exists?
- return isset($this->_cellCollection[$pCoordinate]);
+ return $this->_cellCollection->isDataSet($pCoordinate);
}
}
@@ -1455,6 +1396,24 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if (strpos($pRange,':') !== false) {
$this->_mergeCells[$pRange] = $pRange;
+
+ // make sure cells are created
+
+ // get the cells in the range
+ $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
+
+ // create upper left cell if it does not already exist
+ $upperLeft = $aReferences[0];
+ if (!$this->cellExists($upperLeft)) {
+ $this->getCell($upperLeft)->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL);
+ }
+
+ // create or blank out the rest of the cells in the range
+ $count = count($aReferences);
+ for ($i = 1; $i < $count; $i++) {
+ $this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL);
+ }
+
} else {
throw new Exception('Merge must be set on a range of cells.');
}
@@ -1533,7 +1492,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* Set merge cells array for the entire sheet. Use instead mergeCells() to merge
* a single cell range.
*
- * @param array
+ * @param array
*/
public function setMergeCells($pValue = array())
{
@@ -1877,6 +1836,26 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
return $this;
}
+ /**
+ * Show row and column headers?
+ *
+ * @return boolean
+ */
+ public function getShowRowColHeaders() {
+ return $this->_showRowColHeaders;
+ }
+
+ /**
+ * Set show row and column headers
+ *
+ * @param boolean $pValue Show row and column headers (true/false)
+ * @return PHPExcel_Worksheet
+ */
+ public function setShowRowColHeaders($pValue = false) {
+ $this->_showRowColHeaders = $pValue;
+ return $this;
+ }
+
/**
* Show summary below? (Row/Column outlining)
*
@@ -2083,7 +2062,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* Fill worksheet from values in array
*
* @param array $source Source array
- * @param mixed $nullValue Value treated as "null"
+ * @param mixed $nullValue Value in source array that stands for blank cell
* @throws Exception
* @return PHPExcel_Worksheet
*/
@@ -2103,9 +2082,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
for ($i = 0; $i < $rowCount; ++$i) {
if ($rowData[$i] != $nullValue) {
// Set cell value
- $this->setCellValue(
- PHPExcel_Cell::stringFromColumnIndex($i + $startColumn) . $currentRow, $rowData[$i]
- );
+ $this->getCell(PHPExcel_Cell::stringFromColumnIndex($i + $startColumn) . $currentRow)
+ ->setValue($rowData[$i]);
}
}
}
@@ -2195,17 +2173,20 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$highestRow = 1;
// Find cells that can be cleaned
- foreach ($this->_cellCollection as $coordinate => $cell) {
+ foreach ($this->_cellCollection->getCellList() as $coordinate) {
+ $cell = $this->getCell($coordinate);
// Can be cleaned?
$canBeCleaned = false;
- // Empty value?
+ /* Excel doesn't remove such empty cells
+ // Empty value?
if (is_null($cell->getValue()) || (!is_object($cell->getValue()) && $cell->getValue() === '' && !$cell->hasHyperlink())) {
// default style ?
if ($cell->getXfIndex() == 0) {
$canBeCleaned = true;
}
}
+ */
// Referenced in image?
if (isset($imageCoordinates[$coordinate]) && $imageCoordinates[$coordinate] === true) {
@@ -2215,7 +2196,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Clean?
if ($canBeCleaned) {
// Remove the cell
- unset($this->_cellCollection[$coordinate]);
+ $this->_cellCollection->deleteCacheData($coordinate);
} else {
// Determine highest column and row
if ($highestColumn < PHPExcel_Cell::columnIndexFromString($cell->getColumn())) {
@@ -2319,8 +2300,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
}
// else create hyperlink
- $cell = $this->getCell($pCellCoordinate);
- $this->_hyperlinkCollection[$pCellCoordinate] = new PHPExcel_Cell_Hyperlink($cell);
+ $this->_hyperlinkCollection[$pCellCoordinate] = new PHPExcel_Cell_Hyperlink();
return $this->_hyperlinkCollection[$pCellCoordinate];
}
@@ -2337,7 +2317,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
unset($this->_hyperlinkCollection[$pCellCoordinate]);
} else {
$this->_hyperlinkCollection[$pCellCoordinate] = $pHyperlink;
- $pHyperlink->setParent($this->getCell($pCellCoordinate));
}
return $this;
}
@@ -2376,8 +2355,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
}
// else create data validation
- $cell = $this->getCell($pCellCoordinate);
- $this->_dataValidationCollection[$pCellCoordinate] = new PHPExcel_Cell_DataValidation($cell);
+ $this->_dataValidationCollection[$pCellCoordinate] = new PHPExcel_Cell_DataValidation();
return $this->_dataValidationCollection[$pCellCoordinate];
}
@@ -2394,7 +2372,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
unset($this->_dataValidationCollection[$pCellCoordinate]);
} else {
$this->_dataValidationCollection[$pCellCoordinate] = $pDataValidation;
- $pDataValidation->setParent($this->getCell($pCellCoordinate));
}
return $this;
}
@@ -2420,6 +2397,34 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
return $this->_dataValidationCollection;
}
+ /**
+ * Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet
+ *
+ * @param string $range
+ * @return string Adjusted range value
+ */
+ public function shrinkRangeToFit($range) {
+ $maxCol = $this->getHighestColumn();
+ $maxRow = $this->getHighestRow();
+ $maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
+
+ $rangeBlocks = explode(' ',$range);
+ foreach ($rangeBlocks as &$rangeSet) {
+ $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet);
+
+ if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) { $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); }
+ if ($rangeBoundaries[0][1] > $maxRow) { $rangeBoundaries[0][1] = $maxRow; }
+ if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) { $rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); }
+ if ($rangeBoundaries[1][1] > $maxRow) { $rangeBoundaries[1][1] = $maxRow; }
+ $rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1];
+ }
+ unset($rangeSet);
+ $stRange = implode(' ',$rangeBlocks);
+
+ return $stRange;
+ }
+
+
/**
* Get tab color
*
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/BaseDrawing.php b/libraries/PHPExcel/PHPExcel/Worksheet/BaseDrawing.php
index 79f8c1611..efc04bcbd 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/BaseDrawing.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/BaseDrawing.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,27 +22,10 @@
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-/** PHPExcel_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Worksheet_Drawing_Shadow */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
-
/**
* PHPExcel_Worksheet_BaseDrawing
*
@@ -51,98 +34,98 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
-{
+{
/**
* Image counter
*
* @var int
*/
private static $_imageCounter = 0;
-
+
/**
* Image index
*
* @var int
*/
private $_imageIndex = 0;
-
+
/**
* Name
*
* @var string
*/
protected $_name;
-
+
/**
* Description
*
* @var string
*/
protected $_description;
-
+
/**
* Worksheet
*
* @var PHPExcel_Worksheet
*/
protected $_worksheet;
-
+
/**
* Coordinates
*
* @var string
*/
protected $_coordinates;
-
+
/**
* Offset X
*
* @var int
*/
protected $_offsetX;
-
+
/**
* Offset Y
*
* @var int
*/
protected $_offsetY;
-
+
/**
* Width
*
* @var int
*/
protected $_width;
-
+
/**
* Height
*
* @var int
*/
protected $_height;
-
+
/**
* Proportional resize
*
* @var boolean
*/
protected $_resizeProportional;
-
+
/**
* Rotation
*
* @var int
*/
protected $_rotation;
-
+
/**
* Shadow
*
* @var PHPExcel_Worksheet_Drawing_Shadow
*/
- protected $_shadow;
-
+ protected $_shadow;
+
/**
* Create a new PHPExcel_Worksheet_BaseDrawing
*/
@@ -160,12 +143,12 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_resizeProportional = true;
$this->_rotation = 0;
$this->_shadow = new PHPExcel_Worksheet_Drawing_Shadow();
-
+
// Set image index
self::$_imageCounter++;
$this->_imageIndex = self::$_imageCounter;
}
-
+
/**
* Get image index
*
@@ -174,7 +157,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getImageIndex() {
return $this->_imageIndex;
}
-
+
/**
* Get Name
*
@@ -183,7 +166,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getName() {
return $this->_name;
}
-
+
/**
* Set Name
*
@@ -194,7 +177,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_name = $pValue;
return $this;
}
-
+
/**
* Get Description
*
@@ -203,7 +186,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getDescription() {
return $this->_description;
}
-
+
/**
* Set Description
*
@@ -223,7 +206,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getWorksheet() {
return $this->_worksheet;
}
-
+
/**
* Set Worksheet
*
@@ -242,7 +225,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
if ($pOverrideOld) {
// Remove drawing from old PHPExcel_Worksheet
$iterator = $this->_worksheet->getDrawingCollection()->getIterator();
-
+
while ($iterator->valid()) {
if ($iterator->current()->getHashCode() == $this->getHashCode()) {
$this->_worksheet->getDrawingCollection()->offsetUnset( $iterator->key() );
@@ -250,7 +233,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
break;
}
}
-
+
// Set new PHPExcel_Worksheet
$this->setWorksheet($pValue);
} else {
@@ -259,7 +242,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get Coordinates
*
@@ -267,8 +250,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
*/
public function getCoordinates() {
return $this->_coordinates;
- }
-
+ }
+
/**
* Set Coordinates
*
@@ -279,7 +262,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_coordinates = $pValue;
return $this;
}
-
+
/**
* Get OffsetX
*
@@ -288,7 +271,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getOffsetX() {
return $this->_offsetX;
}
-
+
/**
* Set OffsetX
*
@@ -299,7 +282,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_offsetX = $pValue;
return $this;
}
-
+
/**
* Get OffsetY
*
@@ -308,7 +291,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getOffsetY() {
return $this->_offsetY;
}
-
+
/**
* Set OffsetY
*
@@ -319,7 +302,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_offsetY = $pValue;
return $this;
}
-
+
/**
* Get Width
*
@@ -328,7 +311,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getWidth() {
return $this->_width;
}
-
+
/**
* Set Width
*
@@ -338,16 +321,16 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function setWidth($pValue = 0) {
// Resize proportional?
if ($this->_resizeProportional && $pValue != 0) {
- $ratio = $this->_height / $this->_width;
+ $ratio = $this->_height / $this->_width;
$this->_height = round($ratio * $pValue);
}
-
+
// Set width
$this->_width = $pValue;
-
+
return $this;
}
-
+
/**
* Get Height
*
@@ -356,7 +339,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getHeight() {
return $this->_height;
}
-
+
/**
* Set Height
*
@@ -366,16 +349,16 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function setHeight($pValue = 0) {
// Resize proportional?
if ($this->_resizeProportional && $pValue != 0) {
- $ratio = $this->_width / $this->_height;
+ $ratio = $this->_width / $this->_height;
$this->_width = round($ratio * $pValue);
}
-
+
// Set height
$this->_height = $pValue;
-
+
return $this;
}
-
+
/**
* Set width and height with proportional resize
* Example:
@@ -403,7 +386,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
}
return $this;
}
-
+
/**
* Get ResizeProportional
*
@@ -412,7 +395,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getResizeProportional() {
return $this->_resizeProportional;
}
-
+
/**
* Set ResizeProportional
*
@@ -423,7 +406,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_resizeProportional = $pValue;
return $this;
}
-
+
/**
* Get Rotation
*
@@ -432,7 +415,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getRotation() {
return $this->_rotation;
}
-
+
/**
* Set Rotation
*
@@ -443,7 +426,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
$this->_rotation = $pValue;
return $this;
}
-
+
/**
* Get Shadow
*
@@ -452,7 +435,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
public function getShadow() {
return $this->_shadow;
}
-
+
/**
* Set Shadow
*
@@ -469,7 +452,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
return md5(
$this->_name
@@ -485,7 +468,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/CellIterator.php b/libraries/PHPExcel/PHPExcel/Worksheet/CellIterator.php
index f0683e6e4..4786997b8 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/CellIterator.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/CellIterator.php
@@ -22,38 +22,20 @@
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel */
-require_once PHPEXCEL_ROOT . 'PHPExcel.php';
-
-/** PHPExcel_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-
/**
* PHPExcel_Worksheet_CellIterator
- *
+ *
* Used to iterate rows in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
-class PHPExcel_Worksheet_CellIterator extends IteratorIterator
+class PHPExcel_Worksheet_CellIterator extends CachingIterator
{
/**
* PHPExcel_Worksheet to iterate
@@ -61,21 +43,21 @@ class PHPExcel_Worksheet_CellIterator extends IteratorIterator
* @var PHPExcel_Worksheet
*/
private $_subject;
-
+
/**
* Row index
*
* @var int
*/
private $_rowIndex;
-
+
/**
* Current iterator position
*
* @var int
*/
private $_position = 0;
-
+
/**
* Loop only existing cells
*
@@ -94,14 +76,14 @@ class PHPExcel_Worksheet_CellIterator extends IteratorIterator
$this->_subject = $subject;
$this->_rowIndex = $rowIndex;
}
-
+
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
-
+
/**
* Rewind iterator
*/
@@ -158,7 +140,7 @@ class PHPExcel_Worksheet_CellIterator extends IteratorIterator
return $this->_position < $columnCount;
}
-
+
/**
* Get loop only existing cells
*
@@ -167,7 +149,7 @@ class PHPExcel_Worksheet_CellIterator extends IteratorIterator
public function getIterateOnlyExistingCells() {
return $this->_onlyExistingCells;
}
-
+
/**
* Set loop only existing cells
*
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/ColumnDimension.php b/libraries/PHPExcel/PHPExcel/Worksheet/ColumnDimension.php
index 7b6810fbf..45233726c 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/ColumnDimension.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/ColumnDimension.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/Drawing.php b/libraries/PHPExcel/PHPExcel/Worksheet/Drawing.php
index e6f84e226..fcdece002 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/Drawing.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/Drawing.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,31 +22,10 @@
* @package PHPExcel_Worksheet_Drawing
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-/** PHPExcel_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Worksheet_BaseDrawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/BaseDrawing.php';
-
-/** PHPExcel_Worksheet_Drawing_Shadow */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
-
-
/**
* PHPExcel_Worksheet_Drawing
*
@@ -54,15 +33,15 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
* @package PHPExcel_Worksheet_Drawing
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
-class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
-{
+class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
+{
/**
* Path
*
* @var string
*/
private $_path;
-
+
/**
* Create a new PHPExcel_Worksheet_Drawing
*/
@@ -70,11 +49,11 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
{
// Initialise values
$this->_path = '';
-
+
// Initialize parent
parent::__construct();
}
-
+
/**
* Get Filename
*
@@ -83,7 +62,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
public function getFilename() {
return basename($this->_path);
}
-
+
/**
* Get indexed filename (using image index)
*
@@ -94,7 +73,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
$fileName = str_replace(' ', '_', $fileName);
return str_replace('.' . $this->getExtension(), '', $fileName) . $this->getImageIndex() . '.' . $this->getExtension();
}
-
+
/**
* Get Extension
*
@@ -104,7 +83,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
$exploded = explode(".", basename($this->_path));
return $exploded[count($exploded) - 1];
}
-
+
/**
* Get Path
*
@@ -113,7 +92,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
public function getPath() {
return $this->_path;
}
-
+
/**
* Set Path
*
@@ -126,7 +105,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
if ($pVerifyFile) {
if (file_exists($pValue)) {
$this->_path = $pValue;
-
+
if ($this->_width == 0 && $this->_height == 0) {
// Get width/height
list($this->_width, $this->_height) = getimagesize($pValue);
@@ -144,7 +123,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
return md5(
$this->_path
@@ -152,7 +131,7 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/Drawing/Shadow.php b/libraries/PHPExcel/PHPExcel/Worksheet/Drawing/Shadow.php
index a294e5a0e..1ee8262c2 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/Drawing/Shadow.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/Drawing/Shadow.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,27 +22,10 @@
* @package PHPExcel_Worksheet_Drawing
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
-}
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-/** PHPExcel_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Style_Color */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
-
/**
* PHPExcel_Worksheet_Drawing_Shadow
*
@@ -51,7 +34,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
-{
+{
/* Shadow alignment */
const SHADOW_BOTTOM = 'b';
const SHADOW_BOTTOM_LEFT = 'bl';
@@ -60,7 +43,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
const SHADOW_LEFT = 'l';
const SHADOW_TOP = 't';
const SHADOW_TOP_LEFT = 'tl';
- const SHADOW_TOP_RIGHT = 'tr';
+ const SHADOW_TOP_RIGHT = 'tr';
/**
* Visible
@@ -68,7 +51,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
* @var boolean
*/
private $_visible;
-
+
/**
* Blur radius
*
@@ -77,7 +60,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
* @var int
*/
private $_blurRadius;
-
+
/**
* Shadow distance
*
@@ -86,35 +69,35 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
* @var int
*/
private $_distance;
-
+
/**
* Shadow direction (in degrees)
*
* @var int
*/
private $_direction;
-
+
/**
* Shadow alignment
*
* @var int
*/
private $_alignment;
-
+
/**
* Color
- *
+ *
* @var PHPExcel_Style_Color
*/
private $_color;
-
+
/**
* Alpha
*
* @var int
*/
private $_alpha;
-
+
/**
* Create a new PHPExcel_Worksheet_Drawing_Shadow
*/
@@ -129,7 +112,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_color = new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_BLACK);
$this->_alpha = 50;
}
-
+
/**
* Get Visible
*
@@ -138,7 +121,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getVisible() {
return $this->_visible;
}
-
+
/**
* Set Visible
*
@@ -149,7 +132,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_visible = $pValue;
return $this;
}
-
+
/**
* Get Blur radius
*
@@ -158,7 +141,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getBlurRadius() {
return $this->_blurRadius;
}
-
+
/**
* Set Blur radius
*
@@ -169,7 +152,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_blurRadius = $pValue;
return $this;
}
-
+
/**
* Get Shadow distance
*
@@ -178,7 +161,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getDistance() {
return $this->_distance;
}
-
+
/**
* Set Shadow distance
*
@@ -189,7 +172,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_distance = $pValue;
return $this;
}
-
+
/**
* Get Shadow direction (in degrees)
*
@@ -198,7 +181,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getDirection() {
return $this->_direction;
}
-
+
/**
* Set Shadow direction (in degrees)
*
@@ -209,7 +192,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_direction = $pValue;
return $this;
}
-
+
/**
* Get Shadow alignment
*
@@ -218,7 +201,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getAlignment() {
return $this->_alignment;
}
-
+
/**
* Set Shadow alignment
*
@@ -229,7 +212,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_alignment = $pValue;
return $this;
}
-
+
/**
* Get Color
*
@@ -238,7 +221,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getColor() {
return $this->_color;
}
-
+
/**
* Set Color
*
@@ -250,7 +233,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
$this->_color = $pValue;
return $this;
}
-
+
/**
* Get Alpha
*
@@ -259,7 +242,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
public function getAlpha() {
return $this->_alpha;
}
-
+
/**
* Set Alpha
*
@@ -275,7 +258,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
return md5(
($this->_visible ? 't' : 'f')
@@ -288,7 +271,7 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/HeaderFooter.php b/libraries/PHPExcel/PHPExcel/Worksheet/HeaderFooter.php
index ef60e77a9..eb33cc246 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/HeaderFooter.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/HeaderFooter.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,22 +22,10 @@
* @package PHPExcel_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_Worksheet_HeaderFooterDrawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/HeaderFooterDrawing.php';
-
-
/**
* PHPExcel_Worksheet_HeaderFooter
*
@@ -46,14 +34,14 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/HeaderFooterDrawing.php';
*
* There are a number of formatting codes that can be written inline with the actual header / footer text, which
* affect the formatting in the header or footer.
- *
+ *
* Example: This example shows the text "Center Bold Header" on the first line (center section), and the date on
* the second line (center section).
* &CCenter &"-,Bold"Bold&"-,Regular"Header_x000A_&D
- *
+ *
* General Rules:
* There is no required order in which these codes must appear.
- *
+ *
* The first occurrence of the following codes turns the formatting ON, the second occurrence turns it OFF again:
* - strikethrough
* - superscript
@@ -75,7 +63,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/HeaderFooterDrawing.php';
* &Y - code for "text subscript" on / off
* &C - code for "center section". When two or more occurrences of this section marker exist, the contents
* from all markers are concatenated, in the order of appearance, and placed into the center section.
- *
+ *
* &D - code for "date"
* &T - code for "time"
* &G - code for "picture as background"
@@ -106,7 +94,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/HeaderFooterDrawing.php';
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Worksheet_HeaderFooter
-{
+{
/* Header/footer image location */
const IMAGE_HEADER_LEFT = 'LH';
const IMAGE_HEADER_CENTER = 'CH';
@@ -114,14 +102,14 @@ class PHPExcel_Worksheet_HeaderFooter
const IMAGE_FOOTER_LEFT = 'LF';
const IMAGE_FOOTER_CENTER = 'CF';
const IMAGE_FOOTER_RIGHT = 'RF';
-
+
/**
* OddHeader
*
* @var string
*/
private $_oddHeader;
-
+
/**
* OddFooter
*
@@ -135,7 +123,7 @@ class PHPExcel_Worksheet_HeaderFooter
* @var string
*/
private $_evenHeader;
-
+
/**
* EvenFooter
*
@@ -149,42 +137,42 @@ class PHPExcel_Worksheet_HeaderFooter
* @var string
*/
private $_firstHeader;
-
+
/**
* FirstFooter
*
* @var string
*/
private $_firstFooter;
-
+
/**
* Different header for Odd/Even, defaults to false
*
* @var boolean
*/
private $_differentOddEven;
-
+
/**
* Different header for first page, defaults to false
*
* @var boolean
*/
private $_differentFirst;
-
+
/**
* Scale with document, defaults to true
*
* @var boolean
*/
private $_scaleWithDocument;
-
+
/**
* Align with margins, defaults to true
*
* @var boolean
*/
private $_alignWithMargins;
-
+
/**
* Header/footer images
*
@@ -207,10 +195,10 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_differentOddEven = false;
$this->_differentFirst = false;
$this->_scaleWithDocument = true;
- $this->_alignWithMargins = true;
+ $this->_alignWithMargins = true;
$this->_headerFooterImages = array();
}
-
+
/**
* Get OddHeader
*
@@ -219,7 +207,7 @@ class PHPExcel_Worksheet_HeaderFooter
public function getOddHeader() {
return $this->_oddHeader;
}
-
+
/**
* Set OddHeader
*
@@ -230,7 +218,7 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_oddHeader = $pValue;
return $this;
}
-
+
/**
* Get OddFooter
*
@@ -239,7 +227,7 @@ class PHPExcel_Worksheet_HeaderFooter
public function getOddFooter() {
return $this->_oddFooter;
}
-
+
/**
* Set OddFooter
*
@@ -250,7 +238,7 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_oddFooter = $pValue;
return $this;
}
-
+
/**
* Get EvenHeader
*
@@ -259,7 +247,7 @@ class PHPExcel_Worksheet_HeaderFooter
public function getEvenHeader() {
return $this->_evenHeader;
}
-
+
/**
* Set EvenHeader
*
@@ -270,7 +258,7 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_evenHeader = $pValue;
return $this;
}
-
+
/**
* Get EvenFooter
*
@@ -279,7 +267,7 @@ class PHPExcel_Worksheet_HeaderFooter
public function getEvenFooter() {
return $this->_evenFooter;
}
-
+
/**
* Set EvenFooter
*
@@ -290,7 +278,7 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_evenFooter = $pValue;
return $this;
}
-
+
/**
* Get FirstHeader
*
@@ -299,7 +287,7 @@ class PHPExcel_Worksheet_HeaderFooter
public function getFirstHeader() {
return $this->_firstHeader;
}
-
+
/**
* Set FirstHeader
*
@@ -310,7 +298,7 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_firstHeader = $pValue;
return $this;
}
-
+
/**
* Get FirstFooter
*
@@ -319,7 +307,7 @@ class PHPExcel_Worksheet_HeaderFooter
public function getFirstFooter() {
return $this->_firstFooter;
}
-
+
/**
* Set FirstFooter
*
@@ -330,7 +318,7 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_firstFooter = $pValue;
return $this;
}
-
+
/**
* Get DifferentOddEven
*
@@ -339,7 +327,7 @@ class PHPExcel_Worksheet_HeaderFooter
public function getDifferentOddEven() {
return $this->_differentOddEven;
}
-
+
/**
* Set DifferentOddEven
*
@@ -350,7 +338,7 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_differentOddEven = $pValue;
return $this;
}
-
+
/**
* Get DifferentFirst
*
@@ -359,7 +347,7 @@ class PHPExcel_Worksheet_HeaderFooter
public function getDifferentFirst() {
return $this->_differentFirst;
}
-
+
/**
* Set DifferentFirst
*
@@ -370,7 +358,7 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_differentFirst = $pValue;
return $this;
}
-
+
/**
* Get ScaleWithDocument
*
@@ -379,7 +367,7 @@ class PHPExcel_Worksheet_HeaderFooter
public function getScaleWithDocument() {
return $this->_scaleWithDocument;
}
-
+
/**
* Set ScaleWithDocument
*
@@ -390,7 +378,7 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_scaleWithDocument = $pValue;
return $this;
}
-
+
/**
* Get AlignWithMargins
*
@@ -399,7 +387,7 @@ class PHPExcel_Worksheet_HeaderFooter
public function getAlignWithMargins() {
return $this->_alignWithMargins;
}
-
+
/**
* Set AlignWithMargins
*
@@ -410,7 +398,7 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_alignWithMargins = $pValue;
return $this;
}
-
+
/**
* Add header/footer image
*
@@ -423,7 +411,7 @@ class PHPExcel_Worksheet_HeaderFooter
$this->_headerFooterImages[$location] = $image;
return $this;
}
-
+
/**
* Remove header/footer image
*
@@ -437,7 +425,7 @@ class PHPExcel_Worksheet_HeaderFooter
}
return $this;
}
-
+
/**
* Set header/footer images
*
@@ -449,11 +437,11 @@ class PHPExcel_Worksheet_HeaderFooter
if (!is_array($images)) {
throw new Exception('Invalid parameter!');
}
-
+
$this->_headerFooterImages = $images;
return $this;
}
-
+
/**
* Get header/footer images
*
@@ -469,10 +457,10 @@ class PHPExcel_Worksheet_HeaderFooter
if (isset($this->_headerFooterImages[self::IMAGE_FOOTER_CENTER])) $images[self::IMAGE_FOOTER_CENTER] = $this->_headerFooterImages[self::IMAGE_FOOTER_CENTER];
if (isset($this->_headerFooterImages[self::IMAGE_FOOTER_RIGHT])) $images[self::IMAGE_FOOTER_RIGHT] = $this->_headerFooterImages[self::IMAGE_FOOTER_RIGHT];
$this->_headerFooterImages = $images;
-
+
return $this->_headerFooterImages;
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/HeaderFooterDrawing.php b/libraries/PHPExcel/PHPExcel/Worksheet/HeaderFooterDrawing.php
index d3be4b75a..7ae8d18f6 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/HeaderFooterDrawing.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/HeaderFooterDrawing.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,31 +22,10 @@
* @package PHPExcel_Worksheet
* @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 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing.php';
-
-
/**
* PHPExcel_Worksheet_HeaderFooterDrawing
*
@@ -54,57 +33,57 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing.php';
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
-class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing implements PHPExcel_IComparable
-{
+class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing implements PHPExcel_IComparable
+{
/**
* Path
*
* @var string
*/
private $_path;
-
+
/**
* Name
*
* @var string
*/
protected $_name;
-
+
/**
* Offset X
*
* @var int
*/
protected $_offsetX;
-
+
/**
* Offset Y
*
* @var int
*/
protected $_offsetY;
-
+
/**
* Width
*
* @var int
*/
protected $_width;
-
+
/**
* Height
*
* @var int
*/
protected $_height;
-
+
/**
* Proportional resize
*
* @var boolean
*/
protected $_resizeProportional;
-
+
/**
* Create a new PHPExcel_Worksheet_HeaderFooterDrawing
*/
@@ -119,7 +98,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
$this->_height = 0;
$this->_resizeProportional = true;
}
-
+
/**
* Get Name
*
@@ -128,7 +107,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function getName() {
return $this->_name;
}
-
+
/**
* Set Name
*
@@ -139,7 +118,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
$this->_name = $pValue;
return $this;
}
-
+
/**
* Get OffsetX
*
@@ -148,7 +127,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function getOffsetX() {
return $this->_offsetX;
}
-
+
/**
* Set OffsetX
*
@@ -159,7 +138,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
$this->_offsetX = $pValue;
return $this;
}
-
+
/**
* Get OffsetY
*
@@ -168,7 +147,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function getOffsetY() {
return $this->_offsetY;
}
-
+
/**
* Set OffsetY
*
@@ -179,7 +158,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
$this->_offsetY = $pValue;
return $this;
}
-
+
/**
* Get Width
*
@@ -188,7 +167,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function getWidth() {
return $this->_width;
}
-
+
/**
* Set Width
*
@@ -198,16 +177,16 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function setWidth($pValue = 0) {
// Resize proportional?
if ($this->_resizeProportional && $pValue != 0) {
- $ratio = $this->_width / $this->_height;
+ $ratio = $this->_width / $this->_height;
$this->_height = round($ratio * $pValue);
}
-
+
// Set width
$this->_width = $pValue;
-
+
return $this;
}
-
+
/**
* Get Height
*
@@ -216,7 +195,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function getHeight() {
return $this->_height;
}
-
+
/**
* Set Height
*
@@ -226,16 +205,16 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function setHeight($pValue = 0) {
// Resize proportional?
if ($this->_resizeProportional && $pValue != 0) {
- $ratio = $this->_width / $this->_height;
+ $ratio = $this->_width / $this->_height;
$this->_width = round($ratio * $pValue);
}
-
+
// Set height
$this->_height = $pValue;
-
+
return $this;
}
-
+
/**
* Set width and height with proportional resize
* Example:
@@ -263,7 +242,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
}
return $this;
}
-
+
/**
* Get ResizeProportional
*
@@ -272,7 +251,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function getResizeProportional() {
return $this->_resizeProportional;
}
-
+
/**
* Set ResizeProportional
*
@@ -283,7 +262,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
$this->_resizeProportional = $pValue;
return $this;
}
-
+
/**
* Get Filename
*
@@ -292,16 +271,17 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function getFilename() {
return basename($this->_path);
}
-
+
/**
* Get Extension
*
* @return string
*/
public function getExtension() {
- return end(explode(".", basename($this->_path)));
+ $parts = explode(".", basename($this->_path));
+ return end($parts);
}
-
+
/**
* Get Path
*
@@ -310,7 +290,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
public function getPath() {
return $this->_path;
}
-
+
/**
* Set Path
*
@@ -323,7 +303,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
if ($pVerifyFile) {
if (file_exists($pValue)) {
$this->_path = $pValue;
-
+
if ($this->_width == 0 && $this->_height == 0) {
// Get width/height
list($this->_width, $this->_height) = getimagesize($pValue);
@@ -341,7 +321,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
return md5(
$this->_path
@@ -353,7 +333,7 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/MemoryDrawing.php b/libraries/PHPExcel/PHPExcel/Worksheet/MemoryDrawing.php
index 05a45dfee..cbc57504d 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/MemoryDrawing.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/MemoryDrawing.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,31 +22,10 @@
* @package PHPExcel_Worksheet
* @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_MemoryDrawing
*
@@ -54,48 +33,48 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
-class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
-{
+class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
+{
/* Rendering functions */
const RENDERING_DEFAULT = 'imagepng';
const RENDERING_PNG = 'imagepng';
const RENDERING_GIF = 'imagegif';
const RENDERING_JPEG = 'imagejpeg';
-
+
/* MIME types */
const MIMETYPE_DEFAULT = 'image/png';
const MIMETYPE_PNG = 'image/png';
const MIMETYPE_GIF = 'image/gif';
const MIMETYPE_JPEG = 'image/jpeg';
-
+
/**
* Image resource
*
* @var resource
*/
private $_imageResource;
-
+
/**
* Rendering function
*
* @var string
*/
private $_renderingFunction;
-
+
/**
* Mime type
*
* @var string
*/
private $_mimeType;
-
+
/**
* Unique name
*
* @var string
*/
private $_uniqueName;
-
+
/**
* Create a new PHPExcel_Worksheet_MemoryDrawing
*/
@@ -106,11 +85,11 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
$this->_renderingFunction = self::RENDERING_DEFAULT;
$this->_mimeType = self::MIMETYPE_DEFAULT;
$this->_uniqueName = md5(rand(0, 9999). time() . rand(0, 9999));
-
+
// Initialize parent
parent::__construct();
}
-
+
/**
* Get image resource
*
@@ -119,7 +98,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
public function getImageResource() {
return $this->_imageResource;
}
-
+
/**
* Set image resource
*
@@ -128,7 +107,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
*/
public function setImageResource($value = null) {
$this->_imageResource = $value;
-
+
if (!is_null($this->_imageResource)) {
// Get width/height
$this->_width = imagesx($this->_imageResource);
@@ -136,7 +115,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
}
return $this;
}
-
+
/**
* Get rendering function
*
@@ -145,7 +124,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
public function getRenderingFunction() {
return $this->_renderingFunction;
}
-
+
/**
* Set rendering function
*
@@ -156,7 +135,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
$this->_renderingFunction = $value;
return $this;
}
-
+
/**
* Get mime type
*
@@ -165,7 +144,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
public function getMimeType() {
return $this->_mimeType;
}
-
+
/**
* Set mime type
*
@@ -176,7 +155,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
$this->_mimeType = $value;
return $this;
}
-
+
/**
* Get indexed filename (using image index)
*
@@ -186,7 +165,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
$extension = strtolower($this->getMimeType());
$extension = explode('/', $extension);
$extension = $extension[1];
-
+
return $this->_uniqueName . $this->getImageIndex() . '.' . $extension;
}
@@ -194,7 +173,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
* Get hash code
*
* @return string Hash code
- */
+ */
public function getHashCode() {
return md5(
$this->_renderingFunction
@@ -204,7 +183,7 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
. __CLASS__
);
}
-
+
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/PageMargins.php b/libraries/PHPExcel/PHPExcel/Worksheet/PageMargins.php
index 80ee4cfe0..eb9a91906 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/PageMargins.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/PageMargins.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/PageSetup.php b/libraries/PHPExcel/PHPExcel/Worksheet/PageSetup.php
index 1424fe062..f85f65e28 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/PageSetup.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/PageSetup.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/Protection.php b/libraries/PHPExcel/PHPExcel/Worksheet/Protection.php
index d87c208e0..3bbd692a1 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/Protection.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/Protection.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,22 +22,10 @@
* @package PHPExcel_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_Shared_PasswordHasher */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PasswordHasher.php';
-
-
/**
* PHPExcel_Worksheet_Protection
*
@@ -53,119 +41,119 @@ class PHPExcel_Worksheet_Protection
* @var boolean
*/
private $_sheet;
-
+
/**
* Objects
*
* @var boolean
*/
private $_objects;
-
+
/**
* Scenarios
*
* @var boolean
*/
private $_scenarios;
-
+
/**
* Format cells
*
* @var boolean
*/
private $_formatCells;
-
+
/**
* Format columns
*
* @var boolean
*/
private $_formatColumns;
-
+
/**
* Format rows
*
* @var boolean
*/
private $_formatRows;
-
+
/**
* Insert columns
*
* @var boolean
*/
private $_insertColumns;
-
+
/**
* Insert rows
*
* @var boolean
*/
private $_insertRows;
-
+
/**
* Insert hyperlinks
*
* @var boolean
*/
private $_insertHyperlinks;
-
+
/**
* Delete columns
*
* @var boolean
*/
private $_deleteColumns;
-
+
/**
* Delete rows
*
* @var boolean
*/
private $_deleteRows;
-
+
/**
* Select locked cells
*
* @var boolean
*/
private $_selectLockedCells;
-
+
/**
* Sort
*
* @var boolean
*/
private $_sort;
-
+
/**
* AutoFilter
*
* @var boolean
*/
private $_autoFilter;
-
+
/**
* Pivot tables
*
* @var boolean
*/
private $_pivotTables;
-
+
/**
* Select unlocked cells
*
* @var boolean
*/
private $_selectUnlockedCells;
-
+
/**
* Password
*
* @var string
*/
private $_password;
-
+
/**
* Create a new PHPExcel_Worksheet_Protection
*/
@@ -214,7 +202,7 @@ class PHPExcel_Worksheet_Protection
$this->_pivotTables ||
$this->_selectUnlockedCells;
}
-
+
/**
* Get Sheet
*
@@ -223,7 +211,7 @@ class PHPExcel_Worksheet_Protection
function getSheet() {
return $this->_sheet;
}
-
+
/**
* Set Sheet
*
@@ -243,7 +231,7 @@ class PHPExcel_Worksheet_Protection
function getObjects() {
return $this->_objects;
}
-
+
/**
* Set Objects
*
@@ -263,7 +251,7 @@ class PHPExcel_Worksheet_Protection
function getScenarios() {
return $this->_scenarios;
}
-
+
/**
* Set Scenarios
*
@@ -283,7 +271,7 @@ class PHPExcel_Worksheet_Protection
function getFormatCells() {
return $this->_formatCells;
}
-
+
/**
* Set FormatCells
*
@@ -303,7 +291,7 @@ class PHPExcel_Worksheet_Protection
function getFormatColumns() {
return $this->_formatColumns;
}
-
+
/**
* Set FormatColumns
*
@@ -323,7 +311,7 @@ class PHPExcel_Worksheet_Protection
function getFormatRows() {
return $this->_formatRows;
}
-
+
/**
* Set FormatRows
*
@@ -343,7 +331,7 @@ class PHPExcel_Worksheet_Protection
function getInsertColumns() {
return $this->_insertColumns;
}
-
+
/**
* Set InsertColumns
*
@@ -363,7 +351,7 @@ class PHPExcel_Worksheet_Protection
function getInsertRows() {
return $this->_insertRows;
}
-
+
/**
* Set InsertRows
*
@@ -383,7 +371,7 @@ class PHPExcel_Worksheet_Protection
function getInsertHyperlinks() {
return $this->_insertHyperlinks;
}
-
+
/**
* Set InsertHyperlinks
*
@@ -403,7 +391,7 @@ class PHPExcel_Worksheet_Protection
function getDeleteColumns() {
return $this->_deleteColumns;
}
-
+
/**
* Set DeleteColumns
*
@@ -423,7 +411,7 @@ class PHPExcel_Worksheet_Protection
function getDeleteRows() {
return $this->_deleteRows;
}
-
+
/**
* Set DeleteRows
*
@@ -443,7 +431,7 @@ class PHPExcel_Worksheet_Protection
function getSelectLockedCells() {
return $this->_selectLockedCells;
}
-
+
/**
* Set SelectLockedCells
*
@@ -463,7 +451,7 @@ class PHPExcel_Worksheet_Protection
function getSort() {
return $this->_sort;
}
-
+
/**
* Set Sort
*
@@ -483,7 +471,7 @@ class PHPExcel_Worksheet_Protection
function getAutoFilter() {
return $this->_autoFilter;
}
-
+
/**
* Set AutoFilter
*
@@ -503,7 +491,7 @@ class PHPExcel_Worksheet_Protection
function getPivotTables() {
return $this->_pivotTables;
}
-
+
/**
* Set PivotTables
*
@@ -523,7 +511,7 @@ class PHPExcel_Worksheet_Protection
function getSelectUnlockedCells() {
return $this->_selectUnlockedCells;
}
-
+
/**
* Set SelectUnlockedCells
*
@@ -534,7 +522,7 @@ class PHPExcel_Worksheet_Protection
$this->_selectUnlockedCells = $pValue;
return $this;
}
-
+
/**
* Get Password (hashed)
*
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/Row.php b/libraries/PHPExcel/PHPExcel/Worksheet/Row.php
index d2105cb10..aa3d1f508 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/Row.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/Row.php
@@ -22,31 +22,13 @@
* @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_Worksheet_CellIterator */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/CellIterator.php';
-
-
/**
* PHPExcel_Worksheet_Row
- *
+ *
* Represents a row in PHPExcel_Worksheet, used by PHPExcel_Worksheet_RowIterator
*
* @category PHPExcel
@@ -61,14 +43,14 @@ class PHPExcel_Worksheet_Row
* @var PHPExcel_Worksheet
*/
private $_parent;
-
+
/**
* Row index
*
* @var int
*/
private $_rowIndex = 0;
-
+
/**
* Create a new row
*
@@ -80,14 +62,14 @@ class PHPExcel_Worksheet_Row
$this->_parent = $parent;
$this->_rowIndex = $rowIndex;
}
-
+
/**
* Destructor
*/
public function __destruct() {
unset($this->_parent);
}
-
+
/**
* Get row index
*
@@ -96,7 +78,7 @@ class PHPExcel_Worksheet_Row
public function getRowIndex() {
return $this->_rowIndex;
}
-
+
/**
* Get cell iterator
*
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/RowDimension.php b/libraries/PHPExcel/PHPExcel/Worksheet/RowDimension.php
index e956c2424..66497a530 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/RowDimension.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/RowDimension.php
@@ -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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/RowIterator.php b/libraries/PHPExcel/PHPExcel/Worksheet/RowIterator.php
index 58b0dcaf4..e2852f45d 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/RowIterator.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/RowIterator.php
@@ -22,38 +22,20 @@
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
- * @version 1.7.2, 2010-01-11
+ * @version 1.7.3, 2010-05-17
*/
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
-}
-
-/** PHPExcel */
-require_once PHPEXCEL_ROOT . 'PHPExcel.php';
-
-/** PHPExcel_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Worksheet_Row */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Row.php';
-
-
/**
* PHPExcel_Worksheet_RowIterator
- *
+ *
* Used to iterate rows in a PHPExcel_Worksheet
*
* @category PHPExcel
* @package PHPExcel_Worksheet
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
-class PHPExcel_Worksheet_RowIterator extends IteratorIterator
+class PHPExcel_Worksheet_RowIterator extends CachingIterator
{
/**
* PHPExcel_Worksheet to iterate
@@ -61,13 +43,13 @@ class PHPExcel_Worksheet_RowIterator extends IteratorIterator
* @var PHPExcel_Worksheet
*/
private $_subject;
-
+
/**
* Current iterator position
*
* @var int
*/
- private $_position = 0;
+ private $_position = 1;
/**
* Create a new row iterator
@@ -78,14 +60,14 @@ class PHPExcel_Worksheet_RowIterator extends IteratorIterator
// Set subject
$this->_subject = $subject;
}
-
+
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
-
+
/**
* Rewind iterator
*/
diff --git a/libraries/PHPExcel/PHPExcel/Worksheet/SheetView.php b/libraries/PHPExcel/PHPExcel/Worksheet/SheetView.php
index 684ef8a21..ab65e612d 100644
--- a/libraries/PHPExcel/PHPExcel/Worksheet/SheetView.php
+++ b/libraries/PHPExcel/PHPExcel/Worksheet/SheetView.php
@@ -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
*/
@@ -82,10 +82,12 @@ class PHPExcel_Worksheet_SheetView
* @return PHPExcel_Worksheet_SheetView
*/
public function setZoomScale($pValue = 100) {
- if (($pValue >= 10 && $pValue <= 400) || is_null($pValue)) {
+ // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
+ // but it is apparently still able to handle any scale >= 1
+ if (($pValue >= 1) || is_null($pValue)) {
$this->_zoomScale = $pValue;
} else {
- throw new Exception("Valid scale is between 10 and 400.");
+ throw new Exception("Scale must be greater than or equal to 1.");
}
return $this;
}
@@ -109,10 +111,10 @@ class PHPExcel_Worksheet_SheetView
* @return PHPExcel_Worksheet_SheetView
*/
public function setZoomScaleNormal($pValue = 100) {
- if (($pValue >= 10 && $pValue <= 400) || is_null($pValue)) {
+ if (($pValue >= 1) || is_null($pValue)) {
$this->_zoomScaleNormal = $pValue;
} else {
- throw new Exception("Valid scale is between 10 and 400.");
+ throw new Exception("Scale must be greater than or equal to 1.");
}
return $this;
}
diff --git a/libraries/PHPExcel/PHPExcel/WorksheetIterator.php b/libraries/PHPExcel/PHPExcel/WorksheetIterator.php
index 57f0d5c45..da5119f83 100644
--- a/libraries/PHPExcel/PHPExcel/WorksheetIterator.php
+++ b/libraries/PHPExcel/PHPExcel/WorksheetIterator.php
@@ -22,35 +22,20 @@
* @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_WorksheetIterator
- *
+ *
* Used to iterate worksheets in PHPExcel
*
* @category PHPExcel
* @package PHPExcel
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
-class PHPExcel_WorksheetIterator extends IteratorIterator
+class PHPExcel_WorksheetIterator extends CachingIterator
{
/**
* Spreadsheet to iterate
@@ -58,7 +43,7 @@ class PHPExcel_WorksheetIterator extends IteratorIterator
* @var PHPExcel
*/
private $_subject;
-
+
/**
* Current iterator position
*
@@ -75,14 +60,14 @@ class PHPExcel_WorksheetIterator extends IteratorIterator
// Set subject
$this->_subject = $subject;
}
-
+
/**
* Destructor
*/
public function __destruct() {
unset($this->_subject);
}
-
+
/**
* Rewind iterator
*/
diff --git a/libraries/PHPExcel/PHPExcel/Writer/CSV.php b/libraries/PHPExcel/PHPExcel/Writer/CSV.php
index fd29f1559..3c722eccf 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/CSV.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/CSV.php
@@ -22,31 +22,10 @@
* @package PHPExcel_Writer
* @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_IWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_RichText */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText.php';
-
-/** PHPExcel_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-
/**
* PHPExcel_Writer_CSV
*
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007.php
index 81b00922a..62c2606b4 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007.php
@@ -22,73 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_HashTable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/HashTable.php';
-
-/** PHPExcel_IComparable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
-
-/** PHPExcel_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_IWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
-
-/** PHPExcel_Shared_XMLWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
-
-/** PHPExcel_Writer_Excel2007_WriterPart */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.php';
-
-/** PHPExcel_Writer_Excel2007_StringTable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/StringTable.php';
-
-/** PHPExcel_Writer_Excel2007_ContentTypes */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/ContentTypes.php';
-
-/** PHPExcel_Writer_Excel2007_DocProps */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/DocProps.php';
-
-/** PHPExcel_Writer_Excel2007_Rels */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/Rels.php';
-
-/** PHPExcel_Writer_Excel2007_Theme */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/Theme.php';
-
-/** PHPExcel_Writer_Excel2007_Style */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/Style.php';
-
-/** PHPExcel_Writer_Excel2007_Workbook */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/Workbook.php';
-
-/** PHPExcel_Writer_Excel2007_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/Worksheet.php';
-
-/** PHPExcel_Writer_Excel2007_Drawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/Drawing.php';
-
-/** PHPExcel_Writer_Excel2007_Comments */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/Comments.php';
-
-
/**
* PHPExcel_Writer_Excel2007
*
@@ -181,7 +118,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
* @var boolean
*/
private $_useDiskCaching = false;
-
+
/**
* Disk caching directory
*
@@ -198,7 +135,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
{
// Assign PHPExcel
$this->setPHPExcel($pPHPExcel);
-
+
// Set up disk caching location
$this->_diskCachingDirectory = './';
@@ -558,7 +495,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
*/
public function setUseDiskCaching($pValue = false, $pDirectory = null) {
$this->_useDiskCaching = $pValue;
-
+
if (!is_null($pDirectory)) {
if (is_dir($pDirectory)) {
$this->_diskCachingDirectory = $pDirectory;
@@ -568,7 +505,7 @@ class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
}
return $this;
}
-
+
/**
* Get disk caching directory
*
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Comments.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Comments.php
index 7b559f569..172dde50b 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Comments.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Comments.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,46 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_Writer_Excel2007 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007.php';
-
-/** PHPExcel_Writer_Excel2007_WriterPart */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.php';
-
-/** PHPExcel_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Comment */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Comment.php';
-
-/** PHPExcel_RichText */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Style_Color */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
-
-/** PHPExcel_Shared_XMLWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
-
-
/**
* PHPExcel_Writer_Excel2007_Comments
*
@@ -87,13 +51,13 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
-
+
// XML header
$objWriter->startDocument('1.0','UTF-8','yes');
-
+
// Comments cache
$comments = $pWorksheet->getComments();
-
+
// Authors cache
$authors = array();
$authorId = 0;
@@ -102,31 +66,31 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
$authors[$comment->getAuthor()] = $authorId++;
}
}
-
+
// comments
$objWriter->startElement('comments');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
-
+
// Loop through authors
$objWriter->startElement('authors');
foreach ($authors as $author => $index) {
$objWriter->writeElement('author', $author);
}
$objWriter->endElement();
-
+
// Loop through comments
$objWriter->startElement('commentList');
foreach ($comments as $key => $value) {
$this->_writeComment($objWriter, $key, $value, $authors);
}
$objWriter->endElement();
-
+
$objWriter->endElement();
// Return
return $objWriter->getData();
}
-
+
/**
* Write comment to XML format
*
@@ -142,15 +106,15 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
$objWriter->startElement('comment');
$objWriter->writeAttribute('ref', $pCellReference);
$objWriter->writeAttribute('authorId', $pAuthors[$pComment->getAuthor()]);
-
+
// text
$objWriter->startElement('text');
$this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $pComment->getText());
$objWriter->endElement();
-
+
$objWriter->endElement();
}
-
+
/**
* Write VML comments to XML format
*
@@ -167,13 +131,13 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
-
+
// XML header
$objWriter->startDocument('1.0','UTF-8','yes');
-
+
// Comments cache
$comments = $pWorksheet->getComments();
-
+
// xml
$objWriter->startElement('xml');
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
@@ -183,46 +147,46 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
// o:shapelayout
$objWriter->startElement('o:shapelayout');
$objWriter->writeAttribute('v:ext', 'edit');
-
+
// o:idmap
$objWriter->startElement('o:idmap');
$objWriter->writeAttribute('v:ext', 'edit');
$objWriter->writeAttribute('data', '1');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// v:shapetype
$objWriter->startElement('v:shapetype');
$objWriter->writeAttribute('id', '_x0000_t202');
$objWriter->writeAttribute('coordsize', '21600,21600');
$objWriter->writeAttribute('o:spt', '202');
$objWriter->writeAttribute('path', 'm,l,21600r21600,l21600,xe');
-
+
// v:stroke
$objWriter->startElement('v:stroke');
$objWriter->writeAttribute('joinstyle', 'miter');
$objWriter->endElement();
-
+
// v:path
$objWriter->startElement('v:path');
$objWriter->writeAttribute('gradientshapeok', 't');
$objWriter->writeAttribute('o:connecttype', 'rect');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// Loop through comments
foreach ($comments as $key => $value) {
$this->_writeVMLComment($objWriter, $key, $value);
}
-
+
$objWriter->endElement();
// Return
return $objWriter->getData();
}
-
+
/**
* Write VML comment to XML format
*
@@ -238,7 +202,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
$column = PHPExcel_Cell::columnIndexFromString($column);
$id = 1024 + $column + $row;
$id = substr($id, 0, 4);
-
+
// v:shape
$objWriter->startElement('v:shape');
$objWriter->writeAttribute('id', '_x0000_s' . $id);
@@ -246,59 +210,59 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
$objWriter->writeAttribute('style', 'position:absolute;margin-left:' . $pComment->getMarginLeft() . ';margin-top:' . $pComment->getMarginTop() . ';width:' . $pComment->getWidth() . ';height:' . $pComment->getHeight() . ';z-index:1;visibility:' . ($pComment->getVisible() ? 'visible' : 'hidden'));
$objWriter->writeAttribute('fillcolor', '#' . $pComment->getFillColor()->getRGB());
$objWriter->writeAttribute('o:insetmode', 'auto');
-
+
// v:fill
$objWriter->startElement('v:fill');
$objWriter->writeAttribute('color2', '#' . $pComment->getFillColor()->getRGB());
$objWriter->endElement();
-
+
// v:shadow
$objWriter->startElement('v:shadow');
$objWriter->writeAttribute('on', 't');
$objWriter->writeAttribute('color', 'black');
$objWriter->writeAttribute('obscured', 't');
$objWriter->endElement();
-
+
// v:path
$objWriter->startElement('v:path');
$objWriter->writeAttribute('o:connecttype', 'none');
$objWriter->endElement();
-
+
// v:textbox
$objWriter->startElement('v:textbox');
$objWriter->writeAttribute('style', 'mso-direction-alt:auto');
-
+
// div
$objWriter->startElement('div');
$objWriter->writeAttribute('style', 'text-align:left');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// x:ClientData
$objWriter->startElement('x:ClientData');
$objWriter->writeAttribute('ObjectType', 'Note');
-
+
// x:MoveWithCells
$objWriter->writeElement('x:MoveWithCells', '');
-
+
// x:SizeWithCells
$objWriter->writeElement('x:SizeWithCells', '');
-
+
// x:Anchor
//$objWriter->writeElement('x:Anchor', $column . ', 15, ' . ($row - 2) . ', 10, ' . ($column + 4) . ', 15, ' . ($row + 5) . ', 18');
// x:AutoFill
$objWriter->writeElement('x:AutoFill', 'False');
-
+
// x:Row
$objWriter->writeElement('x:Row', ($row - 1));
-
+
// x:Column
$objWriter->writeElement('x:Column', ($column - 1));
-
- $objWriter->endElement();
-
+
+ $objWriter->endElement();
+
$objWriter->endElement();
}
}
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/ContentTypes.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/ContentTypes.php
index 17505f5e0..397330c09 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/ContentTypes.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/ContentTypes.php
@@ -22,34 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_Writer_Excel2007 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007.php';
-
-/** PHPExcel_Writer_Excel2007_WriterPart */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.php';
-
-/** PHPExcel_Shared_File */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/File.php';
-
-/** PHPExcel_Shared_XMLWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
-
-
/**
* PHPExcel_Writer_Excel2007_ContentTypes
*
@@ -159,7 +135,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
for ($i = 0; $i < $mediaCount; ++$i) {
$extension = '';
$mimeType = '';
-
+
if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) {
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
$mimeType = $this->_getImageMimeType( $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath() );
@@ -167,10 +143,10 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
$extension = explode('/', $extension);
$extension = $extension[1];
-
+
$mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType();
}
-
+
if (!isset( $aMediaContentTypes[$extension]) ) {
$aMediaContentTypes[$extension] = $mimeType;
@@ -179,7 +155,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
);
}
}
-
+
$sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) {
if (count($pPHPExcel->getSheet()->getHeaderFooter()->getImages()) > 0) {
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/DocProps.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/DocProps.php
index 3046cb5ce..4203147ab 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/DocProps.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/DocProps.php
@@ -22,31 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_Writer_Excel2007 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007.php';
-
-/** PHPExcel_Writer_Excel2007_WriterPart */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.php';
-
-/** PHPExcel_Shared_XMLWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
-
-
/**
* PHPExcel_Writer_Excel2007_DocProps
*
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Drawing.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Drawing.php
index 584c65d89..c8bc67c0a 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Drawing.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Drawing.php
@@ -22,49 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_Writer_Excel2007 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007.php';
-
-/** PHPExcel_Writer_Excel2007_WriterPart */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.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 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Shared_Drawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Drawing.php';
-
-/** PHPExcel_Shared_XMLWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
-
-
/**
* PHPExcel_Writer_Excel2007_Drawing
*
@@ -204,23 +165,23 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
$objWriter->endElement();
- // a:solidFill
- $objWriter->startElement('a:solidFill');
+// // a:solidFill
+// $objWriter->startElement('a:solidFill');
- // a:srgbClr
- $objWriter->startElement('a:srgbClr');
- $objWriter->writeAttribute('val', 'FFFFFF');
+// // a:srgbClr
+// $objWriter->startElement('a:srgbClr');
+// $objWriter->writeAttribute('val', 'FFFFFF');
-/* SHADE
- // a:shade
- $objWriter->startElement('a:shade');
- $objWriter->writeAttribute('val', '85000');
- $objWriter->endElement();
-*/
+///* SHADE
+// // a:shade
+// $objWriter->startElement('a:shade');
+// $objWriter->writeAttribute('val', '85000');
+// $objWriter->endElement();
+//*/
- $objWriter->endElement();
+// $objWriter->endElement();
- $objWriter->endElement();
+// $objWriter->endElement();
/*
// a:ln
$objWriter->startElement('a:ln');
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Rels.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Rels.php
index ba81c1be5..e80eb0f33 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Rels.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Rels.php
@@ -22,34 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_Writer_Excel2007 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007.php';
-
-/** PHPExcel_Writer_Excel2007_WriterPart */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.php';
-
-/** PHPExcel_Shared_XMLWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
-
-
/**
* PHPExcel_Writer_Excel2007_Rels
*
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/StringTable.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/StringTable.php
index 1e67d932d..ca233f541 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/StringTable.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/StringTable.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,34 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_Writer_Excel2007 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007.php';
-
-/** PHPExcel_Writer_Excel2007_WriterPart */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.php';
-
-/** PHPExcel_Cell_DataType */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
-
-/** PHPExcel_Shared_XMLWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
-
-/** PHPExcel_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-
/**
* PHPExcel_Writer_Excel2007_StringTable
*
@@ -74,18 +50,19 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
$aStringTable = array();
$cellCollection = null;
$aFlippedStringTable = null; // For faster lookup
-
+
// Is an existing table given?
if (!is_null($pExistingTable) && is_array($pExistingTable)) {
$aStringTable = $pExistingTable;
}
-
+
// Fill index array
$aFlippedStringTable = $this->flipStringTable($aStringTable);
-
+
// Loop through cells
$cellCollection = $pSheet->getCellCollection();
- foreach ($cellCollection as $cell) {
+ foreach ($cellCollection as $cellID) {
+ $cell = $pSheet->getCell($cellID);
if (!is_object($cell->getValue()) &&
!isset($aFlippedStringTable[$cell->getValue()]) &&
!is_null($cell->getValue()) &&
@@ -94,7 +71,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
) {
$aStringTable[] = $cell->getValue();
$aFlippedStringTable[$cell->getValue()] = 1;
-
+
} else if ($cell->getValue() instanceof PHPExcel_RichText &&
!isset($aFlippedStringTable[$cell->getValue()->getHashCode()]) &&
!is_null($cell->getValue())
@@ -110,7 +87,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
throw new Exception("Invalid PHPExcel_Worksheet object passed.");
}
}
-
+
/**
* Write string table to XML format
*
@@ -120,7 +97,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
*/
public function writeStringTable($pStringTable = null)
{
- if (!is_null($pStringTable)) {
+ if (!is_null($pStringTable)) {
// Create XML writer
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
@@ -128,19 +105,19 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
-
+
// XML header
$objWriter->startDocument('1.0','UTF-8','yes');
-
+
// String table
$objWriter->startElement('sst');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('uniqueCount', count($pStringTable));
-
+
// Loop through string table
foreach ($pStringTable as $textElement) {
$objWriter->startElement('si');
-
+
if (! $textElement instanceof PHPExcel_RichText) {
$textToWrite = PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $textElement );
$objWriter->startElement('t');
@@ -152,10 +129,10 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
} else if ($textElement instanceof PHPExcel_RichText) {
$this->writeRichText($objWriter, $textElement);
}
-
+
$objWriter->endElement();
}
-
+
$objWriter->endElement();
// Return
@@ -179,7 +156,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
foreach ($elements as $element) {
// r
$objWriter->startElement('r');
-
+
// rPr
if ($element instanceof PHPExcel_RichText_Run) {
// rPr
@@ -189,17 +166,17 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
$objWriter->startElement('rFont');
$objWriter->writeAttribute('val', $element->getFont()->getName());
$objWriter->endElement();
-
+
// Bold
$objWriter->startElement('b');
$objWriter->writeAttribute('val', ($element->getFont()->getBold() ? 'true' : 'false'));
$objWriter->endElement();
-
+
// Italic
$objWriter->startElement('i');
$objWriter->writeAttribute('val', ($element->getFont()->getItalic() ? 'true' : 'false'));
$objWriter->endElement();
-
+
// Superscript / subscript
if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
$objWriter->startElement('vertAlign');
@@ -210,40 +187,40 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
}
$objWriter->endElement();
}
-
+
// Strikethrough
$objWriter->startElement('strike');
$objWriter->writeAttribute('val', ($element->getFont()->getStrikethrough() ? 'true' : 'false'));
- $objWriter->endElement();
-
+ $objWriter->endElement();
+
// Color
$objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $element->getFont()->getColor()->getARGB());
- $objWriter->endElement();
-
+ $objWriter->endElement();
+
// Size
$objWriter->startElement('sz');
$objWriter->writeAttribute('val', $element->getFont()->getSize());
$objWriter->endElement();
-
+
// Underline
$objWriter->startElement('u');
$objWriter->writeAttribute('val', $element->getFont()->getUnderline());
$objWriter->endElement();
-
+
$objWriter->endElement();
}
-
+
// t
$objWriter->startElement('t');
$objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeRaw(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() ));
$objWriter->endElement();
-
+
$objWriter->endElement();
- }
+ }
}
-
+
/**
* Flip string table (for index searching)
*
@@ -253,7 +230,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
public function flipStringTable($stringTable = array()) {
// Return value
$returnValue = array();
-
+
// Loop through stringtable and add flipped items to $returnValue
foreach ($stringTable as $key => $value) {
if (! $value instanceof PHPExcel_RichText) {
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Style.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Style.php
index 8a41a6f35..8cfa52d49 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Style.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Style.php
@@ -22,58 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_Writer_Excel2007 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007.php';
-
-/** PHPExcel_Writer_Excel2007_WriterPart */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.php';
-
-/** PHPExcel_Style */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style.php';
-
-/** PHPExcel_Style_Borders */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Borders.php';
-
-/** PHPExcel_Style_Border */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Border.php';
-
-/** PHPExcel_Style_Color */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
-
-/** PHPExcel_Style_Fill */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Fill.php';
-
-/** PHPExcel_Style_Font */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.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_Shared_XMLWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
-
-
/**
* PHPExcel_Writer_Excel2007_Style
*
@@ -330,19 +282,17 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('val', $pFont->getSize());
$objWriter->endElement();
- // Bold
- if ($pFont->getBold()) {
- $objWriter->startElement('b');
- $objWriter->writeAttribute('val', 'true');
- $objWriter->endElement();
- }
+ // Bold. We explicitly write this element also when false (like MS Office Excel 2007 does
+ // for conditional formatting). Otherwise it will apparently not be picked up in conditional
+ // formatting style dialog
+ $objWriter->startElement('b');
+ $objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0');
+ $objWriter->endElement();
// Italic
- if ($pFont->getItalic()) {
- $objWriter->startElement('i');
- $objWriter->writeAttribute('val', 'true');
- $objWriter->endElement();
- }
+ $objWriter->startElement('i');
+ $objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0');
+ $objWriter->endElement();
// Superscript / subscript
if ($pFont->getSuperScript() || $pFont->getSubScript()) {
@@ -361,11 +311,9 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->endElement();
// Strikethrough
- if ($pFont->getStrikethrough()) {
- $objWriter->startElement('strike');
- $objWriter->writeAttribute('val', 'true');
- $objWriter->endElement();
- }
+ $objWriter->startElement('strike');
+ $objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0');
+ $objWriter->endElement();
// Foreground color
$objWriter->startElement('color');
@@ -425,13 +373,13 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('xf');
$objWriter->writeAttribute('xfId', 0);
$objWriter->writeAttribute('fontId', (int)$this->getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode()));
-
+
if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) {
$objWriter->writeAttribute('numFmtId', (int)($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164) );
} else {
$objWriter->writeAttribute('numFmtId', (int)$pStyle->getNumberFormat()->getBuiltInFormatCode());
}
-
+
$objWriter->writeAttribute('fillId', (int)$this->getParentWriter()->getFillHashTable()->getIndexForHashCode($pStyle->getFill()->getHashCode()));
$objWriter->writeAttribute('borderId', (int)$this->getParentWriter()->getBordersHashTable()->getIndexForHashCode($pStyle->getBorders()->getHashCode()));
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Theme.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Theme.php
index cf4565c78..f62fdbb42 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Theme.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Theme.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,31 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_Writer_Excel2007 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007.php';
-
-/** PHPExcel_Writer_Excel2007_WriterPart */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.php';
-
-/** PHPExcel_Shared_XMLWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
-
-
/**
* PHPExcel_Writer_Excel2007_DocProps
*
@@ -64,7 +43,7 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
* @throws Exception
*/
public function writeTheme(PHPExcel $pPHPExcel = null)
- {
+ {
// Create XML writer
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
@@ -72,7 +51,7 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
-
+
// XML header
$objWriter->startDocument('1.0','UTF-8','yes');
@@ -80,533 +59,533 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('a:theme');
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
$objWriter->writeAttribute('name', 'Office Theme');
-
+
// a:themeElements
$objWriter->startElement('a:themeElements');
-
+
{
// a:clrScheme
$objWriter->startElement('a:clrScheme');
$objWriter->writeAttribute('name', 'Office');
-
+
// a:dk1
$objWriter->startElement('a:dk1');
-
+
// a:sysClr
$objWriter->startElement('a:sysClr');
$objWriter->writeAttribute('val', 'windowText');
$objWriter->writeAttribute('lastClr', '000000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:lt1
$objWriter->startElement('a:lt1');
-
+
// a:sysClr
$objWriter->startElement('a:sysClr');
$objWriter->writeAttribute('val', 'window');
$objWriter->writeAttribute('lastClr', 'FFFFFF');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:dk2
$objWriter->startElement('a:dk2');
-
+
// a:sysClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '1F497D');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:lt2
$objWriter->startElement('a:lt2');
-
+
// a:sysClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', 'EEECE1');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:accent1
$objWriter->startElement('a:accent1');
-
+
// a:sysClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '4F81BD');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:accent2
$objWriter->startElement('a:accent2');
-
+
// a:sysClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', 'C0504D');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:accent3
$objWriter->startElement('a:accent3');
-
+
// a:sysClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '9BBB59');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:accent4
$objWriter->startElement('a:accent4');
-
+
// a:sysClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '8064A2');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:accent5
$objWriter->startElement('a:accent5');
-
+
// a:sysClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '4BACC6');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:accent6
$objWriter->startElement('a:accent6');
-
+
// a:sysClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', 'F79646');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:hlink
$objWriter->startElement('a:hlink');
-
+
// a:sysClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '0000FF');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:folHlink
$objWriter->startElement('a:folHlink');
-
+
// a:sysClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '800080');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
}
-
+
{
// a:fontScheme
$objWriter->startElement('a:fontScheme');
$objWriter->writeAttribute('name', 'Office');
-
+
// a:majorFont
$objWriter->startElement('a:majorFont');
-
+
// a:latin
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', 'Cambria');
$objWriter->endElement();
-
- // a:ea
+
+ // a:ea
$objWriter->startElement('a:ea');
$objWriter->writeAttribute('typeface', '');
$objWriter->endElement();
-
+
// a:cs
$objWriter->startElement('a:cs');
$objWriter->writeAttribute('typeface', '');
- $objWriter->endElement();
-
+ $objWriter->endElement();
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Jpan');
$objWriter->writeAttribute('typeface', '?? ?????');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Hang');
$objWriter->writeAttribute('typeface', '?? ??');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Hans');
$objWriter->writeAttribute('typeface', '??');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Hant');
$objWriter->writeAttribute('typeface', '????');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Arab');
$objWriter->writeAttribute('typeface', 'Times New Roman');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Hebr');
$objWriter->writeAttribute('typeface', 'Times New Roman');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Thai');
$objWriter->writeAttribute('typeface', 'Tahoma');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Ethi');
$objWriter->writeAttribute('typeface', 'Nyala');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Beng');
$objWriter->writeAttribute('typeface', 'Vrinda');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Gujr');
$objWriter->writeAttribute('typeface', 'Shruti');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Khmr');
$objWriter->writeAttribute('typeface', 'MoolBoran');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Knda');
$objWriter->writeAttribute('typeface', 'Tunga');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Guru');
$objWriter->writeAttribute('typeface', 'Raavi');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Cans');
$objWriter->writeAttribute('typeface', 'Euphemia');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Cher');
$objWriter->writeAttribute('typeface', 'Plantagenet Cherokee');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Yiii');
$objWriter->writeAttribute('typeface', 'Microsoft Yi Baiti');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Tibt');
$objWriter->writeAttribute('typeface', 'Microsoft Himalaya');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Thaa');
$objWriter->writeAttribute('typeface', 'MV Boli');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Deva');
$objWriter->writeAttribute('typeface', 'Mangal');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Telu');
$objWriter->writeAttribute('typeface', 'Gautami');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Taml');
$objWriter->writeAttribute('typeface', 'Latha');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Syrc');
$objWriter->writeAttribute('typeface', 'Estrangelo Edessa');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Orya');
$objWriter->writeAttribute('typeface', 'Kalinga');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Mlym');
$objWriter->writeAttribute('typeface', 'Kartika');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Laoo');
$objWriter->writeAttribute('typeface', 'DokChampa');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Sinh');
$objWriter->writeAttribute('typeface', 'Iskoola Pota');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Mong');
$objWriter->writeAttribute('typeface', 'Mongolian Baiti');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Viet');
$objWriter->writeAttribute('typeface', 'Times New Roman');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Uigh');
$objWriter->writeAttribute('typeface', 'Microsoft Uighur');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:minorFont
$objWriter->startElement('a:minorFont');
-
+
// a:latin
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', 'Calibri');
$objWriter->endElement();
-
- // a:ea
+
+ // a:ea
$objWriter->startElement('a:ea');
$objWriter->writeAttribute('typeface', '');
$objWriter->endElement();
-
+
// a:cs
$objWriter->startElement('a:cs');
$objWriter->writeAttribute('typeface', '');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Jpan');
$objWriter->writeAttribute('typeface', '?? ?????');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Hang');
$objWriter->writeAttribute('typeface', '?? ??');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Hans');
$objWriter->writeAttribute('typeface', '??');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Hant');
$objWriter->writeAttribute('typeface', '????');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Arab');
$objWriter->writeAttribute('typeface', 'Arial');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Hebr');
$objWriter->writeAttribute('typeface', 'Arial');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Thai');
$objWriter->writeAttribute('typeface', 'Tahoma');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Ethi');
$objWriter->writeAttribute('typeface', 'Nyala');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Beng');
$objWriter->writeAttribute('typeface', 'Vrinda');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Gujr');
$objWriter->writeAttribute('typeface', 'Shruti');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Khmr');
$objWriter->writeAttribute('typeface', 'DaunPenh');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Knda');
$objWriter->writeAttribute('typeface', 'Tunga');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Guru');
$objWriter->writeAttribute('typeface', 'Raavi');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Cans');
$objWriter->writeAttribute('typeface', 'Euphemia');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Cher');
$objWriter->writeAttribute('typeface', 'Plantagenet Cherokee');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Yiii');
$objWriter->writeAttribute('typeface', 'Microsoft Yi Baiti');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Tibt');
$objWriter->writeAttribute('typeface', 'Microsoft Himalaya');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Thaa');
$objWriter->writeAttribute('typeface', 'MV Boli');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Deva');
$objWriter->writeAttribute('typeface', 'Mangal');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Telu');
$objWriter->writeAttribute('typeface', 'Gautami');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Taml');
$objWriter->writeAttribute('typeface', 'Latha');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Syrc');
$objWriter->writeAttribute('typeface', 'Estrangelo Edessa');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Orya');
$objWriter->writeAttribute('typeface', 'Kalinga');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Mlym');
$objWriter->writeAttribute('typeface', 'Kartika');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Laoo');
$objWriter->writeAttribute('typeface', 'DokChampa');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Sinh');
$objWriter->writeAttribute('typeface', 'Iskoola Pota');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Mong');
$objWriter->writeAttribute('typeface', 'Mongolian Baiti');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Viet');
$objWriter->writeAttribute('typeface', 'Arial');
$objWriter->endElement();
-
+
// a:font
$objWriter->startElement('a:font');
$objWriter->writeAttribute('script', 'Uigh');
$objWriter->writeAttribute('typeface', 'Microsoft Uighur');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
}
@@ -614,107 +593,107 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
// a:fmtScheme
$objWriter->startElement('a:fmtScheme');
$objWriter->writeAttribute('name', 'Office');
-
+
// a:fillStyleLst
$objWriter->startElement('a:fillStyleLst');
-
+
// a:solidFill
$objWriter->startElement('a:solidFill');
-
+
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:gradFill
$objWriter->startElement('a:gradFill');
$objWriter->writeAttribute('rotWithShape', '1');
-
+
// a:gsLst
$objWriter->startElement('a:gsLst');
// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '0');
-
+
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
-
+
// a:tint
$objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '50000');
$objWriter->endElement();
-
+
// a:satMod
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '300000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '35000');
-
+
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
-
+
// a:tint
$objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '37000');
$objWriter->endElement();
-
+
// a:satMod
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '300000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '100000');
-
+
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
-
+
// a:tint
$objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '15000');
$objWriter->endElement();
-
+
// a:satMod
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '350000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:lin
$objWriter->startElement('a:lin');
$objWriter->writeAttribute('ang', '16200000');
$objWriter->writeAttribute('scaled', '1');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:gradFill
$objWriter->startElement('a:gradFill');
$objWriter->writeAttribute('rotWithShape', '1');
-
+
// a:gsLst
$objWriter->startElement('a:gsLst');
@@ -725,21 +704,21 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
-
+
// a:shade
$objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '51000');
$objWriter->endElement();
-
+
// a:satMod
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '130000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '80000');
@@ -747,21 +726,21 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
-
+
// a:shade
$objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '93000');
$objWriter->endElement();
-
+
// a:satMod
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '130000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '100000');
@@ -769,31 +748,31 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
-
+
// a:shade
$objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '94000');
$objWriter->endElement();
-
+
// a:satMod
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '135000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:lin
$objWriter->startElement('a:lin');
$objWriter->writeAttribute('ang', '16200000');
$objWriter->writeAttribute('scaled', '0');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
// a:lnStyleLst
@@ -805,42 +784,42 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('cap', 'flat');
$objWriter->writeAttribute('cmpd', 'sng');
$objWriter->writeAttribute('algn', 'ctr');
-
+
// a:solidFill
$objWriter->startElement('a:solidFill');
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
-
+
// a:shade
$objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '95000');
$objWriter->endElement();
-
+
// a:satMod
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '105000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:prstDash
$objWriter->startElement('a:prstDash');
$objWriter->writeAttribute('val', 'solid');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:ln
$objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', '25400');
$objWriter->writeAttribute('cap', 'flat');
$objWriter->writeAttribute('cmpd', 'sng');
$objWriter->writeAttribute('algn', 'ctr');
-
+
// a:solidFill
$objWriter->startElement('a:solidFill');
@@ -848,23 +827,23 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:prstDash
$objWriter->startElement('a:prstDash');
$objWriter->writeAttribute('val', 'solid');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:ln
$objWriter->startElement('a:ln');
$objWriter->writeAttribute('w', '38100');
$objWriter->writeAttribute('cap', 'flat');
$objWriter->writeAttribute('cmpd', 'sng');
$objWriter->writeAttribute('algn', 'ctr');
-
+
// a:solidFill
$objWriter->startElement('a:solidFill');
@@ -872,16 +851,16 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:prstDash
$objWriter->startElement('a:prstDash');
$objWriter->writeAttribute('val', 'solid');
$objWriter->endElement();
-
- $objWriter->endElement();
-
+
+ $objWriter->endElement();
+
$objWriter->endElement();
@@ -891,167 +870,167 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
// a:effectStyle
$objWriter->startElement('a:effectStyle');
-
+
// a:effectLst
$objWriter->startElement('a:effectLst');
// a:outerShdw
$objWriter->startElement('a:outerShdw');
- $objWriter->writeAttribute('blurRad', '40000');
- $objWriter->writeAttribute('dist', '20000');
- $objWriter->writeAttribute('dir', '5400000');
- $objWriter->writeAttribute('rotWithShape', '0');
-
- // a:srgbClr
- $objWriter->startElement('a:srgbClr');
- $objWriter->writeAttribute('val', '000000');
-
- // a:alpha
- $objWriter->startElement('a:alpha');
- $objWriter->writeAttribute('val', '38000');
- $objWriter->endElement();
-
- $objWriter->endElement();
-
- $objWriter->endElement();
-
- $objWriter->endElement();
-
- $objWriter->endElement();
-
- // a:effectStyle
- $objWriter->startElement('a:effectStyle');
-
- // a:effectLst
- $objWriter->startElement('a:effectLst');
-
- // a:outerShdw
- $objWriter->startElement('a:outerShdw');
- $objWriter->writeAttribute('blurRad', '40000');
- $objWriter->writeAttribute('dist', '23000');
- $objWriter->writeAttribute('dir', '5400000');
+ $objWriter->writeAttribute('blurRad', '40000');
+ $objWriter->writeAttribute('dist', '20000');
+ $objWriter->writeAttribute('dir', '5400000');
$objWriter->writeAttribute('rotWithShape', '0');
-
+
// a:srgbClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '000000');
-
+
// a:alpha
$objWriter->startElement('a:alpha');
- $objWriter->writeAttribute('val', '35000');
- $objWriter->endElement();
-
- $objWriter->endElement();
-
+ $objWriter->writeAttribute('val', '38000');
+ $objWriter->endElement();
+
+ $objWriter->endElement();
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
// a:effectStyle
$objWriter->startElement('a:effectStyle');
-
+
// a:effectLst
$objWriter->startElement('a:effectLst');
// a:outerShdw
$objWriter->startElement('a:outerShdw');
- $objWriter->writeAttribute('blurRad', '40000');
- $objWriter->writeAttribute('dist', '23000');
- $objWriter->writeAttribute('dir', '5400000');
+ $objWriter->writeAttribute('blurRad', '40000');
+ $objWriter->writeAttribute('dist', '23000');
+ $objWriter->writeAttribute('dir', '5400000');
$objWriter->writeAttribute('rotWithShape', '0');
-
+
// a:srgbClr
$objWriter->startElement('a:srgbClr');
$objWriter->writeAttribute('val', '000000');
-
+
// a:alpha
$objWriter->startElement('a:alpha');
- $objWriter->writeAttribute('val', '35000');
- $objWriter->endElement();
-
- $objWriter->endElement();
-
+ $objWriter->writeAttribute('val', '35000');
+ $objWriter->endElement();
+
+ $objWriter->endElement();
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
+ $objWriter->endElement();
+
+ // a:effectStyle
+ $objWriter->startElement('a:effectStyle');
+
+ // a:effectLst
+ $objWriter->startElement('a:effectLst');
+
+ // a:outerShdw
+ $objWriter->startElement('a:outerShdw');
+ $objWriter->writeAttribute('blurRad', '40000');
+ $objWriter->writeAttribute('dist', '23000');
+ $objWriter->writeAttribute('dir', '5400000');
+ $objWriter->writeAttribute('rotWithShape', '0');
+
+ // a:srgbClr
+ $objWriter->startElement('a:srgbClr');
+ $objWriter->writeAttribute('val', '000000');
+
+ // a:alpha
+ $objWriter->startElement('a:alpha');
+ $objWriter->writeAttribute('val', '35000');
+ $objWriter->endElement();
+
+ $objWriter->endElement();
+
+ $objWriter->endElement();
+
+ $objWriter->endElement();
+
// a:scene3d
$objWriter->startElement('a:scene3d');
// a:camera
$objWriter->startElement('a:camera');
- $objWriter->writeAttribute('prst', 'orthographicFront');
+ $objWriter->writeAttribute('prst', 'orthographicFront');
// a:rot
$objWriter->startElement('a:rot');
$objWriter->writeAttribute('lat', '0');
$objWriter->writeAttribute('lon', '0');
$objWriter->writeAttribute('rev', '0');
- $objWriter->endElement();
-
+ $objWriter->endElement();
+
$objWriter->endElement();
// a:lightRig
$objWriter->startElement('a:lightRig');
- $objWriter->writeAttribute('rig', 'threePt');
- $objWriter->writeAttribute('dir', 't');
+ $objWriter->writeAttribute('rig', 'threePt');
+ $objWriter->writeAttribute('dir', 't');
// a:rot
$objWriter->startElement('a:rot');
$objWriter->writeAttribute('lat', '0');
$objWriter->writeAttribute('lon', '0');
$objWriter->writeAttribute('rev', '1200000');
- $objWriter->endElement();
-
+ $objWriter->endElement();
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:sp3d
$objWriter->startElement('a:sp3d');
// a:bevelT
$objWriter->startElement('a:bevelT');
- $objWriter->writeAttribute('w', '63500');
- $objWriter->writeAttribute('h', '25400');
+ $objWriter->writeAttribute('w', '63500');
+ $objWriter->writeAttribute('h', '25400');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
$objWriter->endElement();
// a:bgFillStyleLst
$objWriter->startElement('a:bgFillStyleLst');
-
+
// a:solidFill
$objWriter->startElement('a:solidFill');
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
- $objWriter->endElement();
-
+ $objWriter->endElement();
+
$objWriter->endElement();
-
+
// a:gradFill
$objWriter->startElement('a:gradFill');
$objWriter->writeAttribute('rotWithShape', '1');
-
+
// a:gsLst
$objWriter->startElement('a:gsLst');
// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '0');
-
+
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
-
+
// a:tint
$objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '40000');
@@ -1061,15 +1040,15 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '350000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '40000');
-
+
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
@@ -1078,45 +1057,45 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '45000');
$objWriter->endElement();
-
+
// a:shade
$objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '99000');
$objWriter->endElement();
-
+
// a:satMod
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '350000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '100000');
-
+
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
-
+
// a:shade
$objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '20000');
$objWriter->endElement();
-
+
// a:satMod
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '255000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:path
$objWriter->startElement('a:path');
$objWriter->writeAttribute('path', 'circle');
@@ -1128,26 +1107,26 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('r', '50000');
$objWriter->writeAttribute('b', '180000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:gradFill
$objWriter->startElement('a:gradFill');
$objWriter->writeAttribute('rotWithShape', '1');
-
+
// a:gsLst
$objWriter->startElement('a:gsLst');
// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '0');
-
+
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
-
+
// a:tint
$objWriter->startElement('a:tint');
$objWriter->writeAttribute('val', '80000');
@@ -1157,35 +1136,35 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '300000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:gs
$objWriter->startElement('a:gs');
$objWriter->writeAttribute('pos', '100000');
-
+
// a:schemeClr
$objWriter->startElement('a:schemeClr');
$objWriter->writeAttribute('val', 'phClr');
-
+
// a:shade
$objWriter->startElement('a:shade');
$objWriter->writeAttribute('val', '30000');
$objWriter->endElement();
-
+
// a:satMod
$objWriter->startElement('a:satMod');
$objWriter->writeAttribute('val', '200000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
// a:path
$objWriter->startElement('a:path');
$objWriter->writeAttribute('path', 'circle');
@@ -1197,24 +1176,24 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('r', '50000');
$objWriter->writeAttribute('b', '50000');
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
-
+
$objWriter->endElement();
}
-
+
$objWriter->endElement();
-
+
// a:objectDefaults
$objWriter->writeElement('a:objectDefaults', null);
-
+
// a:extraClrSchemeLst
$objWriter->writeElement('a:extraClrSchemeLst', null);
-
+
$objWriter->endElement();
// Return
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Workbook.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Workbook.php
index 727a5d32f..0501fe478 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Workbook.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Workbook.php
@@ -22,37 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_Writer_Excel2007 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007.php';
-
-/** PHPExcel_Writer_Excel2007_WriterPart */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Shared_Date */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
-
-/** PHPExcel_Shared_XMLWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
-
-
/**
* PHPExcel_Writer_Excel2007_Workbook
*
@@ -142,13 +115,13 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
private function _writeWorkbookPr(PHPExcel_Shared_XMLWriter $objWriter = null)
{
$objWriter->startElement('workbookPr');
-
+
if (PHPExcel_Shared_Date::getExcelCalendar() == PHPExcel_Shared_Date::CALENDAR_MAC_1904) {
$objWriter->writeAttribute('date1904', '1');
}
-
+
$objWriter->writeAttribute('codeName', 'ThisWorkbook');
-
+
$objWriter->endElement();
}
@@ -342,7 +315,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
$objWriter->startElement('definedName');
$objWriter->writeAttribute('name', $pNamedRange->getName());
if ($pNamedRange->getLocalOnly()) {
- $objWriter->writeAttribute('localSheetId', $pNamedRange->getWorksheet()->getParent()->getIndex($pNamedRange->getWorksheet()));
+ $objWriter->writeAttribute('localSheetId', $pNamedRange->getScope()->getParent()->getIndex($pNamedRange->getScope()));
}
// Create absolute coordinate and write as raw text
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Worksheet.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Worksheet.php
index 30fdc5f87..bcfa3f498 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Worksheet.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/Worksheet.php
@@ -22,52 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_Writer_Excel2007 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007.php';
-
-/** PHPExcel_Writer_Excel2007_WriterPart */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/WriterPart.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Style_Conditional */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Conditional.php';
-
-/** PHPExcel_Style_NumberFormat */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
-
-/** PHPExcel_Shared_Font */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Font.php';
-
-/** PHPExcel_Shared_Date */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
-
-/** PHPExcel_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-/** PHPExcel_RichText */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText.php';
-
-/** PHPExcel_Shared_XMLWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
-
-
/**
* PHPExcel_Writer_Excel2007_Worksheet
*
@@ -196,7 +154,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->writeAttribute('rgb', $pSheet->getTabColor()->getARGB());
$objWriter->endElement();
}
-
+
// outlinePr
$objWriter->startElement('outlinePr');
$objWriter->writeAttribute('summaryBelow', ($pSheet->getShowSummaryBelow() ? '1' : '0'));
@@ -244,13 +202,13 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$sheetSelected = false;
if ($this->getParentWriter()->getPHPExcel()->getIndex($pSheet) == $this->getParentWriter()->getPHPExcel()->getActiveSheetIndex())
$sheetSelected = true;
-
-
+
+
// sheetView
$objWriter->startElement('sheetView');
$objWriter->writeAttribute('tabSelected', $sheetSelected ? '1' : '0');
$objWriter->writeAttribute('workbookViewId', '0');
-
+
// Zoom scales
if ($pSheet->getSheetView()->getZoomScale() != 100) {
$objWriter->writeAttribute('zoomScale', $pSheet->getSheetView()->getZoomScale());
@@ -265,7 +223,14 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
} else {
$objWriter->writeAttribute('showGridLines', 'false');
}
-
+
+ // Row and column headers
+ if ($pSheet->getShowRowColHeaders()) {
+ $objWriter->writeAttribute('showRowColHeaders', '1');
+ } else {
+ $objWriter->writeAttribute('showRowColHeaders', '0');
+ }
+
// Right-to-left
if ($pSheet->getRightToLeft()) {
$objWriter->writeAttribute('rightToLeft', 'true');
@@ -485,7 +450,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
&& $conditional->getOperatorType() != PHPExcel_Style_Conditional::OPERATOR_NONE) {
$objWriter->writeAttribute('operator', $conditional->getOperatorType());
}
-
+
if ($conditional->getConditionType() == PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT
&& !is_null($conditional->getText())) {
$objWriter->writeAttribute('text', $conditional->getText());
@@ -890,7 +855,8 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$cellCollection = $pSheet->getCellCollection();
$cellsByRow = array();
- foreach ($cellCollection as $cell) {
+ foreach ($cellCollection as $cellID) {
+ $cell = $pSheet->getCell($cellID);
$cellsByRow[$cell->getRow()][] = $cell;
}
@@ -905,40 +871,40 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$rowDimension->getCollapsed() == true ||
$rowDimension->getOutlineLevel() > 0 ||
$rowDimension->getXfIndex() !== null;
-
- if ($writeCurrentRow) {
+
+ if ($writeCurrentRow) {
// Start a new row
$objWriter->startElement('row');
$objWriter->writeAttribute('r', $currentRow);
$objWriter->writeAttribute('spans', '1:' . $colCount);
-
+
// Row dimensions
if ($rowDimension->getRowHeight() >= 0) {
$objWriter->writeAttribute('customHeight', '1');
$objWriter->writeAttribute('ht', PHPExcel_Shared_String::FormatNumber($rowDimension->getRowHeight()));
}
-
+
// Row visibility
if ($rowDimension->getVisible() == false) {
$objWriter->writeAttribute('hidden', 'true');
}
-
+
// Collapsed
if ($rowDimension->getCollapsed() == true) {
$objWriter->writeAttribute('collapsed', 'true');
}
-
+
// Outline level
if ($rowDimension->getOutlineLevel() > 0) {
$objWriter->writeAttribute('outlineLevel', $rowDimension->getOutlineLevel());
}
-
+
// Style
if ($rowDimension->getXfIndex() !== null) {
$objWriter->writeAttribute('s', $rowDimension->getXfIndex());
$objWriter->writeAttribute('customFormat', '1');
}
-
+
// Write cells
if (isset($cellsByRow[$currentRow])) {
foreach($cellsByRow[$currentRow] as $cell) {
@@ -946,7 +912,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$this->_writeCell($objWriter, $pSheet, $cell, $pStringTable, $aFlippedStringTable);
}
}
-
+
// End row
$objWriter->endElement();
}
@@ -970,6 +936,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
*/
private function _writeCell(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, PHPExcel_Cell $pCell = null, $pStringTable = null, $pFlippedStringTable = null)
{
+ $pCell->attach($pSheet);
if (is_array($pStringTable) && is_array($pFlippedStringTable)) {
// Cell
$objWriter->startElement('c');
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/WriterPart.php b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/WriterPart.php
index c09d05a19..2b50fefb2 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel2007/WriterPart.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel2007/WriterPart.php
@@ -8,12 +8,12 @@
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
- *
+ *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@@ -22,22 +22,10 @@
* @package PHPExcel_Writer_Excel2007
* @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_IWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
-
-
/**
* PHPExcel_Writer_Excel2007_WriterPart
*
@@ -53,7 +41,7 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart
* @var PHPExcel_Writer_IWriter
*/
private $_parentWriter;
-
+
/**
* Set parent IWriter object
*
@@ -63,7 +51,7 @@ abstract class PHPExcel_Writer_Excel2007_WriterPart
public function setParentWriter(PHPExcel_Writer_IWriter $pWriter = null) {
$this->_parentWriter = $pWriter;
}
-
+
/**
* Get parent IWriter object
*
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5.php
index 050e066f8..3694c1a8a 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5.php
@@ -22,43 +22,10 @@
* @package PHPExcel_Writer_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_IWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_HashTable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/HashTable.php';
-
-/** PHPExcel_Shared_File */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/File.php';
-
-/** PHPExcel_Shared_OLE_PPS_Root */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_Root.php';
-
-/** PHPExcel_Shared_OLE_PPS_File */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_File.php';
-
-/** PHPExcel_Writer_Excel5_Parser */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Parser.php';
-
-/** PHPExcel_Writer_Excel5_Workbook */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Workbook.php';
-
-
/**
* PHPExcel_Writer_Excel5
*
@@ -89,13 +56,6 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
*/
private $_BIFF_version;
- /**
- * Temporary storage directory
- *
- * @var string
- */
- private $_tempDir = '';
-
/**
* Total number of shared strings in workbook
*
@@ -141,13 +101,12 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
$this->_preCalculateFormulas = true;
$this->_phpExcel = $phpExcel;
$this->_BIFF_version = 0x0600;
- $this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir();
-
+
$this->_str_total = 0;
$this->_str_unique = 0;
$this->_str_table = array();
$this->_parser = new PHPExcel_Writer_Excel5_Parser($this->_BIFF_version);
-
+
}
/**
@@ -158,11 +117,6 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
*/
public function save($pFilename = null) {
- // check mbstring.func_overload
- if (ini_get('mbstring.func_overload') != 0) {
- throw new Exception('Multibyte string function overloading in PHP must be disabled.');
- }
-
// garbage collect
$this->_phpExcel->garbageCollect();
@@ -174,17 +128,17 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
// Initialise workbook writer
$this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel, $this->_BIFF_version,
- $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser, $this->_tempDir);
+ $this->_str_total, $this->_str_unique, $this->_str_table, $this->_colors, $this->_parser);
// Initialise worksheet writers
$countSheets = count($this->_phpExcel->getAllSheets());
for ($i = 0; $i < $countSheets; ++$i) {
$phpSheet = $this->_phpExcel->getSheet($i);
-
+
$writerWorksheet = new PHPExcel_Writer_Excel5_Worksheet($this->_BIFF_version,
$this->_str_total, $this->_str_unique,
$this->_str_table, $this->_colors,
- $this->_parser, $this->_tempDir,
+ $this->_parser,
$this->_preCalculateFormulas,
$phpSheet);
$this->_writerWorksheets[$i] = $writerWorksheet;
@@ -206,11 +160,6 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
$workbookStreamName = ($this->_BIFF_version == 0x0600) ? 'Workbook' : 'Book';
$OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName));
- if ($this->_tempDir != '') {
- $OLE->setTempDir($this->_tempDir);
- }
- $res = $OLE->init();
-
// Write the worksheet streams before the global workbook stream,
// because the byte sizes of these are needed in the global workbook stream
$worksheetSizes = array();
@@ -224,49 +173,25 @@ class PHPExcel_Writer_Excel5 implements PHPExcel_Writer_IWriter
// add binary data for sheet streams
for ($i = 0; $i < $countSheets; ++$i) {
- while ( ($tmp = $this->_writerWorksheets[$i]->getData()) !== false ) {
- $OLE->append($tmp);
- }
+ $OLE->append($this->_writerWorksheets[$i]->getData());
}
$root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), array($OLE));
- if ($this->_tempDir != '') {
- $root->setTempDir($this->_tempDir);
- }
-
// save the OLE file
$res = $root->save($pFilename);
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
-
- // clean up
- foreach ($this->_writerWorksheets as $sheet) {
- $sheet->cleanup();
- }
- }
-
- /**
- * Get temporary storage directory
- *
- * @return string
- */
- public function getTempDir() {
- return $this->_tempDir;
}
/**
* Set temporary storage directory
*
+ * @deprecated
* @param string $pValue Temporary storage directory
* @throws Exception Exception when directory does not exist
* @return PHPExcel_Writer_Excel5
*/
public function setTempDir($pValue = '') {
- if (is_dir($pValue)) {
- $this->_tempDir = $pValue;
- } else {
- throw new Exception("Directory does not exist: $pValue");
- }
return $this;
}
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5/BIFFwriter.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5/BIFFwriter.php
index b293ddeeb..a19463f7f 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5/BIFFwriter.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5/BIFFwriter.php
@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_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
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_BIFFwriter (used as the base for this class):
@@ -73,7 +73,7 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* The BIFF/Excel version (5).
* @var integer
*/
- var $_BIFF_version = 0x0500;
+ public $_BIFF_version = 0x0500;
/**
* The byte order of this architecture. 0 => little endian, 1 => big endian
@@ -85,20 +85,20 @@ class PHPExcel_Writer_Excel5_BIFFwriter
* The string containing the data of the BIFF stream
* @var string
*/
- var $_data;
+ public $_data;
/**
* The size of the data in bytes. Should be the same as strlen($this->_data)
* @var integer
*/
- var $_datasize;
+ public $_datasize;
/**
* The maximum length for a BIFF record (excluding record header and length field). See _addContinue()
* @var integer
* @see _addContinue()
*/
- var $_limit;
+ public $_limit;
/**
* Constructor
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Escher.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Escher.php
index 4d5f22bd1..965f2eeb7 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Escher.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Escher.php
@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_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
*/
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Font.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Font.php
index 97a553140..d3b1c248e 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Font.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Font.php
@@ -22,24 +22,9 @@
* @package PHPExcel_Writer_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_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-/** PHPExcel_Style_Font */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
-
/**
* PHPExcel_Writer_Excel5_Font
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Parser.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Parser.php
index 116513d45..867d4c6cb 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Parser.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Parser.php
@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_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
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Parser (used as the base for this class):
@@ -50,21 +50,6 @@
// */
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
-}
-
-/** PHPExcel_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-/** PHPExcel_Writer_Excel5_BIFFwriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/BIFFwriter.php';
-
-
/**
* PHPExcel_Writer_Excel5_Parser
*
@@ -74,53 +59,67 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/BIFFwriter.php';
*/
class PHPExcel_Writer_Excel5_Parser
{
+ /** Constants */
+ // Sheet title in unquoted form
+ // Invalid sheet title characters cannot occur in the sheet title:
+ // *:/\?[]
+ // Moreover, there are valid sheet title characters that cannot occur in unquoted form (there may be more?)
+ // +-% '^&<>=,;#()"{}
+ const REGEX_SHEET_TITLE_UNQUOTED = '[^\*\:\/\\\\\?\[\]\+\-\% \\\'\^\&\<\>\=\,\;\#\(\)\"\{\}]+';
+
+ // Sheet title in quoted form (without surrounding quotes)
+ // Invalid sheet title characters cannot occur in the sheet title:
+ // *:/\?[] (usual invalid sheet title characters)
+ // Single quote is represented as a pair ''
+ const REGEX_SHEET_TITLE_QUOTED = '(([^\*\:\/\\\\\?\[\]\\\'])+|(\\\'\\\')+)+';
+
/**
* The index of the character we are currently looking at
* @var integer
*/
- var $_current_char;
+ public $_current_char;
/**
* The token we are working on.
* @var string
*/
- var $_current_token;
+ public $_current_token;
/**
* The formula to parse
* @var string
*/
- var $_formula;
+ public $_formula;
/**
* The character ahead of the current char
* @var string
*/
- var $_lookahead;
+ public $_lookahead;
/**
* The parse tree to be generated
* @var string
*/
- var $_parse_tree;
+ public $_parse_tree;
/**
* Array of external sheets
* @var array
*/
- var $_ext_sheets;
+ public $_ext_sheets;
/**
* Array of sheet references in the form of REF structures
* @var array
*/
- var $_references;
+ public $_references;
/**
* The BIFF version for the workbook
* @var integer
*/
- var $_BIFF_version;
+ public $_BIFF_version;
/**
* The class constructor
@@ -534,27 +533,23 @@ class PHPExcel_Writer_Excel5_Parser
return $this->_convertRef2d($token);
// match external references like Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1
- } elseif (preg_match("/^\w+(\:\w+)?\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u",$token)) {
+ } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u",$token)) {
return $this->_convertRef3d($token);
// match external references like 'Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1
- } elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u",$token)) {
+ } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?(\d+)$/u",$token)) {
return $this->_convertRef3d($token);
- // match ranges like A1:B2
- } elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token)) {
- return $this->_convertRange2d($token);
-
- // match ranges like A1..B2
- } elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/",$token)) {
+ // match ranges like A1:B2 or $A$1:$B$2
+ } elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)\:(\$)?[A-Ia-i]?[A-Za-z](\$)?(\d+)$/', $token)) {
return $this->_convertRange2d($token);
// match external ranges like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
- } elseif (preg_match("/^\w+(\:\w+)?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u",$token)) {
+ } elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u",$token)) {
return $this->_convertRange3d($token);
// match external ranges like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
- } elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u",$token)) {
+ } elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)\:\\$?([A-Ia-i]?[A-Za-z])?\\$?(\d+)$/u",$token)) {
return $this->_convertRange3d($token);
// operators (including parentheses)
@@ -644,18 +639,15 @@ class PHPExcel_Writer_Excel5_Parser
* Convert an Excel range such as A1:D4 to a ptgRefV.
*
* @access private
- * @param string $range An Excel range in the A1:A2 or A1..A2 format.
+ * @param string $range An Excel range in the A1:A2
*/
function _convertRange2d($range, $class=0)
{
// TODO: possible class value 0,1,2 check Formula.pm
// Split the range into 2 cell refs
- if (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\:([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) {
+ if (preg_match('/^(\$)?([A-Ia-i]?[A-Za-z])(\$)?(\d+)\:(\$)?([A-Ia-i]?[A-Za-z])(\$)?(\d+)$/', $range)) {
list($cell1, $cell2) = explode(':', $range);
- } elseif (preg_match("/^([A-Ia-i]?[A-Za-z])(\d+)\.\.([A-Ia-i]?[A-Za-z])(\d+)$/", $range)) {
- list($cell1, $cell2) = explode('..', $range);
-
} else {
// TODO: use real error codes
throw new Exception("Unknown range separator");
@@ -691,7 +683,7 @@ class PHPExcel_Writer_Excel5_Parser
*/
function _convertRange3d($token)
{
- $class = 2; // as far as I know, this is magick.
+ $class = 0; // formulas like Sheet1!$A$1:$A$2 in list type data validation need this class (0x3B)
// Split the ref at the ! symbol
list($ext_ref, $range) = explode('!', $token);
@@ -856,6 +848,7 @@ class PHPExcel_Writer_Excel5_Parser
{
$ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading ' if any.
$ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.
+ $ext_ref = str_replace('\'\'', '\'', $ext_ref); // Replace escaped '' with '
// Check if there is a sheet range eg., Sheet1:Sheet2.
if (preg_match("/:/", $ext_ref)) {
@@ -1156,7 +1149,7 @@ class PHPExcel_Writer_Excel5_Parser
return $token;
break;
default:
- // if it's a reference
+ // if it's a reference A1 or $A$1 or $A1 or A$1
if (preg_match('/^\$?[A-Ia-i]?[A-Za-z]\$?[0-9]+$/',$token) and
!preg_match("/[0-9]/",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.') and
@@ -1165,39 +1158,33 @@ class PHPExcel_Writer_Excel5_Parser
return $token;
}
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
- elseif (preg_match("/^\w+(\:\w+)?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$token) and
+ elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$token) and
!preg_match("/[0-9]/",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
return $token;
}
- // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1)
- elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$token) and
+ // If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
+ elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$token) and
!preg_match("/[0-9]/",$this->_lookahead) and
($this->_lookahead != ':') and ($this->_lookahead != '.'))
{
return $token;
}
- // if it's a range (A1:A2)
- elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
- !preg_match("/[0-9]/",$this->_lookahead))
- {
- return $token;
- }
- // if it's a range (A1..A2)
- elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$token) and
+ // if it's a range A1:A2 or $A$1:$A$2
+ elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/', $token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
return $token;
}
// If it's an external range like Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2
- elseif (preg_match("/^\w+(\:\w+)?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$token) and
+ elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
return $token;
}
// If it's an external range like 'Sheet1'!A1:B2 or 'Sheet1:Sheet2'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1:Sheet2'!$A$1:$B$2
- elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$token) and
+ elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$token) and
!preg_match("/[0-9]/",$this->_lookahead))
{
return $token;
@@ -1235,7 +1222,7 @@ class PHPExcel_Writer_Excel5_Parser
{
$this->_current_char = 0;
$this->_formula = $formula;
- $this->_lookahead = $formula{1};
+ $this->_lookahead = isset($formula{1}) ? $formula{1} : '';
$this->_advance();
$this->_parse_tree = $this->_condition();
return true;
@@ -1389,29 +1376,30 @@ class PHPExcel_Writer_Excel5_Parser
return $result;
}
// If it's an external reference (Sheet1!A1 or Sheet1:Sheet2!A1 or Sheet1!$A$1 or Sheet1:Sheet2!$A$1)
- elseif (preg_match("/^\w+(\:\w+)?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$this->_current_token))
+ elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$this->_current_token))
{
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return $result;
}
// If it's an external reference ('Sheet1'!A1 or 'Sheet1:Sheet2'!A1 or 'Sheet1'!$A$1 or 'Sheet1:Sheet2'!$A$1)
- elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$this->_current_token))
+ elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?[A-Ia-i]?[A-Za-z]\\$?[0-9]+$/u",$this->_current_token))
{
$result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return $result;
}
// if it's a range A1:B2 or $A$1:$B$2
- elseif (preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token) or
- preg_match("/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/",$this->_current_token))
+ elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+:(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/',$this->_current_token) or
+ preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?[0-9]+$/',$this->_current_token))
{
- $result = $this->_current_token;
+ // must be an error?
+ $result = $this->_createTree($this->_current_token, '', '');
$this->_advance();
return $result;
}
// If it's an external range (Sheet1!A1:B2 or Sheet1:Sheet2!A1:B2 or Sheet1!$A$1:$B$2 or Sheet1:Sheet2!$A$1:$B$2)
- elseif (preg_match("/^\w+(\:\w+)?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$this->_current_token))
+ elseif (preg_match("/^" . self::REGEX_SHEET_TITLE_UNQUOTED . "(\:" . self::REGEX_SHEET_TITLE_UNQUOTED . ")?\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$this->_current_token))
{
// must be an error?
//$result = $this->_current_token;
@@ -1420,7 +1408,7 @@ class PHPExcel_Writer_Excel5_Parser
return $result;
}
// If it's an external range ('Sheet1'!A1:B2 or 'Sheet1'!A1:B2 or 'Sheet1'!$A$1:$B$2 or 'Sheet1'!$A$1:$B$2)
- elseif (preg_match("/^'[\w -]+(\:[\w -]+)?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$this->_current_token))
+ elseif (preg_match("/^'" . self::REGEX_SHEET_TITLE_QUOTED . "(\:" . self::REGEX_SHEET_TITLE_QUOTED . ")?'\!\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+:\\$?([A-Ia-i]?[A-Za-z])?\\$?[0-9]+$/u",$this->_current_token))
{
// must be an error?
//$result = $this->_current_token;
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Workbook.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Workbook.php
index bdae49f5c..0b12fe52a 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Workbook.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Workbook.php
@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_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
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Workbook (used as the base for this class):
@@ -33,7 +33,7 @@
// * The majority of this is _NOT_ my code. I simply ported it from the
// * PERL Spreadsheet::WriteExcel module.
// *
-// * The author of the Spreadsheet::WriteExcel module is John McNamara
+// * The author of the Spreadsheet::WriteExcel module is John McNamara
// *
// *
// * I _DO_ maintain this code, and John McNamara has nothing to do with the
@@ -61,54 +61,6 @@
// */
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
-}
-
-/** PHPExcel_Shared_Date */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
-
-/** PHPExcel_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-/** PHPExcel_Shared_Escher */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher.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_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
-
-/** PHPExcel_Writer_Excel5_Xf */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Xf.php';
-
-/** PHPExcel_Writer_Excel5_BIFFwriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/BIFFwriter.php';
-
-/** PHPExcel_Writer_Excel5_Worksheet */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Worksheet.php';
-
-/** PHPExcel_Writer_Excel5_Font */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Font.php';
-
-/** PHPExcel_Writer_Excel5_Escher */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Escher.php';
-
-
/**
* PHPExcel_Writer_Excel5_Workbook
*
@@ -130,7 +82,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @var integer
* @see _calcSheetOffsets()
*/
- var $_biffsize;
+ public $_biffsize;
/**
* XF Writers
@@ -142,25 +94,19 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* Array containing the colour palette
* @var array
*/
- var $_palette;
+ public $_palette;
/**
* The codepage indicates the text encoding used for strings
* @var integer
*/
- var $_codepage;
+ public $_codepage;
/**
* The country code used for localization
* @var integer
*/
- var $_country_code;
-
- /**
- * The temporary dir for storing the OLE file
- * @var string
- */
- var $_tmp_dir;
+ public $_country_code;
/**
* Workbook
@@ -249,7 +195,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*/
public function __construct(PHPExcel $phpExcel = null, $BIFF_version = 0x0600,
&$str_total,
- &$str_unique, &$str_table, &$colors, $parser, $tempDir = ''
+ &$str_unique, &$str_table, &$colors, $parser
)
{
// It needs to call its parent's constructor explicitly
@@ -266,10 +212,9 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_str_table = &$str_table;
$this->_colors = &$colors;
$this->_setPaletteXl97();
- $this->_tmp_dir = $tempDir;
-
+
$this->_phpExcel = $phpExcel;
-
+
if ($BIFF_version == 0x0600) {
$this->_BIFF_version = 0x0600;
// change BIFFwriter limit for CONTINUE records
@@ -281,7 +226,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$countSheets = count($phpExcel->getAllSheets());
for ($i = 0; $i < $countSheets; ++$i) {
$phpSheet = $phpExcel->getSheet($i);
-
+
$this->_parser->setExtSheet($phpSheet->getTitle(), $i); // Register worksheet name with parser
// for BIFF8
@@ -480,30 +425,30 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
public function writeWorkbook($pWorksheetSizes = null)
{
$this->_worksheetSizes = $pWorksheetSizes;
-
+
// Calculate the number of selected worksheet tabs and call the finalization
// methods for each worksheet
$total_worksheets = count($this->_phpExcel->getAllSheets());
// Add part 1 of the Workbook globals, what goes before the SHEET records
$this->_storeBof(0x0005);
- $this->_storeCodepage();
+ $this->_writeCodepage();
if ($this->_BIFF_version == 0x0600) {
- $this->_storeWindow1();
+ $this->_writeWindow1();
}
if ($this->_BIFF_version == 0x0500) {
- $this->_storeExterns(); // For print area and repeat rows
- $this->_storeNames(); // For print area and repeat rows
+ $this->_writeExterns(); // For print area and repeat rows
+ $this->_writeNames(); // For print area and repeat rows
}
if ($this->_BIFF_version == 0x0500) {
- $this->_storeWindow1();
+ $this->_writeWindow1();
}
- $this->_storeDatemode();
- $this->_storeAllFonts();
- $this->_storeAllNumFormats();
- $this->_storeAllXfs();
- $this->_storeAllStyles();
- $this->_storePalette();
+ $this->_writeDatemode();
+ $this->_writeAllFonts();
+ $this->_writeAllNumFormats();
+ $this->_writeAllXfs();
+ $this->_writeAllStyles();
+ $this->_writePalette();
// Prepare part 3 of the workbook global stream, what goes after the SHEET records
$part3 = '';
@@ -527,12 +472,12 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// Add part 2 of the Workbook globals, the SHEET records
$this->_calcSheetOffsets();
for ($i = 0; $i < $total_worksheets; ++$i) {
- $this->_storeBoundsheet($this->_phpExcel->getSheet($i), $this->_worksheetOffsets[$i]);
+ $this->_writeBoundsheet($this->_phpExcel->getSheet($i), $this->_worksheetOffsets[$i]);
}
// Add part 3 of the Workbook globals
$this->_data .= $part3;
-
+
return $this->_data;
}
@@ -572,10 +517,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the Excel FONT records.
- *
- * @access private
*/
- function _storeAllFonts()
+ private function _writeAllFonts()
{
foreach ($this->_fontWriters as $fontWriter) {
$this->_append($fontWriter->writeFont());
@@ -584,22 +527,18 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store user defined numerical formats i.e. FORMAT records
- *
- * @access private
*/
- function _storeAllNumFormats()
+ private function _writeAllNumFormats()
{
foreach ($this->_numberFormats as $numberFormatIndex => $numberFormat) {
- $this->_storeNumFormat($numberFormat->getFormatCode(), $numberFormatIndex);
+ $this->_writeNumFormat($numberFormat->getFormatCode(), $numberFormatIndex);
}
}
/**
* Write all XF records.
- *
- * @access private
*/
- function _storeAllXfs()
+ private function _writeAllXfs()
{
foreach ($this->_xfWriters as $xfWriter) {
$this->_append($xfWriter->writeXf());
@@ -608,37 +547,31 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write all STYLE records.
- *
- * @access private
*/
- function _storeAllStyles()
+ private function _writeAllStyles()
{
- $this->_storeStyle();
+ $this->_writeStyle();
}
/**
* Write the EXTERNCOUNT and EXTERNSHEET records. These are used as indexes for
* the NAME records.
- *
- * @access private
*/
- function _storeExterns()
+ private function _writeExterns()
{
// Create EXTERNCOUNT with number of worksheets
- $this->_storeExterncount(count($this->_phpExcel->getAllSheets()));
+ $this->_writeExterncount(count($this->_phpExcel->getAllSheets()));
// Create EXTERNSHEET for each worksheet
foreach ($this->_phpExcel->getWorksheetIterator() as $sheet) {
- $this->_storeExternsheet($sheet->getTitle());
+ $this->_writeExternsheet($sheet->getTitle());
}
}
/**
* Write the NAME record to define the print area and the repeat rows and cols.
- *
- * @access private
*/
- function _storeNames()
+ private function _writeNames()
{
// total number of sheets
$total_worksheets = count($this->_phpExcel->getAllSheets());
@@ -652,13 +585,13 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$printArea = $printArea[0];
$printArea[0] = PHPExcel_Cell::coordinateFromString($printArea[0]);
$printArea[1] = PHPExcel_Cell::coordinateFromString($printArea[1]);
-
+
$print_rowmin = $printArea[0][1] - 1;
$print_rowmax = $printArea[1][1] - 1;
$print_colmin = PHPExcel_Cell::columnIndexFromString($printArea[0][0]) - 1;
$print_colmax = PHPExcel_Cell::columnIndexFromString($printArea[1][0]) - 1;
- $this->_storeNameShort(
+ $this->_writeNameShort(
$i, // sheet index
0x06, // NAME type
$print_rowmin,
@@ -681,8 +614,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$repeat = $this->_phpExcel->getSheet($i)->getPageSetup()->getRowsToRepeatAtTop();
$rowmin = $repeat[0] - 1;
$rowmax = $repeat[1] - 1;
-
- $this->_storeNameLong(
+
+ $this->_writeNameLong(
$i, // sheet index
0x07, // NAME type
$rowmin,
@@ -714,7 +647,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$rowmax = 16383;
}
- $this->_storeNameShort(
+ $this->_writeNameShort(
$i, // sheet index
0x07, // NAME type
$rowmin,
@@ -740,7 +673,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// Loop named ranges
$namedRanges = $this->_phpExcel->getNamedRanges();
foreach ($namedRanges as $namedRange) {
-
+
// Create absolute coordinate
$range = PHPExcel_Cell::splitRange($namedRange->getRange());
for ($i = 0; $i < count($range); $i++) {
@@ -755,7 +688,20 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
try {
$error = $this->_parser->parse($range);
$formulaData = $this->_parser->toReversePolish();
- $chunk .= $this->writeData($this->_writeDefinedNameBiff8($namedRange->getName(), $formulaData, 0, false));
+
+ // make sure tRef3d is of type tRef3dR (0x3A)
+ if (isset($formulaData{0}) and ($formulaData{0} == "\x7A" or $formulaData{0} == "\x5A")) {
+ $formulaData = "\x3A" . substr($formulaData, 1);
+ }
+
+ if ($namedRange->getLocalOnly()) {
+ // local scope
+ $scope = $this->_phpExcel->getIndex($namedRange->getScope()) + 1;
+ } else {
+ // global scope
+ $scope = 0;
+ }
+ $chunk .= $this->writeData($this->_writeDefinedNameBiff8($namedRange->getName(), $formulaData, $scope, false));
} catch(Exception $e) {
// do nothing
@@ -830,7 +776,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$printAreaRect = $printArea[$j]; // e.g. A3:J6
$printAreaRect[0] = PHPExcel_Cell::coordinateFromString($printAreaRect[0]);
$printAreaRect[1] = PHPExcel_Cell::coordinateFromString($printAreaRect[1]);
-
+
$print_rowmin = $printAreaRect[0][1] - 1;
$print_rowmax = $printAreaRect[1][1] - 1;
$print_colmin = PHPExcel_Cell::columnIndexFromString($printAreaRect[0][0]) - 1;
@@ -838,7 +784,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// construct formula data manually because parser does not recognize absolute 3d cell references
$formulaData .= pack('Cvvvvv', 0x3B, $i, $print_rowmin, $print_rowmax, $print_colmin, $print_colmax);
-
+
if ($j > 0) {
$formulaData .= pack('C', 0x10); // list operator token ','
}
@@ -889,10 +835,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Stores the CODEPAGE biff record.
- *
- * @access private
*/
- function _storeCodepage()
+ private function _writeCodepage()
{
$record = 0x0042; // Record identifier
$length = 0x0002; // Number of bytes to follow
@@ -906,10 +850,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write Excel BIFF WINDOW1 record.
- *
- * @access private
*/
- function _storeWindow1()
+ private function _writeWindow1()
{
$record = 0x003D; // Record identifier
$length = 0x0012; // Number of bytes to follow
@@ -920,10 +862,10 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$dyWn = 0x1572; // Height of window
$grbit = 0x0038; // Option flags
-
+
// not supported by PHPExcel, so there is only one selected sheet, the active
$ctabsel = 1; // Number of workbook tabs selected
-
+
$wTabRatio = 0x0258; // Tab to scrollbar ratio
// not supported by PHPExcel, set to 0
@@ -943,9 +885,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*
* @param PHPExcel_Worksheet $sheet Worksheet name
* @param integer $offset Location of worksheet BOF
- * @access private
*/
- function _storeBoundsheet($sheet, $offset)
+ private function _writeBoundsheet($sheet, $offset)
{
$sheetname = $sheet->getTitle();
$record = 0x0085; // Record identifier
@@ -1012,10 +953,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write Excel BIFF STYLE records.
- *
- * @access private
*/
- function _storeStyle()
+ private function _writeStyle()
{
$record = 0x0293; // Record identifier
$length = 0x0004; // Bytes to follow
@@ -1035,9 +974,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
*
* @param string $format Custom format string
* @param integer $ifmt Format index code
- * @access private
*/
- function _storeNumFormat($format, $ifmt)
+ private function _writeNumFormat($format, $ifmt)
{
$record = 0x041E; // Record identifier
@@ -1062,10 +1000,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write DATEMODE record to indicate the date system in use (1904 or 1900).
- *
- * @access private
*/
- function _storeDatemode()
+ private function _writeDatemode()
{
$record = 0x0022; // Record identifier
$length = 0x0002; // Bytes to follow
@@ -1090,9 +1026,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* A similar method is used in Worksheet.php for a slightly different purpose.
*
* @param integer $cxals Number of external references
- * @access private
*/
- function _storeExterncount($cxals)
+ private function _writeExterncount($cxals)
{
$record = 0x0016; // Record identifier
$length = 0x0002; // Number of bytes to follow
@@ -1111,9 +1046,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* A similar method is used in Worksheet.php for a slightly different purpose.
*
* @param string $sheetname Worksheet name
- * @access private
*/
- function _storeExternsheet($sheetname)
+ private function _writeExternsheet($sheetname)
{
$record = 0x0017; // Record identifier
$length = 0x02 + strlen($sheetname); // Number of bytes to follow
@@ -1137,9 +1071,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param integer $rowmax End row
* @param integer $colmin Start colum
* @param integer $colmax End column
- * @access private
*/
- function _storeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax)
+ private function _writeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax)
{
$record = 0x0018; // Record identifier
$length = 0x0024; // Number of bytes to follow
@@ -1194,7 +1127,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the NAME record in the long format that is used for storing the repeat
* rows and columns when both are specified. This shares a lot of code with
- * _storeNameShort() but we use a separate method to keep the code clean.
+ * _writeNameShort() but we use a separate method to keep the code clean.
* Code abstraction for reuse can be carried too far, and I should know. ;-)
*
* @param integer $index Sheet index
@@ -1203,9 +1136,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
* @param integer $rowmax End row
* @param integer $colmin Start colum
* @param integer $colmax End column
- * @access private
*/
- function _storeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax)
+ private function _writeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax)
{
$record = 0x0018; // Record identifier
$length = 0x003d; // Number of bytes to follow
@@ -1312,10 +1244,8 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Stores the PALETTE biff record.
- *
- * @access private
*/
- function _storePalette()
+ private function _writePalette()
{
$aref = $this->_palette;
@@ -1551,6 +1481,15 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
$blipData = file_get_contents($filename);
break;
+ case 6: // Windows DIB (BMP), we convert to PNG
+ $blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
+ $imageResource = PHPExcel_Shared_Drawing::imagecreatefrombmp($filename);
+ ob_start();
+ imagepng($imageResource);
+ $blipData = ob_get_contents();
+ ob_end_clean();
+ break;
+
default: continue 2;
}
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Worksheet.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Worksheet.php
index 831740964..e70cbe926 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Worksheet.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Worksheet.php
@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_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
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Worksheet (used as the base for this class):
@@ -33,7 +33,7 @@
// * The majority of this is _NOT_ my code. I simply ported it from the
// * PERL Spreadsheet::WriteExcel module.
// *
-// * The author of the Spreadsheet::WriteExcel module is John McNamara
+// * The author of the Spreadsheet::WriteExcel module is John McNamara
// *
// *
// * I _DO_ maintain this code, and John McNamara has nothing to do with the
@@ -61,51 +61,6 @@
// */
-/** 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_Writer_Excel5_Parser.php */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Parser.php';
-
-/** PHPExcel_Writer_Excel5_BIFFwriter.php */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/BIFFwriter.php';
-
-/** PHPExcel_Writer_Excel5_Escher */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel5/Escher.php';
-
-/** PHPExcel_RichText */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText.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_Excel5 */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Excel5.php';
-
-/** PHPExcel_Shared_Escher */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher.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_Writer_Excel5_Worksheet
*
@@ -122,101 +77,77 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
*/
private $_parser;
- /**
- * Filehandle to the temporary file for storing data
- * @var resource
- */
- var $_filehandle;
-
- /**
- * Boolean indicating if we are using a temporary file for storing data
- * @var bool
- */
- var $_using_tmpfile;
-
/**
* Maximum number of characters for a string (LABEL record in BIFF5)
* @var integer
*/
- var $_xls_strmax;
+ public $_xls_strmax;
/**
* Array containing format information for columns
* @var array
*/
- var $_colinfo;
+ public $_colinfo;
/**
* Array containing the selected area for the worksheet
* @var array
*/
- var $_selection;
+ public $_selection;
/**
* The active pane for the worksheet
* @var integer
*/
- var $_active_pane;
+ public $_active_pane;
/**
* Whether to use outline.
* @var integer
*/
- var $_outline_on;
+ public $_outline_on;
/**
* Auto outline styles.
* @var bool
*/
- var $_outline_style;
+ public $_outline_style;
/**
* Whether to have outline summary below.
* @var bool
*/
- var $_outline_below;
+ public $_outline_below;
/**
* Whether to have outline summary at the right.
* @var bool
*/
- var $_outline_right;
+ public $_outline_right;
/**
* Reference to the total number of strings in the workbook
* @var integer
*/
- var $_str_total;
+ public $_str_total;
/**
* Reference to the number of unique strings in the workbook
* @var integer
*/
- var $_str_unique;
+ public $_str_unique;
/**
* Reference to the array containing all the unique strings in the workbook
* @var array
*/
- var $_str_table;
+ public $_str_table;
/**
* Color cache
*/
private $_colors;
- /**
- * The temporary dir for storing files
- * @var string
- */
- var $_tmp_dir;
-
- /**
- * List of temporary files created
- * @var array
- */
- var $_tempFilesCreated = array();
-
/**
* Index of first used row (at least 0)
* @var int
@@ -268,7 +199,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
public function __construct($BIFF_version,
&$str_total,
&$str_unique, &$str_table, &$colors,
- $parser, $tempDir = '', $preCalculateFormulas, $phpSheet)
+ $parser, $preCalculateFormulas, $phpSheet)
{
// It needs to call its parent's constructor explicitly
parent::__construct();
@@ -286,13 +217,10 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_str_table = &$str_table;
$this->_colors = &$colors;
$this->_parser = $parser;
-
+
$this->_phpSheet = $phpSheet;
//$this->ext_sheets = array();
- $this->_filehandle = '';
- $this->_using_tmpfile = true;
- //$this->fileclosed = 0;
//$this->offset = 0;
$this->_xls_strmax = 255;
$this->_colinfo = array();
@@ -306,19 +234,16 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_outline_right = 1;
$this->_outline_on = 1;
- $this->_dv = array();
-
- $this->_tmp_dir = $tempDir;
-
// calculate values for DIMENSIONS record
$this->_firstRowIndex = 0;
$this->_lastRowIndex = -1;
$this->_firstColumnIndex = 0;
$this->_lastColumnIndex = -1;
- foreach ($this->_phpSheet->getCellCollection(false) as $cell) {
- $row = $cell->getRow() - 1;
- $column = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1;
+ foreach ($this->_phpSheet->getCellCollection(false) as $cellID) {
+ preg_match('/^(\w+)(\d+)$/U',$cellID,$matches);
+ list(,$col,$row) = $matches;
+ $column = PHPExcel_Cell::columnIndexFromString($col) - 1;
// Don't break Excel!
if ($row + 1 > 65536 or $column + 1 > 256) {
@@ -331,43 +256,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_lastColumnIndex = max($this->_lastColumnIndex, $column);
}
- $this->_initialize();
$this->_countCellStyleXfs = count($phpSheet->getParent()->getCellStyleXfCollection());
}
- /**
- * Cleanup
- */
- public function cleanup() {
- @fclose($this->_filehandle);
-
- foreach ($this->_tempFilesCreated as $file) {
- @unlink($file);
- }
- }
-
- /**
- * Open a tmp file to store the majority of the Worksheet data. If this fails,
- * for example due to write permissions, store the data in memory. This can be
- * slow for large files.
- *
- * @access private
- */
- function _initialize()
- {
- // Open tmp file for storing Worksheet data
- $fileName = tempnam($this->_tmp_dir, 'XLSHEET');
- $fh = fopen($fileName, 'w+');
- if ($fh) {
- // Store filehandle
- $this->_filehandle = $fh;
- $this->_tempFilesCreated[] = $fileName;
- } else {
- // If tmpfile() fails store data in memory
- $this->_using_tmpfile = false;
- }
- }
-
/**
* Add data to the beginning of the workbook (note the reverse order)
* and to the end of the workbook.
@@ -382,8 +273,14 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// Write BOF record
$this->_storeBof(0x0010);
- // Write DEFCOLWIDTH record
- $this->_storeDefcol();
+ // Write PRINTHEADERS
+ $this->_writePrintHeaders();
+
+ // Write PRINTGRIDLINES
+ $this->_writePrintGridlines();
+
+ // Write GRIDSET
+ $this->_writeGridset();
// Calculate column widths
$this->_phpSheet->calculateColumnWidths();
@@ -412,81 +309,59 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$xfIndex = $columnDimension->getXfIndex() + 15; // there are 15 cell style Xfs
}
- $this->_setColumn( $i, $i, $width, $xfIndex, $hidden, $level);
+ // Components of _colinfo:
+ // $firstcol first column on the range
+ // $lastcol last column on the range
+ // $width width to set
+ // $xfIndex The optional cell style Xf index to apply to the columns
+ // $hidden The optional hidden atribute
+ // $level The optional outline level
+ $this->_colinfo[] = array($i, $i, $width, $xfIndex, $hidden, $level);
}
- // Write the COLINFO records if they exist
- if (!empty($this->_colinfo)) {
- $colcount = count($this->_colinfo);
- for ($i = 0; $i < $colcount; ++$i) {
- $this->_storeColinfo($this->_colinfo[$i]);
- }
- }
-
- // Write EXTERNCOUNT of external references
- if ($this->_BIFF_version == 0x0500) {
- $this->_storeExterncount($num_sheets);
- }
-
- // Write EXTERNSHEET references
- if ($this->_BIFF_version == 0x0500) {
- for ($i = 0; $i < $num_sheets; ++$i) {
- $this->_storeExternsheet($this->_phpSheet->getParent()->getSheet($i)->getTitle());
- }
- }
-
- // Write PRINTHEADERS
- $this->_storePrintHeaders();
-
- // Write PRINTGRIDLINES
- $this->_storePrintGridlines();
-
// Write GUTS
- $this->_storeGuts();
-
- // Write GRIDSET
- $this->_storeGridset();
+ $this->_writeGuts();
// Write DEFAULTROWHEIGHT
if ($this->_BIFF_version == 0x0600) {
- $this->_storeDefaultRowHeight();
+ $this->_writeDefaultRowHeight();
}
// Write WSBOOL
- $this->_storeWsbool();
+ $this->_writeWsbool();
// Write horizontal and vertical page breaks
- $this->_storeBreaks();
+ $this->_writeBreaks();
// Write page header
- $this->_storeHeader();
+ $this->_writeHeader();
// Write page footer
- $this->_storeFooter();
+ $this->_writeFooter();
// Write page horizontal centering
- $this->_storeHcenter();
+ $this->_writeHcenter();
// Write page vertical centering
- $this->_storeVcenter();
+ $this->_writeVcenter();
// Write left margin
- $this->_storeMarginLeft();
+ $this->_writeMarginLeft();
// Write right margin
- $this->_storeMarginRight();
+ $this->_writeMarginRight();
// Write top margin
- $this->_storeMarginTop();
+ $this->_writeMarginTop();
// Write bottom margin
- $this->_storeMarginBottom();
+ $this->_writeMarginBottom();
// Write page setup
- $this->_storeSetup();
+ $this->_writeSetup();
// Write sheet protection
- $this->_storeProtect();
+ $this->_writeProtect();
// Write SCENPROTECT
$this->_writeScenProtect();
@@ -495,19 +370,43 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_writeObjectProtect();
// Write sheet password
- $this->_storePassword();
+ $this->_writePassword();
+
+ // Write DEFCOLWIDTH record
+ $this->_writeDefcol();
+
+ // Write the COLINFO records if they exist
+ if (!empty($this->_colinfo)) {
+ $colcount = count($this->_colinfo);
+ for ($i = 0; $i < $colcount; ++$i) {
+ $this->_writeColinfo($this->_colinfo[$i]);
+ }
+ }
+
+ // Write EXTERNCOUNT of external references
+ if ($this->_BIFF_version == 0x0500) {
+ $this->_writeExterncount($num_sheets);
+ }
+
+ // Write EXTERNSHEET references
+ if ($this->_BIFF_version == 0x0500) {
+ for ($i = 0; $i < $num_sheets; ++$i) {
+ $this->_writeExternsheet($this->_phpSheet->getParent()->getSheet($i)->getTitle());
+ }
+ }
// Write sheet dimensions
- $this->_storeDimensions();
+ $this->_writeDimensions();
// Row dimensions
foreach ($this->_phpSheet->getRowDimensions() as $rowDimension) {
$xfIndex = $rowDimension->getXfIndex() + 15; // there are 15 cellXfs
- $this->_setRow( $rowDimension->getRowIndex() - 1, $rowDimension->getRowHeight(), $xfIndex, ($rowDimension->getVisible() ? '0' : '1'), $rowDimension->getOutlineLevel() );
+ $this->_writeRow( $rowDimension->getRowIndex() - 1, $rowDimension->getRowHeight(), $xfIndex, ($rowDimension->getVisible() ? '0' : '1'), $rowDimension->getOutlineLevel() );
}
// Write Cells
- foreach ($this->_phpSheet->getCellCollection() as $cell) {
+ foreach ($this->_phpSheet->getCellCollection() as $cellID) {
+ $cell = $this->_phpSheet->getCell($cellID);
$row = $cell->getRow() - 1;
$column = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1;
@@ -518,7 +417,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// Write cell value
$xfIndex = $cell->getXfIndex() + 15; // there are 15 cell style Xfs
-
+
if ($cell->getValue() instanceof PHPExcel_RichText) {
$this->_writeString($row, $column, $cell->getValue()->getPlainText(), $xfIndex);
} else {
@@ -555,15 +454,15 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// Append
if ($this->_BIFF_version == 0x0600) {
- $this->_storeMsoDrawing();
+ $this->_writeMsoDrawing();
}
- $this->_storeWindow2();
- $this->_storeZoom();
+ $this->_writeWindow2();
+ $this->_writeZoom();
if ($this->_phpSheet->getFreezePane()) {
- $this->_storePanes();
+ $this->_writePanes();
}
- $this->_storeSelection();
- $this->_storeMergedCells();
+ $this->_writeSelection();
+ $this->_writeMergedCells();
// Hyperlinks
if ($this->_BIFF_version == 0x0600) {
@@ -584,19 +483,16 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// external (local file)
$url = 'external:' . $url;
}
-
+
$this->_writeUrl($row - 1, PHPExcel_Cell::columnIndexFromString($column) - 1, $url);
}
}
- /*if ($this->_BIFF_version == 0x0600) {
- $this->_storeDataValidity();
- }*/
-
if ($this->_BIFF_version == 0x0600) {
- $this->_storeSheetLayout();
+ $this->_writeDataValidity();
+ $this->_writeSheetLayout();
$this->_writeSheetProtection();
- $this->_storeRangeProtection();
+ $this->_writeRangeProtection();
}
$this->_storeEof();
@@ -651,41 +547,12 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
if (isset($this->_data)) {
$tmp = $this->_data;
unset($this->_data);
- $fh = $this->_filehandle;
- if ($this->_using_tmpfile) {
- fseek($fh, 0);
- }
return $tmp;
}
- // Return data stored on disk
- if ($this->_using_tmpfile) {
- if ($tmp = fread($this->_filehandle, $buffer)) {
- return $tmp;
- }
- }
-
// No data to return
return false;
}
- /**
- * Set the width of a single column or a range of columns.
- *
- * @param integer $firstcol first column on the range
- * @param integer $lastcol last column on the range
- * @param integer $width width to set
- * @param integer $xfIndex The optional cell style Xf index to apply to the columns
- * @param integer $hidden The optional hidden atribute
- * @param integer $level The optional outline level
- */
- private function _setColumn($firstcol, $lastcol, $width, $xfIndex = 15, $hidden = 0, $level = 0)
- {
- $this->_colinfo[] = array($firstcol, $lastcol, $width, $xfIndex, $hidden, $level);
-
- // Set width to zero if column is hidden
- $width = ($hidden) ? 0 : $width;
- }
-
/**
* Set the option to print the row and column headers on the printed page.
*
@@ -697,27 +564,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_print_headers = $print;
}
- /**
- * Store Worksheet data in memory using the parent's class append() or to a
- * temporary file, the default.
- *
- * @access private
- * @param string $data The binary data to append
- */
- function _append($data)
- {
- if ($this->_using_tmpfile) {
- // Add CONTINUE records if necessary
- if (strlen($data) - 4 > $this->_limit) {
- $data = $this->_addContinue($data);
- }
- fwrite($this->_filehandle, $data);
- $this->_datasize += strlen($data);
- } else {
- parent::_append($data);
- }
- }
-
/**
* This method sets the properties for outlining and grouping. The defaults
* correspond to Excel's defaults.
@@ -1002,8 +848,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// Strip the '=' or '@' sign at the beginning of the formula string
if (preg_match("/^=/", $formula)) {
$formula = preg_replace("/(^=)/", "", $formula);
- } elseif (preg_match("/^@/", $formula)) {
- $formula = preg_replace("/(^@)/", "", $formula);
} else {
// Error handling
$this->_writeString($row, $col, 'Unrecognised character for formula');
@@ -1317,7 +1161,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* @param bool $hidden The optional hidden attribute
* @param integer $level The optional outline level for row, in range [0,7]
*/
- private function _setRow($row, $height, $xfIndex, $hidden = false, $level = 0)
+ private function _writeRow($row, $height, $xfIndex, $hidden = false, $level = 0)
{
$record = 0x0208; // Record identifier
$length = 0x0010; // Number of bytes to follow
@@ -1333,7 +1177,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$height = null;
}
- // Use _setRow($row, null, $XF) to set XF format without setting height
+ // Use _writeRow($row, null, $XF) to set XF format without setting height
if ($height != null) {
$miyRw = $height * 20; // row height
} else {
@@ -1366,10 +1210,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Writes Excel DIMENSIONS to define the area in which there is data.
- *
- * @access private
*/
- function _storeDimensions()
+ private function _writeDimensions()
{
$record = 0x0200; // Record identifier
@@ -1400,10 +1242,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write BIFF record Window2.
- *
- * @access private
*/
- function _storeWindow2()
+ private function _writeWindow2()
{
$record = 0x023E; // Record identifier
if ($this->_BIFF_version == 0x0500) {
@@ -1420,7 +1260,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// The options flags that comprise $grbit
$fDspFmla = 0; // 0 - bit
$fDspGrid = $this->_phpSheet->getShowGridlines() ? 1 : 0; // 1
- $fDspRwCol = 1; // 2
+ $fDspRwCol = $this->_phpSheet->getShowRowColHeaders() ? 1 : 0; // 2
$fFrozen = $this->_phpSheet->getFreezePane() ? 1 : 0; // 3
$fDspZeros = 1; // 4
$fDefaultHdr = 1; // 5
@@ -1460,10 +1300,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write BIFF record DEFAULTROWHEIGHT.
- *
- * @access private
*/
- private function _storeDefaultRowHeight()
+ private function _writeDefaultRowHeight()
{
$defaultRowHeight = $this->_phpSheet->getDefaultRowDimension()->getRowHeight();
@@ -1484,13 +1322,11 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write BIFF record DEFCOLWIDTH if COLINFO records are in use.
- *
- * @access private
*/
- function _storeDefcol()
+ private function _writeDefcol()
{
$defaultColWidth = 8;
-
+
$record = 0x0055; // Record identifier
$length = 0x0002; // Number of bytes to follow
@@ -1505,7 +1341,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* Note: The SDK says the record length is 0x0B but Excel writes a 0x0C
* length record.
*
- * @access private
* @param array $col_array This is the only parameter received and is composed of the following:
* 0 => First formatted column,
* 1 => Last formatted column,
@@ -1514,7 +1349,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* 4 => Option flags.
* 5 => Optional outline level
*/
- function _storeColinfo($col_array)
+ private function _writeColinfo($col_array)
{
if (isset($col_array[0])) {
$colFirst = $col_array[0];
@@ -1543,28 +1378,26 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$level = 0;
}
$record = 0x007D; // Record identifier
- $length = 0x000B; // Number of bytes to follow
+ $length = 0x000C; // Number of bytes to follow
$coldx *= 256; // Convert to units of 1/256 of a char
$ixfe = $xfIndex;
- $reserved = 0x00; // Reserved
+ $reserved = 0x0000; // Reserved
$level = max(0, min($level, 7));
$grbit |= $level << 8;
$header = pack("vv", $record, $length);
- $data = pack("vvvvvC", $colFirst, $colLast, $coldx,
+ $data = pack("vvvvvv", $colFirst, $colLast, $coldx,
$ixfe, $grbit, $reserved);
$this->_append($header.$data);
}
/**
* Write BIFF record SELECTION.
- *
- * @access private
*/
- function _storeSelection()
+ private function _writeSelection()
{
// look up the selected cell range
$selectedCells = $this->_phpSheet->getSelectedCells();
@@ -1576,7 +1409,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$first = $selectedCells[0];
$last = $selectedCells[0];
}
-
+
list($colFirst, $rwFirst) = PHPExcel_Cell::coordinateFromString($first);
$colFirst = PHPExcel_Cell::columnIndexFromString($colFirst) - 1; // base 0 column index
--$rwFirst; // base 0 row index
@@ -1584,7 +1417,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
list($colLast, $rwLast) = PHPExcel_Cell::coordinateFromString($last);
$colLast = PHPExcel_Cell::columnIndexFromString($colLast) - 1; // base 0 column index
--$rwLast; // base 0 row index
-
+
// make sure we are not out of bounds
$colFirst = min($colFirst, 255);
$colLast = min($colLast, 255);
@@ -1631,37 +1464,35 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the MERGEDCELLS records for all ranges of merged cells
- *
- * @access private
*/
- function _storeMergedCells()
+ private function _writeMergedCells()
{
$mergeCells = $this->_phpSheet->getMergeCells();
$countMergeCells = count($mergeCells);
-
+
if ($countMergeCells == 0) {
return;
}
-
+
// maximum allowed number of merged cells per record
if ($this->_BIFF_version == 0x0600) {
$maxCountMergeCellsPerRecord = 1027;
} else {
$maxCountMergeCellsPerRecord = 259;
}
-
+
// record identifier
$record = 0x00E5;
-
+
// counter for total number of merged cells treated so far by the writer
$i = 0;
-
+
// counter for number of merged cells written in record currently being written
$j = 0;
-
+
// initialize record data
$recordData = '';
-
+
// loop through the merged cells
foreach ($mergeCells as $mergeCell) {
++$i;
@@ -1681,7 +1512,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$length = strlen($recordData);
$header = pack('vv', $record, $length);
$this->_append($header . $recordData);
-
+
// initialize for next record, if any
$recordData = '';
$j = 0;
@@ -1692,7 +1523,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write SHEETLAYOUT record
*/
- private function _storeSheetLayout()
+ private function _writeSheetLayout()
{
if (!$this->_phpSheet->isTabColorSet()) {
return;
@@ -1715,7 +1546,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack('vv', $record, $length);
$this->_append($header . $recordData);
}
-
+
/**
* Write SHEETPROTECTION
*/
@@ -1759,14 +1590,14 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$this->_append($header . $recordData);
}
-
+
/**
* Write BIFF record RANGEPROTECTION
- *
+ *
* Openoffice.org's Documentaion of the Microsoft Excel File Format uses term RANGEPROTECTION for these records
* Microsoft Office Excel 97-2007 Binary File Format Specification uses term FEAT for these records
*/
- private function _storeRangeProtection()
+ private function _writeRangeProtection()
{
foreach ($this->_phpSheet->getProtectedCells() as $range => $password) {
// number of ranges, e.g. 'A1:B3 C20:D25'
@@ -1818,10 +1649,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* complexity and eliminates the need for a two way dialogue between the formula
* parser the worksheet objects.
*
- * @access private
* @param integer $count The number of external sheet references in this worksheet
*/
- function _storeExterncount($count)
+ private function _writeExterncount($count)
{
$record = 0x0016; // Record identifier
$length = 0x0002; // Number of bytes to follow
@@ -1837,10 +1667,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* reference to all of the external worksheets the EXTERNSHEET index is the same
* as the worksheet index.
*
- * @access private
* @param string $sheetname The name of a external worksheet
*/
- function _storeExternsheet($sheetname)
+ private function _writeExternsheet($sheetname)
{
$record = 0x0017; // Record identifier
@@ -1868,10 +1697,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* The panes can either be frozen or thawed (unfrozen).
* Frozen panes are specified in terms of an integer number of rows and columns.
* Thawed panes are specified in terms of Excel's units for rows and columns.
- *
- * @access private
*/
- function _storePanes()
+ private function _writePanes()
{
$panes = array();
if ($freezePane = $this->_phpSheet->getFreezePane()) {
@@ -1882,7 +1709,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
// thaw panes
return;
}
-
+
$y = isset($panes[0]) ? $panes[0] : null;
$x = isset($panes[1]) ? $panes[1] : null;
$rwTop = isset($panes[2]) ? $panes[2] : null;
@@ -1941,7 +1768,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
}
}
- $this->_active_pane = $pnnAct; // Used in _storeSelection
+ $this->_active_pane = $pnnAct; // Used in _writeSelection
$header = pack("vv", $record, $length);
$data = pack("vvvvv", $x, $y, $rwTop, $colLeft, $pnnAct);
@@ -1950,10 +1777,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the page setup SETUP BIFF record.
- *
- * @access private
*/
- function _storeSetup()
+ private function _writeSetup()
{
$record = 0x00A1; // Record identifier
$length = 0x0022; // Number of bytes to follow
@@ -1969,9 +1794,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$grbit = 0x00; // Option flags
$iRes = 0x0258; // Print resolution
$iVRes = 0x0258; // Vertical print resolution
-
+
$numHdr = $this->_phpSheet->getPageMargins()->getHeader(); // Header Margin
-
+
$numFtr = $this->_phpSheet->getPageMargins()->getFooter(); // Footer Margin
$iCopies = 0x01; // Number of copies
@@ -2020,10 +1845,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the header caption BIFF record.
- *
- * @access private
*/
- function _storeHeader()
+ private function _writeHeader()
{
$record = 0x0014; // Record identifier
@@ -2035,7 +1858,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$str = '';
}
*/
-
+
if ($this->_BIFF_version == 0x0600) {
$recordData = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($this->_phpSheet->getHeaderFooter()->getOddHeader());
$length = strlen($recordData);
@@ -2053,10 +1876,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the footer caption BIFF record.
- *
- * @access private
*/
- function _storeFooter()
+ private function _writeFooter()
{
$record = 0x0015; // Record identifier
@@ -2068,7 +1889,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$str = '';
}
*/
-
+
if ($this->_BIFF_version == 0x0600) {
$recordData = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($this->_phpSheet->getHeaderFooter()->getOddFooter());
$length = strlen($recordData);
@@ -2089,7 +1910,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
*
* @access private
*/
- function _storeHcenter()
+ private function _writeHcenter()
{
$record = 0x0083; // Record identifier
$length = 0x0002; // Bytes to follow
@@ -2104,10 +1925,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the vertical centering VCENTER BIFF record.
- *
- * @access private
*/
- function _storeVcenter()
+ private function _writeVcenter()
{
$record = 0x0084; // Record identifier
$length = 0x0002; // Bytes to follow
@@ -2121,10 +1940,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the LEFTMARGIN BIFF record.
- *
- * @access private
*/
- function _storeMarginLeft()
+ private function _writeMarginLeft()
{
$record = 0x0026; // Record identifier
$length = 0x0008; // Bytes to follow
@@ -2142,10 +1959,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the RIGHTMARGIN BIFF record.
- *
- * @access private
*/
- function _storeMarginRight()
+ private function _writeMarginRight()
{
$record = 0x0027; // Record identifier
$length = 0x0008; // Bytes to follow
@@ -2163,10 +1978,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the TOPMARGIN BIFF record.
- *
- * @access private
*/
- function _storeMarginTop()
+ private function _writeMarginTop()
{
$record = 0x0028; // Record identifier
$length = 0x0008; // Bytes to follow
@@ -2184,10 +1997,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the BOTTOMMARGIN BIFF record.
- *
- * @access private
*/
- function _storeMarginBottom()
+ private function _writeMarginBottom()
{
$record = 0x0029; // Record identifier
$length = 0x0008; // Bytes to follow
@@ -2205,10 +2016,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write the PRINTHEADERS BIFF record.
- *
- * @access private
*/
- function _storePrintHeaders()
+ private function _writePrintHeaders()
{
$record = 0x002a; // Record identifier
$length = 0x0002; // Bytes to follow
@@ -2223,10 +2032,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write the PRINTGRIDLINES BIFF record. Must be used in conjunction with the
* GRIDSET record.
- *
- * @access private
*/
- function _storePrintGridlines()
+ private function _writePrintGridlines()
{
$record = 0x002b; // Record identifier
$length = 0x0002; // Bytes to follow
@@ -2241,10 +2048,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write the GRIDSET BIFF record. Must be used in conjunction with the
* PRINTGRIDLINES record.
- *
- * @access private
*/
- function _storeGridset()
+ private function _writeGridset()
{
$record = 0x0082; // Record identifier
$length = 0x0002; // Bytes to follow
@@ -2261,10 +2066,9 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* where Excel outline symbols are displayed. The visibility of the gutters is
* controlled by a flag in WSBOOL.
*
- * @see _storeWsbool()
- * @access private
+ * @see _writeWsbool()
*/
- function _storeGuts()
+ private function _writeGuts()
{
$record = 0x0080; // Record identifier
$length = 0x0008; // Bytes to follow
@@ -2281,7 +2085,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$col_level = 0;
// Calculate the maximum column outline level. The equivalent calculation
- // for the row outline level is carried out in _setRow().
+ // for the row outline level is carried out in _writeRow().
$colcount = count($this->_colinfo);
for ($i = 0; $i < $colcount; ++$i) {
$col_level = max($this->_colinfo[$i][5], $col_level);
@@ -2308,10 +2112,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write the WSBOOL BIFF record, mainly for fit-to-page. Used in conjunction
* with the SETUP record.
- *
- * @access private
*/
- function _storeWsbool()
+ private function _writeWsbool()
{
$record = 0x0081; // Record identifier
$length = 0x0002; // Bytes to follow
@@ -2346,7 +2148,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write the HORIZONTALPAGEBREAKS and VERTICALPAGEBREAKS BIFF records.
*/
- private function _storeBreaks()
+ private function _writeBreaks()
{
// initialize
$vbreaks = array();
@@ -2374,7 +2176,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
break;
}
}
-
+
//horizontal page breaks
if (count($hbreaks) > 0) {
@@ -2446,10 +2248,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Set the Biff PROTECT record to indicate that the worksheet is protected.
- *
- * @access private
*/
- function _storeProtect()
+ private function _writeProtect()
{
// Exit unless sheet protection has been specified
if (!$this->_phpSheet->getProtection()->getSheet()) {
@@ -2517,10 +2317,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write the worksheet PASSWORD record.
- *
- * @access private
*/
- function _storePassword()
+ private function _writePassword()
{
// Exit unless sheet protection and password have been specified
if (!$this->_phpSheet->getProtection()->getSheet() || !$this->_phpSheet->getProtection()->getPassword()) {
@@ -2676,7 +2474,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$x2 = $width / PHPExcel_Shared_Excel5::sizeCol($this->_phpSheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object
$y2 = $height / PHPExcel_Shared_Excel5::sizeRow($this->_phpSheet, $row_end + 1) * 256; // Distance to bottom of object
- $this->_storeObjPicture($col_start, $x1,
+ $this->_writeObjPicture($col_start, $x1,
$row_start, $y1,
$col_end, $x2,
$row_end, $y2);
@@ -2686,7 +2484,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* Store the OBJ record that precedes an IMDATA record. This could be generalise
* to support other Excel objects.
*
- * @access private
* @param integer $colL Column containing upper left corner of object
* @param integer $dxL Distance from left side of cell
* @param integer $rwT Row containing top left corner of object
@@ -2696,7 +2493,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
* @param integer $rwB Row containing bottom right corner of object
* @param integer $dyB Distance from bottom of cell
*/
- function _storeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB)
+ private function _writeObjPicture($colL,$dxL,$rwT,$dyT,$colR,$dxR,$rwB,$dyB)
{
$record = 0x005d; // Record identifier
$length = 0x003c; // Bytes to follow
@@ -2880,10 +2677,8 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Store the window zoom factor. This should be a reduced fraction but for
* simplicity we will store all fractions with a numerator of 100.
- *
- * @access private
*/
- function _storeZoom()
+ private function _writeZoom()
{
// If scale is 100 we don't need to write a record
if ($this->_phpSheet->getSheetView()->getZoomScale() == 100) {
@@ -2901,7 +2696,7 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
/**
* Write MSODRAWING record
*/
- private function _storeMsoDrawing()
+ private function _writeMsoDrawing()
{
// check if there are any shapes for this sheet
if (count($this->_phpSheet->getDrawingCollection()) == 0) {
@@ -3034,34 +2829,163 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$header = pack('vv', $record, $length);
$this->_append($header . $objData);
}
-
+
}
/**
- * Store the DVAL and DV records.
- *
- * @access private
+ * Store the DATAVALIDATIONS and DATAVALIDATION records.
*/
- function _storeDataValidity()
+ private function _writeDataValidity()
{
- $record = 0x01b2; // Record identifier
+ // Datavalidation collection
+ $dataValidationCollection = $this->_phpSheet->getDataValidationCollection();
+
+ // Write data validations?
+ if (count($dataValidationCollection) > 0) {
+
+ // DATAVALIDATIONS record
+ $record = 0x01B2; // Record identifier
$length = 0x0012; // Bytes to follow
- $grbit = 0x0002; // Prompt box at cell, no cached validity data at DV records
+ $grbit = 0x0000; // Prompt box at cell, no cached validity data at DV records
$horPos = 0x00000000; // Horizontal position of prompt box, if fixed position
$verPos = 0x00000000; // Vertical position of prompt box, if fixed position
- $objId = 0xffffffff; // Object identifier of drop down arrow object, or -1 if not visible
+ $objId = 0xFFFFFFFF; // Object identifier of drop down arrow object, or -1 if not visible
$header = pack('vv', $record, $length);
$data = pack('vVVVV', $grbit, $horPos, $verPos, $objId,
- count($this->_dv));
+ count($dataValidationCollection));
$this->_append($header.$data);
- $record = 0x01be; // Record identifier
- foreach ($this->_dv as $dv) {
- $length = strlen($dv); // Bytes to follow
+ // DATAVALIDATION records
+ $record = 0x01BE; // Record identifier
+
+ foreach ($dataValidationCollection as $cellCoordinate => $dataValidation) {
+ // initialize record data
+ $data = '';
+
+ // options
+ $options = 0x00000000;
+
+ // data type
+ $type = $dataValidation->getType();
+ switch ($type) {
+ case PHPExcel_Cell_DataValidation::TYPE_NONE: $type = 0x00; break;
+ case PHPExcel_Cell_DataValidation::TYPE_WHOLE: $type = 0x01; break;
+ case PHPExcel_Cell_DataValidation::TYPE_DECIMAL: $type = 0x02; break;
+ case PHPExcel_Cell_DataValidation::TYPE_LIST: $type = 0x03; break;
+ case PHPExcel_Cell_DataValidation::TYPE_DATE: $type = 0x04; break;
+ case PHPExcel_Cell_DataValidation::TYPE_TIME: $type = 0x05; break;
+ case PHPExcel_Cell_DataValidation::TYPE_TEXTLENGTH: $type = 0x06; break;
+ case PHPExcel_Cell_DataValidation::TYPE_CUSTOM: $type = 0x07; break;
+ }
+ $options |= $type << 0;
+
+ // error style
+ $errorStyle = $dataValidation->getType();
+ switch ($errorStyle) {
+ case PHPExcel_Cell_DataValidation::STYLE_STOP: $errorStyle = 0x00; break;
+ case PHPExcel_Cell_DataValidation::STYLE_WARNING: $errorStyle = 0x01; break;
+ case PHPExcel_Cell_DataValidation::STYLE_INFORMATION: $errorStyle = 0x02; break;
+ }
+ $options |= $errorStyle << 4;
+
+ // explicit formula?
+ if ($type == 0x03 && preg_match('/^\".*\"$/', $dataValidation->getFormula1())) {
+ $options |= 0x01 << 7;
+ }
+
+ // empty cells allowed
+ $options |= $dataValidation->getAllowBlank() << 8;
+
+ // show drop down
+ $options |= (!$dataValidation->getShowDropDown()) << 9;
+
+ // show input message
+ $options |= $dataValidation->getShowInputMessage() << 18;
+
+ // show error message
+ $options |= $dataValidation->getShowErrorMessage() << 19;
+
+ // condition operator
+ $operator = $dataValidation->getOperator();
+ switch ($operator) {
+ case PHPExcel_Cell_DataValidation::OPERATOR_BETWEEN: $operator = 0x00 ; break;
+ case PHPExcel_Cell_DataValidation::OPERATOR_NOTBETWEEN: $operator = 0x01 ; break;
+ case PHPExcel_Cell_DataValidation::OPERATOR_EQUAL: $operator = 0x02 ; break;
+ case PHPExcel_Cell_DataValidation::OPERATOR_NOTEQUAL: $operator = 0x03 ; break;
+ case PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHAN: $operator = 0x04 ; break;
+ case PHPExcel_Cell_DataValidation::OPERATOR_LESSTHAN: $operator = 0x05 ; break;
+ case PHPExcel_Cell_DataValidation::OPERATOR_GREATERTHANOREQUAL: $operator = 0x06; break;
+ case PHPExcel_Cell_DataValidation::OPERATOR_LESSTHANOREQUAL: $operator = 0x07 ; break;
+ }
+ $options |= $operator << 20;
+
+ $data = pack('V', $options);
+
+ // prompt title
+ $promptTitle = $dataValidation->getPromptTitle() !== '' ?
+ $dataValidation->getPromptTitle() : chr(0);
+ $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($promptTitle);
+
+ // error title
+ $errorTitle = $dataValidation->getErrorTitle() !== '' ?
+ $dataValidation->getErrorTitle() : chr(0);
+ $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($errorTitle);
+
+ // prompt text
+ $prompt = $dataValidation->getPrompt() !== '' ?
+ $dataValidation->getPrompt() : chr(0);
+ $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($prompt);
+
+ // error text
+ $error = $dataValidation->getError() !== '' ?
+ $dataValidation->getError() : chr(0);
+ $data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($error);
+
+ // formula 1
+ try {
+ $formula1 = $dataValidation->getFormula1();
+ if ($type == 0x03) { // list type
+ $formula1 = str_replace(',', chr(0), $formula1);
+ }
+ $this->_parser->parse($formula1);
+ $formula1 = $this->_parser->toReversePolish();
+ $sz1 = strlen($formula1);
+
+ } catch(Exception $e) {
+ $sz1 = 0;
+ $formula1 = '';
+ }
+ $data .= pack('vv', $sz1, 0x0000);
+ $data .= $formula1;
+
+ // formula 2
+ try {
+ $formula2 = $dataValidation->getFormula2();
+ if ($formula2 === '') {
+ throw new Exception('No formula2');
+ }
+ $this->_parser->parse($formula2);
+ $formula2 = $this->_parser->toReversePolish();
+ $sz2 = strlen($formula2);
+
+ } catch(Exception $e) {
+ $sz2 = 0;
+ $formula2 = '';
+ }
+ $data .= pack('vv', $sz2, 0x0000);
+ $data .= $formula2;
+
+ // cell range address list
+ $data .= pack('v', 0x0001);
+ $data .= $this->_writeBIFF8CellRangeAddressFixed($cellCoordinate);
+
+ $length = strlen($data);
$header = pack("vv", $record, $length);
- $this->_append($header . $dv);
+
+ $this->_append($header . $data);
+ }
}
}
diff --git a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Xf.php b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Xf.php
index be8d11ad8..8efd19037 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/Excel5/Xf.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/Excel5/Xf.php
@@ -22,7 +22,7 @@
* @package PHPExcel_Writer_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
*/
// Original file header of PEAR::Spreadsheet_Excel_Writer_Format (used as the base for this class):
@@ -33,7 +33,7 @@
// * The majority of this is _NOT_ my code. I simply ported it from the
// * PERL Spreadsheet::WriteExcel module.
// *
-// * The author of the Spreadsheet::WriteExcel module is John McNamara
+// * The author of the Spreadsheet::WriteExcel module is John McNamara
// *
// *
// * I _DO_ maintain this code, and John McNamara has nothing to do with the
@@ -61,27 +61,6 @@
// */
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
-}
-
-/** PHPExcel_Style_Alignment */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Alignment.php';
-
-/** PHPExcel_Style_Border */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Border.php';
-
-/** PHPExcel_Style_Fill */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Fill.php';
-
-/** PHPExcel_Style_Protection */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Protection.php';
-
-
/**
* PHPExcel_Writer_Excel5_Xf
*
@@ -115,49 +94,49 @@ class PHPExcel_Writer_Excel5_Xf
* An index (2 bytes) to a FORMAT record (number format).
* @var integer
*/
- var $_numberFormatIndex;
+ public $_numberFormatIndex;
/**
* 1 bit, apparently not used.
* @var integer
*/
- var $_text_justlast;
+ public $_text_justlast;
/**
* The cell's foreground color.
* @var integer
*/
- var $_fg_color;
+ public $_fg_color;
/**
* The cell's background color.
* @var integer
*/
- var $_bg_color;
+ public $_bg_color;
/**
* Color of the bottom border of the cell.
* @var integer
*/
- var $_bottom_color;
+ public $_bottom_color;
/**
* Color of the top border of the cell.
* @var integer
*/
- var $_top_color;
+ public $_top_color;
/**
* Color of the left border of the cell.
* @var integer
*/
- var $_left_color;
+ public $_left_color;
/**
* Color of the right border of the cell.
* @var integer
*/
- var $_right_color;
+ public $_right_color;
/**
* Constructor
diff --git a/libraries/PHPExcel/PHPExcel/Writer/HTML.php b/libraries/PHPExcel/PHPExcel/Writer/HTML.php
index 4ac8c73a6..90f96bddf 100644
--- a/libraries/PHPExcel/PHPExcel/Writer/HTML.php
+++ b/libraries/PHPExcel/PHPExcel/Writer/HTML.php
@@ -22,37 +22,10 @@
* @package PHPExcel_Writer
* @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_IWriter */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
-
-/** PHPExcel_Cell */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
-
-/** PHPExcel_RichText */
-require_once PHPEXCEL_ROOT . 'PHPExcel/RichText.php';
-
-/** PHPExcel_Shared_Drawing */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Drawing.php';
-
-/** PHPExcel_Shared_String */
-require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
-
-/** PHPExcel_HashTable */
-require_once PHPEXCEL_ROOT . 'PHPExcel/HashTable.php';
-
-
/**
* PHPExcel_Writer_HTML
*
@@ -88,14 +61,14 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
* @var string
*/
private $_imagesRoot = '.';
-
+
/**
* Use inline CSS?
*
* @var boolean
*/
private $_useInlineCss = false;
-
+
/**
* Array of CSS styles
*
@@ -184,7 +157,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
// Build CSS
$this->buildCSS(!$this->_useInlineCss);
-
+
// Open file
$fileHandle = fopen($pFilename, 'w');
if ($fileHandle === false) {
@@ -194,6 +167,11 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
// Write headers
fwrite($fileHandle, $this->generateHTMLHeader(!$this->_useInlineCss));
+ // Write navigation (tabs)
+ if (!$this->_isPdf) {
+ fwrite($fileHandle, $this->generateNavigation());
+ }
+
// Write data
fwrite($fileHandle, $this->generateSheetData());
@@ -349,9 +327,29 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
$dimension[1] = PHPExcel_Cell::coordinateFromString($dimension[1]);
$dimension[1][0] = PHPExcel_Cell::columnIndexFromString($dimension[1][0]) - 1;
- // Loop through cells
+ // row min,max
+ $rowMin = $dimension[0][1];
+ $rowMax = $dimension[1][1];
+
+ // calculate start of ,
+ $tbodyStart = $rowMin;
+ $tbodyEnd = $rowMax;
+ $theadStart = 0; // default: no
+ $theadEnd = 0; // default: no
+ if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
+ $rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop();
+
+ // we can only support repeating rows that start at top row
+ if ($rowsToRepeatAtTop[0] == 1) {
+ $theadStart = $rowsToRepeatAtTop[0];
+ $theadEnd = $rowsToRepeatAtTop[1];
+ $tbodyStart = $rowsToRepeatAtTop[1] + 1;
+ }
+ }
+
+ // Loop through cells
$rowData = null;
- for ($row = $dimension[0][1]; $row <= $dimension[1][1]; ++$row) {
+ for ($row = $rowMin; $row <= $rowMax; ++$row) {
// Start a new row
$rowData = array();
@@ -359,21 +357,41 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
for ($column = $dimension[0][0]; $column <= $dimension[1][0]; ++$column) {
// Cell exists?
if ($sheet->cellExistsByColumnAndRow($column, $row)) {
- $rowData[$column] = $sheet->getCellByColumnAndRow($column, $row);
+ $rowData[$column] = $cell = $sheet->getCellByColumnAndRow($column, $row);
} else {
$rowData[$column] = '';
}
}
- // Write row if there are HTML table cells in it
+ // ?
+ if ($row == $theadStart) {
+ $html .= ' ' . "\r\n";
+ }
+
+ // ?
+ if ($row == $tbodyStart) {
+ $html .= ' ' . "\r\n";
+ }
+
+ // Write row if there are HTML table cells in it
if ( !isset($this->_isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row]) ) {
$html .= $this->_generateRow($sheet, $rowData, $row - 1);
}
+
+ // ?
+ if ($row == $theadEnd) {
+ $html .= ' ' . "\r\n";
+ }
+
+ // ?
+ if ($row == $tbodyEnd) {
+ $html .= ' ' . "\r\n";
+ }
}
// Write table footer
$html .= $this->_generateTableFooter();
-
+
// Writing PDF?
if ($this->_isPdf)
{
@@ -381,7 +399,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
$html .= '';
}
}
-
+
// Next sheet
++$sheetId;
}
@@ -390,6 +408,48 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
return $html;
}
+ /**
+ * Generate sheet tabs
+ *
+ * @return string
+ * @throws Exception
+ */
+ public function generateNavigation()
+ {
+ // PHPExcel object known?
+ if (is_null($this->_phpExcel)) {
+ throw new Exception('Internal PHPExcel object not set to an instance of an object.');
+ }
+
+ // Fetch sheets
+ $sheets = array();
+ if (is_null($this->_sheetIndex)) {
+ $sheets = $this->_phpExcel->getAllSheets();
+ } else {
+ $sheets[] = $this->_phpExcel->getSheet($this->_sheetIndex);
+ }
+
+ // Construct HTML
+ $html = '';
+
+ // Only if there are more than 1 sheets
+ if (count($sheets) > 1) {
+ // Loop all sheets
+ $sheetId = 0;
+
+ $html .= '' . "\r\n";
+ }
+
+ return $html;
+ }
+
/**
* Generate image tag in cell
*
@@ -446,7 +506,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
if (is_null($this->_phpExcel)) {
throw new Exception('Internal PHPExcel object not set to an instance of an object.');
}
-
+
// Build CSS
$css = $this->buildCSS($generateSurroundingHTML);
@@ -458,7 +518,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
$html .= '