Minor style changes, and added timings to Examples

This commit is contained in:
Mark Baker 2012-11-28 21:30:58 +00:00
parent b98f27f4a7
commit a032194211
46 changed files with 1456 additions and 1035 deletions

View File

@ -74,7 +74,7 @@ class PHPExcel_Autoloader
str_replace('_',DIRECTORY_SEPARATOR,$pClassName) . str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
'.php'; '.php';
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) { if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) {
// Can't load // Can't load
return FALSE; return FALSE;
} }

View File

@ -1,280 +1,281 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel
* *
* Copyright (c) 2006 - 2012 PHPExcel * Copyright (c) 2006 - 2012 PHPExcel
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * 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, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** /**
* PHPExcel_CachedObjectStorage_APC * PHPExcel_CachedObjectStorage_APC
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_CachedObjectStorage * @package PHPExcel_CachedObjectStorage
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache { class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
/** /**
* Prefix used to uniquely identify cache data for this worksheet * Prefix used to uniquely identify cache data for this worksheet
* *
* @access private * @access private
* @var string * @var string
*/ */
private $_cachePrefix = null; private $_cachePrefix = null;
/** /**
* Cache timeout * Cache timeout
* *
* @access private * @access private
* @var integer * @var integer
*/ */
private $_cacheTime = 600; private $_cacheTime = 600;
/** /**
* Store cell data in cache for the current cell object if it's "dirty", * Store cell data in cache for the current cell object if it's "dirty",
* and the 'nullify' the current cell object * and the 'nullify' the current cell object
* *
* @access private * @access private
* @return void * @return void
* @throws Exception * @throws PHPExcel_Exception
*/ */
private function _storeData() { private function _storeData() {
if ($this->_currentCellIsDirty) { if ($this->_currentCellIsDirty) {
$this->_currentObject->detach(); $this->_currentObject->detach();
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) { if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
$this->__destruct(); $this->__destruct();
throw new Exception('Failed to store cell '.$this->_currentObjectID.' in APC'); throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
} }
$this->_currentCellIsDirty = false; $this->_currentCellIsDirty = false;
} }
$this->_currentObjectID = $this->_currentObject = null; $this->_currentObjectID = $this->_currentObject = null;
} // function _storeData() } // function _storeData()
/** /**
* Add or Update a cell in cache identified by coordinate address * Add or Update a cell in cache identified by coordinate address
* *
* @access public * @access public
* @param string $pCoord Coordinate address of the cell to update * @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update * @param PHPExcel_Cell $cell Cell to update
* @return void * @return void
* @throws Exception * @throws PHPExcel_Exception
*/ */
public function addCacheData($pCoord, PHPExcel_Cell $cell) { public function addCacheData($pCoord, PHPExcel_Cell $cell) {
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) { if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData(); $this->_storeData();
} }
$this->_cellCache[$pCoord] = true; $this->_cellCache[$pCoord] = true;
$this->_currentObjectID = $pCoord; $this->_currentObjectID = $pCoord;
$this->_currentObject = $cell; $this->_currentObject = $cell;
$this->_currentCellIsDirty = true; $this->_currentCellIsDirty = true;
return $cell; return $cell;
} // function addCacheData() } // function addCacheData()
/** /**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
* *
* @access public * @access public
* @param string $pCoord Coordinate address of the cell to check * @param string $pCoord Coordinate address of the cell to check
* @return void * @return void
* @return boolean * @return boolean
*/ */
public function isDataSet($pCoord) { public function isDataSet($pCoord) {
// Check if the requested entry is the current object, or exists in the cache // Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) { if (parent::isDataSet($pCoord)) {
if ($this->_currentObjectID == $pCoord) { if ($this->_currentObjectID == $pCoord) {
return true; return true;
} }
// Check if the requested entry still exists in apc // Check if the requested entry still exists in apc
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache'); $success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
if ($success === false) { if ($success === FALSE) {
// Entry no longer exists in APC, so clear it from the cache array // Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord); parent::deleteCacheData($pCoord);
throw new Exception('Cell entry '.$pCoord.' no longer exists in APC'); throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
} }
return true; return true;
} }
return false; return false;
} // function isDataSet() } // function isDataSet()
/** /**
* Get cell at a specific coordinate * Get cell at a specific coordinate
* *
* @access public * @access public
* @param string $pCoord Coordinate of the cell * @param string $pCoord Coordinate of the cell
* @throws Exception * @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found * @return PHPExcel_Cell Cell that was found, or null if not found
*/ */
public function getCacheData($pCoord) { public function getCacheData($pCoord) {
if ($pCoord === $this->_currentObjectID) { if ($pCoord === $this->_currentObjectID) {
return $this->_currentObject; return $this->_currentObject;
} }
$this->_storeData(); $this->_storeData();
// Check if the entry that has been requested actually exists // Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) { if (parent::isDataSet($pCoord)) {
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache'); $obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
if ($obj === false) { if ($obj === FALSE) {
// Entry no longer exists in APC, so clear it from the cache array // Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord); parent::deleteCacheData($pCoord);
throw new Exception('Cell entry '.$pCoord.' no longer exists in APC'); throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
} }
} else { } else {
// Return null if requested entry doesn't exist in cache // Return null if requested entry doesn't exist in cache
return null; return null;
} }
// Set current entry to the requested entry // Set current entry to the requested entry
$this->_currentObjectID = $pCoord; $this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($obj); $this->_currentObject = unserialize($obj);
// Re-attach the parent worksheet // Re-attach the parent worksheet
$this->_currentObject->attach($this->_parent); $this->_currentObject->attach($this->_parent);
// Return requested entry // Return requested entry
return $this->_currentObject; return $this->_currentObject;
} // function getCacheData() } // function getCacheData()
/** /**
* Delete a cell in cache identified by coordinate address * Delete a cell in cache identified by coordinate address
* *
* @access public * @access public
* @param string $pCoord Coordinate address of the cell to delete * @param string $pCoord Coordinate address of the cell to delete
* @throws Exception * @throws PHPExcel_Exception
*/ */
public function deleteCacheData($pCoord) { public function deleteCacheData($pCoord) {
// Delete the entry from APC // Delete the entry from APC
apc_delete($this->_cachePrefix.$pCoord.'.cache'); apc_delete($this->_cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array // Delete the entry from our cell address array
parent::deleteCacheData($pCoord); parent::deleteCacheData($pCoord);
} // function deleteCacheData() } // function deleteCacheData()
/** /**
* Clone the cell collection * Clone the cell collection
* *
* @access public * @access public
* @param PHPExcel_Worksheet $parent The new worksheet * @param PHPExcel_Worksheet $parent The new worksheet
* @return void * @throws PHPExcel_Exception
*/ * @return void
public function copyCellCollection(PHPExcel_Worksheet $parent) { */
parent::copyCellCollection($parent); public function copyCellCollection(PHPExcel_Worksheet $parent) {
// Get a new id for the new file name parent::copyCellCollection($parent);
$baseUnique = $this->_getUniqueID(); // Get a new id for the new file name
$newCachePrefix = substr(md5($baseUnique),0,8).'.'; $baseUnique = $this->_getUniqueID();
$cacheList = $this->getCellList(); $newCachePrefix = substr(md5($baseUnique),0,8).'.';
foreach($cacheList as $cellID) { $cacheList = $this->getCellList();
if ($cellID != $this->_currentObjectID) { foreach($cacheList as $cellID) {
$obj = apc_fetch($this->_cachePrefix.$cellID.'.cache'); if ($cellID != $this->_currentObjectID) {
if ($obj === false) { $obj = apc_fetch($this->_cachePrefix.$cellID.'.cache');
// Entry no longer exists in APC, so clear it from the cache array if ($obj === FALSE) {
parent::deleteCacheData($cellID); // Entry no longer exists in APC, so clear it from the cache array
throw new Exception('Cell entry '.$cellID.' no longer exists in APC'); parent::deleteCacheData($cellID);
} throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in APC');
if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) { }
$this->__destruct(); if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) {
throw new Exception('Failed to store cell '.$cellID.' in APC'); $this->__destruct();
} throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC');
} }
} }
$this->_cachePrefix = $newCachePrefix; }
} // function copyCellCollection() $this->_cachePrefix = $newCachePrefix;
} // function copyCellCollection()
/**
* Clear the cell collection and disconnect from our parent /**
* * Clear the cell collection and disconnect from our parent
* @return void *
*/ * @return void
public function unsetWorksheetCells() { */
if ($this->_currentObject !== NULL) { public function unsetWorksheetCells() {
$this->_currentObject->detach(); if ($this->_currentObject !== NULL) {
$this->_currentObject = $this->_currentObjectID = null; $this->_currentObject->detach();
} $this->_currentObject = $this->_currentObjectID = null;
}
// Flush the APC cache
$this->__destruct(); // Flush the APC cache
$this->__destruct();
$this->_cellCache = array();
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null; // detach ourself from the worksheet, so that it can then delete this object successfully
} // function unsetWorksheetCells() $this->_parent = null;
} // function unsetWorksheetCells()
/**
* Initialise this new cell collection /**
* * Initialise this new cell collection
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection *
* @param array of mixed $arguments Additional initialisation arguments * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
*/ * @param array of mixed $arguments Additional initialisation arguments
public function __construct(PHPExcel_Worksheet $parent, $arguments) { */
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; public function __construct(PHPExcel_Worksheet $parent, $arguments) {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if ($this->_cachePrefix === NULL) {
$baseUnique = $this->_getUniqueID(); if ($this->_cachePrefix === NULL) {
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.'; $baseUnique = $this->_getUniqueID();
$this->_cacheTime = $cacheTime; $this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
$this->_cacheTime = $cacheTime;
parent::__construct($parent);
} parent::__construct($parent);
} // function __construct() }
} // function __construct()
/**
* Destroy this cell collection /**
*/ * Destroy this cell collection
public function __destruct() { */
$cacheList = $this->getCellList(); public function __destruct() {
foreach($cacheList as $cellID) { $cacheList = $this->getCellList();
apc_delete($this->_cachePrefix.$cellID.'.cache'); foreach($cacheList as $cellID) {
} apc_delete($this->_cachePrefix.$cellID.'.cache');
} // function __destruct() }
} // function __destruct()
/**
* Identify whether the caching method is currently available /**
* Some methods are dependent on the availability of certain extensions being enabled in the PHP build * Identify whether the caching method is currently available
* * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
* @return boolean *
*/ * @return boolean
public static function cacheMethodIsAvailable() { */
if (!function_exists('apc_store')) { public static function cacheMethodIsAvailable() {
return false; if (!function_exists('apc_store')) {
} return FALSE;
if (apc_sma_info() === false) { }
return false; if (apc_sma_info() === FALSE) {
} return FALSE;
}
return true;
} return TRUE;
}
}
}

