Minor style changes, and added timings to Examples
This commit is contained in:
parent
b98f27f4a7
commit
a032194211
|
@ -74,7 +74,7 @@ class PHPExcel_Autoloader
|
|||
str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
|
||||
'.php';
|
||||
|
||||
if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
|
||||
if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) {
|
||||
// Can't load
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @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##
|
||||
*/
|
||||
|
||||
|
@ -35,246 +35,247 @@
|
|||
*/
|
||||
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_cachePrefix = null;
|
||||
/**
|
||||
* Prefix used to uniquely identify cache data for this worksheet
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_cachePrefix = null;
|
||||
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @access private
|
||||
* @var integer
|
||||
*/
|
||||
private $_cacheTime = 600;
|
||||
/**
|
||||
* Cache timeout
|
||||
*
|
||||
* @access private
|
||||
* @var integer
|
||||
*/
|
||||
private $_cacheTime = 600;
|
||||
|
||||
|
||||
/**
|
||||
* Store cell data in cache for the current cell object if it's "dirty",
|
||||
* and the 'nullify' the current cell object
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
* @throws Exception
|
||||
* @access private
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
private function _storeData() {
|
||||
if ($this->_currentCellIsDirty) {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
|
||||
}
|
||||
$this->_currentCellIsDirty = false;
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
$this->_currentCellIsDirty = true;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->_currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in apc
|
||||
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry '.$pCoord.' no longer exists in APC');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->_currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in apc
|
||||
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($success === FALSE) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry '.$pCoord.' no longer exists in APC');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($obj === FALSE) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
* @access public
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
// Delete the entry from APC
|
||||
apc_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
public function deleteCacheData($pCoord) {
|
||||
// Delete the entry from APC
|
||||
apc_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @access public
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
if ($cellID != $this->_currentObjectID) {
|
||||
$obj = apc_fetch($this->_cachePrefix.$cellID.'.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($cellID);
|
||||
throw new Exception('Cell entry '.$cellID.' no longer exists in APC');
|
||||
}
|
||||
if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell '.$cellID.' in APC');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_cachePrefix = $newCachePrefix;
|
||||
} // function copyCellCollection()
|
||||
/**
|
||||
* Clone the cell collection
|
||||
*
|
||||
* @access public
|
||||
* @param PHPExcel_Worksheet $parent The new worksheet
|
||||
* @throws PHPExcel_Exception
|
||||
* @return void
|
||||
*/
|
||||
public function copyCellCollection(PHPExcel_Worksheet $parent) {
|
||||
parent::copyCellCollection($parent);
|
||||
// Get a new id for the new file name
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
if ($cellID != $this->_currentObjectID) {
|
||||
$obj = apc_fetch($this->_cachePrefix.$cellID.'.cache');
|
||||
if ($obj === FALSE) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
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();
|
||||
throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_cachePrefix = $newCachePrefix;
|
||||
} // function copyCellCollection()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if ($this->_currentObject !== NULL) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
/**
|
||||
* Clear the cell collection and disconnect from our parent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unsetWorksheetCells() {
|
||||
if ($this->_currentObject !== 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;
|
||||
} // function unsetWorksheetCells()
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @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;
|
||||
/**
|
||||
* Initialise this new cell collection
|
||||
*
|
||||
* @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;
|
||||
|
||||
if ($this->_cachePrefix === NULL) {
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$this->_cacheTime = $cacheTime;
|
||||
if ($this->_cachePrefix === NULL) {
|
||||
$baseUnique = $this->_getUniqueID();
|
||||
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
|
||||
$this->_cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
} // function __construct()
|
||||
parent::__construct($parent);
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
apc_delete($this->_cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
/**
|
||||
* Destroy this cell collection
|
||||
*/
|
||||
public function __destruct() {
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
apc_delete($this->_cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // 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
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('apc_store')) {
|
||||
return false;
|
||||
}
|
||||
if (apc_sma_info() === false) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public static function cacheMethodIsAvailable() {
|
||||
if (!function_exists('apc_store')) {
|
||||
return FALSE;
|
||||
}
|
||||
if (apc_sma_info() === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,18 +21,18 @@
|
|||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @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##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,148 +45,148 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = null)
|
||||
{
|
||||
// sanitize UTF-8 strings
|
||||
if (is_string($value)) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
}
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = null)
|
||||
{
|
||||
// sanitize UTF-8 strings
|
||||
if (is_string($value)) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
}
|
||||
|
||||
// Find out data type
|
||||
$dataType = parent::dataTypeForValue($value);
|
||||
// Find out data type
|
||||
$dataType = parent::dataTypeForValue($value);
|
||||
|
||||
// Style logic - strings
|
||||
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
|
||||
// Test for booleans using locale-setting
|
||||
if ($value == PHPExcel_Calculation::getTRUE()) {
|
||||
$cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL);
|
||||
return true;
|
||||
} elseif($value == PHPExcel_Calculation::getFALSE()) {
|
||||
$cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL);
|
||||
return true;
|
||||
}
|
||||
// Style logic - strings
|
||||
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
|
||||
// Test for booleans using locale-setting
|
||||
if ($value == PHPExcel_Calculation::getTRUE()) {
|
||||
$cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL);
|
||||
return true;
|
||||
} elseif($value == PHPExcel_Calculation::getFALSE()) {
|
||||
$cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for number in scientific format
|
||||
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) {
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
return true;
|
||||
}
|
||||
// Check for number in scientific format
|
||||
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) {
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for fraction
|
||||
if (preg_match('/^([+-]?) *([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
||||
// Convert value to number
|
||||
$value = $matches[2] / $matches[3];
|
||||
if ($matches[1] == '-') $value = 0 - $value;
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( '??/??' );
|
||||
return true;
|
||||
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
||||
// Convert value to number
|
||||
$value = $matches[2] + ($matches[3] / $matches[4]);
|
||||
if ($matches[1] == '-') $value = 0 - $value;
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( '# ??/??' );
|
||||
return true;
|
||||
}
|
||||
// Check for fraction
|
||||
if (preg_match('/^([+-]?) *([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
||||
// Convert value to number
|
||||
$value = $matches[2] / $matches[3];
|
||||
if ($matches[1] == '-') $value = 0 - $value;
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( '??/??' );
|
||||
return true;
|
||||
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
||||
// Convert value to number
|
||||
$value = $matches[2] + ($matches[3] / $matches[4]);
|
||||
if ($matches[1] == '-') $value = 0 - $value;
|
||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( '# ??/??' );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for percentage
|
||||
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
|
||||
// Convert value to number
|
||||
$value = (float) str_replace('%', '', $value) / 100;
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 );
|
||||
return true;
|
||||
}
|
||||
// Check for percentage
|
||||
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
|
||||
// Convert value to number
|
||||
$value = (float) str_replace('%', '', $value) / 100;
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for currency
|
||||
$currencyCode = PHPExcel_Shared_String::getCurrencyCode();
|
||||
$decimalSeparator = PHPExcel_Shared_String::getDecimalSeparator();
|
||||
$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)) {
|
||||
// Convert value to number
|
||||
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode(
|
||||
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
|
||||
);
|
||||
return true;
|
||||
} elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
|
||||
// Convert value to number
|
||||
$value = (float) trim(str_replace(array('$',','), '', $value));
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
|
||||
return true;
|
||||
}
|
||||
// Check for currency
|
||||
$currencyCode = PHPExcel_Shared_String::getCurrencyCode();
|
||||
$decimalSeparator = PHPExcel_Shared_String::getDecimalSeparator();
|
||||
$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)) {
|
||||
// Convert value to number
|
||||
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode(
|
||||
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
|
||||
);
|
||||
return true;
|
||||
} elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
|
||||
// Convert value to number
|
||||
$value = (float) trim(str_replace(array('$',','), '', $value));
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
// Convert value to number
|
||||
list($h, $m) = explode(':', $value);
|
||||
$days = $h / 24 + $m / 1440;
|
||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
|
||||
return true;
|
||||
}
|
||||
// Check for time without seconds e.g. '9:45', '09:45'
|
||||
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
|
||||
// Convert value to number
|
||||
list($h, $m) = explode(':', $value);
|
||||
$days = $h / 24 + $m / 1440;
|
||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for 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)) {
|
||||
// Convert value to number
|
||||
list($h, $m, $s) = explode(':', $value);
|
||||
$days = $h / 24 + $m / 1440 + $s / 86400;
|
||||
// Convert value to number
|
||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
|
||||
return true;
|
||||
}
|
||||
// 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)) {
|
||||
// Convert value to number
|
||||
list($h, $m, $s) = explode(':', $value);
|
||||
$days = $h / 24 + $m / 1440 + $s / 86400;
|
||||
// Convert value to number
|
||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// Convert value to number
|
||||
$cell->setValueExplicit($d, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Determine style. Either there is a time part or not. Look for ':'
|
||||
if (strpos($value, ':') !== false) {
|
||||
$formatCode = 'yyyy-mm-dd h:mm';
|
||||
} else {
|
||||
$formatCode = 'yyyy-mm-dd';
|
||||
}
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode($formatCode);
|
||||
return true;
|
||||
}
|
||||
// Check for 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) {
|
||||
// Convert value to number
|
||||
$cell->setValueExplicit($d, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
// Determine style. Either there is a time part or not. Look for ':'
|
||||
if (strpos($value, ':') !== false) {
|
||||
$formatCode = 'yyyy-mm-dd h:mm';
|
||||
} else {
|
||||
$formatCode = 'yyyy-mm-dd';
|
||||
}
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getNumberFormat()->setFormatCode($formatCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for newline character "\n"
|
||||
if (strpos($value, "\n") !== FALSE) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getAlignment()->setWrapText(TRUE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Check for newline character "\n"
|
||||
if (strpos($value, "\n") !== FALSE) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
||||
->getAlignment()->setWrapText(TRUE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Not bound yet? Use parent...
|
||||
return parent::bindValue($cell, $value);
|
||||
}
|
||||
// Not bound yet? Use parent...
|
||||
return parent::bindValue($cell, $value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @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##
|
||||
*/
|
||||
|
||||
|
@ -35,80 +35,88 @@
|
|||
*/
|
||||
class PHPExcel_Cell_DataType
|
||||
{
|
||||
/* Data types */
|
||||
const TYPE_STRING2 = 'str';
|
||||
const TYPE_STRING = 's';
|
||||
const TYPE_FORMULA = 'f';
|
||||
const TYPE_NUMERIC = 'n';
|
||||
const TYPE_BOOL = 'b';
|
||||
const TYPE_NULL = 'null';
|
||||
const TYPE_INLINE = 'inlineStr';
|
||||
const TYPE_ERROR = 'e';
|
||||
/* Data types */
|
||||
const TYPE_STRING2 = 'str';
|
||||
const TYPE_STRING = 's';
|
||||
const TYPE_FORMULA = 'f';
|
||||
const TYPE_NUMERIC = 'n';
|
||||
const TYPE_BOOL = 'b';
|
||||
const TYPE_NULL = 'null';
|
||||
const TYPE_INLINE = 'inlineStr';
|
||||
const TYPE_ERROR = 'e';
|
||||
|
||||
/**
|
||||
* List of error codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_errorCodes = array('#NULL!' => 0, '#DIV/0!' => 1, '#VALUE!' => 2, '#REF!' => 3, '#NAME?' => 4, '#NUM!' => 5, '#N/A' => 6);
|
||||
/**
|
||||
* List of error codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getErrorCodes() {
|
||||
return self::$_errorCodes;
|
||||
}
|
||||
/**
|
||||
* Get list of error codes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getErrorCodes() {
|
||||
return self::$_errorCodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* DataType for value
|
||||
*
|
||||
* @deprecated Replaced by PHPExcel_Cell_IValueBinder infrastructure
|
||||
* @param mixed $pValue
|
||||
* @return int
|
||||
*/
|
||||
public static function dataTypeForValue($pValue = null) {
|
||||
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
|
||||
}
|
||||
/**
|
||||
* DataType for value
|
||||
*
|
||||
* @deprecated Replaced by PHPExcel_Cell_IValueBinder infrastructure, will be removed in version 1.8.0
|
||||
* @param mixed $pValue
|
||||
* @return string
|
||||
*/
|
||||
public static function dataTypeForValue($pValue = null) {
|
||||
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a string that it satisfies Excel requirements
|
||||
*
|
||||
* @param mixed Value to sanitize to an Excel string
|
||||
* @return mixed Sanitized value
|
||||
*/
|
||||
public static function checkString($pValue = null)
|
||||
{
|
||||
if ($pValue instanceof PHPExcel_RichText) {
|
||||
// TODO: Sanitize Rich-Text string (max. character count is 32,767)
|
||||
return $pValue;
|
||||
}
|
||||
/**
|
||||
* Check a string that it satisfies Excel requirements
|
||||
*
|
||||
* @param mixed Value to sanitize to an Excel string
|
||||
* @return mixed Sanitized value
|
||||
*/
|
||||
public static function checkString($pValue = null)
|
||||
{
|
||||
if ($pValue instanceof PHPExcel_RichText) {
|
||||
// TODO: Sanitize Rich-Text string (max. character count is 32,767)
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
// string must never be longer than 32,767 characters, truncate if necessary
|
||||
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767);
|
||||
// string must never be longer than 32,767 characters, truncate if necessary
|
||||
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767);
|
||||
|
||||
// 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);
|
||||
// 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);
|
||||
|
||||
return $pValue;
|
||||
}
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a value that it is a valid error code
|
||||
*
|
||||
* @param mixed Value to sanitize to an Excel error code
|
||||
* @return string Sanitized value
|
||||
*/
|
||||
public static function checkErrorCode($pValue = null)
|
||||
{
|
||||
$pValue = (string)$pValue;
|
||||
/**
|
||||
* Check a value that it is a valid error code
|
||||
*
|
||||
* @param mixed Value to sanitize to an Excel error code
|
||||
* @return string Sanitized value
|
||||
*/
|
||||
public static function checkErrorCode($pValue = null)
|
||||
{
|
||||
$pValue = (string) $pValue;
|
||||
|
||||
if ( !array_key_exists($pValue, self::$_errorCodes) ) {
|
||||
$pValue = '#NULL!';
|
||||
}
|
||||
if ( !array_key_exists($pValue, self::$_errorCodes) ) {
|
||||
$pValue = '#NULL!';
|
||||
}
|
||||
|
||||
return $pValue;
|
||||
}
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @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##
|
||||
*/
|
||||
|
||||
|
@ -35,30 +35,30 @@
|
|||
*/
|
||||
class PHPExcel_Cell_DataValidation
|
||||
{
|
||||
/* Data validation types */
|
||||
const TYPE_NONE = 'none';
|
||||
const TYPE_CUSTOM = 'custom';
|
||||
const TYPE_DATE = 'date';
|
||||
const TYPE_DECIMAL = 'decimal';
|
||||
const TYPE_LIST = 'list';
|
||||
const TYPE_TEXTLENGTH = 'textLength';
|
||||
const TYPE_TIME = 'time';
|
||||
const TYPE_WHOLE = 'whole';
|
||||
/* Data validation types */
|
||||
const TYPE_NONE = 'none';
|
||||
const TYPE_CUSTOM = 'custom';
|
||||
const TYPE_DATE = 'date';
|
||||
const TYPE_DECIMAL = 'decimal';
|
||||
const TYPE_LIST = 'list';
|
||||
const TYPE_TEXTLENGTH = 'textLength';
|
||||
const TYPE_TIME = 'time';
|
||||
const TYPE_WHOLE = 'whole';
|
||||
|
||||
/* Data validation error styles */
|
||||
const STYLE_STOP = 'stop';
|
||||
const STYLE_WARNING = 'warning';
|
||||
const STYLE_INFORMATION = 'information';
|
||||
/* Data validation error styles */
|
||||
const STYLE_STOP = 'stop';
|
||||
const STYLE_WARNING = 'warning';
|
||||
const STYLE_INFORMATION = 'information';
|
||||
|
||||
/* Data validation operators */
|
||||
const OPERATOR_BETWEEN = 'between';
|
||||
const OPERATOR_EQUAL = 'equal';
|
||||
const OPERATOR_GREATERTHAN = 'greaterThan';
|
||||
const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
|
||||
const OPERATOR_LESSTHAN = 'lessThan';
|
||||
const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
|
||||
const OPERATOR_NOTBETWEEN = 'notBetween';
|
||||
const OPERATOR_NOTEQUAL = 'notEqual';
|
||||
/* Data validation operators */
|
||||
const OPERATOR_BETWEEN = 'between';
|
||||
const OPERATOR_EQUAL = 'equal';
|
||||
const OPERATOR_GREATERTHAN = 'greaterThan';
|
||||
const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
|
||||
const OPERATOR_LESSTHAN = 'lessThan';
|
||||
const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
|
||||
const OPERATOR_NOTBETWEEN = 'notBetween';
|
||||
const OPERATOR_NOTEQUAL = 'notEqual';
|
||||
|
||||
/**
|
||||
* Formula 1
|
||||
|
@ -154,321 +154,321 @@ class PHPExcel_Cell_DataValidation
|
|||
/**
|
||||
* Create a new PHPExcel_Cell_DataValidation
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise member variables
|
||||
$this->_formula1 = '';
|
||||
$this->_formula2 = '';
|
||||
$this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
|
||||
$this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
|
||||
$this->_operator = '';
|
||||
$this->_allowBlank = false;
|
||||
$this->_showDropDown = false;
|
||||
$this->_showInputMessage = false;
|
||||
$this->_showErrorMessage = false;
|
||||
$this->_errorTitle = '';
|
||||
$this->_error = '';
|
||||
$this->_promptTitle = '';
|
||||
$this->_prompt = '';
|
||||
// Initialise member variables
|
||||
$this->_formula1 = '';
|
||||
$this->_formula2 = '';
|
||||
$this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE;
|
||||
$this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
|
||||
$this->_operator = '';
|
||||
$this->_allowBlank = FALSE;
|
||||
$this->_showDropDown = FALSE;
|
||||
$this->_showInputMessage = FALSE;
|
||||
$this->_showErrorMessage = FALSE;
|
||||
$this->_errorTitle = '';
|
||||
$this->_error = '';
|
||||
$this->_promptTitle = '';
|
||||
$this->_prompt = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Formula 1
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormula1() {
|
||||
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__
|
||||
);
|
||||
/**
|
||||
* Get Formula 1
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormula1() {
|
||||
return $this->_formula1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,18 +21,18 @@
|
|||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @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##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,62 +45,62 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||
*/
|
||||
class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = null)
|
||||
{
|
||||
// sanitize UTF-8 strings
|
||||
if (is_string($value)) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
}
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = null)
|
||||
{
|
||||
// sanitize UTF-8 strings
|
||||
if (is_string($value)) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
}
|
||||
|
||||
// Set value explicit
|
||||
$cell->setValueExplicit( $value, self::dataTypeForValue($value) );
|
||||
// Set value explicit
|
||||
$cell->setValueExplicit( $value, self::dataTypeForValue($value) );
|
||||
|
||||
// Done!
|
||||
return true;
|
||||
}
|
||||
// Done!
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* DataType for value
|
||||
*
|
||||
* @param mixed $pValue
|
||||
* @return int
|
||||
*/
|
||||
public static function dataTypeForValue($pValue = null) {
|
||||
// Match the value against a few data types
|
||||
if (is_null($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NULL;
|
||||
/**
|
||||
* DataType for value
|
||||
*
|
||||
* @param mixed $pValue
|
||||
* @return string
|
||||
*/
|
||||
public static function dataTypeForValue($pValue = null) {
|
||||
// Match the value against a few data types
|
||||
if (is_null($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NULL;
|
||||
|
||||
} elseif ($pValue === '') {
|
||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
} elseif ($pValue === '') {
|
||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
|
||||
} elseif ($pValue instanceof PHPExcel_RichText) {
|
||||
return PHPExcel_Cell_DataType::TYPE_INLINE;
|
||||
} elseif ($pValue instanceof PHPExcel_RichText) {
|
||||
return PHPExcel_Cell_DataType::TYPE_INLINE;
|
||||
|
||||
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
|
||||
return PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
|
||||
return PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
|
||||
} elseif (is_bool($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
} elseif (is_bool($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
|
||||
} elseif (is_float($pValue) || is_int($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
} elseif (is_float($pValue) || is_int($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
|
||||
} elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
} elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
|
||||
} elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) {
|
||||
return PHPExcel_Cell_DataType::TYPE_ERROR;
|
||||
} elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) {
|
||||
return PHPExcel_Cell_DataType::TYPE_ERROR;
|
||||
|
||||
} else {
|
||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
} else {
|
||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @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##
|
||||
*/
|
||||
|
||||
|
@ -35,93 +35,92 @@
|
|||
*/
|
||||
class PHPExcel_Cell_Hyperlink
|
||||
{
|
||||
/**
|
||||
* URL to link the cell to
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_url;
|
||||
/**
|
||||
* URL to link the cell to
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_url;
|
||||
|
||||
/**
|
||||
* Tooltip to display on the hyperlink
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tooltip;
|
||||
/**
|
||||
* Tooltip to display on the hyperlink
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_tooltip;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Cell_Hyperlink
|
||||
*
|
||||
* @param string $pUrl Url to link the cell to
|
||||
* @param string $pTooltip Tooltip to display on the hyperlink
|
||||
* @throws Exception
|
||||
* @param string $pUrl Url to link the cell to
|
||||
* @param string $pTooltip Tooltip to display on the hyperlink
|
||||
*/
|
||||
public function __construct($pUrl = '', $pTooltip = '')
|
||||
{
|
||||
// Initialise member variables
|
||||
$this->_url = $pUrl;
|
||||
$this->_tooltip = $pTooltip;
|
||||
// Initialise member variables
|
||||
$this->_url = $pUrl;
|
||||
$this->_tooltip = $pTooltip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl() {
|
||||
return $this->_url;
|
||||
}
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl() {
|
||||
return $this->_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set URL
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_Hyperlink
|
||||
*/
|
||||
public function setUrl($value = '') {
|
||||
$this->_url = $value;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set URL
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_Hyperlink
|
||||
*/
|
||||
public function setUrl($value = '') {
|
||||
$this->_url = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tooltip
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTooltip() {
|
||||
return $this->_tooltip;
|
||||
}
|
||||
/**
|
||||
* Get tooltip
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTooltip() {
|
||||
return $this->_tooltip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tooltip
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_Hyperlink
|
||||
*/
|
||||
public function setTooltip($value = '') {
|
||||
$this->_tooltip = $value;
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Set tooltip
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Cell_Hyperlink
|
||||
*/
|
||||
public function setTooltip($value = '') {
|
||||
$this->_tooltip = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this hyperlink internal? (to another sheet)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isInternal() {
|
||||
return strpos($this->_url, 'sheet://') !== false;
|
||||
}
|
||||
/**
|
||||
* Is this hyperlink internal? (to another worksheet)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isInternal() {
|
||||
return strpos($this->_url, 'sheet://') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_url
|
||||
. $this->_tooltip
|
||||
. __CLASS__
|
||||
);
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_url
|
||||
. $this->_tooltip
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @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##
|
||||
*/
|
||||
|
||||
|
@ -35,12 +35,12 @@
|
|||
*/
|
||||
interface PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = null);
|
||||
/**
|
||||
* Bind value to a cell
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return boolean
|
||||
*/
|
||||
public function bindValue(PHPExcel_Cell $cell, $value = NULL);
|
||||
}
|
||||
|
|
|
@ -182,9 +182,6 @@ class PHPExcel_Shared_OLERead {
|
|||
$pos = $block * 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);
|
||||
}
|
||||
|
||||
|
@ -202,9 +199,6 @@ class PHPExcel_Shared_OLERead {
|
|||
while ($block != -2) {
|
||||
$pos = ($block + 1) * 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);
|
||||
}
|
||||
|
||||
|
@ -226,9 +220,6 @@ class PHPExcel_Shared_OLERead {
|
|||
while ($block != -2) {
|
||||
$pos = ($block + 1) * 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);
|
||||
}
|
||||
return $data;
|
||||
|
|
|
@ -434,7 +434,6 @@ class PHPExcel_Shared_String
|
|||
{
|
||||
// character count
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
|
||||
// option flags
|
||||
if(empty($arrcRuns)){
|
||||
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
|
||||
|
|
|
@ -1029,7 +1029,6 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
|
|||
// End row
|
||||
$objWriter->endElement();
|
||||
}
|
||||
// $objWriter->flush();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
|
|
@ -656,7 +656,6 @@ class PHPExcel_Writer_Excel5_Worksheet extends PHPExcel_Writer_Excel5_BIFFwriter
|
|||
private function _writeRichTextString($row, $col, $str, $xfIndex, $arrcRun){
|
||||
$record = 0x00FD; // Record identifier
|
||||
$length = 0x000A; // Bytes to follow
|
||||
|
||||
$str = PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($str, $arrcRun);
|
||||
|
||||
/* check if string is already present */
|
||||
|
|
|
@ -1126,10 +1126,11 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
|||
$rowSpan = 1;
|
||||
|
||||
// initialize
|
||||
$cellData = '';
|
||||
$cellData = ' ';
|
||||
|
||||
// PHPExcel_Cell
|
||||
if ($cell instanceof PHPExcel_Cell) {
|
||||
$cellData = '';
|
||||
if (is_null($cell->getParent())) {
|
||||
$cell->attach($pSheet);
|
||||
}
|
||||
|
|
|
@ -76,14 +76,32 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
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
|
||||
|
|
|
@ -76,14 +76,32 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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;
|
||||
// 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;
|
||||
$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
|
||||
|
|
|
@ -122,16 +122,34 @@ $objPHPExcel->getActiveSheet()->setTitle('Datatypes');
|
|||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
// 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__));
|
||||
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;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$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());
|
||||
|
||||
|
||||
|
@ -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 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;
|
||||
|
|
|
@ -110,7 +110,7 @@ $objPHPExcel->getActiveSheet()->setCellValue('A12', 'NULL')
|
|||
->setCellValue('C12', NULL);
|
||||
|
||||
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
|
||||
|
||||
// Rename worksheet
|
||||
|
@ -124,14 +124,31 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$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());
|
||||
|
||||
|
||||
|
@ -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 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;
|
||||
|
|
|
@ -104,14 +104,32 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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;
|
||||
// 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;
|
||||
$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
|
||||
|
|
|
@ -89,14 +89,32 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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;
|
||||
// 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;
|
||||
$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
|
||||
|
|
|
@ -33,11 +33,11 @@ require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
|
|||
|
||||
|
||||
// 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();
|
||||
|
||||
// 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")
|
||||
->setLastModifiedBy("Maarten Balliauw")
|
||||
->setTitle("Office 2007 XLSX Test Document")
|
||||
|
@ -48,7 +48,7 @@ $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
|||
|
||||
|
||||
// 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->getActiveSheet()->setCellValue('B1', 'Invoice');
|
||||
$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');
|
||||
|
||||
// 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');
|
||||
$objCommentRichText = $objPHPExcel->getActiveSheet()->getComment('E11')->getText()->createTextRun('PHPExcel:');
|
||||
|
@ -114,7 +114,7 @@ $objPHPExcel->getActiveSheet()->getComment('E13')->getFillColor()->setRGB('EEEEE
|
|||
|
||||
|
||||
// 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->createText('This invoice is ');
|
||||
|
||||
|
@ -128,28 +128,28 @@ $objRichText->createText(', unless specified otherwise on the invoice.');
|
|||
$objPHPExcel->getActiveSheet()->getCell('A18')->setValue($objRichText);
|
||||
|
||||
// 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('A28:B28'); // Just to test...
|
||||
$objPHPExcel->getActiveSheet()->unmergeCells('A28:B28'); // Just to test...
|
||||
|
||||
// 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()->protectCells('A3:E13', 'PHPExcel');
|
||||
|
||||
// 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);
|
||||
|
||||
// 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('D')->setWidth(12);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(12);
|
||||
|
||||
// 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()->setSize(20);
|
||||
$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);
|
||||
|
||||
// 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('D12')->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);
|
||||
|
||||
// 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(
|
||||
'borders' => array(
|
||||
'outline' => array(
|
||||
|
@ -187,7 +187,7 @@ $objPHPExcel->getActiveSheet()->getStyle('A4:E10')->applyFromArray($styleThinBla
|
|||
|
||||
|
||||
// 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(
|
||||
'borders' => array(
|
||||
'outline' => array(
|
||||
|
@ -199,12 +199,12 @@ $styleThickBrownBorderOutline = array(
|
|||
$objPHPExcel->getActiveSheet()->getStyle('D13:E13')->applyFromArray($styleThickBrownBorderOutline);
|
||||
|
||||
// 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()->getStartColor()->setARGB('FF808080');
|
||||
|
||||
// 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(
|
||||
array(
|
||||
'font' => array(
|
||||
|
@ -263,11 +263,11 @@ $objPHPExcel->getActiveSheet()->getStyle('E3')->applyFromArray(
|
|||
);
|
||||
|
||||
// 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);
|
||||
|
||||
// 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()->getCell('E26')->getHyperlink()->setUrl('http://www.phpexcel.net');
|
||||
$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);
|
||||
|
||||
// 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->setName('Logo');
|
||||
$objDrawing->setDescription('Logo');
|
||||
|
@ -288,7 +288,7 @@ $objDrawing->setHeight(36);
|
|||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// 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->setName('Paid');
|
||||
$objDrawing->setDescription('Paid');
|
||||
|
@ -301,7 +301,7 @@ $objDrawing->getShadow()->setDirection(45);
|
|||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// 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->setName('PHPExcel logo');
|
||||
$objDrawing->setDescription('PHPExcel logo');
|
||||
|
@ -312,36 +312,36 @@ $objDrawing->setOffsetX(10);
|
|||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// 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()->removeRow(6, 10);
|
||||
$objPHPExcel->getActiveSheet()->insertNewColumnBefore('E', 5);
|
||||
$objPHPExcel->getActiveSheet()->removeColumn('E', 5);
|
||||
|
||||
// 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()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');
|
||||
|
||||
// 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()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
|
||||
|
||||
// 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');
|
||||
|
||||
|
||||
// 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();
|
||||
|
||||
// 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.';
|
||||
|
||||
// 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->getActiveSheet()->setCellValue('A1', 'Terms and conditions');
|
||||
$objPHPExcel->getActiveSheet()->setCellValue('A3', $sLloremIpsum);
|
||||
|
@ -350,19 +350,19 @@ $objPHPExcel->getActiveSheet()->setCellValue('A5', $sLloremIpsum);
|
|||
$objPHPExcel->getActiveSheet()->setCellValue('A6', $sLloremIpsum);
|
||||
|
||||
// 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');;
|
||||
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
|
||||
// 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()->setSize(20);
|
||||
$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);
|
||||
|
||||
// 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->setName('Terms and conditions');
|
||||
$objDrawing->setDescription('Terms and conditions');
|
||||
|
@ -380,12 +380,12 @@ $objDrawing->setCoordinates('B14');
|
|||
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
|
||||
|
||||
// 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()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
|
||||
|
||||
// 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');
|
||||
|
||||
|
||||
|
|
|
@ -42,14 +42,33 @@ require_once '../Classes/PHPExcel/IOFactory.php';
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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;
|
||||
// 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;
|
||||
$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 date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
|
||||
|
|
|
@ -39,6 +39,7 @@ require_once '../Classes/PHPExcel.php';
|
|||
|
||||
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip;
|
||||
PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
|
||||
echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
|
||||
|
||||
|
||||
// Create new PHPExcel object
|
||||
|
@ -104,9 +105,17 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -113,11 +113,19 @@ for ($i = 2; $i <= 5000; $i++) {
|
|||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 5 file
|
||||
// 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
|
||||
|
|
|
@ -115,9 +115,17 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -42,12 +42,30 @@ if (!file_exists("05featuredemo.xlsx")) {
|
|||
}
|
||||
|
||||
echo date('H:i:s') , " Load from Excel2007 file" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$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;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -157,9 +157,17 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -104,9 +104,17 @@ $objPHPExcel->getActiveSheet()->duplicateConditionalStyle(
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -85,14 +85,32 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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;
|
||||
// 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;
|
||||
$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
|
||||
|
|
|
@ -182,19 +182,40 @@ $autoFilter->getColumn('E')
|
|||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// 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->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s').' File written to '.str_replace('.php', '.xlsx', __FILE__).EOL;
|
||||
// Save Excel5 file
|
||||
echo date('H:i:s').' Write to Excel5 format'.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;
|
||||
|
||||
|
||||
// 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__));
|
||||
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 date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;
|
||||
|
||||
// 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;
|
||||
|
|
|
@ -174,19 +174,40 @@ $autoFilter->getColumn('E')
|
|||
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// 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->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s').' File written to '.str_replace('.php', '.xlsx', __FILE__).EOL;
|
||||
// Save Excel5 file
|
||||
echo date('H:i:s').' Write to Excel5 format'.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;
|
||||
|
||||
|
||||
// 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__));
|
||||
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 date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;
|
||||
|
||||
// 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;
|
||||
|
|
|
@ -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
|
||||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// 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->save(str_replace('.php', '.xlsx', __FILE__));
|
||||
echo date('H:i:s').' File written to '.str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)).EOL;
|
||||
// Save Excel5 file
|
||||
echo date('H:i:s').' Write to Excel5 format'.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;
|
||||
|
||||
|
||||
// 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__));
|
||||
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 date('H:i:s').' Peak memory usage: '.(memory_get_peak_usage(true) / 1024 / 1024).' MB'.EOL;
|
||||
|
|
|
@ -86,11 +86,19 @@ $objPHPExcel->getActiveSheet()->getProtection()->setFormatCells(true);
|
|||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
// 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
|
||||
|
|
|
@ -88,9 +88,17 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -204,9 +204,17 @@ for ($col = 'B'; $col != 'G'; ++$col) {
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -40,10 +40,19 @@ include "05featuredemo.inc.php";
|
|||
require_once '../Classes/PHPExcel/IOFactory.php';
|
||||
|
||||
|
||||
// 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
|
||||
|
|
|
@ -98,11 +98,19 @@ $objValidation->setFormula1('"Item A,Item B,Item C"'); // Make sure to put the l
|
|||
$objPHPExcel->setActiveSheetIndex(0);
|
||||
|
||||
|
||||
// Save Excel 2007 file
|
||||
// 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
|
||||
|
|
|
@ -100,9 +100,17 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -42,26 +42,47 @@ require_once '../Classes/PHPExcel/IOFactory.php';
|
|||
|
||||
|
||||
echo date('H:i:s') , " Write to CSV format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV')->setDelimiter(',')
|
||||
->setEnclosure('"')
|
||||
->setLineEnding("\r\n")
|
||||
->setSheetIndex(0)
|
||||
->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 '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;
|
||||
$callStartTime = microtime(true);
|
||||
$objReader = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',')
|
||||
->setEnclosure('"')
|
||||
->setLineEnding("\r\n")
|
||||
->setSheetIndex(0);
|
||||
$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;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter2007 = PHPExcel_IOFactory::createWriter($objPHPExcelFromCSV, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -42,11 +42,18 @@ require_once '../Classes/PHPExcel/IOFactory.php';
|
|||
|
||||
|
||||
echo date('H:i:s') , " Write to HTML format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
|
||||
$objWriter->setSheetIndex(0);
|
||||
//$objWriter->setImagesRoot('http://www.example.com');
|
||||
$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 '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
|
||||
|
|
|
@ -108,9 +108,17 @@ $objPHPExcel->setActiveSheetIndex(0);
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -44,12 +44,31 @@ if (!file_exists("14excel5.xls")) {
|
|||
}
|
||||
|
||||
echo date('H:i:s') , " Load workbook from Excel5 file" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$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;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -73,10 +73,17 @@ if (!PHPExcel_Settings::setPdfRenderer(
|
|||
}
|
||||
|
||||
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
|
||||
$objWriter->setSheetIndex(0);
|
||||
$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 '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
|
||||
|
|
|
@ -80,9 +80,32 @@ $objPHPExcel->getActiveSheet()->getStyle('C5:R95')->applyFromArray(
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -88,9 +88,32 @@ $objPHPExcel->getActiveSheet()->setSharedStyle($sharedStyle2, "C5:R95");
|
|||
|
||||
// Save Excel 2007 file
|
||||
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||
$callStartTime = microtime(true);
|
||||
|
||||
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||
$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 '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
|
||||
|
|
|
@ -45,6 +45,7 @@ $aTests = array(
|
|||
, '06largescale-xls.php'
|
||||
, '07reader.php'
|
||||
, '08conditionalformatting.php'
|
||||
, '08conditionalformatting2.php'
|
||||
, '09pagebreaks.php'
|
||||
, '10autofilter.php'
|
||||
, '10autofilter-selection-1.php'
|
||||
|
|
|
@ -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
|
||||
- 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: (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: (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
|
||||
|
|
Loading…
Reference in New Issue