mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-30 01:06:03 +03:00
Merge branch 'develop' of https://github.com/PHPOffice/PHPExcel into develop
This commit is contained in:
commit
4e9bfc4607
4
.gitattributes
vendored
Normal file
4
.gitattributes
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
/Build export-ignore
|
||||||
|
/Documentation export-ignore
|
||||||
|
/Tests export-ignore
|
||||||
|
README.md export-ignore
|
@ -42,6 +42,13 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||||||
*/
|
*/
|
||||||
class PHPExcel
|
class PHPExcel
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Unique ID
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_uniqueID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document properties
|
* Document properties
|
||||||
*
|
*
|
||||||
@ -63,6 +70,13 @@ class PHPExcel
|
|||||||
*/
|
*/
|
||||||
private $_workSheetCollection = array();
|
private $_workSheetCollection = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculation Engine
|
||||||
|
*
|
||||||
|
* @var PHPExcel_Calculation
|
||||||
|
*/
|
||||||
|
private $_calculationEngine = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Active sheet index
|
* Active sheet index
|
||||||
*
|
*
|
||||||
@ -103,6 +117,9 @@ class PHPExcel
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->_uniqueID = uniqid();
|
||||||
|
$this->_calculationEngine = PHPExcel_Calculation::getInstance($this);
|
||||||
|
|
||||||
// Initialise worksheet collection and add one worksheet
|
// Initialise worksheet collection and add one worksheet
|
||||||
$this->_workSheetCollection = array();
|
$this->_workSheetCollection = array();
|
||||||
$this->_workSheetCollection[] = new PHPExcel_Worksheet($this);
|
$this->_workSheetCollection[] = new PHPExcel_Worksheet($this);
|
||||||
@ -126,13 +143,23 @@ class PHPExcel
|
|||||||
$this->addCellStyleXf(new PHPExcel_Style);
|
$this->addCellStyleXf(new PHPExcel_Style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Code to execute when this worksheet is unset()
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __destruct() {
|
||||||
|
PHPExcel_Calculation::unsetInstance($this);
|
||||||
|
$this->disconnectWorksheets();
|
||||||
|
} // function __destruct()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnect all worksheets from this PHPExcel workbook object,
|
* Disconnect all worksheets from this PHPExcel workbook object,
|
||||||
* typically so that the PHPExcel object can be unset
|
* typically so that the PHPExcel object can be unset
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function disconnectWorksheets() {
|
public function disconnectWorksheets()
|
||||||
|
{
|
||||||
|
$worksheet = NULL;
|
||||||
foreach($this->_workSheetCollection as $k => &$worksheet) {
|
foreach($this->_workSheetCollection as $k => &$worksheet) {
|
||||||
$worksheet->disconnectCells();
|
$worksheet->disconnectCells();
|
||||||
$this->_workSheetCollection[$k] = null;
|
$this->_workSheetCollection[$k] = null;
|
||||||
@ -141,6 +168,16 @@ class PHPExcel
|
|||||||
$this->_workSheetCollection = array();
|
$this->_workSheetCollection = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the calculation engine for this worksheet
|
||||||
|
*
|
||||||
|
* @return PHPExcel_Calculation
|
||||||
|
*/
|
||||||
|
public function getCalculationEngine()
|
||||||
|
{
|
||||||
|
return $this->_calculationEngine;
|
||||||
|
} // function getCellCacheController()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get properties
|
* Get properties
|
||||||
*
|
*
|
||||||
@ -840,12 +877,14 @@ class PHPExcel
|
|||||||
foreach ($sheet->getColumnDimensions() as $columnDimension) {
|
foreach ($sheet->getColumnDimensions() as $columnDimension) {
|
||||||
$columnDimension->setXfIndex( $map[$columnDimension->getXfIndex()] );
|
$columnDimension->setXfIndex( $map[$columnDimension->getXfIndex()] );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// also do garbage collection for all the sheets
|
// also do garbage collection for all the sheets
|
||||||
foreach ($this->getWorksheetIterator() as $sheet) {
|
|
||||||
$sheet->garbageCollect();
|
$sheet->garbageCollect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getID() {
|
||||||
|
return $this->_uniqueID;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -154,8 +154,8 @@ class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_Cach
|
|||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = unserialize($obj);
|
$this->_currentObject = unserialize($obj);
|
||||||
// Re-attach the parent worksheet
|
// Re-attach this as the cell's parent
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
|
@ -86,6 +86,11 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
|
|||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
|
||||||
|
|
||||||
|
public function getParent()
|
||||||
|
{
|
||||||
|
return $this->_parent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||||
*
|
*
|
||||||
@ -101,6 +106,27 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
|
|||||||
} // function isDataSet()
|
} // function isDataSet()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a cell object from one address to another
|
||||||
|
*
|
||||||
|
* @param string $fromAddress Current address of the cell to move
|
||||||
|
* @param string $toAddress Destination address of the cell to move
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function moveCell($fromAddress, $toAddress) {
|
||||||
|
if ($fromAddress === $this->_currentObjectID) {
|
||||||
|
$this->_currentObjectID = $toAddress;
|
||||||
|
}
|
||||||
|
$this->_currentCellIsDirty = true;
|
||||||
|
if (isset($this->_cellCache[$fromAddress])) {
|
||||||
|
$this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress];
|
||||||
|
unset($this->_cellCache[$fromAddress]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
} // function moveCell()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add or Update a cell in cache
|
* Add or Update a cell in cache
|
||||||
*
|
*
|
||||||
@ -151,7 +177,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
|
|||||||
public function getSortedCellList() {
|
public function getSortedCellList() {
|
||||||
$sortKeys = array();
|
$sortKeys = array();
|
||||||
foreach ($this->getCellList() as $coord) {
|
foreach ($this->getCellList() as $coord) {
|
||||||
list($column,$row) = sscanf($coord,'%[A-Z]%d');
|
sscanf($coord,'%[A-Z]%d', $column, $row);
|
||||||
$sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
|
$sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;
|
||||||
}
|
}
|
||||||
ksort($sortKeys);
|
ksort($sortKeys);
|
||||||
@ -172,7 +198,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
|
|||||||
$col = array('A' => '1A');
|
$col = array('A' => '1A');
|
||||||
$row = array(1);
|
$row = array(1);
|
||||||
foreach ($this->getCellList() as $coord) {
|
foreach ($this->getCellList() as $coord) {
|
||||||
list($c,$r) = sscanf($coord,'%[A-Z]%d');
|
sscanf($coord,'%[A-Z]%d', $c, $r);
|
||||||
$row[$r] = $r;
|
$row[$r] = $r;
|
||||||
$col[$c] = strlen($c).$c;
|
$col[$c] = strlen($c).$c;
|
||||||
}
|
}
|
||||||
@ -188,6 +214,23 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getCurrentAddress()
|
||||||
|
{
|
||||||
|
return $this->_currentObjectID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCurrentColumn()
|
||||||
|
{
|
||||||
|
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
|
||||||
|
return $column;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCurrentRow()
|
||||||
|
{
|
||||||
|
sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get highest worksheet column
|
* Get highest worksheet column
|
||||||
*
|
*
|
||||||
@ -237,7 +280,7 @@ abstract class PHPExcel_CachedObjectStorage_CacheBase {
|
|||||||
|
|
||||||
$this->_parent = $parent;
|
$this->_parent = $parent;
|
||||||
if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {
|
if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {
|
||||||
$this->_currentObject->attach($parent);
|
$this->_currentObject->attach($this);
|
||||||
}
|
}
|
||||||
} // function copyCellCollection()
|
} // function copyCellCollection()
|
||||||
|
|
||||||
|
@ -124,8 +124,8 @@ class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage
|
|||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
||||||
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
||||||
// Re-attach the parent worksheet
|
// Re-attach this as the cell's parent
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
|
@ -96,8 +96,8 @@ class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage
|
|||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]);
|
$this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]);
|
||||||
// Re-attach the parent worksheet
|
// Re-attach this as the cell's parent
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
|
@ -158,8 +158,8 @@ class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage
|
|||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = unserialize($obj);
|
$this->_currentObject = unserialize($obj);
|
||||||
// Re-attach the parent worksheet
|
// Re-attach this as the cell's parent
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
|
@ -48,11 +48,15 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C
|
|||||||
*
|
*
|
||||||
* @param string $pCoord Coordinate address of the cell to update
|
* @param string $pCoord Coordinate address of the cell to update
|
||||||
* @param PHPExcel_Cell $cell Cell to update
|
* @param PHPExcel_Cell $cell Cell to update
|
||||||
* @return void
|
* @return PHPExcel_Cell
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||||
$this->_cellCache[$pCoord] = $cell;
|
$this->_cellCache[$pCoord] = $cell;
|
||||||
|
|
||||||
|
// Set current entry to the new/updated entry
|
||||||
|
$this->_currentObjectID = $pCoord;
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
} // function addCacheData()
|
} // function addCacheData()
|
||||||
|
|
||||||
@ -67,10 +71,14 @@ class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_C
|
|||||||
public function getCacheData($pCoord) {
|
public function getCacheData($pCoord) {
|
||||||
// Check if the entry that has been requested actually exists
|
// Check if the entry that has been requested actually exists
|
||||||
if (!isset($this->_cellCache[$pCoord])) {
|
if (!isset($this->_cellCache[$pCoord])) {
|
||||||
|
$this->_currentObjectID = NULL;
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Return null if requested entry doesn't exist in cache
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set current entry to the requested entry
|
||||||
|
$this->_currentObjectID = $pCoord;
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_cellCache[$pCoord];
|
return $this->_cellCache[$pCoord];
|
||||||
} // function getCacheData()
|
} // function getCacheData()
|
||||||
|
@ -96,8 +96,8 @@ class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStora
|
|||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
|
$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
|
||||||
// Re-attach the parent worksheet
|
// Re-attach this as the cell's parent
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
|
@ -96,8 +96,8 @@ class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjec
|
|||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = unserialize($this->_cellCache[$pCoord]);
|
$this->_currentObject = unserialize($this->_cellCache[$pCoord]);
|
||||||
// Re-attach the parent worksheet
|
// Re-attach this as the cell's parent
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
|
@ -116,8 +116,8 @@ class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_
|
|||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
||||||
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
||||||
// Re-attach the parent worksheet
|
// Re-attach this as the cell's parent
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
|
@ -116,8 +116,8 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
|
|||||||
|
|
||||||
$cellResult = $cellResultSet->fetchSingle();
|
$cellResult = $cellResultSet->fetchSingle();
|
||||||
$this->_currentObject = unserialize($cellResult);
|
$this->_currentObject = unserialize($cellResult);
|
||||||
// Re-attach the parent worksheet
|
// Re-attach this as the cell's parent
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
@ -169,6 +169,32 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
|
|||||||
} // function deleteCacheData()
|
} // function deleteCacheData()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a cell object from one address to another
|
||||||
|
*
|
||||||
|
* @param string $fromAddress Current address of the cell to move
|
||||||
|
* @param string $toAddress Destination address of the cell to move
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function moveCell($fromAddress, $toAddress) {
|
||||||
|
if ($fromAddress === $this->_currentObjectID) {
|
||||||
|
$this->_currentObjectID = $toAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";
|
||||||
|
$result = $this->_DBHandle->exec($query);
|
||||||
|
if ($result === false)
|
||||||
|
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||||
|
|
||||||
|
$query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";
|
||||||
|
$result = $this->_DBHandle->exec($query);
|
||||||
|
if ($result === false)
|
||||||
|
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
} // function moveCell()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all cell addresses currently held in cache
|
* Get a list of all cell addresses currently held in cache
|
||||||
*
|
*
|
||||||
@ -256,6 +282,10 @@ class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_C
|
|||||||
* Destroy this cell collection
|
* Destroy this cell collection
|
||||||
*/
|
*/
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
|
if (!is_null($this->_DBHandle)) {
|
||||||
|
$this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName);
|
||||||
|
$this->_DBHandle->close();
|
||||||
|
}
|
||||||
$this->_DBHandle = null;
|
$this->_DBHandle = null;
|
||||||
} // function __destruct()
|
} // function __destruct()
|
||||||
|
|
||||||
|
@ -49,6 +49,11 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
|
|||||||
*/
|
*/
|
||||||
private $_DBHandle = null;
|
private $_DBHandle = null;
|
||||||
|
|
||||||
|
private $_selectQuery;
|
||||||
|
private $_insertQuery;
|
||||||
|
private $_updateQuery;
|
||||||
|
private $_deleteQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store cell data in cache for the current cell object if it's "dirty",
|
* Store cell data in cache for the current cell object if it's "dirty",
|
||||||
* and the 'nullify' the current cell object
|
* and the 'nullify' the current cell object
|
||||||
@ -60,10 +65,9 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
|
|||||||
if ($this->_currentCellIsDirty) {
|
if ($this->_currentCellIsDirty) {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
|
|
||||||
$query = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");
|
$this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
|
||||||
$query->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);
|
$this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
|
||||||
$query->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);
|
$result = $this->_insertQuery->execute();
|
||||||
$result = $query->execute();
|
|
||||||
if ($result === false)
|
if ($result === false)
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||||
$this->_currentCellIsDirty = false;
|
$this->_currentCellIsDirty = false;
|
||||||
@ -106,21 +110,23 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
|
|||||||
}
|
}
|
||||||
$this->_storeData();
|
$this->_storeData();
|
||||||
|
|
||||||
$query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
||||||
$cellResult = $this->_DBHandle->querySingle($query);
|
$cellResult = $this->_selectQuery->execute();
|
||||||
if ($cellResult === false) {
|
if ($cellResult === FALSE) {
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||||
} elseif (is_null($cellResult)) {
|
}
|
||||||
|
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||||
|
if ($cellData === FALSE) {
|
||||||
// Return null if requested entry doesn't exist in cache
|
// Return null if requested entry doesn't exist in cache
|
||||||
return null;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
|
|
||||||
$this->_currentObject = unserialize($cellResult);
|
$this->_currentObject = unserialize($cellData['value']);
|
||||||
// Re-attach the parent worksheet
|
// Re-attach this as the cell's parent
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
@ -135,19 +141,18 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
|
|||||||
*/
|
*/
|
||||||
public function isDataSet($pCoord) {
|
public function isDataSet($pCoord) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
if ($pCoord === $this->_currentObjectID) {
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the requested entry exists in the cache
|
// Check if the requested entry exists in the cache
|
||||||
$query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
$this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
||||||
$cellResult = $this->_DBHandle->querySingle($query);
|
$cellResult = $this->_selectQuery->execute();
|
||||||
if ($cellResult === false) {
|
if ($cellResult === FALSE) {
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||||
} elseif (is_null($cellResult)) {
|
|
||||||
// Return null if requested entry doesn't exist in cache
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
$cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
|
||||||
|
|
||||||
|
return ($cellData === FALSE) ? FALSE : TRUE;
|
||||||
} // function isDataSet()
|
} // function isDataSet()
|
||||||
|
|
||||||
|
|
||||||
@ -160,17 +165,44 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
|
|||||||
public function deleteCacheData($pCoord) {
|
public function deleteCacheData($pCoord) {
|
||||||
if ($pCoord === $this->_currentObjectID) {
|
if ($pCoord === $this->_currentObjectID) {
|
||||||
$this->_currentObject->detach();
|
$this->_currentObject->detach();
|
||||||
$this->_currentObjectID = $this->_currentObject = null;
|
$this->_currentObjectID = $this->_currentObject = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the requested entry exists in the cache
|
// Check if the requested entry exists in the cache
|
||||||
$query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";
|
$this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT);
|
||||||
$result = $this->_DBHandle->exec($query);
|
$result = $this->_deleteQuery->execute();
|
||||||
|
if ($result === FALSE)
|
||||||
|
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||||
|
|
||||||
|
$this->_currentCellIsDirty = FALSE;
|
||||||
|
} // function deleteCacheData()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a cell object from one address to another
|
||||||
|
*
|
||||||
|
* @param string $fromAddress Current address of the cell to move
|
||||||
|
* @param string $toAddress Destination address of the cell to move
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function moveCell($fromAddress, $toAddress) {
|
||||||
|
if ($fromAddress === $this->_currentObjectID) {
|
||||||
|
$this->_currentObjectID = $toAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT);
|
||||||
|
$result = $this->_deleteQuery->execute();
|
||||||
if ($result === false)
|
if ($result === false)
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||||
|
|
||||||
$this->_currentCellIsDirty = false;
|
$this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT);
|
||||||
} // function deleteCacheData()
|
$this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT);
|
||||||
|
$result = $this->_updateQuery->execute();
|
||||||
|
if ($result === false)
|
||||||
|
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
} // function moveCell()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -253,6 +285,11 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
|
|||||||
if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
|
if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))
|
||||||
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id");
|
||||||
|
$this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");
|
||||||
|
$this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId");
|
||||||
|
$this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id");
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
|
||||||
|
|
||||||
@ -261,6 +298,7 @@ class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_
|
|||||||
*/
|
*/
|
||||||
public function __destruct() {
|
public function __destruct() {
|
||||||
if (!is_null($this->_DBHandle)) {
|
if (!is_null($this->_DBHandle)) {
|
||||||
|
$this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName);
|
||||||
$this->_DBHandle->close();
|
$this->_DBHandle->close();
|
||||||
}
|
}
|
||||||
$this->_DBHandle = null;
|
$this->_DBHandle = null;
|
||||||
|
@ -158,8 +158,8 @@ class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage
|
|||||||
// Set current entry to the requested entry
|
// Set current entry to the requested entry
|
||||||
$this->_currentObjectID = $pCoord;
|
$this->_currentObjectID = $pCoord;
|
||||||
$this->_currentObject = unserialize($obj);
|
$this->_currentObject = unserialize($obj);
|
||||||
// Re-attach the parent worksheet
|
// Re-attach this as the cell's parent
|
||||||
$this->_currentObject->attach($this->_parent);
|
$this->_currentObject->attach($this);
|
||||||
|
|
||||||
// Return requested entry
|
// Return requested entry
|
||||||
return $this->_currentObject;
|
return $this->_currentObject;
|
||||||
|
58
Classes/PHPExcel/CalcEngine/CyclicReferenceStack.php
Normal file
58
Classes/PHPExcel/CalcEngine/CyclicReferenceStack.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPExcel
|
||||||
|
*
|
||||||
|
* Copyright (c) 2006 - 2012 PHPExcel
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* @category PHPExcel
|
||||||
|
* @package PHPExcel_Calculation
|
||||||
|
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class PHPExcel_CalcEngine_CyclicReferenceStack {
|
||||||
|
|
||||||
|
private $_stack = array();
|
||||||
|
|
||||||
|
|
||||||
|
public function count() {
|
||||||
|
return count($this->_stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function push($value) {
|
||||||
|
$this->_stack[] = $value;
|
||||||
|
} // function push()
|
||||||
|
|
||||||
|
public function pop() {
|
||||||
|
return array_pop($this->_stack);
|
||||||
|
} // function pop()
|
||||||
|
|
||||||
|
public function onStack($value) {
|
||||||
|
return in_array($value,$this->_stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clear() {
|
||||||
|
$this->_stack = array();
|
||||||
|
} // function push()
|
||||||
|
|
||||||
|
public function showStack() {
|
||||||
|
return $this->_stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // class PHPExcel_CalcEngine_CyclicReferenceStack
|
121
Classes/PHPExcel/CalcEngine/Logger.php
Normal file
121
Classes/PHPExcel/CalcEngine/Logger.php
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPExcel
|
||||||
|
*
|
||||||
|
* Copyright (c) 2006 - 2012 PHPExcel
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* @category PHPExcel
|
||||||
|
* @package PHPExcel_Calculation
|
||||||
|
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHPExcel_Calculation_Logger
|
||||||
|
*
|
||||||
|
* @category PHPExcel
|
||||||
|
* @package PHPExcel_Calculation
|
||||||
|
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
|
*/
|
||||||
|
class PHPExcel_CalcEngine_Logger {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to determine whether a debug log should be generated by the calculation engine
|
||||||
|
* If true, then a debug log will be generated
|
||||||
|
* If false, then a debug log will not be generated
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private $_writeDebugLog = FALSE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to determine whether a debug log should be echoed by the calculation engine
|
||||||
|
* If true, then a debug log will be echoed
|
||||||
|
* If false, then a debug log will not be echoed
|
||||||
|
* A debug log can only be echoed if it is generated
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private $_echoDebugLog = FALSE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The debug log generated by the calculation engine
|
||||||
|
*
|
||||||
|
* @var string[]
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private $_debugLog = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The calculation engine cell reference stack
|
||||||
|
*
|
||||||
|
* @var PHPExcel_CalcEngine_CyclicReferenceStack
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private $_cellStack;
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack) {
|
||||||
|
$this->_cellStack = $stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setWriteDebugLog($pValue = FALSE) {
|
||||||
|
$this->_writeDebugLog = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getWriteDebugLog() {
|
||||||
|
return $this->_writeDebugLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEchoDebugLog($pValue = FALSE) {
|
||||||
|
$this->_echoDebugLog = $pValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEchoDebugLog() {
|
||||||
|
return $this->_echoDebugLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function writeDebugLog() {
|
||||||
|
// Only write the debug log if logging is enabled
|
||||||
|
if ($this->_writeDebugLog) {
|
||||||
|
$message = implode(func_get_args());
|
||||||
|
$cellReference = implode(' -> ', $this->_cellStack->showStack());
|
||||||
|
if ($this->_echoDebugLog) {
|
||||||
|
echo $cellReference,
|
||||||
|
($this->_cellStack->count() > 0 ? ' => ' : ''),
|
||||||
|
$message,
|
||||||
|
PHP_EOL;
|
||||||
|
}
|
||||||
|
$this->_debugLog[] = $cellReference .
|
||||||
|
($this->_cellStack->count() > 0 ? ' => ' : '') .
|
||||||
|
$message;
|
||||||
|
}
|
||||||
|
} // function _writeDebug()
|
||||||
|
|
||||||
|
public function clearLog() {
|
||||||
|
$this->_debugLog = array();
|
||||||
|
} // function flushLogger()
|
||||||
|
|
||||||
|
public function getLog() {
|
||||||
|
return $this->_debugLog;
|
||||||
|
} // function flushLogger()
|
||||||
|
|
||||||
|
} // class PHPExcel_CalcEngine_Logger
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1932,7 +1932,7 @@ class PHPExcel_Calculation_Engineering {
|
|||||||
/**
|
/**
|
||||||
* IMLOG2
|
* IMLOG2
|
||||||
*
|
*
|
||||||
* Returns the common logarithm (base 10) of a complex number in x + yi or x + yj text format.
|
* Returns the base-2 logarithm of a complex number in x + yi or x + yj text format.
|
||||||
*
|
*
|
||||||
* Excel Function:
|
* Excel Function:
|
||||||
* IMLOG2(complexNumber)
|
* IMLOG2(complexNumber)
|
||||||
|
@ -67,7 +67,9 @@ class PHPExcel_Calculation_Token_Stack {
|
|||||||
} // function last()
|
} // function last()
|
||||||
|
|
||||||
|
|
||||||
function __construct() {
|
function clear() {
|
||||||
|
$this->_stack = array();
|
||||||
|
$this->_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // class PHPExcel_Calculation_Token_Stack
|
} // class PHPExcel_Calculation_Token_Stack
|
||||||
|
@ -50,13 +50,6 @@ class PHPExcel_Cell
|
|||||||
*/
|
*/
|
||||||
private static $_valueBinder = NULL;
|
private static $_valueBinder = NULL;
|
||||||
|
|
||||||
/**
|
|
||||||
* Cell Address (e.g. A1)
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_coordinate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value of the cell
|
* Value of the cell
|
||||||
*
|
*
|
||||||
@ -86,7 +79,7 @@ class PHPExcel_Cell
|
|||||||
/**
|
/**
|
||||||
* Parent worksheet
|
* Parent worksheet
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Worksheet
|
* @var PHPExcel_CachedObjectStorage_CacheBase
|
||||||
*/
|
*/
|
||||||
private $_parent;
|
private $_parent;
|
||||||
|
|
||||||
@ -110,7 +103,8 @@ class PHPExcel_Cell
|
|||||||
* @return void
|
* @return void
|
||||||
**/
|
**/
|
||||||
public function notifyCacheController() {
|
public function notifyCacheController() {
|
||||||
$this->_parent->getCellCacheController()->updateCacheData($this);
|
$this->_parent->updateCacheData($this);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +112,9 @@ class PHPExcel_Cell
|
|||||||
$this->_parent = NULL;
|
$this->_parent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attach($parent) {
|
public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent) {
|
||||||
|
|
||||||
|
|
||||||
$this->_parent = $parent;
|
$this->_parent = $parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,23 +122,18 @@ class PHPExcel_Cell
|
|||||||
/**
|
/**
|
||||||
* Create a new Cell
|
* Create a new Cell
|
||||||
*
|
*
|
||||||
* @param string $pColumn
|
|
||||||
* @param int $pRow
|
|
||||||
* @param mixed $pValue
|
* @param mixed $pValue
|
||||||
* @param string $pDataType
|
* @param string $pDataType
|
||||||
* @param PHPExcel_Worksheet $pSheet
|
* @param PHPExcel_Worksheet $pSheet
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($pCoordinate = 'A1', $pValue = NULL, $pDataType = NULL, PHPExcel_Worksheet $pSheet = NULL)
|
public function __construct($pValue = NULL, $pDataType = NULL, PHPExcel_Worksheet $pSheet = NULL)
|
||||||
{
|
{
|
||||||
// Initialise cell coordinate
|
|
||||||
$this->_coordinate = strtoupper($pCoordinate);
|
|
||||||
|
|
||||||
// Initialise cell value
|
// Initialise cell value
|
||||||
$this->_value = $pValue;
|
$this->_value = $pValue;
|
||||||
|
|
||||||
// Set worksheet
|
// Set worksheet cache
|
||||||
$this->_parent = $pSheet;
|
$this->_parent = $pSheet->getCellCacheController();
|
||||||
|
|
||||||
// Set datatype?
|
// Set datatype?
|
||||||
if ($pDataType !== NULL) {
|
if ($pDataType !== NULL) {
|
||||||
@ -166,8 +157,7 @@ class PHPExcel_Cell
|
|||||||
*/
|
*/
|
||||||
public function getColumn()
|
public function getColumn()
|
||||||
{
|
{
|
||||||
list($column) = sscanf($this->_coordinate, '%[A-Z]%d');
|
return $this->_parent->getCurrentColumn();
|
||||||
return $column;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -177,8 +167,7 @@ class PHPExcel_Cell
|
|||||||
*/
|
*/
|
||||||
public function getRow()
|
public function getRow()
|
||||||
{
|
{
|
||||||
list(,$row) = sscanf($this->_coordinate, '%[A-Z]%d');
|
return $this->_parent->getCurrentRow();
|
||||||
return $row;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,7 +177,7 @@ class PHPExcel_Cell
|
|||||||
*/
|
*/
|
||||||
public function getCoordinate()
|
public function getCoordinate()
|
||||||
{
|
{
|
||||||
return $this->_coordinate;
|
return $this->_parent->getCurrentAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -210,7 +199,7 @@ class PHPExcel_Cell
|
|||||||
{
|
{
|
||||||
return (string) PHPExcel_Style_NumberFormat::toFormattedString(
|
return (string) PHPExcel_Style_NumberFormat::toFormattedString(
|
||||||
$this->getCalculatedValue(),
|
$this->getCalculatedValue(),
|
||||||
$this->_parent->getParent()->getCellXfByIndex($this->getXfIndex())
|
$this->getWorksheet()->getParent()->getCellXfByIndex($this->getXfIndex())
|
||||||
->getNumberFormat()->getFormatCode()
|
->getNumberFormat()->getFormatCode()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -284,38 +273,44 @@ class PHPExcel_Cell
|
|||||||
*/
|
*/
|
||||||
public function getCalculatedValue($resetLog = TRUE)
|
public function getCalculatedValue($resetLog = TRUE)
|
||||||
{
|
{
|
||||||
// echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().'<br />';
|
//echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().PHP_EOL;
|
||||||
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||||
try {
|
try {
|
||||||
// echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value<br />';
|
//echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value'.PHP_EOL;
|
||||||
$result = PHPExcel_Calculation::getInstance()->calculateCellValue($this,$resetLog);
|
$result = PHPExcel_Calculation::getInstance(
|
||||||
// echo $this->getCoordinate().' calculation result is '.$result.'<br />';
|
$this->getWorksheet()->getParent()
|
||||||
|
)->calculateCellValue($this,$resetLog);
|
||||||
|
//echo $this->getCoordinate().' calculation result is '.$result.PHP_EOL;
|
||||||
|
// We don't yet handle array returns
|
||||||
|
if (is_array($result)) {
|
||||||
|
while (is_array($result)) {
|
||||||
|
$result = array_pop($result);
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch ( PHPExcel_Exception $ex ) {
|
} catch ( PHPExcel_Exception $ex ) {
|
||||||
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) {
|
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) {
|
||||||
// echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().'<br />';
|
//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
|
||||||
return $this->_calculatedValue; // Fallback for calculations referencing external files.
|
return $this->_calculatedValue; // Fallback for calculations referencing external files.
|
||||||
}
|
}
|
||||||
// echo 'Calculation Exception: '.$ex->getMessage().'<br />';
|
//echo 'Calculation Exception: '.$ex->getMessage().PHP_EOL;
|
||||||
$result = '#N/A';
|
$result = '#N/A';
|
||||||
throw(
|
throw(
|
||||||
new PHPExcel_Calculation_Exception(
|
new PHPExcel_Calculation_Exception(
|
||||||
$this->getParent()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage()
|
$this->getWorksheet()->getTitle().'!'.$this->getCoordinate().' -> '.$ex->getMessage()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result === '#Not Yet Implemented') {
|
if ($result === '#Not Yet Implemented') {
|
||||||
// echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().'<br />';
|
//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
|
||||||
return $this->_calculatedValue; // Fallback if calculation engine does not support the formula.
|
return $this->_calculatedValue; // Fallback if calculation engine does not support the formula.
|
||||||
}
|
}
|
||||||
// echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().'<br />';
|
//echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().PHP_EOL;
|
||||||
return $result;
|
return $result;
|
||||||
|
} elseif($this->_value instanceof PHPExcel_RichText) {
|
||||||
|
// echo 'Cell value for '.$this->getCoordinate().' is rich text: Returning data value of '.$this->_value.'<br />';
|
||||||
|
return $this->_value->getPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ($this->_value === NULL) {
|
|
||||||
// echo 'Cell '.$this->getCoordinate().' has no value, formula or otherwise<br />';
|
|
||||||
// return NULL;
|
|
||||||
// }
|
|
||||||
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.'<br />';
|
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.'<br />';
|
||||||
return $this->_value;
|
return $this->_value;
|
||||||
}
|
}
|
||||||
@ -388,7 +383,7 @@ class PHPExcel_Cell
|
|||||||
throw new PHPExcel_Exception('Cannot check for data validation when cell is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot check for data validation when cell is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_parent->dataValidationExists($this->getCoordinate());
|
return $this->getWorksheet()->dataValidationExists($this->getCoordinate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -403,7 +398,7 @@ class PHPExcel_Cell
|
|||||||
throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_parent->getDataValidation($this->getCoordinate());
|
return $this->getWorksheet()->getDataValidation($this->getCoordinate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -419,7 +414,7 @@ class PHPExcel_Cell
|
|||||||
throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_parent->setDataValidation($this->getCoordinate(), $pDataValidation);
|
$this->getWorksheet()->setDataValidation($this->getCoordinate(), $pDataValidation);
|
||||||
|
|
||||||
return $this->notifyCacheController();
|
return $this->notifyCacheController();
|
||||||
}
|
}
|
||||||
@ -436,7 +431,7 @@ class PHPExcel_Cell
|
|||||||
throw new PHPExcel_Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_parent->hyperlinkExists($this->getCoordinate());
|
return $this->getWorksheet()->hyperlinkExists($this->getCoordinate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -451,7 +446,7 @@ class PHPExcel_Cell
|
|||||||
throw new PHPExcel_Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_parent->getHyperlink($this->getCoordinate());
|
return $this->getWorksheet()->getHyperlink($this->getCoordinate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -467,7 +462,7 @@ class PHPExcel_Cell
|
|||||||
throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_parent->setHyperlink($this->getCoordinate(), $pHyperlink);
|
$this->getWorksheet()->setHyperlink($this->getCoordinate(), $pHyperlink);
|
||||||
|
|
||||||
return $this->notifyCacheController();
|
return $this->notifyCacheController();
|
||||||
}
|
}
|
||||||
@ -481,6 +476,15 @@ class PHPExcel_Cell
|
|||||||
return $this->_parent;
|
return $this->_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get parent worksheet
|
||||||
|
*
|
||||||
|
* @return PHPExcel_Worksheet
|
||||||
|
*/
|
||||||
|
public function getWorksheet() {
|
||||||
|
return $this->_parent->getParent();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-bind parent
|
* Re-bind parent
|
||||||
*
|
*
|
||||||
@ -488,7 +492,7 @@ class PHPExcel_Cell
|
|||||||
* @return PHPExcel_Cell
|
* @return PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function rebindParent(PHPExcel_Worksheet $parent) {
|
public function rebindParent(PHPExcel_Worksheet $parent) {
|
||||||
$this->_parent = $parent;
|
$this->_parent = $parent->getCellCacheController();
|
||||||
|
|
||||||
return $this->notifyCacheController();
|
return $this->notifyCacheController();
|
||||||
}
|
}
|
||||||
@ -818,8 +822,8 @@ class PHPExcel_Cell
|
|||||||
|
|
||||||
// Range...
|
// Range...
|
||||||
list($rangeStart, $rangeEnd) = $range;
|
list($rangeStart, $rangeEnd) = $range;
|
||||||
list($startCol, $startRow) = sscanf($rangeStart,'%[A-Z]%d');
|
sscanf($rangeStart,'%[A-Z]%d', $startCol, $startRow);
|
||||||
list($endCol, $endRow) = sscanf($rangeEnd,'%[A-Z]%d');
|
sscanf($rangeEnd,'%[A-Z]%d', $endCol, $endRow);
|
||||||
$endCol++;
|
$endCol++;
|
||||||
|
|
||||||
// Current data
|
// Current data
|
||||||
@ -841,7 +845,7 @@ class PHPExcel_Cell
|
|||||||
// Sort the result by column and row
|
// Sort the result by column and row
|
||||||
$sortKeys = array();
|
$sortKeys = array();
|
||||||
foreach (array_unique($returnValue) as $coord) {
|
foreach (array_unique($returnValue) as $coord) {
|
||||||
list($column,$row) = sscanf($coord,'%[A-Z]%d');
|
sscanf($coord,'%[A-Z]%d', $column, $row);
|
||||||
$sortKeys[sprintf('%3s%09d',$column,$row)] = $coord;
|
$sortKeys[sprintf('%3s%09d',$column,$row)] = $coord;
|
||||||
}
|
}
|
||||||
ksort($sortKeys);
|
ksort($sortKeys);
|
||||||
@ -859,11 +863,11 @@ class PHPExcel_Cell
|
|||||||
*/
|
*/
|
||||||
public static function compareCells(PHPExcel_Cell $a, PHPExcel_Cell $b)
|
public static function compareCells(PHPExcel_Cell $a, PHPExcel_Cell $b)
|
||||||
{
|
{
|
||||||
if ($a->_row < $b->_row) {
|
if ($a->getRow() < $b->getRow()) {
|
||||||
return -1;
|
return -1;
|
||||||
} elseif ($a->_row > $b->_row) {
|
} elseif ($a->getRow() > $b->getRow()) {
|
||||||
return 1;
|
return 1;
|
||||||
} elseif (self::columnIndexFromString($a->_column) < self::columnIndexFromString($b->_column)) {
|
} elseif (self::columnIndexFromString($a->getColumn()) < self::columnIndexFromString($b->getColumn())) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -86,7 +86,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
|||||||
if ($matches[1] == '-') $value = 0 - $value;
|
if ($matches[1] == '-') $value = 0 - $value;
|
||||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||||
->getNumberFormat()->setFormatCode( '??/??' );
|
->getNumberFormat()->setFormatCode( '??/??' );
|
||||||
return true;
|
return true;
|
||||||
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
|
||||||
@ -95,7 +95,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
|||||||
if ($matches[1] == '-') $value = 0 - $value;
|
if ($matches[1] == '-') $value = 0 - $value;
|
||||||
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||||
->getNumberFormat()->setFormatCode( '# ??/??' );
|
->getNumberFormat()->setFormatCode( '# ??/??' );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
|||||||
$value = (float) str_replace('%', '', $value) / 100;
|
$value = (float) str_replace('%', '', $value) / 100;
|
||||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 );
|
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
|||||||
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
|
$value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value));
|
||||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||||
->getNumberFormat()->setFormatCode(
|
->getNumberFormat()->setFormatCode(
|
||||||
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
|
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
|
||||||
);
|
);
|
||||||
@ -130,7 +130,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
|||||||
$value = (float) trim(str_replace(array('$',','), '', $value));
|
$value = (float) trim(str_replace(array('$',','), '', $value));
|
||||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
|
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
|||||||
$days = $h / 24 + $m / 1440;
|
$days = $h / 24 + $m / 1440;
|
||||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
|
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
|||||||
// Convert value to number
|
// Convert value to number
|
||||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||||
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
|
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
|||||||
} else {
|
} else {
|
||||||
$formatCode = 'yyyy-mm-dd';
|
$formatCode = 'yyyy-mm-dd';
|
||||||
}
|
}
|
||||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||||
->getNumberFormat()->setFormatCode($formatCode);
|
->getNumberFormat()->setFormatCode($formatCode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
|||||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||||
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
|
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||||
// Set style
|
// Set style
|
||||||
$cell->getParent()->getStyle( $cell->getCoordinate() )
|
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
|
||||||
->getAlignment()->setWrapText(TRUE);
|
->getAlignment()->setWrapText(TRUE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ class PHPExcel_Chart_DataSeriesValues
|
|||||||
|
|
||||||
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) {
|
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) {
|
||||||
if ($this->_dataSource !== NULL) {
|
if ($this->_dataSource !== NULL) {
|
||||||
$calcEngine = PHPExcel_Calculation::getInstance();
|
$calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent());
|
||||||
$newDataValues = PHPExcel_Calculation::_unwrapResult(
|
$newDataValues = PHPExcel_Calculation::_unwrapResult(
|
||||||
$calcEngine->_calculateFormulaValue(
|
$calcEngine->_calculateFormulaValue(
|
||||||
'='.$this->_dataSource,
|
'='.$this->_dataSource,
|
||||||
|
@ -106,10 +106,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Initialise variables
|
// Initialise variables
|
||||||
$this->_author = 'Author';
|
$this->_author = 'Author';
|
||||||
$this->_text = new PHPExcel_RichText();
|
$this->_text = new PHPExcel_RichText();
|
||||||
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
|
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
|
||||||
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -314,4 +314,9 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __toString() {
|
||||||
|
return $this->_text->getPlainText();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1608,15 +1608,16 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$range = explode('!', (string)$definedName);
|
if ($mapSheetId[(integer) $definedName['localSheetId']] !== null) {
|
||||||
if (count($range) == 2) {
|
$range = explode('!', (string)$definedName);
|
||||||
$range[0] = str_replace("''", "'", $range[0]);
|
if (count($range) == 2) {
|
||||||
$range[0] = str_replace("'", "", $range[0]);
|
$range[0] = str_replace("''", "'", $range[0]);
|
||||||
if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) {
|
$range[0] = str_replace("'", "", $range[0]);
|
||||||
$extractedRange = str_replace('$', '', $range[1]);
|
if ($worksheet = $docSheet->getParent()->getSheetByName($range[0])) {
|
||||||
$scope = $docSheet->getParent()->getSheet((string)$definedName['localSheetId']);
|
$extractedRange = str_replace('$', '', $range[1]);
|
||||||
|
$scope = $docSheet->getParent()->getSheet($mapSheetId[(integer) $definedName['localSheetId']]);
|
||||||
$excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope) );
|
$excel->addNamedRange( new PHPExcel_NamedRange((string)$definedName['name'], $worksheet, $extractedRange, true, $scope) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -69,24 +69,328 @@ class PHPExcel_ReferenceHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a new column, updating all possible related data
|
* Compare two column addresses
|
||||||
|
* Intended for use as a Callback function for sorting column addresses by column
|
||||||
*
|
*
|
||||||
* @param int $pBefore Insert before this one
|
* @param string $a First column to test (e.g. 'AA')
|
||||||
* @param int $pNumCols Number of columns to insert
|
* @param string $b Second column to test (e.g. 'Z')
|
||||||
* @param int $pNumRows Number of rows to insert
|
* @return integer
|
||||||
* @throws PHPExcel_Exception
|
|
||||||
*/
|
*/
|
||||||
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null) {
|
public static function columnSort($a, $b) {
|
||||||
|
return strcasecmp(strlen($a) . $a, strlen($b) . $b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare two column addresses
|
||||||
|
* Intended for use as a Callback function for reverse sorting column addresses by column
|
||||||
|
*
|
||||||
|
* @param string $a First column to test (e.g. 'AA')
|
||||||
|
* @param string $b Second column to test (e.g. 'Z')
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public static function columnReverseSort($a, $b) {
|
||||||
|
return 1 - strcasecmp(strlen($a) . $a, strlen($b) . $b);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare two cell addresses
|
||||||
|
* Intended for use as a Callback function for sorting cell addresses by column and row
|
||||||
|
*
|
||||||
|
* @param string $a First cell to test (e.g. 'AA1')
|
||||||
|
* @param string $b Second cell to test (e.g. 'Z1')
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public static function cellSort($a, $b) {
|
||||||
|
sscanf($a,'%[A-Z]%d', $ac, $ar);
|
||||||
|
sscanf($b,'%[A-Z]%d', $bc, $br);
|
||||||
|
|
||||||
|
if ($ar == $br) {
|
||||||
|
return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
|
||||||
|
}
|
||||||
|
return ($ar < $br) ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare two cell addresses
|
||||||
|
* Intended for use as a Callback function for sorting cell addresses by column and row
|
||||||
|
*
|
||||||
|
* @param string $a First cell to test (e.g. 'AA1')
|
||||||
|
* @param string $b Second cell to test (e.g. 'Z1')
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public static function cellReverseSort($a, $b) {
|
||||||
|
sscanf($a,'%[A-Z]%d', $ac, $ar);
|
||||||
|
sscanf($b,'%[A-Z]%d', $bc, $br);
|
||||||
|
|
||||||
|
if ($ar == $br) {
|
||||||
|
return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
|
||||||
|
}
|
||||||
|
return ($ar < $br) ? 1 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether a cell address falls within a defined range of cells
|
||||||
|
*
|
||||||
|
* @param string $cellAddress Address of the cell we're testing
|
||||||
|
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||||
|
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||||
|
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||||
|
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols) {
|
||||||
|
list($cellColumn, $cellRow) = PHPExcel_Cell::coordinateFromString($cellAddress);
|
||||||
|
$cellColumnIndex = PHPExcel_Cell::columnIndexFromString($cellColumn);
|
||||||
|
// Is cell within the range of rows/columns if we're deleting
|
||||||
|
if ($pNumRows < 0 &&
|
||||||
|
($cellRow >= ($beforeRow + $pNumRows)) &&
|
||||||
|
($cellRow < $beforeRow)) {
|
||||||
|
return TRUE;
|
||||||
|
} elseif ($pNumCols < 0 &&
|
||||||
|
($cellColumnIndex >= ($beforeColumnIndex + $pNumCols)) &&
|
||||||
|
($cellColumnIndex < $beforeColumnIndex)) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update page breaks when inserting/deleting rows/columns
|
||||||
|
*
|
||||||
|
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||||
|
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||||
|
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||||
|
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||||
|
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||||
|
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||||
|
*/
|
||||||
|
protected function _adjustPageBreaks(PHPExcel_Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||||
|
{
|
||||||
|
$aBreaks = $pSheet->getBreaks();
|
||||||
|
($pNumCols > 0 || $pNumRows > 0) ?
|
||||||
|
uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||||
|
uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||||
|
|
||||||
|
foreach ($aBreaks as $key => $value) {
|
||||||
|
if (self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) {
|
||||||
|
// If we're deleting, then clear any defined breaks that are within the range
|
||||||
|
// of rows/columns that we're deleting
|
||||||
|
$pSheet->setBreak($key, PHPExcel_Worksheet::BREAK_NONE);
|
||||||
|
} else {
|
||||||
|
// Otherwise update any affected breaks by inserting a new break at the appropriate point
|
||||||
|
// and removing the old affected break
|
||||||
|
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||||
|
if ($key != $newReference) {
|
||||||
|
$pSheet->setBreak($newReference, $value)
|
||||||
|
->setBreak($key, PHPExcel_Worksheet::BREAK_NONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update cell comments when inserting/deleting rows/columns
|
||||||
|
*
|
||||||
|
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||||
|
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||||
|
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||||
|
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||||
|
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||||
|
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||||
|
*/
|
||||||
|
protected function _adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||||
|
{
|
||||||
|
$aComments = $pSheet->getComments();
|
||||||
|
$aNewComments = array(); // the new array of all comments
|
||||||
|
|
||||||
|
foreach ($aComments as $key => &$value) {
|
||||||
|
// Any comments inside a deleted range will be ignored
|
||||||
|
if (!self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) {
|
||||||
|
// Otherwise build a new array of comments indexed by the adjusted cell reference
|
||||||
|
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||||
|
$aNewComments[$newReference] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Replace the comments array with the new set of comments
|
||||||
|
$pSheet->setComments($aNewComments);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update hyperlinks when inserting/deleting rows/columns
|
||||||
|
*
|
||||||
|
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||||
|
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||||
|
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||||
|
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||||
|
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||||
|
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||||
|
*/
|
||||||
|
protected function _adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||||
|
{
|
||||||
|
$aHyperlinkCollection = $pSheet->getHyperlinkCollection();
|
||||||
|
($pNumCols > 0 || $pNumRows > 0) ?
|
||||||
|
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||||
|
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||||
|
|
||||||
|
foreach ($aHyperlinkCollection as $key => $value) {
|
||||||
|
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||||
|
if ($key != $newReference) {
|
||||||
|
$pSheet->setHyperlink( $newReference, $value );
|
||||||
|
$pSheet->setHyperlink( $key, null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update data validations when inserting/deleting rows/columns
|
||||||
|
*
|
||||||
|
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||||
|
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||||
|
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||||
|
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||||
|
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||||
|
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||||
|
*/
|
||||||
|
protected function _adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||||
|
{
|
||||||
|
$aDataValidationCollection = $pSheet->getDataValidationCollection();
|
||||||
|
($pNumCols > 0 || $pNumRows > 0) ?
|
||||||
|
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||||
|
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||||
|
foreach ($aDataValidationCollection as $key => $value) {
|
||||||
|
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||||
|
if ($key != $newReference) {
|
||||||
|
$pSheet->setDataValidation( $newReference, $value );
|
||||||
|
$pSheet->setDataValidation( $key, null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update merged cells when inserting/deleting rows/columns
|
||||||
|
*
|
||||||
|
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||||
|
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||||
|
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||||
|
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||||
|
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||||
|
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||||
|
*/
|
||||||
|
protected function _adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||||
|
{
|
||||||
|
$aMergeCells = $pSheet->getMergeCells();
|
||||||
|
$aNewMergeCells = array(); // the new array of all merge cells
|
||||||
|
foreach ($aMergeCells as $key => &$value) {
|
||||||
|
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||||
|
$aNewMergeCells[$newReference] = $newReference;
|
||||||
|
}
|
||||||
|
$pSheet->setMergeCells($aNewMergeCells); // replace the merge cells array
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update protected cells when inserting/deleting rows/columns
|
||||||
|
*
|
||||||
|
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||||
|
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||||
|
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||||
|
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||||
|
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||||
|
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||||
|
*/
|
||||||
|
protected function _adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||||
|
{
|
||||||
|
$aProtectedCells = $pSheet->getProtectedCells();
|
||||||
|
($pNumCols > 0 || $pNumRows > 0) ?
|
||||||
|
uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||||
|
uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||||
|
foreach ($aProtectedCells as $key => $value) {
|
||||||
|
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||||
|
if ($key != $newReference) {
|
||||||
|
$pSheet->protectCells( $newReference, $value, true );
|
||||||
|
$pSheet->unprotectCells( $key );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update column dimensions when inserting/deleting rows/columns
|
||||||
|
*
|
||||||
|
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||||
|
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||||
|
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||||
|
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||||
|
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||||
|
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||||
|
*/
|
||||||
|
protected function _adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||||
|
{
|
||||||
|
$aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true);
|
||||||
|
if (!empty($aColumnDimensions)) {
|
||||||
|
foreach ($aColumnDimensions as $objColumnDimension) {
|
||||||
|
$newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows);
|
||||||
|
list($newReference) = PHPExcel_Cell::coordinateFromString($newReference);
|
||||||
|
if ($objColumnDimension->getColumnIndex() != $newReference) {
|
||||||
|
$objColumnDimension->setColumnIndex($newReference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$pSheet->refreshColumnDimensions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update row dimensions when inserting/deleting rows/columns
|
||||||
|
*
|
||||||
|
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||||
|
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||||
|
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||||
|
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||||
|
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||||
|
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||||
|
*/
|
||||||
|
protected function _adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||||
|
{
|
||||||
|
$aRowDimensions = array_reverse($pSheet->getRowDimensions(), true);
|
||||||
|
if (!empty($aRowDimensions)) {
|
||||||
|
foreach ($aRowDimensions as $objRowDimension) {
|
||||||
|
$newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows);
|
||||||
|
list(, $newReference) = PHPExcel_Cell::coordinateFromString($newReference);
|
||||||
|
if ($objRowDimension->getRowIndex() != $newReference) {
|
||||||
|
$objRowDimension->setRowIndex($newReference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$pSheet->refreshRowDimensions();
|
||||||
|
|
||||||
|
$copyDimension = $pSheet->getRowDimension($beforeRow - 1);
|
||||||
|
for ($i = $beforeRow; $i <= $beforeRow - 1 + $pNumRows; ++$i) {
|
||||||
|
$newDimension = $pSheet->getRowDimension($i);
|
||||||
|
$newDimension->setRowHeight($copyDimension->getRowHeight());
|
||||||
|
$newDimension->setVisible($copyDimension->getVisible());
|
||||||
|
$newDimension->setOutlineLevel($copyDimension->getOutlineLevel());
|
||||||
|
$newDimension->setCollapsed($copyDimension->getCollapsed());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert a new column or row, updating all possible related data
|
||||||
|
*
|
||||||
|
* @param string $pBefore Insert before this cell address (e.g. 'A1')
|
||||||
|
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||||
|
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||||
|
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||||
|
* @throws PHPExcel_Exception
|
||||||
|
*/
|
||||||
|
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = NULL)
|
||||||
|
{
|
||||||
$remove = ($pNumCols < 0 || $pNumRows < 0);
|
$remove = ($pNumCols < 0 || $pNumRows < 0);
|
||||||
$aCellCollection = $pSheet->getCellCollection();
|
$aCellCollection = $pSheet->getCellCollection();
|
||||||
|
|
||||||
// Get coordinates of $pBefore
|
// Get coordinates of $pBefore
|
||||||
$beforeColumn = 'A';
|
$beforeColumn = 'A';
|
||||||
$beforeRow = 1;
|
$beforeRow = 1;
|
||||||
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );
|
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString($pBefore);
|
||||||
$beforeColumnIndex = PHPExcel_Cell::columnIndexFromString($beforeColumn);
|
$beforeColumnIndex = PHPExcel_Cell::columnIndexFromString($beforeColumn);
|
||||||
|
|
||||||
|
|
||||||
// Clear cells if we are removing columns or rows
|
// Clear cells if we are removing columns or rows
|
||||||
$highestColumn = $pSheet->getHighestColumn();
|
$highestColumn = $pSheet->getHighestColumn();
|
||||||
$highestRow = $pSheet->getHighestRow();
|
$highestRow = $pSheet->getHighestRow();
|
||||||
@ -119,7 +423,6 @@ class PHPExcel_ReferenceHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Loop through cells, bottom-up, and change cell coordinates
|
// Loop through cells, bottom-up, and change cell coordinates
|
||||||
while (($cellID = $remove ? array_shift($aCellCollection) : array_pop($aCellCollection))) {
|
while (($cellID = $remove ? array_shift($aCellCollection) : array_pop($aCellCollection))) {
|
||||||
$cell = $pSheet->getCell($cellID);
|
$cell = $pSheet->getCell($cellID);
|
||||||
@ -164,7 +467,6 @@ class PHPExcel_ReferenceHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Duplicate styles for the newly inserted cells
|
// Duplicate styles for the newly inserted cells
|
||||||
$highestColumn = $pSheet->getHighestColumn();
|
$highestColumn = $pSheet->getHighestColumn();
|
||||||
$highestRow = $pSheet->getHighestRow();
|
$highestRow = $pSheet->getHighestRow();
|
||||||
@ -216,105 +518,29 @@ class PHPExcel_ReferenceHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update worksheet: column dimensions
|
// Update worksheet: column dimensions
|
||||||
$aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true);
|
$this->_adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||||
if (!empty($aColumnDimensions)) {
|
|
||||||
foreach ($aColumnDimensions as $objColumnDimension) {
|
|
||||||
$newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows);
|
|
||||||
list($newReference) = PHPExcel_Cell::coordinateFromString($newReference);
|
|
||||||
if ($objColumnDimension->getColumnIndex() != $newReference) {
|
|
||||||
$objColumnDimension->setColumnIndex($newReference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$pSheet->refreshColumnDimensions();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Update worksheet: row dimensions
|
// Update worksheet: row dimensions
|
||||||
$aRowDimensions = array_reverse($pSheet->getRowDimensions(), true);
|
$this->_adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||||
if (!empty($aRowDimensions)) {
|
|
||||||
foreach ($aRowDimensions as $objRowDimension) {
|
|
||||||
$newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows);
|
|
||||||
list(, $newReference) = PHPExcel_Cell::coordinateFromString($newReference);
|
|
||||||
if ($objRowDimension->getRowIndex() != $newReference) {
|
|
||||||
$objRowDimension->setRowIndex($newReference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$pSheet->refreshRowDimensions();
|
|
||||||
|
|
||||||
$copyDimension = $pSheet->getRowDimension($beforeRow - 1);
|
// Update worksheet: page breaks
|
||||||
for ($i = $beforeRow; $i <= $beforeRow - 1 + $pNumRows; ++$i) {
|
$this->_adjustPageBreaks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||||
$newDimension = $pSheet->getRowDimension($i);
|
|
||||||
$newDimension->setRowHeight($copyDimension->getRowHeight());
|
|
||||||
$newDimension->setVisible($copyDimension->getVisible());
|
|
||||||
$newDimension->setOutlineLevel($copyDimension->getOutlineLevel());
|
|
||||||
$newDimension->setCollapsed($copyDimension->getCollapsed());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Update worksheet: comments
|
||||||
// Update worksheet: breaks
|
$this->_adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||||
$aBreaks = array_reverse($pSheet->getBreaks(), true);
|
|
||||||
foreach ($aBreaks as $key => $value) {
|
|
||||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
|
||||||
if ($key != $newReference) {
|
|
||||||
$pSheet->setBreak( $newReference, $value );
|
|
||||||
$pSheet->setBreak( $key, PHPExcel_Worksheet::BREAK_NONE );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update worksheet: comments
|
|
||||||
$aComments = $pSheet->getComments();
|
|
||||||
$aNewComments = array(); // the new array of all comments
|
|
||||||
foreach ($aComments as $key => &$value) {
|
|
||||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
|
||||||
$aNewComments[$newReference] = $value;
|
|
||||||
}
|
|
||||||
$pSheet->setComments($aNewComments); // replace the comments array
|
|
||||||
|
|
||||||
// Update worksheet: hyperlinks
|
// Update worksheet: hyperlinks
|
||||||
$aHyperlinkCollection = array_reverse($pSheet->getHyperlinkCollection(), true);
|
$this->_adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||||
foreach ($aHyperlinkCollection as $key => $value) {
|
|
||||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
|
||||||
if ($key != $newReference) {
|
|
||||||
$pSheet->setHyperlink( $newReference, $value );
|
|
||||||
$pSheet->setHyperlink( $key, null );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Update worksheet: data validations
|
// Update worksheet: data validations
|
||||||
$aDataValidationCollection = array_reverse($pSheet->getDataValidationCollection(), true);
|
$this->_adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||||
foreach ($aDataValidationCollection as $key => $value) {
|
|
||||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
|
||||||
if ($key != $newReference) {
|
|
||||||
$pSheet->setDataValidation( $newReference, $value );
|
|
||||||
$pSheet->setDataValidation( $key, null );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Update worksheet: merge cells
|
// Update worksheet: merge cells
|
||||||
$aMergeCells = $pSheet->getMergeCells();
|
$this->_adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||||
$aNewMergeCells = array(); // the new array of all merge cells
|
|
||||||
foreach ($aMergeCells as $key => &$value) {
|
|
||||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
|
||||||
$aNewMergeCells[$newReference] = $newReference;
|
|
||||||
}
|
|
||||||
$pSheet->setMergeCells($aNewMergeCells); // replace the merge cells array
|
|
||||||
|
|
||||||
|
|
||||||
// Update worksheet: protected cells
|
// Update worksheet: protected cells
|
||||||
$aProtectedCells = array_reverse($pSheet->getProtectedCells(), true);
|
$this->_adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||||
foreach ($aProtectedCells as $key => $value) {
|
|
||||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
|
||||||
if ($key != $newReference) {
|
|
||||||
$pSheet->protectCells( $newReference, $value, true );
|
|
||||||
$pSheet->unprotectCells( $key );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Update worksheet: autofilter
|
// Update worksheet: autofilter
|
||||||
$autoFilter = $pSheet->getAutoFilter();
|
$autoFilter = $pSheet->getAutoFilter();
|
||||||
@ -323,7 +549,7 @@ class PHPExcel_ReferenceHelper
|
|||||||
if ($pNumCols != 0) {
|
if ($pNumCols != 0) {
|
||||||
$autoFilterColumns = array_keys($autoFilter->getColumns());
|
$autoFilterColumns = array_keys($autoFilter->getColumns());
|
||||||
if (count($autoFilterColumns) > 0) {
|
if (count($autoFilterColumns) > 0) {
|
||||||
list($column,$row) = sscanf($pBefore,'%[A-Z]%d');
|
sscanf($pBefore,'%[A-Z]%d', $column, $row);
|
||||||
$columnIndex = PHPExcel_Cell::columnIndexFromString($column);
|
$columnIndex = PHPExcel_Cell::columnIndexFromString($column);
|
||||||
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
|
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
|
||||||
if ($columnIndex <= $rangeEnd[0]) {
|
if ($columnIndex <= $rangeEnd[0]) {
|
||||||
@ -374,19 +600,16 @@ class PHPExcel_ReferenceHelper
|
|||||||
$pSheet->setAutoFilter( $this->updateCellReference($autoFilterRange, $pBefore, $pNumCols, $pNumRows) );
|
$pSheet->setAutoFilter( $this->updateCellReference($autoFilterRange, $pBefore, $pNumCols, $pNumRows) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update worksheet: freeze pane
|
// Update worksheet: freeze pane
|
||||||
if ($pSheet->getFreezePane() != '') {
|
if ($pSheet->getFreezePane() != '') {
|
||||||
$pSheet->freezePane( $this->updateCellReference($pSheet->getFreezePane(), $pBefore, $pNumCols, $pNumRows) );
|
$pSheet->freezePane( $this->updateCellReference($pSheet->getFreezePane(), $pBefore, $pNumCols, $pNumRows) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Page setup
|
// Page setup
|
||||||
if ($pSheet->getPageSetup()->isPrintAreaSet()) {
|
if ($pSheet->getPageSetup()->isPrintAreaSet()) {
|
||||||
$pSheet->getPageSetup()->setPrintArea( $this->updateCellReference($pSheet->getPageSetup()->getPrintArea(), $pBefore, $pNumCols, $pNumRows) );
|
$pSheet->getPageSetup()->setPrintArea( $this->updateCellReference($pSheet->getPageSetup()->getPrintArea(), $pBefore, $pNumCols, $pNumRows) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update worksheet: drawings
|
// Update worksheet: drawings
|
||||||
$aDrawings = $pSheet->getDrawingCollection();
|
$aDrawings = $pSheet->getDrawingCollection();
|
||||||
foreach ($aDrawings as $objDrawing) {
|
foreach ($aDrawings as $objDrawing) {
|
||||||
@ -396,7 +619,6 @@ class PHPExcel_ReferenceHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update workbook: named ranges
|
// Update workbook: named ranges
|
||||||
if (count($pSheet->getParent()->getNamedRanges()) > 0) {
|
if (count($pSheet->getParent()->getNamedRanges()) > 0) {
|
||||||
foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) {
|
foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) {
|
||||||
|
@ -253,7 +253,7 @@ class PHPExcel_Shared_Date
|
|||||||
*/
|
*/
|
||||||
public static function isDateTime(PHPExcel_Cell $pCell) {
|
public static function isDateTime(PHPExcel_Cell $pCell) {
|
||||||
return self::isDateTimeFormat(
|
return self::isDateTimeFormat(
|
||||||
$pCell->getParent()->getStyle(
|
$pCell->getWorksheet()->getStyle(
|
||||||
$pCell->getCoordinate()
|
$pCell->getCoordinate()
|
||||||
)->getNumberFormat()
|
)->getNumberFormat()
|
||||||
);
|
);
|
||||||
|
@ -482,7 +482,7 @@ class PHPExcel_Shared_String
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert string from one encoding to another. First try iconv, then mbstring, or no convertion
|
* Convert string from one encoding to another. First try mbstring, then iconv, finally strlen
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param string $to Encoding to convert to, e.g. 'UTF-8'
|
* @param string $to Encoding to convert to, e.g. 'UTF-8'
|
||||||
@ -548,20 +548,20 @@ class PHPExcel_Shared_String
|
|||||||
*/
|
*/
|
||||||
public static function CountCharacters($value, $enc = 'UTF-8')
|
public static function CountCharacters($value, $enc = 'UTF-8')
|
||||||
{
|
{
|
||||||
if (self::getIsIconvEnabled()) {
|
|
||||||
return iconv_strlen($value, $enc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self::getIsMbstringEnabled()) {
|
if (self::getIsMbstringEnabled()) {
|
||||||
return mb_strlen($value, $enc);
|
return mb_strlen($value, $enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self::getIsIconvEnabled()) {
|
||||||
|
return iconv_strlen($value, $enc);
|
||||||
|
}
|
||||||
|
|
||||||
// else strlen
|
// else strlen
|
||||||
return strlen($value);
|
return strlen($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a substring of a UTF-8 encoded string
|
* Get a substring of a UTF-8 encoded string. First try mbstring, then iconv, finally strlen
|
||||||
*
|
*
|
||||||
* @param string $pValue UTF-8 encoded string
|
* @param string $pValue UTF-8 encoded string
|
||||||
* @param int $start Start offset
|
* @param int $start Start offset
|
||||||
@ -570,14 +570,14 @@ class PHPExcel_Shared_String
|
|||||||
*/
|
*/
|
||||||
public static function Substring($pValue = '', $pStart = 0, $pLength = 0)
|
public static function Substring($pValue = '', $pStart = 0, $pLength = 0)
|
||||||
{
|
{
|
||||||
if (self::getIsIconvEnabled()) {
|
|
||||||
return iconv_substr($pValue, $pStart, $pLength, 'UTF-8');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self::getIsMbstringEnabled()) {
|
if (self::getIsMbstringEnabled()) {
|
||||||
return mb_substr($pValue, $pStart, $pLength, 'UTF-8');
|
return mb_substr($pValue, $pStart, $pLength, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self::getIsIconvEnabled()) {
|
||||||
|
return iconv_substr($pValue, $pStart, $pLength, 'UTF-8');
|
||||||
|
}
|
||||||
|
|
||||||
// else substr
|
// else substr
|
||||||
return substr($pValue, $pStart, $pLength);
|
return substr($pValue, $pStart, $pLength);
|
||||||
}
|
}
|
||||||
|
@ -263,11 +263,7 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
|
|||||||
* @return string The red colour component
|
* @return string The red colour component
|
||||||
*/
|
*/
|
||||||
public static function getRed($RGB,$hex=TRUE) {
|
public static function getRed($RGB,$hex=TRUE) {
|
||||||
if (strlen($RGB) == 8) {
|
return self::_getColourComponent($RGB, strlen($RGB) - 6, $hex);
|
||||||
return self::_getColourComponent($RGB, 2, $hex);
|
|
||||||
} elseif (strlen($RGB) == 6) {
|
|
||||||
return self::_getColourComponent($RGB, 0, $hex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -279,11 +275,7 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
|
|||||||
* @return string The green colour component
|
* @return string The green colour component
|
||||||
*/
|
*/
|
||||||
public static function getGreen($RGB,$hex=TRUE) {
|
public static function getGreen($RGB,$hex=TRUE) {
|
||||||
if (strlen($RGB) == 8) {
|
return self::_getColourComponent($RGB, strlen($RGB) - 4, $hex);
|
||||||
return self::_getColourComponent($RGB, 4, $hex);
|
|
||||||
} elseif (strlen($RGB) == 6) {
|
|
||||||
return self::_getColourComponent($RGB, 2, $hex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -295,11 +287,7 @@ class PHPExcel_Style_Color extends PHPExcel_Style_Supervisor implements PHPExcel
|
|||||||
* @return string The blue colour component
|
* @return string The blue colour component
|
||||||
*/
|
*/
|
||||||
public static function getBlue($RGB,$hex=TRUE) {
|
public static function getBlue($RGB,$hex=TRUE) {
|
||||||
if (strlen($RGB) == 8) {
|
return self::_getColourComponent($RGB, strlen($RGB) - 2, $hex);
|
||||||
return self::_getColourComponent($RGB, 6, $hex);
|
|
||||||
} elseif (strlen($RGB) == 6) {
|
|
||||||
return self::_getColourComponent($RGB, 4, $hex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -439,7 +439,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
|
|||||||
* @param array $callBack Callback function for additional formatting of string
|
* @param array $callBack Callback function for additional formatting of string
|
||||||
* @return string Formatted string
|
* @return string Formatted string
|
||||||
*/
|
*/
|
||||||
public static function toFormattedString($value = '', $format = '', $callBack = null)
|
public static function toFormattedString($value = PHPExcel_Style_NumberFormat::FORMAT_GENERAL, $format = '', $callBack = null)
|
||||||
{
|
{
|
||||||
// For now we do not treat strings although section 4 of a format code affects strings
|
// For now we do not treat strings although section 4 of a format code affects strings
|
||||||
if (!is_numeric($value)) return $value;
|
if (!is_numeric($value)) return $value;
|
||||||
|
@ -376,22 +376,32 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* typically so that the worksheet object can be unset
|
* typically so that the worksheet object can be unset
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function disconnectCells()
|
public function disconnectCells() {
|
||||||
{
|
if ( $this->_cellCollection !== NULL){
|
||||||
$this->_cellCollection->unsetWorksheetCells();
|
$this->_cellCollection->unsetWorksheetCells();
|
||||||
$this->_cellCollection = null;
|
$this->_cellCollection = NULL;
|
||||||
|
}
|
||||||
// detach ourself from the workbook, so that it can then delete this worksheet successfully
|
// detach ourself from the workbook, so that it can then delete this worksheet successfully
|
||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Code to execute when this worksheet is unset()
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function __destruct() {
|
||||||
|
PHPExcel_Calculation::getInstance($this->_parent)
|
||||||
|
->clearCalculationCacheForWorksheet($this->_title);
|
||||||
|
|
||||||
|
$this->disconnectCells();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* Return the cache controller for the cell collection
|
* Return the cache controller for the cell collection
|
||||||
*
|
*
|
||||||
* @return PHPExcel_CachedObjectStorage_xxx
|
* @return PHPExcel_CachedObjectStorage_xxx
|
||||||
*/
|
*/
|
||||||
public function getCellCacheController()
|
public function getCellCacheController() {
|
||||||
{
|
|
||||||
return $this->_cellCollection;
|
return $this->_cellCollection;
|
||||||
} // function getCellCacheController()
|
} // function getCellCacheController()
|
||||||
|
|
||||||
@ -698,21 +708,22 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
// loop through all cells in the worksheet
|
// loop through all cells in the worksheet
|
||||||
foreach ($this->getCellCollection(false) as $cellID) {
|
foreach ($this->getCellCollection(false) as $cellID) {
|
||||||
$cell = $this->getCell($cellID);
|
$cell = $this->getCell($cellID);
|
||||||
if (isset($autoSizes[$cell->getColumn()])) {
|
if (isset($autoSizes[$this->_cellCollection->getCurrentColumn()])) {
|
||||||
// Determine width if cell does not participate in a merge
|
// Determine width if cell does not participate in a merge
|
||||||
if (!isset($isMergeCell[$cell->getCoordinate()])) {
|
if (!isset($isMergeCell[$this->_cellCollection->getCurrentAddress()])) {
|
||||||
// Calculated value
|
// Calculated value
|
||||||
$cellValue = $cell->getCalculatedValue();
|
|
||||||
|
|
||||||
// To formatted string
|
// To formatted string
|
||||||
$cellValue = PHPExcel_Style_NumberFormat::toFormattedString($cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode());
|
$cellValue = PHPExcel_Style_NumberFormat::toFormattedString(
|
||||||
|
$cell->getCalculatedValue(),
|
||||||
|
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode()
|
||||||
|
);
|
||||||
|
|
||||||
$autoSizes[$cell->getColumn()] = max(
|
$autoSizes[$this->_cellCollection->getCurrentColumn()] = max(
|
||||||
(float)$autoSizes[$cell->getColumn()],
|
(float) $autoSizes[$this->_cellCollection->getCurrentColumn()],
|
||||||
(float)PHPExcel_Shared_Font::calculateColumnWidth(
|
(float)PHPExcel_Shared_Font::calculateColumnWidth(
|
||||||
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
|
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
|
||||||
$cellValue,
|
$cellValue,
|
||||||
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
|
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
|
||||||
$this->getDefaultStyle()->getFont()
|
$this->getDefaultStyle()->getFont()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -735,8 +746,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent() {
|
||||||
{
|
|
||||||
return $this->_parent;
|
return $this->_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,8 +756,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param PHPExcel $parent
|
* @param PHPExcel $parent
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function rebindParent(PHPExcel $parent)
|
public function rebindParent(PHPExcel $parent) {
|
||||||
{
|
|
||||||
$namedRanges = $this->_parent->getNamedRanges();
|
$namedRanges = $this->_parent->getNamedRanges();
|
||||||
foreach ($namedRanges as $namedRange) {
|
foreach ($namedRanges as $namedRange) {
|
||||||
$parent->addNamedRange($namedRange);
|
$parent->addNamedRange($namedRange);
|
||||||
@ -780,7 +789,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* This should be left as the default true, unless you are
|
* This should be left as the default true, unless you are
|
||||||
* certain that no formula cells on any worksheet contain
|
* certain that no formula cells on any worksheet contain
|
||||||
* references to this worksheet
|
* references to this worksheet
|
||||||
*
|
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function setTitle($pValue = 'Worksheet', $updateFormulaCellReferences = true)
|
public function setTitle($pValue = 'Worksheet', $updateFormulaCellReferences = true)
|
||||||
@ -796,16 +804,16 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
// Old title
|
// Old title
|
||||||
$oldTitle = $this->getTitle();
|
$oldTitle = $this->getTitle();
|
||||||
|
|
||||||
if ($this->getParent()) {
|
if ($this->_parent) {
|
||||||
// Is there already such sheet name?
|
// Is there already such sheet name?
|
||||||
if ($this->getParent()->sheetNameExists($pValue)) {
|
if ($this->_parent->sheetNameExists($pValue)) {
|
||||||
// Use name, but append with lowest possible integer
|
// Use name, but append with lowest possible integer
|
||||||
|
|
||||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
|
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
|
||||||
$pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
|
$pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
|
||||||
}
|
}
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($this->getParent()->sheetNameExists($pValue . ' ' . $i)) {
|
while ($this->_parent->sheetNameExists($pValue . ' ' . $i)) {
|
||||||
++$i;
|
++$i;
|
||||||
if ($i == 10) {
|
if ($i == 10) {
|
||||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
|
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
|
||||||
@ -827,11 +835,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$this->_title = $pValue;
|
$this->_title = $pValue;
|
||||||
$this->_dirty = true;
|
$this->_dirty = true;
|
||||||
|
|
||||||
if ($this->getParent()) {
|
if ($this->_parent) {
|
||||||
// New title
|
// New title
|
||||||
$newTitle = $this->getTitle();
|
$newTitle = $this->getTitle();
|
||||||
|
PHPExcel_Calculation::getInstance($this->_parent)
|
||||||
|
->renameCalculationCacheForWorksheet($oldTitle, $newTitle);
|
||||||
if ($updateFormulaCellReferences)
|
if ($updateFormulaCellReferences)
|
||||||
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->getParent(), $oldTitle, $newTitle);
|
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -842,8 +852,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return string Sheet state (visible, hidden, veryHidden)
|
* @return string Sheet state (visible, hidden, veryHidden)
|
||||||
*/
|
*/
|
||||||
public function getSheetState()
|
public function getSheetState() {
|
||||||
{
|
|
||||||
return $this->_sheetState;
|
return $this->_sheetState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,8 +862,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param string $value Sheet state (visible, hidden, veryHidden)
|
* @param string $value Sheet state (visible, hidden, veryHidden)
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE)
|
public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) {
|
||||||
{
|
|
||||||
$this->_sheetState = $value;
|
$this->_sheetState = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -1099,7 +1107,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
// Worksheet reference?
|
// Worksheet reference?
|
||||||
if (strpos($pCoordinate, '!') !== false) {
|
if (strpos($pCoordinate, '!') !== false) {
|
||||||
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
|
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
|
||||||
return $this->getParent()->getSheetByName($worksheetReference[0])->getCell($worksheetReference[1]);
|
return $this->_parent->getSheetByName($worksheetReference[0])->getCell($worksheetReference[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Named range?
|
// Named range?
|
||||||
@ -1125,7 +1133,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
// Coordinates
|
// Coordinates
|
||||||
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
|
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
|
||||||
|
|
||||||
$cell = $this->_cellCollection->addCacheData($pCoordinate,new PHPExcel_Cell($pCoordinate, NULL, PHPExcel_Cell_DataType::TYPE_NULL, $this));
|
$cell = $this->_cellCollection->addCacheData($pCoordinate,new PHPExcel_Cell(NULL, PHPExcel_Cell_DataType::TYPE_NULL, $this));
|
||||||
$this->_cellCollectionIsSorted = false;
|
$this->_cellCollectionIsSorted = false;
|
||||||
|
|
||||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
|
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
|
||||||
@ -1165,7 +1173,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$coordinate = $columnLetter . $pRow;
|
$coordinate = $columnLetter . $pRow;
|
||||||
|
|
||||||
if (!$this->_cellCollection->isDataSet($coordinate)) {
|
if (!$this->_cellCollection->isDataSet($coordinate)) {
|
||||||
$cell = $this->_cellCollection->addCacheData($coordinate, new PHPExcel_Cell($coordinate, NULL, PHPExcel_Cell_DataType::TYPE_NULL, $this));
|
$cell = $this->_cellCollection->addCacheData($coordinate, new PHPExcel_Cell(NULL, PHPExcel_Cell_DataType::TYPE_NULL, $this));
|
||||||
$this->_cellCollectionIsSorted = false;
|
$this->_cellCollectionIsSorted = false;
|
||||||
|
|
||||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn)
|
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn)
|
||||||
@ -1191,7 +1199,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
// Worksheet reference?
|
// Worksheet reference?
|
||||||
if (strpos($pCoordinate, '!') !== false) {
|
if (strpos($pCoordinate, '!') !== false) {
|
||||||
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
|
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
|
||||||
return $this->getParent()->getSheetByName($worksheetReference[0])->cellExists($worksheetReference[1]);
|
return $this->_parent->getSheetByName($worksheetReference[0])->cellExists($worksheetReference[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Named range?
|
// Named range?
|
||||||
@ -1511,7 +1519,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* Please note that this will overwrite existing cell styles for cells in range!
|
* Please note that this will overwrite existing cell styles for cells in range!
|
||||||
*
|
*
|
||||||
* @param [PHPExcel_Style_Conditional] $pCellStyle Cell style to duplicate
|
* @param array of PHPExcel_Style_Conditional $pCellStyle Cell style to duplicate
|
||||||
* @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
|
* @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
@ -1596,7 +1604,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$pCell = strtoupper($pCell);
|
$pCell = strtoupper($pCell);
|
||||||
|
|
||||||
if ($pCell != '') {
|
if ($pCell != '') {
|
||||||
$this->_breaks[$pCell] = $pBreak;
|
if ($pBreak == PHPExcel_Worksheet::BREAK_NONE) {
|
||||||
|
if (isset($this->_breaks[$pCell])) {
|
||||||
|
unset($this->_breaks[$pCell]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->_breaks[$pCell] = $pBreak;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Exception('No cell coordinate specified.');
|
throw new PHPExcel_Exception('No cell coordinate specified.');
|
||||||
}
|
}
|
||||||
@ -2168,7 +2182,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
/**
|
/**
|
||||||
* Set comments array for the entire sheet.
|
* Set comments array for the entire sheet.
|
||||||
*
|
*
|
||||||
* @param [PHPExcel_Comment] $pValue
|
* @param array of PHPExcel_Comment
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function setComments($pValue = array())
|
public function setComments($pValue = array())
|
||||||
@ -2386,10 +2400,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* True - Return rows and columns indexed by their actual row and column IDs
|
* True - Return rows and columns indexed by their actual row and column IDs
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function rangeToArray(
|
public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
|
||||||
$pRange = 'A1', $nullValue = null, $calculateFormulas = true,
|
|
||||||
$formatData = true, $returnCellRef = false)
|
|
||||||
{
|
|
||||||
// Returnvalue
|
// Returnvalue
|
||||||
$returnValue = array();
|
$returnValue = array();
|
||||||
// Identify the range that we need to extract from the worksheet
|
// Identify the range that we need to extract from the worksheet
|
||||||
@ -2427,7 +2438,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
if ($formatData) {
|
if ($formatData) {
|
||||||
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
||||||
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
|
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
|
||||||
$returnValue[$rRef][$cRef], $style->getNumberFormat()->getFormatCode()
|
$returnValue[$rRef][$cRef],
|
||||||
|
($style->getNumberFormat()) ?
|
||||||
|
$style->getNumberFormat()->getFormatCode() :
|
||||||
|
PHPExcel_Style_NumberFormat::FORMAT_GENERAL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2458,20 +2472,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @return array
|
* @return array
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function namedRangeToArray(
|
public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
|
||||||
$pNamedRange = '', $nullValue = null, $calculateFormulas = true,
|
|
||||||
$formatData = true, $returnCellRef = false
|
|
||||||
)
|
|
||||||
{
|
|
||||||
$namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this);
|
$namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this);
|
||||||
if ($namedRange !== NULL) {
|
if ($namedRange !== NULL) {
|
||||||
$pWorkSheet = $namedRange->getWorksheet();
|
$pWorkSheet = $namedRange->getWorksheet();
|
||||||
$pCellRange = $namedRange->getRange();
|
$pCellRange = $namedRange->getRange();
|
||||||
|
|
||||||
return $pWorkSheet->rangeToArray(
|
return $pWorkSheet->rangeToArray( $pCellRange,
|
||||||
$pCellRange,
|
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
|
||||||
$nullValue, $calculateFormulas, $formatData, $returnCellRef
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.');
|
throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.');
|
||||||
@ -2488,8 +2496,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* True - Return rows and columns indexed by their actual row and column IDs
|
* True - Return rows and columns indexed by their actual row and column IDs
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)
|
public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
|
||||||
{
|
|
||||||
// Garbage collect...
|
// Garbage collect...
|
||||||
$this->garbageCollect();
|
$this->garbageCollect();
|
||||||
|
|
||||||
@ -2497,10 +2504,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$maxCol = $this->getHighestColumn();
|
$maxCol = $this->getHighestColumn();
|
||||||
$maxRow = $this->getHighestRow();
|
$maxRow = $this->getHighestRow();
|
||||||
// Return
|
// Return
|
||||||
return $this->rangeToArray(
|
return $this->rangeToArray( 'A1:'.$maxCol.$maxRow,
|
||||||
'A1:'.$maxCol.$maxRow,
|
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
|
||||||
$nullValue, $calculateFormulas, $formatData, $returnCellRef
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2509,8 +2514,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param integer $startRow The row number at which to start iterating
|
* @param integer $startRow The row number at which to start iterating
|
||||||
* @return PHPExcel_Worksheet_RowIterator
|
* @return PHPExcel_Worksheet_RowIterator
|
||||||
*/
|
*/
|
||||||
public function getRowIterator($startRow = 1)
|
public function getRowIterator($startRow = 1) {
|
||||||
{
|
|
||||||
return new PHPExcel_Worksheet_RowIterator($this,$startRow);
|
return new PHPExcel_Worksheet_RowIterator($this,$startRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2519,8 +2523,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function garbageCollect()
|
public function garbageCollect() {
|
||||||
{
|
|
||||||
// Flush cache
|
// Flush cache
|
||||||
$this->_cellCollection->getCacheData('A1');
|
$this->_cellCollection->getCacheData('A1');
|
||||||
// Build a reference table from images
|
// Build a reference table from images
|
||||||
@ -2564,8 +2567,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return string Hash code
|
* @return string Hash code
|
||||||
*/
|
*/
|
||||||
public function getHashCode()
|
public function getHashCode() {
|
||||||
{
|
|
||||||
if ($this->_dirty) {
|
if ($this->_dirty) {
|
||||||
$this->_hash = md5( $this->_title .
|
$this->_hash = md5( $this->_title .
|
||||||
$this->_autoFilter .
|
$this->_autoFilter .
|
||||||
@ -2587,8 +2589,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param bool $returnRange Return range? (see example)
|
* @param bool $returnRange Return range? (see example)
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function extractSheetTitle($pRange, $returnRange = false)
|
public static function extractSheetTitle($pRange, $returnRange = false) {
|
||||||
{
|
|
||||||
// Sheet title included?
|
// Sheet title included?
|
||||||
if (($sep = strpos($pRange, '!')) === false) {
|
if (($sep = strpos($pRange, '!')) === false) {
|
||||||
return '';
|
return '';
|
||||||
@ -2719,8 +2720,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param string $range
|
* @param string $range
|
||||||
* @return string Adjusted range value
|
* @return string Adjusted range value
|
||||||
*/
|
*/
|
||||||
public function shrinkRangeToFit($range)
|
public function shrinkRangeToFit($range) {
|
||||||
{
|
|
||||||
$maxCol = $this->getHighestColumn();
|
$maxCol = $this->getHighestColumn();
|
||||||
$maxRow = $this->getHighestRow();
|
$maxRow = $this->getHighestRow();
|
||||||
$maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
|
$maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
|
||||||
@ -2782,8 +2782,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function copy()
|
public function copy() {
|
||||||
{
|
|
||||||
$copied = clone $this;
|
$copied = clone $this;
|
||||||
|
|
||||||
return $copied;
|
return $copied;
|
||||||
@ -2792,8 +2791,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone()
|
public function __clone() {
|
||||||
{
|
|
||||||
foreach ($this as $key => $val) {
|
foreach ($this as $key => $val) {
|
||||||
if ($key == '_parent') {
|
if ($key == '_parent') {
|
||||||
continue;
|
continue;
|
||||||
|
@ -725,7 +725,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
// Date based
|
// Date based
|
||||||
if ($dynamicRuleType{0} == 'M' || $dynamicRuleType{0} == 'Q') {
|
if ($dynamicRuleType{0} == 'M' || $dynamicRuleType{0} == 'Q') {
|
||||||
// Month or Quarter
|
// Month or Quarter
|
||||||
list($periodType,$period) = sscanf($dynamicRuleType,'%[A-Z]%d');
|
sscanf($dynamicRuleType,'%[A-Z]%d', $periodType, $period);
|
||||||
if ($periodType == 'M') {
|
if ($periodType == 'M') {
|
||||||
$ruleValues = array($period);
|
$ruleValues = array($period);
|
||||||
} else {
|
} else {
|
||||||
|
@ -102,8 +102,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
|
|||||||
// Fetch sheet
|
// Fetch sheet
|
||||||
$sheet = $this->_phpExcel->getSheet($this->_sheetIndex);
|
$sheet = $this->_phpExcel->getSheet($this->_sheetIndex);
|
||||||
|
|
||||||
$saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog;
|
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
|
||||||
PHPExcel_Calculation::getInstance()->writeDebugLog = false;
|
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE);
|
||||||
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
|
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
|
||||||
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
|
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
|
|||||||
fclose($fileHandle);
|
fclose($fileHandle);
|
||||||
|
|
||||||
PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType);
|
PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType);
|
||||||
PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog;
|
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,8 +179,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog;
|
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->getWriteDebugLog();
|
||||||
PHPExcel_Calculation::getInstance()->writeDebugLog = false;
|
PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog(FALSE);
|
||||||
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
|
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
|
||||||
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
|
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
|
||||||
PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog;
|
PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog);
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
if ($objZip->close() === false) {
|
if ($objZip->close() === false) {
|
||||||
|
@ -230,6 +230,7 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
$id1 = $id2 = 0;
|
$id1 = $id2 = 0;
|
||||||
|
$this->_seriesIndex = 0;
|
||||||
$objWriter->startElement('c:plotArea');
|
$objWriter->startElement('c:plotArea');
|
||||||
|
|
||||||
$layout = $plotArea->getLayout();
|
$layout = $plotArea->getLayout();
|
||||||
@ -737,11 +738,11 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
|
|||||||
$objWriter->startElement('c:ser');
|
$objWriter->startElement('c:ser');
|
||||||
|
|
||||||
$objWriter->startElement('c:idx');
|
$objWriter->startElement('c:idx');
|
||||||
$objWriter->writeAttribute('val', $plotSeriesIdx);
|
$objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesIdx);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->startElement('c:order');
|
$objWriter->startElement('c:order');
|
||||||
$objWriter->writeAttribute('val', $plotSeriesRef);
|
$objWriter->writeAttribute('val', $this->_seriesIndex + $plotSeriesRef);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) ||
|
if (($groupType == PHPExcel_Chart_DataSeries::TYPE_PIECHART) ||
|
||||||
@ -865,6 +866,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa
|
|||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_seriesIndex += $plotSeriesIdx + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1074,12 +1074,9 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
|
|||||||
$objWriter->writeAttribute('t', $mappedType);
|
$objWriter->writeAttribute('t', $mappedType);
|
||||||
break;
|
break;
|
||||||
case 'f': // Formula
|
case 'f': // Formula
|
||||||
$calculatedValue = null;
|
$calculatedValue = ($this->getParentWriter()->getPreCalculateFormulas()) ?
|
||||||
if ($this->getParentWriter()->getPreCalculateFormulas()) {
|
$pCell->getCalculatedValue() :
|
||||||
$calculatedValue = $pCell->getCalculatedValue();
|
$cellValue;
|
||||||
} else {
|
|
||||||
$calculatedValue = $cellValue;
|
|
||||||
}
|
|
||||||
if (is_string($calculatedValue)) {
|
if (is_string($calculatedValue)) {
|
||||||
$objWriter->writeAttribute('t', 'str');
|
$objWriter->writeAttribute('t', 'str');
|
||||||
}
|
}
|
||||||
@ -1125,7 +1122,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
|
|||||||
}
|
}
|
||||||
if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
|
if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
|
||||||
if ($this->getParentWriter()->getPreCalculateFormulas()) {
|
if ($this->getParentWriter()->getPreCalculateFormulas()) {
|
||||||
$calculatedValue = $pCell->getCalculatedValue();
|
// $calculatedValue = $pCell->getCalculatedValue();
|
||||||
if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') {
|
if (!is_array($calculatedValue) && substr($calculatedValue, 0, 1) != '#') {
|
||||||
$objWriter->writeElement('v', PHPExcel_Shared_String::FormatNumber($calculatedValue));
|
$objWriter->writeElement('v', PHPExcel_Shared_String::FormatNumber($calculatedValue));
|
||||||
} else {
|
} else {
|
||||||
|
@ -120,8 +120,8 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
|
|||||||
// garbage collect
|
// garbage collect
|
||||||
$this->_phpExcel->garbageCollect();
|
$this->_phpExcel->garbageCollect();
|
||||||
|
|
||||||
$saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog;
|
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
|
||||||
PHPExcel_Calculation::getInstance()->writeDebugLog = false;
|
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE);
|
||||||
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
|
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
|
||||||
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
|
|||||||
$res = $root->save($pFilename);
|
$res = $root->save($pFilename);
|
||||||
|
|
||||||
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
|
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
|
||||||
PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog;
|
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -596,7 +596,6 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
|
|||||||
// GKPIDDSI_CATEGORY : Category
|
// GKPIDDSI_CATEGORY : Category
|
||||||
if($this->_phpExcel->getProperties()->getCategory()){
|
if($this->_phpExcel->getProperties()->getCategory()){
|
||||||
$dataProp = $this->_phpExcel->getProperties()->getCategory();
|
$dataProp = $this->_phpExcel->getProperties()->getCategory();
|
||||||
$dataProp = 'Test result file';
|
|
||||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02),
|
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02),
|
||||||
'offset' => array('pack' => 'V'),
|
'offset' => array('pack' => 'V'),
|
||||||
'type' => array('pack' => 'V', 'data' => 0x1E),
|
'type' => array('pack' => 'V', 'data' => 0x1E),
|
||||||
|
@ -152,8 +152,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
|||||||
// garbage collect
|
// garbage collect
|
||||||
$this->_phpExcel->garbageCollect();
|
$this->_phpExcel->garbageCollect();
|
||||||
|
|
||||||
$saveDebugLog = PHPExcel_Calculation::getInstance()->writeDebugLog;
|
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
|
||||||
PHPExcel_Calculation::getInstance()->writeDebugLog = false;
|
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE);
|
||||||
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
|
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
|
||||||
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
|
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
|||||||
fclose($fileHandle);
|
fclose($fileHandle);
|
||||||
|
|
||||||
PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType);
|
PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType);
|
||||||
PHPExcel_Calculation::getInstance()->writeDebugLog = $saveDebugLog;
|
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -394,7 +394,6 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
|||||||
|
|
||||||
// calculate start of <tbody>, <thead>
|
// calculate start of <tbody>, <thead>
|
||||||
$tbodyStart = $rowMin;
|
$tbodyStart = $rowMin;
|
||||||
$tbodyEnd = $rowMax;
|
|
||||||
$theadStart = $theadEnd = 0; // default: no <thead> no </thead>
|
$theadStart = $theadEnd = 0; // default: no <thead> no </thead>
|
||||||
if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
|
if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
|
||||||
$rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop();
|
$rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop();
|
||||||
@ -441,14 +440,12 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
|||||||
if ($row == $theadEnd) {
|
if ($row == $theadEnd) {
|
||||||
$html .= ' </thead>' . PHP_EOL;
|
$html .= ' </thead>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// </tbody> ?
|
|
||||||
if ($row == $tbodyEnd) {
|
|
||||||
$html .= ' </tbody>' . PHP_EOL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$html .= $this->_extendRowsForChartsAndImages($sheet, $row);
|
$html .= $this->_extendRowsForChartsAndImages($sheet, $row);
|
||||||
|
|
||||||
|
// Close table body.
|
||||||
|
$html .= ' </tbody>' . PHP_EOL;
|
||||||
|
|
||||||
// Write table footer
|
// Write table footer
|
||||||
$html .= $this->_generateTableFooter();
|
$html .= $this->_generateTableFooter();
|
||||||
|
|
||||||
@ -520,9 +517,9 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
|||||||
$chartCol = PHPExcel_Cell::columnIndexFromString($chartTL[0]);
|
$chartCol = PHPExcel_Cell::columnIndexFromString($chartTL[0]);
|
||||||
if ($chartTL[1] > $rowMax) {
|
if ($chartTL[1] > $rowMax) {
|
||||||
$rowMax = $chartTL[1];
|
$rowMax = $chartTL[1];
|
||||||
}
|
if ($chartCol > PHPExcel_Cell::columnIndexFromString($colMax)) {
|
||||||
if ($chartCol > PHPExcel_Cell::columnIndexFromString($colMax)) {
|
$colMax = $chartTL[0];
|
||||||
$colMax = $chartTL[0];
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -534,15 +531,15 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
|||||||
$imageCol = PHPExcel_Cell::columnIndexFromString($imageTL[0]);
|
$imageCol = PHPExcel_Cell::columnIndexFromString($imageTL[0]);
|
||||||
if ($imageTL[1] > $rowMax) {
|
if ($imageTL[1] > $rowMax) {
|
||||||
$rowMax = $imageTL[1];
|
$rowMax = $imageTL[1];
|
||||||
}
|
if ($imageCol > PHPExcel_Cell::columnIndexFromString($colMax)) {
|
||||||
if ($imageCol > PHPExcel_Cell::columnIndexFromString($colMax)) {
|
$colMax = $imageTL[0];
|
||||||
$colMax = $imageTL[0];
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$html = '';
|
$html = '';
|
||||||
$colMax++;
|
$colMax++;
|
||||||
while ($row <= $rowMax) {
|
while ($row < $rowMax) {
|
||||||
$html .= '<tr>';
|
$html .= '<tr>';
|
||||||
for ($col = 'A'; $col != $colMax; ++$col) {
|
for ($col = 'A'; $col != $colMax; ++$col) {
|
||||||
$html .= '<td>';
|
$html .= '<td>';
|
||||||
@ -966,7 +963,10 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
|||||||
*/
|
*/
|
||||||
private function _createCSSStyleBorder(PHPExcel_Style_Border $pStyle) {
|
private function _createCSSStyleBorder(PHPExcel_Style_Border $pStyle) {
|
||||||
// Create CSS
|
// Create CSS
|
||||||
$css = $this->_mapBorderStyle($pStyle->getBorderStyle()) . ' #' . $pStyle->getColor()->getRGB();
|
// $css = $this->_mapBorderStyle($pStyle->getBorderStyle()) . ' #' . $pStyle->getColor()->getRGB();
|
||||||
|
// Create CSS - add !important to non-none border styles for merged cells
|
||||||
|
$borderStyle = $this->_mapBorderStyle($pStyle->getBorderStyle());
|
||||||
|
$css = $borderStyle . ' #' . $pStyle->getColor()->getRGB() . (($borderStyle == 'none') ? '' : ' !important');
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $css;
|
return $css;
|
||||||
@ -1016,6 +1016,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
|||||||
|
|
||||||
// Construct HTML
|
// Construct HTML
|
||||||
$html = '';
|
$html = '';
|
||||||
|
$html .= $this->_setMargins($pSheet);
|
||||||
|
|
||||||
if (!$this->_useInlineCss) {
|
if (!$this->_useInlineCss) {
|
||||||
$gridlines = $pSheet->getShowGridLines() ? ' gridlines' : '';
|
$gridlines = $pSheet->getShowGridLines() ? ' gridlines' : '';
|
||||||
@ -1228,6 +1229,11 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
|||||||
$spans = $this->_isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum];
|
$spans = $this->_isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum];
|
||||||
$rowSpan = $spans['rowspan'];
|
$rowSpan = $spans['rowspan'];
|
||||||
$colSpan = $spans['colspan'];
|
$colSpan = $spans['colspan'];
|
||||||
|
|
||||||
|
// Also apply style from last cell in merge to fix borders -
|
||||||
|
// relies on !important for non-none border declarations in _createCSSStyleBorder
|
||||||
|
$endCellCoord = PHPExcel_Cell::stringFromColumnIndex($colNum + $colSpan - 1) . ($pRow + $rowSpan);
|
||||||
|
$cssClass .= ' style' . $pSheet->getCell($endCellCoord)->getXfIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
@ -1495,4 +1501,27 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
|
|||||||
$this->_spansAreCalculated = true;
|
$this->_spansAreCalculated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function _setMargins(PHPExcel_Worksheet $pSheet) {
|
||||||
|
$htmlPage = '@page { ';
|
||||||
|
$htmlBody = 'body { ';
|
||||||
|
|
||||||
|
$left = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getLeft()) . 'in; ';
|
||||||
|
$htmlPage .= 'left-margin: ' . $left;
|
||||||
|
$htmlBody .= 'left-margin: ' . $left;
|
||||||
|
$right = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getRight()) . 'in; ';
|
||||||
|
$htmlPage .= 'right-margin: ' . $right;
|
||||||
|
$htmlBody .= 'right-margin: ' . $right;
|
||||||
|
$top = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getTop()) . 'in; ';
|
||||||
|
$htmlPage .= 'top-margin: ' . $top;
|
||||||
|
$htmlBody .= 'top-margin: ' . $top;
|
||||||
|
$bottom = PHPExcel_Shared_String::FormatNumber($pSheet->getPageMargins()->getBottom()) . 'in; ';
|
||||||
|
$htmlPage .= 'bottom-margin: ' . $bottom;
|
||||||
|
$htmlBody .= 'bottom-margin: ' . $bottom;
|
||||||
|
|
||||||
|
$htmlPage .= "}\n";
|
||||||
|
$htmlBody .= "}\n";
|
||||||
|
|
||||||
|
return "<style>\n" . $htmlPage . $htmlBody . "</style>\n";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
126
Examples/06largescale-with-cellcaching-sqlite.php
Normal file
126
Examples/06largescale-with-cellcaching-sqlite.php
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPExcel
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 - 2012 PHPExcel
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* @category PHPExcel
|
||||||
|
* @package PHPExcel
|
||||||
|
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Error reporting */
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
|
|
||||||
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||||
|
|
||||||
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
/** Include PHPExcel */
|
||||||
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_sqlite;
|
||||||
|
PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
|
||||||
|
echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
|
||||||
|
|
||||||
|
|
||||||
|
// Create new PHPExcel object
|
||||||
|
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||||
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
|
// Set document properties
|
||||||
|
echo date('H:i:s') , " Set properties" , EOL;
|
||||||
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
|
->setSubject("Office 2007 XLSX Test Document")
|
||||||
|
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||||
|
->setKeywords("office 2007 openxml php")
|
||||||
|
->setCategory("Test result file");
|
||||||
|
|
||||||
|
|
||||||
|
// Create a first sheet
|
||||||
|
echo date('H:i:s') , " Add data" , EOL;
|
||||||
|
$objPHPExcel->setActiveSheetIndex(0);
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('D1', "Fax");
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
||||||
|
|
||||||
|
|
||||||
|
// Hide "Phone" and "fax" column
|
||||||
|
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL;
|
||||||
|
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
|
||||||
|
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
|
// Set outline levels
|
||||||
|
echo date('H:i:s') , " Set outline levels" , EOL;
|
||||||
|
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
|
||||||
|
->setVisible(false)
|
||||||
|
->setCollapsed(true);
|
||||||
|
|
||||||
|
// Freeze panes
|
||||||
|
echo date('H:i:s') , " Freeze panes" , EOL;
|
||||||
|
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||||
|
|
||||||
|
|
||||||
|
// Rows to repeat at top
|
||||||
|
echo date('H:i:s') , " Rows to repeat at top" , EOL;
|
||||||
|
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
|
||||||
|
|
||||||
|
|
||||||
|
// Add data
|
||||||
|
for ($i = 2; $i <= 5000; $i++) {
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i")
|
||||||
|
->setCellValue('B' . $i, "LName $i")
|
||||||
|
->setCellValue('C' . $i, "PhoneNo $i")
|
||||||
|
->setCellValue('D' . $i, "FaxNo $i")
|
||||||
|
->setCellValue('E' . $i, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
$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
|
||||||
|
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 'File has been created in ' , getcwd() , EOL;
|
126
Examples/06largescale-with-cellcaching-sqlite3.php
Normal file
126
Examples/06largescale-with-cellcaching-sqlite3.php
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPExcel
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 - 2012 PHPExcel
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* @category PHPExcel
|
||||||
|
* @package PHPExcel
|
||||||
|
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Error reporting */
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
|
|
||||||
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||||
|
|
||||||
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
/** Include PHPExcel */
|
||||||
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_sqlite3;
|
||||||
|
PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
|
||||||
|
echo date('H:i:s') , " Enable Cell Caching using " , $cacheMethod , " method" , EOL;
|
||||||
|
|
||||||
|
|
||||||
|
// Create new PHPExcel object
|
||||||
|
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||||
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
|
// Set document properties
|
||||||
|
echo date('H:i:s') , " Set properties" , EOL;
|
||||||
|
$objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
|
||||||
|
->setLastModifiedBy("Maarten Balliauw")
|
||||||
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
|
->setSubject("Office 2007 XLSX Test Document")
|
||||||
|
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||||
|
->setKeywords("office 2007 openxml php")
|
||||||
|
->setCategory("Test result file");
|
||||||
|
|
||||||
|
|
||||||
|
// Create a first sheet
|
||||||
|
echo date('H:i:s') , " Add data" , EOL;
|
||||||
|
$objPHPExcel->setActiveSheetIndex(0);
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', "Firstname");
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('B1', "Lastname");
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('C1', "Phone");
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('D1', "Fax");
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('E1', "Is Client ?");
|
||||||
|
|
||||||
|
|
||||||
|
// Hide "Phone" and "fax" column
|
||||||
|
echo date('H:i:s') , " Hide 'Phone' and 'fax' columns" , EOL;
|
||||||
|
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->setVisible(false);
|
||||||
|
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
|
||||||
|
|
||||||
|
|
||||||
|
// Set outline levels
|
||||||
|
echo date('H:i:s') , " Set outline levels" , EOL;
|
||||||
|
$objPHPExcel->getActiveSheet()->getColumnDimension('E')->setOutlineLevel(1)
|
||||||
|
->setVisible(false)
|
||||||
|
->setCollapsed(true);
|
||||||
|
|
||||||
|
// Freeze panes
|
||||||
|
echo date('H:i:s') , " Freeze panes" , EOL;
|
||||||
|
$objPHPExcel->getActiveSheet()->freezePane('A2');
|
||||||
|
|
||||||
|
|
||||||
|
// Rows to repeat at top
|
||||||
|
echo date('H:i:s') , " Rows to repeat at top" , EOL;
|
||||||
|
$objPHPExcel->getActiveSheet()->getPageSetup()->setRowsToRepeatAtTopByStartAndEnd(1, 1);
|
||||||
|
|
||||||
|
|
||||||
|
// Add data
|
||||||
|
for ($i = 2; $i <= 5000; $i++) {
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('A' . $i, "FName $i")
|
||||||
|
->setCellValue('B' . $i, "LName $i")
|
||||||
|
->setCellValue('C' . $i, "PhoneNo $i")
|
||||||
|
->setCellValue('D' . $i, "FaxNo $i")
|
||||||
|
->setCellValue('E' . $i, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
$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
|
||||||
|
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 'File has been created in ' , getcwd() , EOL;
|
107
Examples/12cellProtection.php
Normal file
107
Examples/12cellProtection.php
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPExcel
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 - 2012 PHPExcel
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* @category PHPExcel
|
||||||
|
* @package PHPExcel
|
||||||
|
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Error reporting */
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
|
|
||||||
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||||
|
|
||||||
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
/** Include PHPExcel */
|
||||||
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
|
// Create new PHPExcel object
|
||||||
|
echo date('H:i:s') , " Create new PHPExcel object" , EOL;
|
||||||
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
|
// Set document properties
|
||||||
|
echo date('H:i:s') , " Set document properties" , EOL;
|
||||||
|
$objPHPExcel->getProperties()->setCreator("Mark Baker")
|
||||||
|
->setLastModifiedBy("Mark Baker")
|
||||||
|
->setTitle("Office 2007 XLSX Test Document")
|
||||||
|
->setSubject("Office 2007 XLSX Test Document")
|
||||||
|
->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
|
||||||
|
->setKeywords("office 2007 openxml php")
|
||||||
|
->setCategory("Test result file");
|
||||||
|
|
||||||
|
|
||||||
|
// Add some data
|
||||||
|
echo date('H:i:s') , " Add some data" , EOL;
|
||||||
|
$objPHPExcel->setActiveSheetIndex(0);
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Crouching');
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('B1', 'Tiger');
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('A2', 'Hidden');
|
||||||
|
$objPHPExcel->getActiveSheet()->setCellValue('B2', 'Dragon');
|
||||||
|
|
||||||
|
// Rename worksheet
|
||||||
|
echo date('H:i:s') , " Rename worksheet" , EOL;
|
||||||
|
$objPHPExcel->getActiveSheet()->setTitle('Simple');
|
||||||
|
|
||||||
|
|
||||||
|
// Set document security
|
||||||
|
echo date('H:i:s') , " Set cell protection" , EOL;
|
||||||
|
|
||||||
|
|
||||||
|
// Set sheet security
|
||||||
|
echo date('H:i:s') , " Set sheet security" , EOL;
|
||||||
|
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);
|
||||||
|
$objPHPExcel->getActiveSheet()
|
||||||
|
->getStyle('A2:B2')
|
||||||
|
->getProtection()->setLocked(
|
||||||
|
PHPExcel_Style_Protection::PROTECTION_UNPROTECTED
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
$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
|
||||||
|
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 'File has been created in ' , getcwd() , EOL;
|
@ -36,11 +36,9 @@ date_default_timezone_set('Europe/London');
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Include path **/
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
|
|
||||||
|
|
||||||
/** PHPExcel */
|
/** PHPExcel */
|
||||||
include 'PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||||
|
@ -36,11 +36,9 @@ date_default_timezone_set('Europe/London');
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Include path **/
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
|
|
||||||
|
|
||||||
/** PHPExcel */
|
/** PHPExcel */
|
||||||
include 'PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||||
|
@ -36,11 +36,9 @@ date_default_timezone_set('Europe/London');
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Include path **/
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
|
|
||||||
|
|
||||||
/** PHPExcel */
|
/** PHPExcel */
|
||||||
include 'PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||||
|
@ -36,11 +36,9 @@ date_default_timezone_set('Europe/London');
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Include path **/
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
|
|
||||||
|
|
||||||
/** PHPExcel */
|
/** PHPExcel */
|
||||||
include 'PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||||
|
@ -36,11 +36,9 @@ date_default_timezone_set('Europe/London');
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Include path **/
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
|
|
||||||
|
|
||||||
/** PHPExcel */
|
/** PHPExcel */
|
||||||
include 'PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||||
|
203
Examples/33chartcreate-composite-chart.php
Normal file
203
Examples/33chartcreate-composite-chart.php
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/** Error reporting */
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', TRUE);
|
||||||
|
ini_set('display_startup_errors', TRUE);
|
||||||
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
||||||
|
|
||||||
|
date_default_timezone_set('Europe/London');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHPExcel
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 - 2012 PHPExcel
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* @category PHPExcel
|
||||||
|
* @package PHPExcel
|
||||||
|
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
* @version ##VERSION##, ##DATE##
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** PHPExcel */
|
||||||
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
|
$objPHPExcel = new PHPExcel();
|
||||||
|
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||||
|
$objWorksheet->fromArray(
|
||||||
|
array(
|
||||||
|
array('', 'Rainfall (mm)', 'Temperature (°F)', 'Humidity (%)'),
|
||||||
|
array('Jan', 78, 52, 61),
|
||||||
|
array('Feb', 64, 54, 62),
|
||||||
|
array('Mar', 62, 57, 63),
|
||||||
|
array('Apr', 21, 62, 59),
|
||||||
|
array('May', 11, 75, 60),
|
||||||
|
array('Jun', 1, 75, 57),
|
||||||
|
array('Jul', 1, 79, 56),
|
||||||
|
array('Aug', 1, 79, 59),
|
||||||
|
array('Sep', 10, 75, 60),
|
||||||
|
array('Oct', 40, 68, 63),
|
||||||
|
array('Nov', 69, 62, 64),
|
||||||
|
array('Dec', 89, 57, 66),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Set the Labels for each data series we want to plot
|
||||||
|
// Datatype
|
||||||
|
// Cell reference for data
|
||||||
|
// Format Code
|
||||||
|
// Number of datapoints in series
|
||||||
|
// Data values
|
||||||
|
// Data Marker
|
||||||
|
$dataseriesLabels1 = array(
|
||||||
|
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // Temperature
|
||||||
|
);
|
||||||
|
$dataseriesLabels2 = array(
|
||||||
|
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // Rainfall
|
||||||
|
);
|
||||||
|
$dataseriesLabels3 = array(
|
||||||
|
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // Humidity
|
||||||
|
);
|
||||||
|
|
||||||
|
// Set the X-Axis Labels
|
||||||
|
// Datatype
|
||||||
|
// Cell reference for data
|
||||||
|
// Format Code
|
||||||
|
// Number of datapoints in series
|
||||||
|
// Data values
|
||||||
|
// Data Marker
|
||||||
|
$xAxisTickValues = array(
|
||||||
|
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$2:$A$13', NULL, 12), // Jan to Dec
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Set the Data values for each data series we want to plot
|
||||||
|
// Datatype
|
||||||
|
// Cell reference for data
|
||||||
|
// Format Code
|
||||||
|
// Number of datapoints in series
|
||||||
|
// Data values
|
||||||
|
// Data Marker
|
||||||
|
$dataSeriesValues1 = array(
|
||||||
|
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$B$2:$B$13', NULL, 12),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Build the dataseries
|
||||||
|
$series1 = new PHPExcel_Chart_DataSeries(
|
||||||
|
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
|
||||||
|
PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping
|
||||||
|
range(0, count($dataSeriesValues1)-1), // plotOrder
|
||||||
|
$dataseriesLabels1, // plotLabel
|
||||||
|
$xAxisTickValues, // plotCategory
|
||||||
|
$dataSeriesValues1 // plotValues
|
||||||
|
);
|
||||||
|
// Set additional dataseries parameters
|
||||||
|
// Make it a vertical column rather than a horizontal bar graph
|
||||||
|
$series1->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
|
||||||
|
|
||||||
|
|
||||||
|
// Set the Data values for each data series we want to plot
|
||||||
|
// Datatype
|
||||||
|
// Cell reference for data
|
||||||
|
// Format Code
|
||||||
|
// Number of datapoints in series
|
||||||
|
// Data values
|
||||||
|
// Data Marker
|
||||||
|
$dataSeriesValues2 = array(
|
||||||
|
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', NULL, 12),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Build the dataseries
|
||||||
|
$series2 = new PHPExcel_Chart_DataSeries(
|
||||||
|
PHPExcel_Chart_DataSeries::TYPE_LINECHART, // plotType
|
||||||
|
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
|
||||||
|
range(0, count($dataSeriesValues2)-1), // plotOrder
|
||||||
|
$dataseriesLabels2, // plotLabel
|
||||||
|
NULL, // plotCategory
|
||||||
|
$dataSeriesValues2 // plotValues
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Set the Data values for each data series we want to plot
|
||||||
|
// Datatype
|
||||||
|
// Cell reference for data
|
||||||
|
// Format Code
|
||||||
|
// Number of datapoints in series
|
||||||
|
// Data values
|
||||||
|
// Data Marker
|
||||||
|
$dataSeriesValues3 = array(
|
||||||
|
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', NULL, 12),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Build the dataseries
|
||||||
|
$series3 = new PHPExcel_Chart_DataSeries(
|
||||||
|
PHPExcel_Chart_DataSeries::TYPE_AREACHART, // plotType
|
||||||
|
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
|
||||||
|
range(0, count($dataSeriesValues2)-1), // plotOrder
|
||||||
|
$dataseriesLabels3, // plotLabel
|
||||||
|
NULL, // plotCategory
|
||||||
|
$dataSeriesValues3 // plotValues
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Set the series in the plot area
|
||||||
|
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series1, $series2, $series3));
|
||||||
|
// Set the chart legend
|
||||||
|
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
|
||||||
|
|
||||||
|
$title = new PHPExcel_Chart_Title('Average Weather Chart for Crete');
|
||||||
|
|
||||||
|
|
||||||
|
// Create the chart
|
||||||
|
$chart = new PHPExcel_Chart(
|
||||||
|
'chart1', // name
|
||||||
|
$title, // title
|
||||||
|
$legend, // legend
|
||||||
|
$plotarea, // plotArea
|
||||||
|
true, // plotVisibleOnly
|
||||||
|
0, // displayBlanksAs
|
||||||
|
NULL, // xAxisLabel
|
||||||
|
NULL // yAxisLabel
|
||||||
|
);
|
||||||
|
|
||||||
|
// Set the position where the chart should appear in the worksheet
|
||||||
|
$chart->setTopLeftPosition('F2');
|
||||||
|
$chart->setBottomRightPosition('O16');
|
||||||
|
|
||||||
|
// Add the chart to the worksheet
|
||||||
|
$objWorksheet->addChart($chart);
|
||||||
|
|
||||||
|
|
||||||
|
// Save Excel 2007 file
|
||||||
|
echo date('H:i:s') , " Write to Excel2007 format" , EOL;
|
||||||
|
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
|
||||||
|
$objWriter->setIncludeCharts(TRUE);
|
||||||
|
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
|
||||||
|
echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , 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 'File has been created in ' , getcwd() , EOL;
|
@ -36,11 +36,9 @@ date_default_timezone_set('Europe/London');
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Include path **/
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
|
|
||||||
|
|
||||||
/** PHPExcel */
|
/** PHPExcel */
|
||||||
include 'PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||||
|
@ -36,11 +36,9 @@ date_default_timezone_set('Europe/London');
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Include path **/
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
|
|
||||||
|
|
||||||
/** PHPExcel */
|
/** PHPExcel */
|
||||||
include 'PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||||
|
@ -36,11 +36,9 @@ date_default_timezone_set('Europe/London');
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Include path **/
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
|
|
||||||
|
|
||||||
/** PHPExcel */
|
/** PHPExcel */
|
||||||
include 'PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||||
|
@ -36,11 +36,9 @@ date_default_timezone_set('Europe/London');
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Include path **/
|
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
|
|
||||||
|
|
||||||
/** PHPExcel */
|
/** PHPExcel */
|
||||||
include 'PHPExcel.php';
|
require_once '../Classes/PHPExcel.php';
|
||||||
|
|
||||||
|
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
$objWorksheet = $objPHPExcel->getActiveSheet();
|
$objWorksheet = $objPHPExcel->getActiveSheet();
|
||||||
|
@ -52,6 +52,7 @@ $aTests = array(
|
|||||||
, '10autofilter-selection-2.php'
|
, '10autofilter-selection-2.php'
|
||||||
, '11documentsecurity.php'
|
, '11documentsecurity.php'
|
||||||
, '11documentsecurity-xls.php'
|
, '11documentsecurity-xls.php'
|
||||||
|
, '12cellProtection.php'
|
||||||
, '13calculation.php'
|
, '13calculation.php'
|
||||||
, '14excel5.php'
|
, '14excel5.php'
|
||||||
, '15datavalidation.php'
|
, '15datavalidation.php'
|
||||||
@ -82,6 +83,8 @@ $aTests = array(
|
|||||||
, '33chartcreate-line.php'
|
, '33chartcreate-line.php'
|
||||||
, '33chartcreate-pie.php'
|
, '33chartcreate-pie.php'
|
||||||
, '33chartcreate-radar.php'
|
, '33chartcreate-radar.php'
|
||||||
|
, '33chartcreate-multiple-charts.php'
|
||||||
|
, '33chartcreate-composite.php'
|
||||||
, '34chartupdate.php'
|
, '34chartupdate.php'
|
||||||
, '35chartrender.php'
|
, '35chartrender.php'
|
||||||
, '36chartreadwriteHTML.php'
|
, '36chartreadwriteHTML.php'
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
**************************************************************************************
|
**************************************************************************************
|
||||||
|
|
||||||
|
|
||||||
Fixed in develop branch:
|
Fixed in develop branch for release v1.7.9:
|
||||||
- Feature: (MBaker) Include charts option for HTML Writer
|
- Feature: (MBaker) Include charts option for HTML Writer
|
||||||
- Feature: (MBaker) Added composer file
|
- Feature: (MBaker) Added composer file
|
||||||
- Bugfix: (Asker) Work item 18777 - Error in PHPEXCEL/Calculation.php script on line 2976 (stack pop check)
|
- Bugfix: (Asker) Work item 18777 - Error in PHPEXCEL/Calculation.php script on line 2976 (stack pop check)
|
||||||
@ -41,6 +41,9 @@ Fixed in develop branch:
|
|||||||
- General: (cfhay) Work item 18958 - Memory and Speed improvements in PHPExcel_Reader_Excel5
|
- General: (cfhay) Work item 18958 - Memory and Speed improvements in PHPExcel_Reader_Excel5
|
||||||
- General: (MBaker) Work item GH-78 - Modify listWorksheetNames() and listWorksheetInfo to use XMLReader with streamed XML rather than SimpleXML
|
- General: (MBaker) Work item GH-78 - Modify listWorksheetNames() and listWorksheetInfo to use XMLReader with streamed XML rather than SimpleXML
|
||||||
- General: (dbonsch) Restructuring of PHPExcel Exceptions
|
- General: (dbonsch) Restructuring of PHPExcel Exceptions
|
||||||
|
- General: (MBaker) Work items 16926 and 15145 - Refactor Calculation Engine from singleton to a Multiton
|
||||||
|
Ensures that calculation cache is maintained independently for different workbooks
|
||||||
|
- General: (MBaker) Modify cell's getCalculatedValue() method to return the content of RichText objects rather than the RichText object itself
|
||||||
- Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows
|
- Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows
|
||||||
- Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges
|
- Bugfix: (alexgann) Work item GH-63 - Fix to cellExists for non-existent namedRanges
|
||||||
- Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't
|
- Bugfix: (MBaker) Work item 18844 - cache_in_memory_gzip "eats" last worksheet line, cache_in_memory doesn't
|
||||||
@ -50,6 +53,12 @@ Fixed in develop branch:
|
|||||||
- Bugfix: (MBaker) Work item GH-104 - echo statements in HTML.php
|
- Bugfix: (MBaker) Work item GH-104 - echo statements in HTML.php
|
||||||
- Feature: (Progi1984) Work item GH-8/CP11704 : Conditional formatting in Excel 5 Writer
|
- Feature: (Progi1984) Work item GH-8/CP11704 : Conditional formatting in Excel 5 Writer
|
||||||
- Bugfix: (MBaker) Work item GH-113 - canRead() Error for GoogleDocs ODS files: in ODS files from Google Docs there is no mimetype file
|
- Bugfix: (MBaker) Work item GH-113 - canRead() Error for GoogleDocs ODS files: in ODS files from Google Docs there is no mimetype file
|
||||||
|
- Bugfix: (MBaker) Work item GH-80 - "Sheet index is out of bounds." Exception
|
||||||
|
- Bugfix: (ccorliss) Work item GH-105 - Fixed number format fatal error
|
||||||
|
- Bugfix: (MBaker) - Add DROP TABLE in destructor for SQLite and SQLite3 cache controllers
|
||||||
|
- Bugfix: (alexgann) Work item GH-154 - Fix merged-cell borders on HTML/PDF output
|
||||||
|
- Bugfix: (Shanto) Work item GH-161 - Fix: Hyperlinks break when removing rows
|
||||||
|
- Bugfix: (neclimdul) Work item GH-166 - Fix Extra Table Row From Images and Charts
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@ -57,7 +66,7 @@ BREAKING CHANGE! As part of the planned changes for handling array formulae in
|
|||||||
workbooks, there are some changes that will affect the PHPExcel_Cell object
|
workbooks, there are some changes that will affect the PHPExcel_Cell object
|
||||||
methods.
|
methods.
|
||||||
|
|
||||||
The following methods are now deprecated, and will be removed in version 1.7.9:
|
The following methods are now deprecated, and will be removed in or after version 1.8.0:
|
||||||
getCalculatedValue() The getValue() method will return calculated
|
getCalculatedValue() The getValue() method will return calculated
|
||||||
values for cells containing formulae instead.
|
values for cells containing formulae instead.
|
||||||
setCalculatedValue() The cell value will always contain the result of a
|
setCalculatedValue() The cell value will always contain the result of a
|
||||||
@ -67,7 +76,7 @@ The following methods are now deprecated, and will be removed in version 1.7.9:
|
|||||||
getFormulaAttributes() This will be replaced by the getArrayFormulaRange()
|
getFormulaAttributes() This will be replaced by the getArrayFormulaRange()
|
||||||
method.
|
method.
|
||||||
|
|
||||||
The following methods will be added in version 1.7.9
|
The following methods will be added in version 1.8.0
|
||||||
getFormula() Use to retrieve a cell formula, will return the cell
|
getFormula() Use to retrieve a cell formula, will return the cell
|
||||||
value if the cell doesn't contain a formula, or
|
value if the cell doesn't contain a formula, or
|
||||||
is not part of an array formula range.
|
is not part of an array formula range.
|
||||||
@ -82,7 +91,7 @@ The following methods will be added in version 1.7.9
|
|||||||
or is part of an array formula range or not.
|
or is part of an array formula range or not.
|
||||||
getArrayFormulaRange() Use to retrieve an array formula range.
|
getArrayFormulaRange() Use to retrieve an array formula range.
|
||||||
|
|
||||||
The following methods will be changed in version 1.7.9
|
The following methods will be changed in version 1.8.0
|
||||||
setValue() The logic behind this will be modified to store
|
setValue() The logic behind this will be modified to store
|
||||||
formula values in the new cell property structure,
|
formula values in the new cell property structure,
|
||||||
but it will still perform the same function.
|
but it will still perform the same function.
|
||||||
|
@ -35,7 +35,16 @@ class AdvancedValueBinderTest extends PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testCurrency($value, $valueBinded, $format, $thousandsSeparator, $decimalSeparator, $currencyCode)
|
public function testCurrency($value, $valueBinded, $format, $thousandsSeparator, $decimalSeparator, $currencyCode)
|
||||||
{
|
{
|
||||||
$sheet = $this->getMock('PHPExcel_Worksheet', array('getStyle', 'getNumberFormat', 'setFormatCode'));
|
$sheet = $this->getMock(
|
||||||
|
'PHPExcel_Worksheet',
|
||||||
|
array('getStyle', 'getNumberFormat', 'setFormatCode','getCellCacheController')
|
||||||
|
);
|
||||||
|
$cache = $this->getMockBuilder('PHPExcel_CachedObjectStorage_Memory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$cache->expects($this->any())
|
||||||
|
->method('getParent')
|
||||||
|
->will($this->returnValue($sheet));
|
||||||
|
|
||||||
$sheet->expects($this->once())
|
$sheet->expects($this->once())
|
||||||
->method('getStyle')
|
->method('getStyle')
|
||||||
@ -47,12 +56,15 @@ class AdvancedValueBinderTest extends PHPUnit_Framework_TestCase
|
|||||||
->method('setFormatCode')
|
->method('setFormatCode')
|
||||||
->with($format)
|
->with($format)
|
||||||
->will($this->returnSelf());
|
->will($this->returnSelf());
|
||||||
|
$sheet->expects($this->any())
|
||||||
|
->method('getCellCacheController')
|
||||||
|
->will($this->returnValue($cache));
|
||||||
|
|
||||||
PHPExcel_Shared_String::setCurrencyCode($currencyCode);
|
PHPExcel_Shared_String::setCurrencyCode($currencyCode);
|
||||||
PHPExcel_Shared_String::setDecimalSeparator($decimalSeparator);
|
PHPExcel_Shared_String::setDecimalSeparator($decimalSeparator);
|
||||||
PHPExcel_Shared_String::setThousandsSeparator($thousandsSeparator);
|
PHPExcel_Shared_String::setThousandsSeparator($thousandsSeparator);
|
||||||
|
|
||||||
$cell = new PHPExcel_Cell('A', 1, null, PHPExcel_Cell_DataType::TYPE_STRING, $sheet);
|
$cell = new PHPExcel_Cell(NULL, PHPExcel_Cell_DataType::TYPE_STRING, $sheet);
|
||||||
|
|
||||||
$binder = new PHPExcel_Cell_AdvancedValueBinder();
|
$binder = new PHPExcel_Cell_AdvancedValueBinder();
|
||||||
$binder->bindValue($cell, $value);
|
$binder->bindValue($cell, $value);
|
||||||
|
58
unitTests/Classes/PHPExcel/ReferenceHelperTest.php
Normal file
58
unitTests/Classes/PHPExcel/ReferenceHelperTest.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class ReferenceHelperTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
|
||||||
|
}
|
||||||
|
require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testColumnSort()
|
||||||
|
{
|
||||||
|
$columnBase = $columnExpectedResult = array(
|
||||||
|
'A','B','Z',
|
||||||
|
'AA','AB','AZ',
|
||||||
|
'BA','BB','BZ',
|
||||||
|
'ZA','ZB','ZZ',
|
||||||
|
'AAA','AAB','AAZ',
|
||||||
|
'ABA','ABB','ABZ',
|
||||||
|
'AZA','AZB','AZZ',
|
||||||
|
'BAA','BAB','BAZ',
|
||||||
|
'BBA','BBB','BBZ',
|
||||||
|
'BZA','BZB','BZZ'
|
||||||
|
);
|
||||||
|
shuffle($columnBase);
|
||||||
|
usort($columnBase, array('PHPExcel_ReferenceHelper','columnSort'));
|
||||||
|
foreach($columnBase as $key => $value) {
|
||||||
|
$this->assertEquals($columnExpectedResult[$key], $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testColumnReverseSort()
|
||||||
|
{
|
||||||
|
$columnBase = $columnExpectedResult = array(
|
||||||
|
'A','B','Z',
|
||||||
|
'AA','AB','AZ',
|
||||||
|
'BA','BB','BZ',
|
||||||
|
'ZA','ZB','ZZ',
|
||||||
|
'AAA','AAB','AAZ',
|
||||||
|
'ABA','ABB','ABZ',
|
||||||
|
'AZA','AZB','AZZ',
|
||||||
|
'BAA','BAB','BAZ',
|
||||||
|
'BBA','BBB','BBZ',
|
||||||
|
'BZA','BZB','BZZ'
|
||||||
|
);
|
||||||
|
shuffle($columnBase);
|
||||||
|
$columnExpectedResult = array_reverse($columnExpectedResult);
|
||||||
|
usort($columnBase, array('PHPExcel_ReferenceHelper','columnReverseSort'));
|
||||||
|
foreach($columnBase as $key => $value) {
|
||||||
|
$this->assertEquals($columnExpectedResult[$key], $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,6 +18,12 @@ class AutoFilterTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->_mockWorksheetObject = $this->getMockBuilder('PHPExcel_Worksheet')
|
$this->_mockWorksheetObject = $this->getMockBuilder('PHPExcel_Worksheet')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
$this->_mockCacheController = $this->getMockBuilder('PHPExcel_CachedObjectStorage_Memory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$this->_mockWorksheetObject->expects($this->any())
|
||||||
|
->method('getCellCacheController')
|
||||||
|
->will($this->returnValue($this->_mockCacheController));
|
||||||
|
|
||||||
$this->_testAutoFilterObject = new PHPExcel_Worksheet_AutoFilter(
|
$this->_testAutoFilterObject = new PHPExcel_Worksheet_AutoFilter(
|
||||||
$this->_testInitialRange,
|
$this->_testInitialRange,
|
||||||
|
@ -35,11 +35,11 @@
|
|||||||
"22 August 98", 36029
|
"22 August 98", 36029
|
||||||
"1st March 2007", 39142 // MS Excel will fail with a #VALUE return, but PHPExcel can parse this date
|
"1st March 2007", 39142 // MS Excel will fail with a #VALUE return, but PHPExcel can parse this date
|
||||||
"The 1st day of March 2007", "#VALUE!"
|
"The 1st day of March 2007", "#VALUE!"
|
||||||
"1 Jan", 40909
|
"1 Jan", 41275
|
||||||
"31/12", 41274
|
"31/12", 41639
|
||||||
"12/31", 11658 // Excel reads as 1st December 1931, not 31st December in current year
|
"12/31", 11658 // Excel reads as 1st December 1931, not 31st December in current year
|
||||||
"5-JUL", 41095
|
"5-JUL", 41460
|
||||||
"5 Jul", 41095
|
"5 Jul", 41460
|
||||||
"12/2008", 39783
|
"12/2008", 39783
|
||||||
"10/32", 11963
|
"10/32", 11963
|
||||||
11, "#VALUE!"
|
11, "#VALUE!"
|
||||||
|
Loading…
Reference in New Issue
Block a user