View File

@ -21,18 +21,18 @@
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** PHPExcel root directory */ /** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) { if (!defined('PHPEXCEL_ROOT')) {
/** /**
* @ignore * @ignore
*/ */
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
} }
@ -45,148 +45,148 @@ if (!defined('PHPEXCEL_ROOT')) {
*/ */
class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
{ {
/** /**
* Bind value to a cell * Bind value to a cell
* *
* @param PHPExcel_Cell $cell Cell to bind value to * @param PHPExcel_Cell $cell Cell to bind value to
* @param mixed $value Value to bind in cell * @param mixed $value Value to bind in cell
* @return boolean * @return boolean
*/ */
public function bindValue(PHPExcel_Cell $cell, $value = null) public function bindValue(PHPExcel_Cell $cell, $value = null)
{ {
// sanitize UTF-8 strings // sanitize UTF-8 strings
if (is_string($value)) { if (is_string($value)) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value); $value = PHPExcel_Shared_String::SanitizeUTF8($value);
} }
// Find out data type // Find out data type
$dataType = parent::dataTypeForValue($value); $dataType = parent::dataTypeForValue($value);
// Style logic - strings // Style logic - strings
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) { if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
// Test for booleans using locale-setting // Test for booleans using locale-setting
if ($value == PHPExcel_Calculation::getTRUE()) { if ($value == PHPExcel_Calculation::getTRUE()) {
$cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL); $cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL);
return true; return true;
} elseif($value == PHPExcel_Calculation::getFALSE()) { } elseif($value == PHPExcel_Calculation::getFALSE()) {
$cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL); $cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL);
return true; return true;
} }
// Check for number in scientific format // Check for number in scientific format
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) { if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) {
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
return true; return true;
} }
// Check for fraction // Check for fraction
if (preg_match('/^([+-]?) *([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) { if (preg_match('/^([+-]?) *([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
// Convert value to number // Convert value to number
$value = $matches[2] / $matches[3]; $value = $matches[2] / $matches[3];
if ($matches[1] == '-') $value = 0 - $value; if ($matches[1] == '-') $value = 0 - $value;
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getParent()->getStyle( $cell->getCoordinate() ) $cell->getParent()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( '??/??' ); ->getNumberFormat()->setFormatCode( '??/??' );
return true; return true;
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) { } elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
// Convert value to number // Convert value to number
$value = $matches[2] + ($matches[3] / $matches[4]); $value = $matches[2] + ($matches[3] / $matches[4]);
if ($matches[1] == '-') $value = 0 - $value; if ($matches[1] == '-') $value = 0 - $value;
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getParent()->getStyle( $cell->getCoordinate() ) $cell->getParent()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( '# ??/??' ); ->getNumberFormat()->setFormatCode( '# ??/??' );
return true; return true;
} }
// Check for percentage // Check for percentage
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) { if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
// Convert value to number // Convert value to number
$value = (float) str_replace('%', '', $value) / 100; $value = (float) str_replace('%', '', $value) / 100;
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getParent()->getStyle( $cell->getCoordinate() ) $cell->getParent()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 ); ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 );
return true; return true;
} }
// Check for currency // Check for currency
$currencyCode = PHPExcel_Shared_String::getCurrencyCode(); $currencyCode = PHPExcel_Shared_String::getCurrencyCode();
$decimalSeparator = PHPExcel_Shared_String::getDecimalSeparator(); $decimalSeparator = PHPExcel_Shared_String::getDecimalSeparator();
$thousandsSeparator = PHPExcel_Shared_String::getThousandsSeparator(); $thousandsSeparator = PHPExcel_Shared_String::getThousandsSeparator();
if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) { if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) {
// Convert value to number // Convert value to number
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value)); $value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getParent()->getStyle( $cell->getCoordinate() ) $cell->getParent()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( ->getNumberFormat()->setFormatCode(
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ) str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
); );
return true; return true;
} elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) { } elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
// Convert value to number // Convert value to number
$value = (float) trim(str_replace(array('$',','), '', $value)); $value = (float) trim(str_replace(array('$',','), '', $value));
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getParent()->getStyle( $cell->getCoordinate() ) $cell->getParent()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ); ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
return true; return true;
} }
// Check for time without seconds 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)) { if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
// Convert value to number // Convert value to number
list($h, $m) = explode(':', $value); list($h, $m) = explode(':', $value);
$days = $h / 24 + $m / 1440; $days = $h / 24 + $m / 1440;
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getParent()->getStyle( $cell->getCoordinate() ) $cell->getParent()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 ); ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
return true; return true;
} }
// Check for time with seconds '9:45:59', '09:45:59' // 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)) { if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) {
// Convert value to number // Convert value to number
list($h, $m, $s) = explode(':', $value); list($h, $m, $s) = explode(':', $value);
$days = $h / 24 + $m / 1440 + $s / 86400; $days = $h / 24 + $m / 1440 + $s / 86400;
// Convert value to number // Convert value to number
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getParent()->getStyle( $cell->getCoordinate() ) $cell->getParent()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 ); ->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
return true; return true;
} }
// Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10' // Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10'
if (($d = PHPExcel_Shared_Date::stringToExcel($value)) !== false) { if (($d = PHPExcel_Shared_Date::stringToExcel($value)) !== false) {
// Convert value to number // Convert value to number
$cell->setValueExplicit($d, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit($d, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Determine style. Either there is a time part or not. Look for ':' // Determine style. Either there is a time part or not. Look for ':'
if (strpos($value, ':') !== false) { if (strpos($value, ':') !== false) {
$formatCode = 'yyyy-mm-dd h:mm'; $formatCode = 'yyyy-mm-dd h:mm';
} else { } else {
$formatCode = 'yyyy-mm-dd'; $formatCode = 'yyyy-mm-dd';
} }
$cell->getParent()->getStyle( $cell->getCoordinate() ) $cell->getParent()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode($formatCode); ->getNumberFormat()->setFormatCode($formatCode);
return true; return true;
} }
// Check for newline character "\n" // Check for newline character "\n"
if (strpos($value, "\n") !== FALSE) { if (strpos($value, "\n") !== FALSE) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value); $value = PHPExcel_Shared_String::SanitizeUTF8($value);
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING); $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
// Set style // Set style
$cell->getParent()->getStyle( $cell->getCoordinate() ) $cell->getParent()->getStyle( $cell->getCoordinate() )
->getAlignment()->setWrapText(TRUE); ->getAlignment()->setWrapText(TRUE);
return true; return true;
} }
} }
// Not bound yet? Use parent... // Not bound yet? Use parent...
return parent::bindValue($cell, $value); return parent::bindValue($cell, $value);
} }
} }

View File

@ -21,7 +21,7 @@
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
@ -35,80 +35,88 @@
*/ */
class PHPExcel_Cell_DataType class PHPExcel_Cell_DataType
{ {
/* Data types */ /* Data types */
const TYPE_STRING2 = 'str'; const TYPE_STRING2 = 'str';
const TYPE_STRING = 's'; const TYPE_STRING = 's';
const TYPE_FORMULA = 'f'; const TYPE_FORMULA = 'f';
const TYPE_NUMERIC = 'n'; const TYPE_NUMERIC = 'n';
const TYPE_BOOL = 'b'; const TYPE_BOOL = 'b';
const TYPE_NULL = 'null'; const TYPE_NULL = 'null';
const TYPE_INLINE = 'inlineStr'; const TYPE_INLINE = 'inlineStr';
const TYPE_ERROR = 'e'; const TYPE_ERROR = 'e';
/** /**
* List of error codes * List of error codes
* *
* @var array * @var array
*/ */
private static $_errorCodes = array('#NULL!' => 0, '#DIV/0!' => 1, '#VALUE!' => 2, '#REF!' => 3, '#NAME?' => 4, '#NUM!' => 5, '#N/A' => 6); private static $_errorCodes = array(
'#NULL!' => 0,
'#DIV/0!' => 1,
'#VALUE!' => 2,
'#REF!' => 3,
'#NAME?' => 4,
'#NUM!' => 5,
'#N/A' => 6
);
/** /**
* Get list of error codes * Get list of error codes
* *
* @return array * @return array
*/ */
public static function getErrorCodes() { public static function getErrorCodes() {
return self::$_errorCodes; return self::$_errorCodes;
} }
/** /**
* DataType for value * DataType for value
* *
* @deprecated Replaced by PHPExcel_Cell_IValueBinder infrastructure * @deprecated Replaced by PHPExcel_Cell_IValueBinder infrastructure, will be removed in version 1.8.0
* @param mixed $pValue * @param mixed $pValue
* @return int * @return string
*/ */
public static function dataTypeForValue($pValue = null) { public static function dataTypeForValue($pValue = null) {
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue); return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
} }
/** /**
* Check a string that it satisfies Excel requirements * Check a string that it satisfies Excel requirements
* *
* @param mixed Value to sanitize to an Excel string * @param mixed Value to sanitize to an Excel string
* @return mixed Sanitized value * @return mixed Sanitized value
*/ */
public static function checkString($pValue = null) public static function checkString($pValue = null)
{ {
if ($pValue instanceof PHPExcel_RichText) { if ($pValue instanceof PHPExcel_RichText) {
// TODO: Sanitize Rich-Text string (max. character count is 32,767) // TODO: Sanitize Rich-Text string (max. character count is 32,767)
return $pValue; return $pValue;
} }
// string must never be longer than 32,767 characters, truncate if necessary // string must never be longer than 32,767 characters, truncate if necessary
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767); $pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767);
// we require that newline is represented as "\n" in core, not as "\r\n" or "\r" // we require that newline is represented as "\n" in core, not as "\r\n" or "\r"
$pValue = str_replace(array("\r\n", "\r"), "\n", $pValue); $pValue = str_replace(array("\r\n", "\r"), "\n", $pValue);
return $pValue; return $pValue;
} }
/** /**
* Check a value that it is a valid error code * Check a value that it is a valid error code
* *
* @param mixed Value to sanitize to an Excel error code * @param mixed Value to sanitize to an Excel error code
* @return string Sanitized value * @return string Sanitized value
*/ */
public static function checkErrorCode($pValue = null) public static function checkErrorCode($pValue = null)
{ {
$pValue = (string)$pValue; $pValue = (string) $pValue;
if ( !array_key_exists($pValue, self::$_errorCodes) ) { if ( !array_key_exists($pValue, self::$_errorCodes) ) {
$pValue = '#NULL!'; $pValue = '#NULL!';
} }
return $pValue; return $pValue;
} }
} }

View File

@ -21,7 +21,7 @@
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
@ -35,30 +35,30 @@
*/ */
class PHPExcel_Cell_DataValidation class PHPExcel_Cell_DataValidation
{ {
/* Data validation types */ /* Data validation types */
const TYPE_NONE = 'none'; const TYPE_NONE = 'none';
const TYPE_CUSTOM = 'custom'; const TYPE_CUSTOM = 'custom';
const TYPE_DATE = 'date'; const TYPE_DATE = 'date';
const TYPE_DECIMAL = 'decimal'; const TYPE_DECIMAL = 'decimal';
const TYPE_LIST = 'list'; const TYPE_LIST = 'list';
const TYPE_TEXTLENGTH = 'textLength'; const TYPE_TEXTLENGTH = 'textLength';
const TYPE_TIME = 'time'; const TYPE_TIME = 'time';
const TYPE_WHOLE = 'whole'; const TYPE_WHOLE = 'whole';
/* Data validation error styles */ /* Data validation error styles */
const STYLE_STOP = 'stop'; const STYLE_STOP = 'stop';
const STYLE_WARNING = 'warning'; const STYLE_WARNING = 'warning';
const STYLE_INFORMATION = 'information'; const STYLE_INFORMATION = 'information';
/* Data validation operators */ /* Data validation operators */
const OPERATOR_BETWEEN = 'between'; const OPERATOR_BETWEEN = 'between';
const OPERATOR_EQUAL = 'equal'; const OPERATOR_EQUAL = 'equal';
const OPERATOR_GREATERTHAN = 'greaterThan'; const OPERATOR_GREATERTHAN = 'greaterThan';
const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual'; const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
const OPERATOR_LESSTHAN = 'lessThan'; const OPERATOR_LESSTHAN = 'lessThan';
const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual'; const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
const OPERATOR_NOTBETWEEN = 'notBetween'; const OPERATOR_NOTBETWEEN = 'notBetween';
const OPERATOR_NOTEQUAL = 'notEqual'; const OPERATOR_NOTEQUAL = 'notEqual';
/** /**
* Formula 1 * Formula 1
@ -154,321 +154,321 @@ class PHPExcel_Cell_DataValidation
/** /**
* Create a new PHPExcel_Cell_DataValidation * Create a new PHPExcel_Cell_DataValidation
* *
* @throws Exception * @throws Exception
*/ */
public function __construct() public function __construct()
{ {
// Initialise member variables // Initialise member variables
$this->_formula1 = ''; $this->_formula1 = '';
$this->_formula2 = ''; $this->_formula2 = '';
$this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE; $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
$this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
$this->_operator = ''; $this->_operator = '';
$this->_allowBlank = false; $this->_allowBlank = FALSE;
$this->_showDropDown = false; $this->_showDropDown = FALSE;
$this->_showInputMessage = false; $this->_showInputMessage = FALSE;
$this->_showErrorMessage = false; $this->_showErrorMessage = FALSE;
$this->_errorTitle = ''; $this->_errorTitle = '';
$this->_error = ''; $this->_error = '';
$this->_promptTitle = ''; $this->_promptTitle = '';
$this->_prompt = ''; $this->_prompt = '';
} }
/** /**
* Get Formula 1 * Get Formula 1
* *
* @return string * @return string
*/ */
public function getFormula1() { public function getFormula1() {
return $this->_formula1; return $this->_formula1;
}
/**
* Set Formula 1
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setFormula1($value = '') {
$this->_formula1 = $value;
return $this;
}
/**
* Get Formula 2
*
* @return string
*/
public function getFormula2() {
return $this->_formula2;
}
/**
* Set Formula 2
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setFormula2($value = '') {
$this->_formula2 = $value;
return $this;
}
/**
* Get Type
*
* @return string
*/
public function getType() {
return $this->_type;
}
/**
* Set Type
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) {
$this->_type = $value;
return $this;
}
/**
* Get Error style
*
* @return string
*/
public function getErrorStyle() {
return $this->_errorStyle;
}
/**
* Set Error style
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) {
$this->_errorStyle = $value;
return $this;
}
/**
* Get Operator
*
* @return string
*/
public function getOperator() {
return $this->_operator;
}
/**
* Set Operator
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setOperator($value = '') {
$this->_operator = $value;
return $this;
}
/**
* Get Allow Blank
*
* @return boolean
*/
public function getAllowBlank() {
return $this->_allowBlank;
}
/**
* Set Allow Blank
*
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setAllowBlank($value = false) {
$this->_allowBlank = $value;
return $this;
}
/**
* Get Show DropDown
*
* @return boolean
*/
public function getShowDropDown() {
return $this->_showDropDown;
}
/**
* Set Show DropDown
*
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setShowDropDown($value = false) {
$this->_showDropDown = $value;
return $this;
}
/**
* Get Show InputMessage
*
* @return boolean
*/
public function getShowInputMessage() {
return $this->_showInputMessage;
}
/**
* Set Show InputMessage
*
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setShowInputMessage($value = false) {
$this->_showInputMessage = $value;
return $this;
}
/**
* Get Show ErrorMessage
*
* @return boolean
*/
public function getShowErrorMessage() {
return $this->_showErrorMessage;
}
/**
* Set Show ErrorMessage
*
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setShowErrorMessage($value = false) {
$this->_showErrorMessage = $value;
return $this;
}
/**
* Get Error title
*
* @return string
*/
public function getErrorTitle() {
return $this->_errorTitle;
}
/**
* Set Error title
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setErrorTitle($value = '') {
$this->_errorTitle = $value;
return $this;
}
/**
* Get Error
*
* @return string
*/
public function getError() {
return $this->_error;
}
/**
* Set Error
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setError($value = '') {
$this->_error = $value;
return $this;
}
/**
* Get Prompt title
*
* @return string
*/
public function getPromptTitle() {
return $this->_promptTitle;
}
/**
* Set Prompt title
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setPromptTitle($value = '') {
$this->_promptTitle = $value;
return $this;
}
/**
* Get Prompt
*
* @return string
*/
public function getPrompt() {
return $this->_prompt;
}
/**
* Set Prompt
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setPrompt($value = '') {
$this->_prompt = $value;
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
return md5(
$this->_formula1
. $this->_formula2
. $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE
. $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
. $this->_operator
. ($this->_allowBlank ? 't' : 'f')
. ($this->_showDropDown ? 't' : 'f')
. ($this->_showInputMessage ? 't' : 'f')
. ($this->_showErrorMessage ? 't' : 'f')
. $this->_errorTitle
. $this->_error
. $this->_promptTitle
. $this->_prompt
. __CLASS__
);
} }
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Set Formula 1
*/ *
public function __clone() { * @param string $value
$vars = get_object_vars($this); * @return PHPExcel_Cell_DataValidation
foreach ($vars as $key => $value) { */
if (is_object($value)) { public function setFormula1($value = '') {
$this->$key = clone $value; $this->_formula1 = $value;
} else { return $this;
$this->$key = $value; }
}
} /**
} * Get Formula 2
*
* @return string
*/
public function getFormula2() {
return $this->_formula2;
}
/**
* Set Formula 2
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setFormula2($value = '') {
$this->_formula2 = $value;
return $this;
}
/**
* Get Type
*
* @return string
*/
public function getType() {
return $this->_type;
}
/**
* Set Type
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) {
$this->_type = $value;
return $this;
}
/**
* Get Error style
*
* @return string
*/
public function getErrorStyle() {
return $this->_errorStyle;
}
/**
* Set Error style
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) {
$this->_errorStyle = $value;
return $this;
}
/**
* Get Operator
*
* @return string
*/
public function getOperator() {
return $this->_operator;
}
/**
* Set Operator
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setOperator($value = '') {
$this->_operator = $value;
return $this;
}
/**
* Get Allow Blank
*
* @return boolean
*/
public function getAllowBlank() {
return $this->_allowBlank;
}
/**
* Set Allow Blank
*
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setAllowBlank($value = false) {
$this->_allowBlank = $value;
return $this;
}
/**
* Get Show DropDown
*
* @return boolean
*/
public function getShowDropDown() {
return $this->_showDropDown;
}
/**
* Set Show DropDown
*
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setShowDropDown($value = false) {
$this->_showDropDown = $value;
return $this;
}
/**
* Get Show InputMessage
*
* @return boolean
*/
public function getShowInputMessage() {
return $this->_showInputMessage;
}
/**
* Set Show InputMessage
*
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setShowInputMessage($value = false) {
$this->_showInputMessage = $value;
return $this;
}
/**
* Get Show ErrorMessage
*
* @return boolean
*/
public function getShowErrorMessage() {
return $this->_showErrorMessage;
}
/**
* Set Show ErrorMessage
*
* @param boolean $value
* @return PHPExcel_Cell_DataValidation
*/
public function setShowErrorMessage($value = false) {
$this->_showErrorMessage = $value;
return $this;
}
/**
* Get Error title
*
* @return string
*/
public function getErrorTitle() {
return $this->_errorTitle;
}
/**
* Set Error title
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setErrorTitle($value = '') {
$this->_errorTitle = $value;
return $this;
}
/**
* Get Error
*
* @return string
*/
public function getError() {
return $this->_error;
}
/**
* Set Error
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setError($value = '') {
$this->_error = $value;
return $this;
}
/**
* Get Prompt title
*
* @return string
*/
public function getPromptTitle() {
return $this->_promptTitle;
}
/**
* Set Prompt title
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setPromptTitle($value = '') {
$this->_promptTitle = $value;
return $this;
}
/**
* Get Prompt
*
* @return string
*/
public function getPrompt() {
return $this->_prompt;
}
/**
* Set Prompt
*
* @param string $value
* @return PHPExcel_Cell_DataValidation
*/
public function setPrompt($value = '') {
$this->_prompt = $value;
return $this;
}
/**
* Get hash code
*
* @return string Hash code
*/
public function getHashCode() {
return md5(
$this->_formula1
. $this->_formula2
. $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE
. $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
. $this->_operator
. ($this->_allowBlank ? 't' : 'f')
. ($this->_showDropDown ? 't' : 'f')
. ($this->_showInputMessage ? 't' : 'f')
. ($this->_showErrorMessage ? 't' : 'f')
. $this->_errorTitle
. $this->_error
. $this->_promptTitle
. $this->_prompt
. __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 (is_object($value)) {
$this->$key = clone $value;
} else {
$this->$key = $value;
}
}
}
} }

View File

@ -21,18 +21,18 @@
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** PHPExcel root directory */ /** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) { if (!defined('PHPEXCEL_ROOT')) {
/** /**
* @ignore * @ignore
*/ */
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
} }
@ -45,62 +45,62 @@ if (!defined('PHPEXCEL_ROOT')) {
*/ */
class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
{ {
/** /**
* Bind value to a cell * Bind value to a cell
* *
* @param PHPExcel_Cell $cell Cell to bind value to * @param PHPExcel_Cell $cell Cell to bind value to
* @param mixed $value Value to bind in cell * @param mixed $value Value to bind in cell
* @return boolean * @return boolean
*/ */
public function bindValue(PHPExcel_Cell $cell, $value = null) public function bindValue(PHPExcel_Cell $cell, $value = null)
{ {
// sanitize UTF-8 strings // sanitize UTF-8 strings
if (is_string($value)) { if (is_string($value)) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value); $value = PHPExcel_Shared_String::SanitizeUTF8($value);
} }
// Set value explicit // Set value explicit
$cell->setValueExplicit( $value, self::dataTypeForValue($value) ); $cell->setValueExplicit( $value, self::dataTypeForValue($value) );
// Done! // Done!
return true; return TRUE;
} }
/** /**
* DataType for value * DataType for value
* *
* @param mixed $pValue * @param mixed $pValue
* @return int * @return string
*/ */
public static function dataTypeForValue($pValue = null) { public static function dataTypeForValue($pValue = null) {
// Match the value against a few data types // Match the value against a few data types
if (is_null($pValue)) { if (is_null($pValue)) {
return PHPExcel_Cell_DataType::TYPE_NULL; return PHPExcel_Cell_DataType::TYPE_NULL;
} elseif ($pValue === '') { } elseif ($pValue === '') {
return PHPExcel_Cell_DataType::TYPE_STRING; return PHPExcel_Cell_DataType::TYPE_STRING;
} elseif ($pValue instanceof PHPExcel_RichText) { } elseif ($pValue instanceof PHPExcel_RichText) {
return PHPExcel_Cell_DataType::TYPE_INLINE; return PHPExcel_Cell_DataType::TYPE_INLINE;
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) { } elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
return PHPExcel_Cell_DataType::TYPE_FORMULA; return PHPExcel_Cell_DataType::TYPE_FORMULA;
} elseif (is_bool($pValue)) { } elseif (is_bool($pValue)) {
return PHPExcel_Cell_DataType::TYPE_BOOL; return PHPExcel_Cell_DataType::TYPE_BOOL;
} elseif (is_float($pValue) || is_int($pValue)) { } elseif (is_float($pValue) || is_int($pValue)) {
return PHPExcel_Cell_DataType::TYPE_NUMERIC; return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) { } elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) {
return PHPExcel_Cell_DataType::TYPE_NUMERIC; return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) { } elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) {
return PHPExcel_Cell_DataType::TYPE_ERROR; return PHPExcel_Cell_DataType::TYPE_ERROR;
} else { } else {
return PHPExcel_Cell_DataType::TYPE_STRING; return PHPExcel_Cell_DataType::TYPE_STRING;
} }
} }
} }

View File

@ -21,7 +21,7 @@
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
@ -35,93 +35,92 @@
*/ */
class PHPExcel_Cell_Hyperlink class PHPExcel_Cell_Hyperlink
{ {
/** /**
* URL to link the cell to * URL to link the cell to
* *
* @var string * @var string
*/ */
private $_url; private $_url;
/** /**
* Tooltip to display on the hyperlink * Tooltip to display on the hyperlink
* *
* @var string * @var string
*/ */
private $_tooltip; private $_tooltip;
/** /**
* Create a new PHPExcel_Cell_Hyperlink * Create a new PHPExcel_Cell_Hyperlink
* *
* @param string $pUrl Url to link the cell to * @param string $pUrl Url to link the cell to
* @param string $pTooltip Tooltip to display on the hyperlink * @param string $pTooltip Tooltip to display on the hyperlink
* @throws Exception
*/ */
public function __construct($pUrl = '', $pTooltip = '') public function __construct($pUrl = '', $pTooltip = '')
{ {
// Initialise member variables // Initialise member variables
$this->_url = $pUrl; $this->_url = $pUrl;
$this->_tooltip = $pTooltip; $this->_tooltip = $pTooltip;
} }
/** /**
* Get URL * Get URL
* *
* @return string * @return string
*/ */
public function getUrl() { public function getUrl() {
return $this->_url; return $this->_url;
} }
/** /**
* Set URL * Set URL
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_Hyperlink * @return PHPExcel_Cell_Hyperlink
*/ */
public function setUrl($value = '') { public function setUrl($value = '') {
$this->_url = $value; $this->_url = $value;
return $this; return $this;
} }
/** /**
* Get tooltip * Get tooltip
* *
* @return string * @return string
*/ */
public function getTooltip() { public function getTooltip() {
return $this->_tooltip; return $this->_tooltip;
} }
/** /**
* Set tooltip * Set tooltip
* *
* @param string $value * @param string $value
* @return PHPExcel_Cell_Hyperlink * @return PHPExcel_Cell_Hyperlink
*/ */
public function setTooltip($value = '') { public function setTooltip($value = '') {
$this->_tooltip = $value; $this->_tooltip = $value;
return $this; return $this;
} }
/** /**
* Is this hyperlink internal? (to another sheet) * Is this hyperlink internal? (to another worksheet)
* *
* @return boolean * @return boolean
*/ */
public function isInternal() { public function isInternal() {
return strpos($this->_url, 'sheet://') !== false; return strpos($this->_url, 'sheet://') !== false;
} }
/** /**
* Get hash code * Get hash code
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode() {
return md5( return md5(
$this->_url $this->_url
. $this->_tooltip . $this->_tooltip
. __CLASS__ . __CLASS__
); );
} }
} }

View File

@ -21,7 +21,7 @@
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Cell * @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
@ -35,12 +35,12 @@
*/ */
interface PHPExcel_Cell_IValueBinder interface PHPExcel_Cell_IValueBinder
{ {
/** /**
* Bind value to a cell * Bind value to a cell
* *
* @param PHPExcel_Cell $cell Cell to bind value to * @param PHPExcel_Cell $cell Cell to bind value to
* @param mixed $value Value to bind in cell * @param mixed $value Value to bind in cell
* @return boolean * @return boolean
*/ */
public function bindValue(PHPExcel_Cell $cell, $value = null); public function bindValue(PHPExcel_Cell $cell, $value = NULL);
} }

View File

@ -182,9 +182,6 @@ class PHPExcel_Shared_OLERead {
$pos = $block * self::SMALL_BLOCK_SIZE; $pos = $block * self::SMALL_BLOCK_SIZE;
$streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE); $streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);
// $block = $this->smallBlockChain[$block];
// $block = unpack('l', substr($this->smallBlockChain, $block*4, 4));
// $block = $block[1];
$block = self::_GetInt4d($this->smallBlockChain, $block*4); $block = self::_GetInt4d($this->smallBlockChain, $block*4);
} }
@ -202,9 +199,6 @@ class PHPExcel_Shared_OLERead {
while ($block != -2) { while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE; $pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); $streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
// $block = $this->bigBlockChain[$block];
// $block = unpack('l', substr($this->bigBlockChain, $block*4, 4));
// $block = $block[1];
$block = self::_GetInt4d($this->bigBlockChain, $block*4); $block = self::_GetInt4d($this->bigBlockChain, $block*4);
} }
@ -226,9 +220,6 @@ class PHPExcel_Shared_OLERead {
while ($block != -2) { while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE; $pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); $data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
// $block = $this->bigBlockChain[$block];
// $block = unpack('l', substr($this->bigBlockChain, $block*4, 4));
// $block = $block[1];
$block = self::_GetInt4d($this->bigBlockChain, $block*4); $block = self::_GetInt4d($this->bigBlockChain, $block*4);
} }
return $data; return $data;

View File

@ -434,7 +434,6 @@ class PHPExcel_Shared_String
{ {
// character count // character count
$ln = self::CountCharacters($value, 'UTF-8'); $ln = self::CountCharacters($value, 'UTF-8');
// option flags // option flags
if(empty($arrcRuns)){ if(empty($arrcRuns)){
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ? $opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?

View File

@ -1029,7 +1029,6 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// End row // End row
$objWriter->endElement(); $objWriter->endElement();
} }
// $objWriter->flush();
} }
$objWriter->endElement(); $objWriter->endElement();

View File

@ -656,7 +656,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
private function _writeRichTextString($row, $col, $str, $xfIndex, $arrcRun){ private function _writeRichTextString($row, $col, $str, $xfIndex, $arrcRun){
$record = 0x00FD; // Record identifier $record = 0x00FD; // Record identifier
$length = 0x000A; // Bytes to follow $length = 0x000A; // Bytes to follow
$str = PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($str, $arrcRun); $str = PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($str, $arrcRun);
/* check if string is already present */ /* check if string is already present */
@ -2962,12 +2961,12 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
private function _writePageLayoutView(){ private function _writePageLayoutView(){
$record = 0x088B; // Record identifier $record = 0x088B; // Record identifier
$length = 0x0010; // Bytes to follow $length = 0x0010; // Bytes to follow
$rt = 0x088B; // 2 $rt = 0x088B; // 2
$grbitFrt = 0x0000; // 2 $grbitFrt = 0x0000; // 2
$reserved = 0x0000000000000000; // 8 $reserved = 0x0000000000000000; // 8
$wScalvePLV = $this->_phpSheet->getSheetView()->getZoomScale(); // 2 $wScalvePLV = $this->_phpSheet->getSheetView()->getZoomScale(); // 2
// The options flags that comprise $grbit // The options flags that comprise $grbit
if($this->_phpSheet->getSheetView()->getView() == PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT){ if($this->_phpSheet->getSheetView()->getView() == PHPExcel_Worksheet_SheetView::SHEETVIEW_PAGE_LAYOUT){
$fPageLayoutView = 1; $fPageLayoutView = 1;
@ -2975,12 +2974,12 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
$fPageLayoutView = 0; $fPageLayoutView = 0;
} }
$fRulerVisible = 0; $fRulerVisible = 0;
$fWhitespaceHidden = 0; $fWhitespaceHidden = 0;
$grbit = $fPageLayoutView; // 2 $grbit = $fPageLayoutView; // 2
$grbit |= $fRulerVisible << 1; $grbit |= $fRulerVisible << 1;
$grbit |= $fWhitespaceHidden << 3; $grbit |= $fWhitespaceHidden << 3;
$header = pack("vv", $record, $length); $header = pack("vv", $record, $length);
$data = pack("vvVVvv", $rt, $grbitFrt, 0x00000000, 0x00000000, $wScalvePLV, $grbit); $data = pack("vvVVvv", $rt, $grbitFrt, 0x00000000, 0x00000000, $wScalvePLV, $grbit);
$this->_append($header . $data); $this->_append($header . $data);

View File

@ -1126,10 +1126,11 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$rowSpan = 1; $rowSpan = 1;
// initialize // initialize
$cellData = ''; $cellData = '&nbsp;';
// PHPExcel_Cell // PHPExcel_Cell
if ($cell instanceof PHPExcel_Cell) { if ($cell instanceof PHPExcel_Cell) {
$cellData = '';
if (is_null($cell->getParent())) { if (is_null($cell->getParent())) {
$cell->attach($pSheet); $cell->attach($pSheet);
} }

View File

@ -76,14 +76,32 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel5 file // Save Excel5 file
echo date('H:i:s') , " Write to Excel5 format" , EOL; echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -76,14 +76,32 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Save Excel5 file echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL; echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -122,16 +122,34 @@ $objPHPExcel->getActiveSheet()->setTitle('Datatypes');
$objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL; echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
echo date('H:i:s') , " Reload workbook from saved file" , EOL; echo date('H:i:s') , " Reload workbook from saved file" , EOL;
$callStartTime = microtime(true);
$objPHPExcel = PHPExcel_IOFactory::load(str_replace('.php', '.xls', __FILE__)); $objPHPExcel = PHPExcel_IOFactory::load(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo 'Call time to reload Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
var_dump($objPHPExcel->getActiveSheet()->toArray()); var_dump($objPHPExcel->getActiveSheet()->toArray());
@ -139,5 +157,5 @@ var_dump($objPHPExcel->getActiveSheet()->toArray());
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done // Echo done
echo date('H:i:s') , " Done writing file" , EOL; echo date('H:i:s') , " Done testing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL; echo 'File has been created in ' , getcwd() , EOL;

View File

@ -110,7 +110,7 @@ $objPHPExcel->getActiveSheet()->setCellValue('A12', 'NULL')
->setCellValue('C12', NULL); ->setCellValue('C12', NULL);
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
// Rename worksheet // Rename worksheet
@ -124,14 +124,31 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
echo date('H:i:s') , " Reload workbook from saved file" , EOL; echo date('H:i:s') , " Reload workbook from saved file" , EOL;
$callStartTime = microtime(true);
$objPHPExcel = PHPExcel_IOFactory::load(str_replace('.php', '.xlsx', __FILE__)); $objPHPExcel = PHPExcel_IOFactory::load(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo 'Call time to reload Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
var_dump($objPHPExcel->getActiveSheet()->toArray()); var_dump($objPHPExcel->getActiveSheet()->toArray());
@ -139,5 +156,5 @@ var_dump($objPHPExcel->getActiveSheet()->toArray());
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo done // Echo done
echo date('H:i:s') , " Done writing file" , EOL; echo date('H:i:s') , " Done testing file" , EOL;
echo 'File has been created in ' , getcwd() , EOL; echo 'File has been created in ' , getcwd() , EOL;

View File

@ -104,14 +104,32 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Save Excel5 file echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL; echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -89,14 +89,32 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Save Excel5 file echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL; echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -33,11 +33,11 @@ require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
// Create new PHPExcel object // Create new PHPExcel object
echo date('H:i:s') , " Create new PHPExcel object" , PHP_EOL; echo date('H:i:s') , " Create new PHPExcel object" , EOL;
$objPHPExcel = new PHPExcel(); $objPHPExcel = new PHPExcel();
// Set document properties // Set document properties
echo date('H:i:s') , " Set document properties" , PHP_EOL; echo date('H:i:s') , " Set document properties" , EOL;
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw") $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
->setLastModifiedBy("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw")
->setTitle("Office 2007 XLSX Test Document") ->setTitle("Office 2007 XLSX Test Document")
@ -48,7 +48,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
// Create a first sheet, representing sales data // Create a first sheet, representing sales data
echo date('H:i:s') , " Add some data" , PHP_EOL; echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Invoice'); $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Invoice');
$objPHPExcel->getActiveSheet()->setCellValue('D1', PHPExcel_Shared_Date::PHPToExcel( gmmktime(0,0,0,date('m'),date('d'),date('Y')) )); $objPHPExcel->getActiveSheet()->setCellValue('D1', PHPExcel_Shared_Date::PHPToExcel( gmmktime(0,0,0,date('m'),date('d'),date('Y')) ));
@ -88,7 +88,7 @@ $objPHPExcel->getActiveSheet()->setCellValue('D13', 'Total incl.:');
$objPHPExcel->getActiveSheet()->setCellValue('E13', '=E11+E12'); $objPHPExcel->getActiveSheet()->setCellValue('E13', '=E11+E12');
// Add comment // Add comment
echo date('H:i:s') , " Add comments" , PHP_EOL; echo date('H:i:s') , " Add comments" , EOL;
$objPHPExcel->getActiveSheet()->getComment('E11')->setAuthor('PHPExcel'); $objPHPExcel->getActiveSheet()->getComment('E11')->setAuthor('PHPExcel');
$objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('PHPExcel:'); $objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('PHPExcel:');
@ -114,7 +114,7 @@ $objPHPExcel->getActiveSheet()->getComment('E13')->getFillColor()->setRGB('EEEEE
// Add rich-text string // Add rich-text string
echo date('H:i:s') , " Add rich-text string" , PHP_EOL; echo date('H:i:s') , " Add rich-text string" , EOL;
$objRichText = new PHPExcel_RichText(); $objRichText = new PHPExcel_RichText();
$objRichText->createText('This invoice is '); $objRichText->createText('This invoice is ');
@ -128,28 +128,28 @@ $objRichText->createText(', unless specified otherwise on the invoice.');
$objPHPExcel->getActiveSheet()->getCell('A18')->setValue($objRichText); $objPHPExcel->getActiveSheet()->getCell('A18')->setValue($objRichText);
// Merge cells // Merge cells
echo date('H:i:s') , " Merge cells" , PHP_EOL; echo date('H:i:s') , " Merge cells" , EOL;
$objPHPExcel->getActiveSheet()->mergeCells('A18:E22'); $objPHPExcel->getActiveSheet()->mergeCells('A18:E22');
$objPHPExcel->getActiveSheet()->mergeCells('A28:B28'); // Just to test... $objPHPExcel->getActiveSheet()->mergeCells('A28:B28'); // Just to test...
$objPHPExcel->getActiveSheet()->unmergeCells('A28:B28'); // Just to test... $objPHPExcel->getActiveSheet()->unmergeCells('A28:B28'); // Just to test...
// Protect cells // Protect cells
echo date('H:i:s') , " Protect cells" , PHP_EOL; echo date('H:i:s') , " Protect cells" , EOL;
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // Needs to be set to true in order to enable any worksheet protection! $objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // Needs to be set to true in order to enable any worksheet protection!
$objPHPExcel->getActiveSheet()->protectCells('A3:E13', 'PHPExcel'); $objPHPExcel->getActiveSheet()->protectCells('A3:E13', 'PHPExcel');
// Set cell number formats // Set cell number formats
echo date('H:i:s') , " Set cell number formats" , PHP_EOL; echo date('H:i:s') , " Set cell number formats" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('E4:E13')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE); $objPHPExcel->getActiveSheet()->getStyle('E4:E13')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
// Set column widths // Set column widths
echo date('H:i:s') , " Set column widths" , PHP_EOL; echo date('H:i:s') , " Set column widths" , EOL;
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12); $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12);
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(12); $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(12);
// Set fonts // Set fonts
echo date('H:i:s') , " Set fonts" , PHP_EOL; echo date('H:i:s') , " Set fonts" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setName('Candara'); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setName('Candara');
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setSize(20); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setSize(20);
$objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true);
@ -163,7 +163,7 @@ $objPHPExcel->getActiveSheet()->getStyle('D13')->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle('E13')->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getStyle('E13')->getFont()->setBold(true);
// Set alignments // Set alignments
echo date('H:i:s') , " Set alignments" , PHP_EOL; echo date('H:i:s') , " Set alignments" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('D11')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle('D11')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->getStyle('D12')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle('D12')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->getStyle('D13')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle('D13')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
@ -174,7 +174,7 @@ $objPHPExcel->getActiveSheet()->getStyle('A18')->getAlignment()->setVertical(PHP
$objPHPExcel->getActiveSheet()->getStyle('B5')->getAlignment()->setShrinkToFit(true); $objPHPExcel->getActiveSheet()->getStyle('B5')->getAlignment()->setShrinkToFit(true);
// Set thin black border outline around column // Set thin black border outline around column
echo date('H:i:s') , " Set thin black border outline around column" , PHP_EOL; echo date('H:i:s') , " Set thin black border outline around column" , EOL;
$styleThinBlackBorderOutline = array( $styleThinBlackBorderOutline = array(
'borders' => array( 'borders' => array(
'outline' => array( 'outline' => array(
@ -187,7 +187,7 @@ $objPHPExcel->getActiveSheet()->getStyle('A4:E10')->applyFromArray($styleThinBla
// Set thick brown border outline around "Total" // Set thick brown border outline around "Total"
echo date('H:i:s') , " Set thick brown border outline around Total" , PHP_EOL; echo date('H:i:s') , " Set thick brown border outline around Total" , EOL;
$styleThickBrownBorderOutline = array( $styleThickBrownBorderOutline = array(
'borders' => array( 'borders' => array(
'outline' => array( 'outline' => array(
@ -199,12 +199,12 @@ $styleThickBrownBorderOutline = array(
$objPHPExcel->getActiveSheet()->getStyle('D13:E13')->applyFromArray($styleThickBrownBorderOutline); $objPHPExcel->getActiveSheet()->getStyle('D13:E13')->applyFromArray($styleThickBrownBorderOutline);
// Set fills // Set fills
echo date('H:i:s') , " Set fills" , PHP_EOL; echo date('H:i:s') , " Set fills" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID); $objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->getStartColor()->setARGB('FF808080'); $objPHPExcel->getActiveSheet()->getStyle('A1:E1')->getFill()->getStartColor()->setARGB('FF808080');
// Set style for header row using alternative method // Set style for header row using alternative method
echo date('H:i:s') , " Set style for header row using alternative method" , PHP_EOL; echo date('H:i:s') , " Set style for header row using alternative method" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('A3:E3')->applyFromArray( $objPHPExcel->getActiveSheet()->getStyle('A3:E3')->applyFromArray(
array( array(
'font' => array( 'font' => array(
@ -263,11 +263,11 @@ $objPHPExcel->getActiveSheet()->getStyle('E3')->applyFromArray(
); );
// Unprotect a cell // Unprotect a cell
echo date('H:i:s') , " Unprotect a cell" , PHP_EOL; echo date('H:i:s') , " Unprotect a cell" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED); $objPHPExcel->getActiveSheet()->getStyle('B1')->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
// Add a hyperlink to the sheet // Add a hyperlink to the sheet
echo date('H:i:s') , " Add a hyperlink to the sheet" , PHP_EOL; echo date('H:i:s') , " Add a hyperlink to the sheet" , EOL;
$objPHPExcel->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net'); $objPHPExcel->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');
$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net'); $objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net');
$objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website'); $objPHPExcel->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website');
@ -279,7 +279,7 @@ $objPHPExcel->getActiveSheet()->getCell('E27')->getHyperlink()->setTooltip('Revi
$objPHPExcel->getActiveSheet()->getStyle('E27')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); $objPHPExcel->getActiveSheet()->getStyle('E27')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
// Add a drawing to the worksheet // Add a drawing to the worksheet
echo date('H:i:s') , " Add a drawing to the worksheet" , PHP_EOL; echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
$objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Logo'); $objDrawing->setName('Logo');
$objDrawing->setDescription('Logo'); $objDrawing->setDescription('Logo');
@ -288,7 +288,7 @@ $objDrawing->setHeight(36);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
// Add a drawing to the worksheet // Add a drawing to the worksheet
echo date('H:i:s') , " Add a drawing to the worksheet" , PHP_EOL; echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
$objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Paid'); $objDrawing->setName('Paid');
$objDrawing->setDescription('Paid'); $objDrawing->setDescription('Paid');
@ -301,7 +301,7 @@ $objDrawing->getShadow()->setDirection(45);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
// Add a drawing to the worksheet // Add a drawing to the worksheet
echo date('H:i:s') , " Add a drawing to the worksheet" , PHP_EOL; echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
$objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('PHPExcel logo'); $objDrawing->setName('PHPExcel logo');
$objDrawing->setDescription('PHPExcel logo'); $objDrawing->setDescription('PHPExcel logo');
@ -312,36 +312,36 @@ $objDrawing->setOffsetX(10);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
// Play around with inserting and removing rows and columns // Play around with inserting and removing rows and columns
echo date('H:i:s') , " Play around with inserting and removing rows and columns" , PHP_EOL; echo date('H:i:s') , " Play around with inserting and removing rows and columns" , EOL;
$objPHPExcel->getActiveSheet()->insertNewRowBefore(6, 10); $objPHPExcel->getActiveSheet()->insertNewRowBefore(6, 10);
$objPHPExcel->getActiveSheet()->removeRow(6, 10); $objPHPExcel->getActiveSheet()->removeRow(6, 10);
$objPHPExcel->getActiveSheet()->insertNewColumnBefore('E', 5); $objPHPExcel->getActiveSheet()->insertNewColumnBefore('E', 5);
$objPHPExcel->getActiveSheet()->removeColumn('E', 5); $objPHPExcel->getActiveSheet()->removeColumn('E', 5);
// Set header and footer. When no different headers for odd/even are used, odd header is assumed. // Set header and footer. When no different headers for odd/even are used, odd header is assumed.
echo date('H:i:s') , " Set header/footer" , PHP_EOL; echo date('H:i:s') , " Set header/footer" , EOL;
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BInvoice&RPrinted on &D'); $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BInvoice&RPrinted on &D');
$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N'); $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
// Set page orientation and size // Set page orientation and size
echo date('H:i:s') , " Set page orientation and size" , PHP_EOL; echo date('H:i:s') , " Set page orientation and size" , EOL;
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT); $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4); $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
// Rename first worksheet // Rename first worksheet
echo date('H:i:s') , " Rename first worksheet" , PHP_EOL; echo date('H:i:s') , " Rename first worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Invoice'); $objPHPExcel->getActiveSheet()->setTitle('Invoice');
// Create a new worksheet, after the default sheet // Create a new worksheet, after the default sheet
echo date('H:i:s') , " Create a second Worksheet object" , PHP_EOL; echo date('H:i:s') , " Create a second Worksheet object" , EOL;
$objPHPExcel->createSheet(); $objPHPExcel->createSheet();
// Llorem ipsum... // Llorem ipsum...
$sLloremIpsum = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus eget ante. Sed cursus nunc semper tortor. Aliquam luctus purus non elit. Fusce vel elit commodo sapien dignissim dignissim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur accumsan magna sed massa. Nullam bibendum quam ac ipsum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin augue. Praesent malesuada justo sed orci. Pellentesque lacus ligula, sodales quis, ultricies a, ultricies vitae, elit. Sed luctus consectetuer dolor. Vivamus vel sem ut nisi sodales accumsan. Nunc et felis. Suspendisse semper viverra odio. Morbi at odio. Integer a orci a purus venenatis molestie. Nam mattis. Praesent rhoncus, nisi vel mattis auctor, neque nisi faucibus sem, non dapibus elit pede ac nisl. Cras turpis.'; $sLloremIpsum = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus eget ante. Sed cursus nunc semper tortor. Aliquam luctus purus non elit. Fusce vel elit commodo sapien dignissim dignissim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur accumsan magna sed massa. Nullam bibendum quam ac ipsum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin augue. Praesent malesuada justo sed orci. Pellentesque lacus ligula, sodales quis, ultricies a, ultricies vitae, elit. Sed luctus consectetuer dolor. Vivamus vel sem ut nisi sodales accumsan. Nunc et felis. Suspendisse semper viverra odio. Morbi at odio. Integer a orci a purus venenatis molestie. Nam mattis. Praesent rhoncus, nisi vel mattis auctor, neque nisi faucibus sem, non dapibus elit pede ac nisl. Cras turpis.';
// Add some data to the second sheet, resembling some different data types // Add some data to the second sheet, resembling some different data types
echo date('H:i:s') , " Add some data" , PHP_EOL; echo date('H:i:s') , " Add some data" , EOL;
$objPHPExcel->setActiveSheetIndex(1); $objPHPExcel->setActiveSheetIndex(1);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Terms and conditions'); $objPHPExcel->getActiveSheet()->setCellValue('A1', 'Terms and conditions');
$objPHPExcel->getActiveSheet()->setCellValue('A3', $sLloremIpsum); $objPHPExcel->getActiveSheet()->setCellValue('A3', $sLloremIpsum);
@ -350,19 +350,19 @@ $objPHPExcel->getActiveSheet()->setCellValue('A5', $sLloremIpsum);
$objPHPExcel->getActiveSheet()->setCellValue('A6', $sLloremIpsum); $objPHPExcel->getActiveSheet()->setCellValue('A6', $sLloremIpsum);
// Set the worksheet tab color // Set the worksheet tab color
echo date('H:i:s') , " Set the worksheet tab color" , PHP_EOL; echo date('H:i:s') , " Set the worksheet tab color" , EOL;
$objPHPExcel->getActiveSheet()->getTabColor()->setARGB('FF0094FF');; $objPHPExcel->getActiveSheet()->getTabColor()->setARGB('FF0094FF');;
// Set alignments // Set alignments
echo date('H:i:s') , " Set alignments" , PHP_EOL; echo date('H:i:s') , " Set alignments" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getAlignment()->setWrapText(true); $objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getAlignment()->setWrapText(true);
// Set column widths // Set column widths
echo date('H:i:s') , " Set column widths" , PHP_EOL; echo date('H:i:s') , " Set column widths" , EOL;
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(80); $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(80);
// Set fonts // Set fonts
echo date('H:i:s') , " Set fonts" , PHP_EOL; echo date('H:i:s') , " Set fonts" , EOL;
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setName('Candara'); $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setName('Candara');
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(20); $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(20);
$objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true);
@ -371,7 +371,7 @@ $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setUnderline(PHPExcel
$objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getFont()->setSize(8); $objPHPExcel->getActiveSheet()->getStyle('A3:A6')->getFont()->setSize(8);
// Add a drawing to the worksheet // Add a drawing to the worksheet
echo date('H:i:s') , " Add a drawing to the worksheet" , PHP_EOL; echo date('H:i:s') , " Add a drawing to the worksheet" , EOL;
$objDrawing = new PHPExcel_Worksheet_Drawing(); $objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('Terms and conditions'); $objDrawing->setName('Terms and conditions');
$objDrawing->setDescription('Terms and conditions'); $objDrawing->setDescription('Terms and conditions');
@ -380,12 +380,12 @@ $objDrawing->setCoordinates('B14');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet()); $objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
// Set page orientation and size // Set page orientation and size
echo date('H:i:s') , " Set page orientation and size" , PHP_EOL; echo date('H:i:s') , " Set page orientation and size" , EOL;
$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE); $objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);
$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4); $objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
// Rename second worksheet // Rename second worksheet
echo date('H:i:s') , " Rename second worksheet" , PHP_EOL; echo date('H:i:s') , " Rename second worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Terms and conditions'); $objPHPExcel->getActiveSheet()->setTitle('Terms and conditions');

View File

@ -42,14 +42,33 @@ require_once '../Classes/PHPExcel/IOFactory.php';
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Save Excel5 file echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL; echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage
echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL; echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;

View File

@ -39,6 +39,7 @@ require_once '../Classes/PHPExcel.php';
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip; $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip;
PHPExcel_Settings::setCacheStorageMethod($cacheMethod); PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
// Create new PHPExcel object // Create new PHPExcel object
@ -104,9 +105,17 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -113,11 +113,19 @@ for ($i = 2; $i <= 5000; $i++) {
$objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 5 file // Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL; echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -115,9 +115,17 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -42,12 +42,30 @@ if (!file_exists("05featuredemo.xlsx")) {
} }
echo date('H:i:s') , " Load from Excel2007 file" , EOL; echo date('H:i:s') , " Load from Excel2007 file" , EOL;
$callStartTime = microtime(true);
$objPHPExcel = PHPExcel_IOFactory::load("05featuredemo.xlsx"); $objPHPExcel = PHPExcel_IOFactory::load("05featuredemo.xlsx");
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo 'Call time to read Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -157,9 +157,17 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -104,9 +104,17 @@ $objPHPExcel->getActiveSheet()->duplicateConditionalStyle(
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -85,14 +85,32 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
// Save Excel5 file echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL; echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -182,19 +182,40 @@ $autoFilter->getColumn('E')
// Set active sheet index to the first sheet, so Excel opens this as the first sheet // Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s').' Write to Excel2007 format'.EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
echo date('H:i:s').' File written to '.str_replace('.php', '.xlsx', __FILE__).EOL; $callEndTime = microtime(true);
// Save Excel5 file $callTime = $callEndTime - $callStartTime;
echo date('H:i:s').' Write to Excel5 format'.EOL;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
echo date('H:i:s').' File written to '.str_replace('.php', '.xls', __FILE__).EOL; $callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage
echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL; echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;
// Echo done // Echo done
echo date('H:i:s').' Done writing file'.EOL; echo date('H:i:s').' Done writing files'.EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -174,19 +174,40 @@ $autoFilter->getColumn('E')
// Set active sheet index to the first sheet, so Excel opens this as the first sheet // Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s').' Write to Excel2007 format'.EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
echo date('H:i:s').' File written to '.str_replace('.php', '.xlsx', __FILE__).EOL; $callEndTime = microtime(true);
// Save Excel5 file $callTime = $callEndTime - $callStartTime;
echo date('H:i:s').' Write to Excel5 format'.EOL;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
echo date('H:i:s').' File written to '.str_replace('.php', '.xls', __FILE__).EOL; $callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage
echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL; echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;
// Echo done // Echo done
echo date('H:i:s').' Done writing file'.EOL; echo date('H:i:s').' Done writing files'.EOL;
echo 'Files have been created in ' , getcwd() , EOL;

View File

@ -132,16 +132,36 @@ $objPHPExcel->getActiveSheet()->setAutoFilter($objPHPExcel->getActiveSheet()->ca
// Set active sheet index to the first sheet, so Excel opens this as the first sheet // Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s').' Write to Excel2007 format'.EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
echo date('H:i:s').' File written to '.str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)).EOL; $callEndTime = microtime(true);
// Save Excel5 file $callTime = $callEndTime - $callStartTime;
echo date('H:i:s').' Write to Excel5 format'.EOL;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
echo date('H:i:s').' File written to '.str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)).EOL; $callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage
echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL; echo date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;

View File

@ -86,11 +86,19 @@ $objPHPExcel->getActiveSheet()->getProtection()->setFormatCells(true);
$objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL; echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -88,9 +88,17 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -204,9 +204,17 @@ for ($col = 'B'; $col != 'G'; ++$col) {
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -40,10 +40,19 @@ include "05featuredemo.inc.php";
require_once '../Classes/PHPExcel/IOFactory.php'; require_once '../Classes/PHPExcel/IOFactory.php';
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL; echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -98,11 +98,19 @@ $objValidation->setFormula1('"Item A,Item B,Item C"'); // Make sure to put the l
$objPHPExcel->setActiveSheetIndex(0); $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL; echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__)); $objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -100,9 +100,17 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -42,26 +42,47 @@ require_once '../Classes/PHPExcel/IOFactory.php';
echo date('H:i:s') , " Write to CSV format" , EOL; echo date('H:i:s') , " Write to CSV format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')->setDelimiter(',') $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')->setDelimiter(',')
->setEnclosure('"') ->setEnclosure('"')
->setLineEnding("\r\n") ->setLineEnding("\r\n")
->setSheetIndex(0) ->setSheetIndex(0)
->save(str_replace('.php', '.csv', __FILE__)); ->save(str_replace('.php', '.csv', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
echo date('H:i:s') , " Read from CSV format" , EOL; echo date('H:i:s') , " Read from CSV format" , EOL;
$callStartTime = microtime(true);
$objReader = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',') $objReader = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',')
->setEnclosure('"') ->setEnclosure('"')
->setLineEnding("\r\n") ->setLineEnding("\r\n")
->setSheetIndex(0); ->setSheetIndex(0);
$objPHPExcelFromCSV = $objReader->load(str_replace('.php', '.csv', __FILE__)); $objPHPExcelFromCSV = $objReader->load(str_replace('.php', '.csv', __FILE__));
echo date('H:i:s') , " File read from " , str_replace('.php', '.csv', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo 'Call time to reload Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter2007 = PHPExcel_IOFactory::createWriter($objPHPExcelFromCSV, 'Excel2007'); $objWriter2007 = PHPExcel_IOFactory::createWriter($objPHPExcelFromCSV, 'Excel2007');
$objWriter2007->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter2007->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -42,11 +42,18 @@ require_once '../Classes/PHPExcel/IOFactory.php';
echo date('H:i:s') , " Write to HTML format" , EOL; echo date('H:i:s') , " Write to HTML format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->setSheetIndex(0); $objWriter->setSheetIndex(0);
//$objWriter->setImagesRoot('http://www.example.com'); //$objWriter->setImagesRoot('http://www.example.com');
$objWriter->save(str_replace('.php', '.htm', __FILE__)); $objWriter->save(str_replace('.php', '.htm', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.htm', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -108,9 +108,17 @@ $objPHPExcel->setActiveSheetIndex(0);
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -44,12 +44,31 @@ if (!file_exists("14excel5.xls")) {
} }
echo date('H:i:s') , " Load workbook from Excel5 file" , EOL; echo date('H:i:s') , " Load workbook from Excel5 file" , EOL;
$callStartTime = microtime(true);
$objPHPExcel = PHPExcel_IOFactory::load("14excel5.xls"); $objPHPExcel = PHPExcel_IOFactory::load("14excel5.xls");
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo 'Call time to load Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -73,10 +73,17 @@ if (!PHPExcel_Settings::setPdfRenderer(
} }
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->setSheetIndex(0); $objWriter->setSheetIndex(0);
$objWriter->save(str_replace('.php', '_'.$rendererName.'.pdf', __FILE__)); $objWriter->save(str_replace('.php', '_'.$rendererName.'.pdf', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '_'.$rendererName.'.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '_'.$rendererName.'.pdf', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -80,9 +80,32 @@ $objPHPExcel->getActiveSheet()->getStyle('C5:R95')->applyFromArray(
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -88,9 +88,32 @@ $objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, "C5:R95");
// Save Excel 2007 file // Save Excel 2007 file
echo date('H:i:s') , " Write to Excel2007 format" , EOL; echo date('H:i:s') , " Write to Excel2007 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__)); $objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL; echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Save Excel 95 file
echo date('H:i:s') , " Write to Excel5 format" , EOL;
$callStartTime = microtime(true);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__));
$callEndTime = microtime(true);
$callTime = $callEndTime - $callStartTime;
echo date('H:i:s') , " File written to " , str_replace('.php', '.xls', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
echo 'Call time to write Workbook was ' , sprintf('%.4f',$callTime) , " seconds" , EOL;
// Echo memory usage
echo date('H:i:s') , ' Current memory usage: ' , (memory_get_usage(true) / 1024 / 1024) , " MB" , EOL;
// Echo memory peak usage // Echo memory peak usage

View File

@ -45,6 +45,7 @@ $aTests = array(
, '06largescale-xls.php' , '06largescale-xls.php'
, '07reader.php' , '07reader.php'
, '08conditionalformatting.php' , '08conditionalformatting.php'
, '08conditionalformatting2.php'
, '09pagebreaks.php' , '09pagebreaks.php'
, '10autofilter.php' , '10autofilter.php'
, '10autofilter-selection-1.php' , '10autofilter-selection-1.php'

View File

@ -37,6 +37,7 @@ Fixed in develop branch:
Provided an option to set the sys_get_temp_dir() call to use the upload_tmp_dir; though by default the standard temp directory will still be used Provided an option to set the sys_get_temp_dir() call to use the upload_tmp_dir; though by default the standard temp directory will still be used
- General: (amironov ) Work item GH-84 - Search style by identity in PHPExcel_Worksheet::duplicateStyle() - General: (amironov ) Work item GH-84 - Search style by identity in PHPExcel_Worksheet::duplicateStyle()
- General: (karak) Work item GH-85 - Fill SheetView IO in Excel5 - General: (karak) Work item GH-85 - Fill SheetView IO in Excel5
- General: (cfhay) Work item 18958 - Memory and Speed improvements in PHPExcel_Reader_Excel5
- Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows - Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows
- Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges - Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges
- Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't - Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't