<?php
+
+/** PHPExcel root directory */
+if (!defined('PHPEXCEL_ROOT')) {
+ define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
+ require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
+}
+
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2014 PHPExcel
+ * Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
-
-
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
- require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
-}
-
-
-/**
- * PHPExcel
- *
- * @category PHPExcel
- * @package PHPExcel
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
- */
class PHPExcel
{
/**
*
* @var string
*/
- private $_uniqueID;
+ private $uniqueID;
/**
* Document properties
*
* @var PHPExcel_DocumentProperties
*/
- private $_properties;
+ private $properties;
/**
* Document security
*
* @var PHPExcel_DocumentSecurity
*/
- private $_security;
+ private $security;
/**
* Collection of Worksheet objects
*
* @var PHPExcel_Worksheet[]
*/
- private $_workSheetCollection = array();
+ private $workSheetCollection = array();
/**
- * Calculation Engine
- *
- * @var PHPExcel_Calculation
- */
- private $_calculationEngine = NULL;
+ * Calculation Engine
+ *
+ * @var PHPExcel_Calculation
+ */
+ private $calculationEngine;
/**
* Active sheet index
*
- * @var int
+ * @var integer
*/
- private $_activeSheetIndex = 0;
+ private $activeSheetIndex = 0;
/**
* Named ranges
*
* @var PHPExcel_NamedRange[]
*/
- private $_namedRanges = array();
+ private $namedRanges = array();
/**
* CellXf supervisor
*
* @var PHPExcel_Style
*/
- private $_cellXfSupervisor;
+ private $cellXfSupervisor;
/**
* CellXf collection
*
* @var PHPExcel_Style[]
*/
- private $_cellXfCollection = array();
+ private $cellXfCollection = array();
/**
* CellStyleXf collection
*
* @var PHPExcel_Style[]
*/
- private $_cellStyleXfCollection = array();
-
- /**
- * _hasMacros : this workbook have macros ?
- *
- * @var bool
- */
- private $_hasMacros = FALSE;
-
- /**
- * _macrosCode : all macros code (the vbaProject.bin file, this include form, code, etc.), NULL if no macro
- *
- * @var binary
- */
- private $_macrosCode=NULL;
- /**
- * _macrosCertificate : if macros are signed, contains vbaProjectSignature.bin file, NULL if not signed
- *
- * @var binary
- */
- private $_macrosCertificate=NULL;
-
- /**
- * _ribbonXMLData : NULL if workbook is'nt Excel 2007 or not contain a customized UI
- *
- * @var NULL|string
- */
- private $_ribbonXMLData=NULL;
-
- /**
- * _ribbonBinObjects : NULL if workbook is'nt Excel 2007 or not contain embedded objects (picture(s)) for Ribbon Elements
- * ignored if $_ribbonXMLData is null
- *
- * @var NULL|array
- */
- private $_ribbonBinObjects=NULL;
-
- /**
- * The workbook has macros ?
- *
- * @return true if workbook has macros, false if not
- */
- public function hasMacros(){
- return $this->_hasMacros;
- }
-
- /**
- * Define if a workbook has macros
- *
- * @param true|false
- */
- public function setHasMacros($hasMacros=false){
- $this->_hasMacros=(bool)$hasMacros;
- }
-
- /**
- * Set the macros code
- *
- * @param binary string|null
- */
- public function setMacrosCode($MacrosCode){
- $this->_macrosCode=$MacrosCode;
- $this->setHasMacros(!is_null($MacrosCode));
- }
-
- /**
- * Return the macros code
- *
- * @return binary|null
- */
- public function getMacrosCode(){
- return $this->_macrosCode;
- }
-
- /**
- * Set the macros certificate
- *
- * @param binary|null
- */
- public function setMacrosCertificate($Certificate=NULL){
- $this->_macrosCertificate=$Certificate;
- }
-
- /**
- * Is the project signed ?
- *
- * @return true|false
- */
- public function hasMacrosCertificate(){
- return !is_null($this->_macrosCertificate);
- }
-
- /**
- * Return the macros certificate
- *
- * @return binary|null
- */
- public function getMacrosCertificate(){
- return $this->_macrosCertificate;
- }
-
- /**
- * Remove all macros, certificate from spreadsheet
- *
- * @param none
- * @return void
- */
- public function discardMacros(){
- $this->_hasMacros=false;
- $this->_macrosCode=NULL;
- $this->_macrosCertificate=NULL;
- }
-
- /**
- * set ribbon XML data
- *
- */
- public function setRibbonXMLData($Target=NULL, $XMLData=NULL){
- if(!is_null($Target) && !is_null($XMLData)){
- $this->_ribbonXMLData=array('target'=>$Target, 'data'=>$XMLData);
- }else{
- $this->_ribbonXMLData=NULL;
- }
- }
-
- /**
- * retrieve ribbon XML Data
- *
- * return string|null|array
- */
- public function getRibbonXMLData($What='all'){//we need some constants here...
- $ReturnData=NULL;
- $What=strtolower($What);
- switch($What){
- case 'all':
- $ReturnData=$this->_ribbonXMLData;
- break;
- case 'target':
- case 'data':
- if(is_array($this->_ribbonXMLData) && array_key_exists($What,$this->_ribbonXMLData)){
- $ReturnData=$this->_ribbonXMLData[$What];
- }//else $ReturnData stay at null
- break;
- }//default: $ReturnData at null
- return $ReturnData;
- }
-
- /**
- * store binaries ribbon objects (pictures)
- *
- */
- public function setRibbonBinObjects($BinObjectsNames=NULL, $BinObjectsData=NULL){
- if(!is_null($BinObjectsNames) && !is_null($BinObjectsData)){
- $this->_ribbonBinObjects=array('names'=>$BinObjectsNames, 'data'=>$BinObjectsData);
- }else{
- $this->_ribbonBinObjects=NULL;
- }
- }
- /**
- * return the extension of a filename. Internal use for a array_map callback (php<5.3 don't like lambda function)
- *
- */
- private function _getExtensionOnly($ThePath){
- return pathinfo($ThePath, PATHINFO_EXTENSION);
- }
-
- /**
- * retrieve Binaries Ribbon Objects
- *
- */
- public function getRibbonBinObjects($What='all'){
- $ReturnData=NULL;
- $What=strtolower($What);
- switch($What){
- case 'all':
- return $this->_ribbonBinObjects;
- break;
- case 'names':
- case 'data':
- if(is_array($this->_ribbonBinObjects) && array_key_exists($What, $this->_ribbonBinObjects)){
- $ReturnData=$this->_ribbonBinObjects[$What];
- }
- break;
- case 'types':
- if(is_array($this->_ribbonBinObjects) && array_key_exists('data', $this->_ribbonBinObjects) && is_array($this->_ribbonBinObjects['data'])){
- $tmpTypes=array_keys($this->_ribbonBinObjects['data']);
- $ReturnData=array_unique(array_map(array($this,'_getExtensionOnly'), $tmpTypes));
- }else
- $ReturnData=array();//the caller want an array... not null if empty
- break;
- }
- return $ReturnData;
- }
-
- /**
- * This workbook have a custom UI ?
- *
- * @return true|false
- */
- public function hasRibbon(){
- return !is_null($this->_ribbonXMLData);
- }
-
- /**
- * This workbook have additionnal object for the ribbon ?
- *
- * @return true|false
- */
- public function hasRibbonBinObjects(){
- return !is_null($this->_ribbonBinObjects);
- }
-
- /**
+ private $cellStyleXfCollection = array();
+
+ /**
+ * hasMacros : this workbook have macros ?
+ *
+ * @var bool
+ */
+ private $hasMacros = false;
+
+ /**
+ * macrosCode : all macros code (the vbaProject.bin file, this include form, code, etc.), null if no macro
+ *
+ * @var binary
+ */
+ private $macrosCode;
+ /**
+ * macrosCertificate : if macros are signed, contains vbaProjectSignature.bin file, null if not signed
+ *
+ * @var binary
+ */
+ private $macrosCertificate;
+
+ /**
+ * ribbonXMLData : null if workbook is'nt Excel 2007 or not contain a customized UI
+ *
+ * @var null|string
+ */
+ private $ribbonXMLData;
+
+ /**
+ * ribbonBinObjects : null if workbook is'nt Excel 2007 or not contain embedded objects (picture(s)) for Ribbon Elements
+ * ignored if $ribbonXMLData is null
+ *
+ * @var null|array
+ */
+ private $ribbonBinObjects;
+
+ /**
+ * The workbook has macros ?
+ *
+ * @return true if workbook has macros, false if not
+ */
+ public function hasMacros()
+ {
+ return $this->hasMacros;
+ }
+
+ /**
+ * Define if a workbook has macros
+ *
+ * @param boolean $hasMacros true|false
+ */
+ public function setHasMacros($hasMacros = false)
+ {
+ $this->hasMacros = (bool) $hasMacros;
+ }
+
+ /**
+ * Set the macros code
+ *
+ * @param string $MacrosCode string|null
+ */
+ public function setMacrosCode($MacrosCode = null)
+ {
+ $this->macrosCode=$MacrosCode;
+ $this->setHasMacros(!is_null($MacrosCode));
+ }
+
+ /**
+ * Return the macros code
+ *
+ * @return string|null
+ */
+ public function getMacrosCode()
+ {
+ return $this->macrosCode;
+ }
+
+ /**
+ * Set the macros certificate
+ *
+ * @param string|null $Certificate
+ */
+ public function setMacrosCertificate($Certificate = null)
+ {
+ $this->macrosCertificate=$Certificate;
+ }
+
+ /**
+ * Is the project signed ?
+ *
+ * @return boolean true|false
+ */
+ public function hasMacrosCertificate()
+ {
+ return !is_null($this->macrosCertificate);
+ }
+
+ /**
+ * Return the macros certificate
+ *
+ * @return string|null
+ */
+ public function getMacrosCertificate()
+ {
+ return $this->macrosCertificate;
+ }
+
+ /**
+ * Remove all macros, certificate from spreadsheet
+ *
+ */
+ public function discardMacros()
+ {
+ $this->hasMacros=false;
+ $this->macrosCode=null;
+ $this->macrosCertificate=null;
+ }
+
+ /**
+ * set ribbon XML data
+ *
+ */
+ public function setRibbonXMLData($Target = null, $XMLData = null)
+ {
+ if (!is_null($Target) && !is_null($XMLData)) {
+ $this->ribbonXMLData = array('target' => $Target, 'data' => $XMLData);
+ } else {
+ $this->ribbonXMLData = null;
+ }
+ }
+
+ /**
+ * retrieve ribbon XML Data
+ *
+ * return string|null|array
+ */
+ public function getRibbonXMLData($What = 'all') //we need some constants here...
+ {
+ $ReturnData = null;
+ $What = strtolower($What);
+ switch ($What){
+ case 'all':
+ $ReturnData = $this->ribbonXMLData;
+ break;
+ case 'target':
+ case 'data':
+ if (is_array($this->ribbonXMLData) && array_key_exists($What, $this->ribbonXMLData)) {
+ $ReturnData = $this->ribbonXMLData[$What];
+ }
+ break;
+ }
+
+ return $ReturnData;
+ }
+
+ /**
+ * store binaries ribbon objects (pictures)
+ *
+ */
+ public function setRibbonBinObjects($BinObjectsNames = null, $BinObjectsData = null)
+ {
+ if (!is_null($BinObjectsNames) && !is_null($BinObjectsData)) {
+ $this->ribbonBinObjects = array('names' => $BinObjectsNames, 'data' => $BinObjectsData);
+ } else {
+ $this->ribbonBinObjects = null;
+ }
+ }
+ /**
+ * return the extension of a filename. Internal use for a array_map callback (php<5.3 don't like lambda function)
+ *
+ */
+ private function getExtensionOnly($ThePath)
+ {
+ return pathinfo($ThePath, PATHINFO_EXTENSION);
+ }
+
+ /**
+ * retrieve Binaries Ribbon Objects
+ *
+ */
+ public function getRibbonBinObjects($What = 'all')
+ {
+ $ReturnData = null;
+ $What = strtolower($What);
+ switch($What) {
+ case 'all':
+ return $this->ribbonBinObjects;
+ break;
+ case 'names':
+ case 'data':
+ if (is_array($this->ribbonBinObjects) && array_key_exists($What, $this->ribbonBinObjects)) {
+ $ReturnData=$this->ribbonBinObjects[$What];
+ }
+ break;
+ case 'types':
+ if (is_array($this->ribbonBinObjects) &&
+ array_key_exists('data', $this->ribbonBinObjects) && is_array($this->ribbonBinObjects['data'])) {
+ $tmpTypes=array_keys($this->ribbonBinObjects['data']);
+ $ReturnData = array_unique(array_map(array($this, 'getExtensionOnly'), $tmpTypes));
+ } else {
+ $ReturnData=array(); // the caller want an array... not null if empty
+ }
+ break;
+ }
+ return $ReturnData;
+ }
+
+ /**
+ * This workbook have a custom UI ?
+ *
+ * @return true|false
+ */
+ public function hasRibbon()
+ {
+ return !is_null($this->ribbonXMLData);
+ }
+
+ /**
+ * This workbook have additionnal object for the ribbon ?
+ *
+ * @return true|false
+ */
+ public function hasRibbonBinObjects()
+ {
+ return !is_null($this->ribbonBinObjects);
+ }
+
+ /**
* Check if a sheet with a specified code name already exists
*
* @param string $pSheetCodeName Name of the worksheet to check
*/
public function sheetCodeNameExists($pSheetCodeName)
{
- return ($this->getSheetByCodeName($pSheetCodeName) !== NULL);
+ return ($this->getSheetByCodeName($pSheetCodeName) !== null);
}
- /**
- * Get sheet by code name. Warning : sheet don't have always a code name !
- *
- * @param string $pName Sheet name
- * @return PHPExcel_Worksheet
- */
- public function getSheetByCodeName($pName = '')
- {
- $worksheetCount = count($this->_workSheetCollection);
- for ($i = 0; $i < $worksheetCount; ++$i) {
- if ($this->_workSheetCollection[$i]->getCodeName() == $pName) {
- return $this->_workSheetCollection[$i];
- }
- }
-
- return null;
- }
-
- /**
- * Create a new PHPExcel with one Worksheet
- */
- public function __construct()
- {
- $this->_uniqueID = uniqid();
- $this->_calculationEngine = PHPExcel_Calculation::getInstance($this);
-
- // Initialise worksheet collection and add one worksheet
- $this->_workSheetCollection = array();
- $this->_workSheetCollection[] = new PHPExcel_Worksheet($this);
- $this->_activeSheetIndex = 0;
+ /**
+ * Get sheet by code name. Warning : sheet don't have always a code name !
+ *
+ * @param string $pName Sheet name
+ * @return PHPExcel_Worksheet
+ */
+ public function getSheetByCodeName($pName = '')
+ {
+ $worksheetCount = count($this->workSheetCollection);
+ for ($i = 0; $i < $worksheetCount; ++$i) {
+ if ($this->workSheetCollection[$i]->getCodeName() == $pName) {
+ return $this->workSheetCollection[$i];
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Create a new PHPExcel with one Worksheet
+ */
+ public function __construct()
+ {
+ $this->uniqueID = uniqid();
+ $this->calculationEngine = PHPExcel_Calculation::getInstance($this);
+
+ // Initialise worksheet collection and add one worksheet
+ $this->workSheetCollection = array();
+ $this->workSheetCollection[] = new PHPExcel_Worksheet($this);
+ $this->activeSheetIndex = 0;
// Create document properties
- $this->_properties = new PHPExcel_DocumentProperties();
+ $this->properties = new PHPExcel_DocumentProperties();
// Create document security
- $this->_security = new PHPExcel_DocumentSecurity();
+ $this->security = new PHPExcel_DocumentSecurity();
// Set named ranges
- $this->_namedRanges = array();
+ $this->namedRanges = array();
// Create the cellXf supervisor
- $this->_cellXfSupervisor = new PHPExcel_Style(true);
- $this->_cellXfSupervisor->bindParent($this);
+ $this->cellXfSupervisor = new PHPExcel_Style(true);
+ $this->cellXfSupervisor->bindParent($this);
// Create the default style
$this->addCellXf(new PHPExcel_Style);
* Code to execute when this worksheet is unset()
*
*/
- public function __destruct() {
+ public function __destruct()
+ {
PHPExcel_Calculation::unsetInstance($this);
$this->disconnectWorksheets();
- } // function __destruct()
+ }
/**
* Disconnect all worksheets from this PHPExcel workbook object,
*/
public function disconnectWorksheets()
{
- $worksheet = NULL;
- foreach($this->_workSheetCollection as $k => &$worksheet) {
+ $worksheet = null;
+ foreach ($this->workSheetCollection as $k => &$worksheet) {
$worksheet->disconnectCells();
- $this->_workSheetCollection[$k] = null;
+ $this->workSheetCollection[$k] = null;
}
unset($worksheet);
- $this->_workSheetCollection = array();
+ $this->workSheetCollection = array();
}
- /**
- * Return the calculation engine for this worksheet
- *
- * @return PHPExcel_Calculation
- */
- public function getCalculationEngine()
- {
- return $this->_calculationEngine;
- } // function getCellCacheController()
+ /**
+ * Return the calculation engine for this worksheet
+ *
+ * @return PHPExcel_Calculation
+ */
+ public function getCalculationEngine()
+ {
+ return $this->calculationEngine;
+ } // function getCellCacheController()
/**
* Get properties
*/
public function getProperties()
{
- return $this->_properties;
+ return $this->properties;
}
/**
*/
public function setProperties(PHPExcel_DocumentProperties $pValue)
{
- $this->_properties = $pValue;
+ $this->properties = $pValue;
}
/**
*/
public function getSecurity()
{
- return $this->_security;
+ return $this->security;
}
/**
*/
public function setSecurity(PHPExcel_DocumentSecurity $pValue)
{
- $this->_security = $pValue;
+ $this->security = $pValue;
}
/**
* Get active sheet
*
* @return PHPExcel_Worksheet
+ *
+ * @throws PHPExcel_Exception
*/
public function getActiveSheet()
{
- return $this->_workSheetCollection[$this->_activeSheetIndex];
+ return $this->getSheet($this->activeSheetIndex);
}
/**
* @return PHPExcel_Worksheet
* @throws PHPExcel_Exception
*/
- public function createSheet($iSheetIndex = NULL)
+ public function createSheet($iSheetIndex = null)
{
$newSheet = new PHPExcel_Worksheet($this);
$this->addSheet($newSheet, $iSheetIndex);
*/
public function sheetNameExists($pSheetName)
{
- return ($this->getSheetByName($pSheetName) !== NULL);
+ return ($this->getSheetByName($pSheetName) !== null);
}
/**
* @return PHPExcel_Worksheet
* @throws PHPExcel_Exception
*/
- public function addSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = NULL)
+ public function addSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null)
{
if ($this->sheetNameExists($pSheet->getTitle())) {
throw new PHPExcel_Exception(
- "Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first."
+ "Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename this worksheet first."
);
}
- if($iSheetIndex === NULL) {
- if ($this->_activeSheetIndex < 0) {
- $this->_activeSheetIndex = 0;
+ if ($iSheetIndex === null) {
+ if ($this->activeSheetIndex < 0) {
+ $this->activeSheetIndex = 0;
}
- $this->_workSheetCollection[] = $pSheet;
+ $this->workSheetCollection[] = $pSheet;
} else {
// Insert the sheet at the requested index
array_splice(
- $this->_workSheetCollection,
+ $this->workSheetCollection,
$iSheetIndex,
0,
array($pSheet)
- );
+ );
// Adjust active sheet index if necessary
- if ($this->_activeSheetIndex >= $iSheetIndex) {
- ++$this->_activeSheetIndex;
+ if ($this->activeSheetIndex >= $iSheetIndex) {
+ ++$this->activeSheetIndex;
}
}
public function removeSheetByIndex($pIndex = 0)
{
- $numSheets = count($this->_workSheetCollection);
-
+ $numSheets = count($this->workSheetCollection);
if ($pIndex > $numSheets - 1) {
throw new PHPExcel_Exception(
- "You tried to remove a sheet by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}."
+ "You tried to remove a sheet by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}."
);
} else {
- array_splice($this->_workSheetCollection, $pIndex, 1);
+ array_splice($this->workSheetCollection, $pIndex, 1);
}
// Adjust active sheet index if necessary
- if (($this->_activeSheetIndex >= $pIndex) &&
- ($pIndex > count($this->_workSheetCollection) - 1)) {
- --$this->_activeSheetIndex;
+ if (($this->activeSheetIndex >= $pIndex) &&
+ ($pIndex > count($this->workSheetCollection) - 1)) {
+ --$this->activeSheetIndex;
}
}
*/
public function getSheet($pIndex = 0)
{
-
- $numSheets = count($this->_workSheetCollection);
-
- if ($pIndex > $numSheets - 1) {
+ if (!isset($this->workSheetCollection[$pIndex])) {
+ $numSheets = $this->getSheetCount();
throw new PHPExcel_Exception(
- "Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}."
- );
- } else {
- return $this->_workSheetCollection[$pIndex];
+ "Your requested sheet index: {$pIndex} is out of bounds. The actual number of sheets is {$numSheets}."
+ );
}
+
+ return $this->workSheetCollection[$pIndex];
}
/**
*/
public function getAllSheets()
{
- return $this->_workSheetCollection;
+ return $this->workSheetCollection;
}
/**
*/
public function getSheetByName($pName = '')
{
- $worksheetCount = count($this->_workSheetCollection);
+ $worksheetCount = count($this->workSheetCollection);
for ($i = 0; $i < $worksheetCount; ++$i) {
- if ($this->_workSheetCollection[$i]->getTitle() === $pName) {
- return $this->_workSheetCollection[$i];
+ if ($this->workSheetCollection[$i]->getTitle() === $pName) {
+ return $this->workSheetCollection[$i];
}
}
- return NULL;
+ return null;
}
/**
*/
public function getIndex(PHPExcel_Worksheet $pSheet)
{
- foreach ($this->_workSheetCollection as $key => $value) {
+ foreach ($this->workSheetCollection as $key => $value) {
if ($value->getHashCode() == $pSheet->getHashCode()) {
return $key;
}
{
$oldIndex = $this->getIndex($this->getSheetByName($sheetName));
$pSheet = array_splice(
- $this->_workSheetCollection,
+ $this->workSheetCollection,
$oldIndex,
1
);
array_splice(
- $this->_workSheetCollection,
+ $this->workSheetCollection,
$newIndex,
0,
$pSheet
*/
public function getSheetCount()
{
- return count($this->_workSheetCollection);
+ return count($this->workSheetCollection);
}
/**
*/
public function getActiveSheetIndex()
{
- return $this->_activeSheetIndex;
+ return $this->activeSheetIndex;
}
/**
*/
public function setActiveSheetIndex($pIndex = 0)
{
- $numSheets = count($this->_workSheetCollection);
+ $numSheets = count($this->workSheetCollection);
if ($pIndex > $numSheets - 1) {
throw new PHPExcel_Exception(
- "You tried to set a sheet active by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}."
+ "You tried to set a sheet active by the out of bounds index: {$pIndex}. The actual number of sheets is {$numSheets}."
);
} else {
- $this->_activeSheetIndex = $pIndex;
+ $this->activeSheetIndex = $pIndex;
}
return $this->getActiveSheet();
}
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet
*/
- public function addExternalSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null) {
+ public function addExternalSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null)
+ {
if ($this->sheetNameExists($pSheet->getTitle())) {
throw new PHPExcel_Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename the external sheet first.");
}
// count how many cellXfs there are in this workbook currently, we will need this below
- $countCellXfs = count($this->_cellXfCollection);
+ $countCellXfs = count($this->cellXfCollection);
// copy all the shared cellXfs from the external workbook and append them to the current
foreach ($pSheet->getParent()->getCellXfCollection() as $cellXf) {
// update the cellXfs
foreach ($pSheet->getCellCollection(false) as $cellID) {
$cell = $pSheet->getCell($cellID);
- $cell->setXfIndex( $cell->getXfIndex() + $countCellXfs );
+ $cell->setXfIndex($cell->getXfIndex() + $countCellXfs);
}
return $this->addSheet($pSheet, $iSheetIndex);
*
* @return PHPExcel_NamedRange[]
*/
- public function getNamedRanges() {
- return $this->_namedRanges;
+ public function getNamedRanges()
+ {
+ return $this->namedRanges;
}
/**
* @param PHPExcel_NamedRange $namedRange
* @return PHPExcel
*/
- public function addNamedRange(PHPExcel_NamedRange $namedRange) {
+ public function addNamedRange(PHPExcel_NamedRange $namedRange)
+ {
if ($namedRange->getScope() == null) {
// global scope
- $this->_namedRanges[$namedRange->getName()] = $namedRange;
+ $this->namedRanges[$namedRange->getName()] = $namedRange;
} else {
// local scope
- $this->_namedRanges[$namedRange->getScope()->getTitle().'!'.$namedRange->getName()] = $namedRange;
+ $this->namedRanges[$namedRange->getScope()->getTitle().'!'.$namedRange->getName()] = $namedRange;
}
return true;
}
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
* @return PHPExcel_NamedRange|null
*/
- public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
+ public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null)
+ {
$returnValue = null;
- if ($namedRange != '' && ($namedRange !== NULL)) {
+ if ($namedRange != '' && ($namedRange !== null)) {
// first look for global defined name
- if (isset($this->_namedRanges[$namedRange])) {
- $returnValue = $this->_namedRanges[$namedRange];
+ if (isset($this->namedRanges[$namedRange])) {
+ $returnValue = $this->namedRanges[$namedRange];
}
// then look for local defined name (has priority over global defined name if both names exist)
- if (($pSheet !== NULL) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
- $returnValue = $this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange];
+ if (($pSheet !== null) && isset($this->namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
+ $returnValue = $this->namedRanges[$pSheet->getTitle() . '!' . $namedRange];
}
}
* @param PHPExcel_Worksheet|null $pSheet Scope: use null for global scope.
* @return PHPExcel
*/
- public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
- if ($pSheet === NULL) {
- if (isset($this->_namedRanges[$namedRange])) {
- unset($this->_namedRanges[$namedRange]);
+ public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null)
+ {
+ if ($pSheet === null) {
+ if (isset($this->namedRanges[$namedRange])) {
+ unset($this->namedRanges[$namedRange]);
}
} else {
- if (isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
- unset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange]);
+ if (isset($this->namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
+ unset($this->namedRanges[$pSheet->getTitle() . '!' . $namedRange]);
}
}
return $this;
*
* @return PHPExcel_WorksheetIterator
*/
- public function getWorksheetIterator() {
+ public function getWorksheetIterator()
+ {
return new PHPExcel_WorksheetIterator($this);
}
*
* @return PHPExcel
*/
- public function copy() {
+ public function copy()
+ {
$copied = clone $this;
- $worksheetCount = count($this->_workSheetCollection);
+ $worksheetCount = count($this->workSheetCollection);
for ($i = 0; $i < $worksheetCount; ++$i) {
- $this->_workSheetCollection[$i] = $this->_workSheetCollection[$i]->copy();
- $this->_workSheetCollection[$i]->rebindParent($this);
+ $this->workSheetCollection[$i] = $this->workSheetCollection[$i]->copy();
+ $this->workSheetCollection[$i]->rebindParent($this);
}
return $copied;
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
- public function __clone() {
- foreach($this as $key => $val) {
+ public function __clone()
+ {
+ foreach ($this as $key => $val) {
if (is_object($val) || (is_array($val))) {
$this->{$key} = unserialize(serialize($val));
}
*/
public function getCellXfCollection()
{
- return $this->_cellXfCollection;
+ return $this->cellXfCollection;
}
/**
*/
public function getCellXfByIndex($pIndex = 0)
{
- return $this->_cellXfCollection[$pIndex];
+ return $this->cellXfCollection[$pIndex];
}
/**
*/
public function getCellXfByHashCode($pValue = '')
{
- foreach ($this->_cellXfCollection as $cellXf) {
+ foreach ($this->cellXfCollection as $cellXf) {
if ($cellXf->getHashCode() == $pValue) {
return $cellXf;
}
*/
public function cellXfExists($pCellStyle = null)
{
- return in_array($pCellStyle, $this->_cellXfCollection, true);
+ return in_array($pCellStyle, $this->cellXfCollection, true);
}
/**
*/
public function getDefaultStyle()
{
- if (isset($this->_cellXfCollection[0])) {
- return $this->_cellXfCollection[0];
+ if (isset($this->cellXfCollection[0])) {
+ return $this->cellXfCollection[0];
}
throw new PHPExcel_Exception('No default style found for this workbook');
}
*/
public function addCellXf(PHPExcel_Style $style)
{
- $this->_cellXfCollection[] = $style;
- $style->setIndex(count($this->_cellXfCollection) - 1);
+ $this->cellXfCollection[] = $style;
+ $style->setIndex(count($this->cellXfCollection) - 1);
}
/**
* Remove cellXf by index. It is ensured that all cells get their xf index updated.
*
- * @param int $pIndex Index to cellXf
+ * @param integer $pIndex Index to cellXf
* @throws PHPExcel_Exception
*/
public function removeCellXfByIndex($pIndex = 0)
{
- if ($pIndex > count($this->_cellXfCollection) - 1) {
+ if ($pIndex > count($this->cellXfCollection) - 1) {
throw new PHPExcel_Exception("CellXf index is out of bounds.");
} else {
// first remove the cellXf
- array_splice($this->_cellXfCollection, $pIndex, 1);
+ array_splice($this->cellXfCollection, $pIndex, 1);
// then update cellXf indexes for cells
- foreach ($this->_workSheetCollection as $worksheet) {
+ foreach ($this->workSheetCollection as $worksheet) {
foreach ($worksheet->getCellCollection(false) as $cellID) {
$cell = $worksheet->getCell($cellID);
$xfIndex = $cell->getXfIndex();
- if ($xfIndex > $pIndex ) {
+ if ($xfIndex > $pIndex) {
// decrease xf index by 1
$cell->setXfIndex($xfIndex - 1);
- } else if ($xfIndex == $pIndex) {
+ } elseif ($xfIndex == $pIndex) {
// set to default xf index 0
$cell->setXfIndex(0);
}
*/
public function getCellXfSupervisor()
{
- return $this->_cellXfSupervisor;
+ return $this->cellXfSupervisor;
}
/**
*/
public function getCellStyleXfCollection()
{
- return $this->_cellStyleXfCollection;
+ return $this->cellStyleXfCollection;
}
/**
* Get cellStyleXf by index
*
- * @param int $pIndex
+ * @param integer $pIndex Index to cellXf
* @return PHPExcel_Style
*/
public function getCellStyleXfByIndex($pIndex = 0)
{
- return $this->_cellStyleXfCollection[$pIndex];
+ return $this->cellStyleXfCollection[$pIndex];
}
/**
*/
public function getCellStyleXfByHashCode($pValue = '')
{
- foreach ($this->_cellXfStyleCollection as $cellStyleXf) {
+ foreach ($this->cellStyleXfCollection as $cellStyleXf) {
if ($cellStyleXf->getHashCode() == $pValue) {
return $cellStyleXf;
}
*/
public function addCellStyleXf(PHPExcel_Style $pStyle)
{
- $this->_cellStyleXfCollection[] = $pStyle;
- $pStyle->setIndex(count($this->_cellStyleXfCollection) - 1);
+ $this->cellStyleXfCollection[] = $pStyle;
+ $pStyle->setIndex(count($this->cellStyleXfCollection) - 1);
}
/**
* Remove cellStyleXf by index
*
- * @param int $pIndex
+ * @param integer $pIndex Index to cellXf
* @throws PHPExcel_Exception
*/
public function removeCellStyleXfByIndex($pIndex = 0)
{
- if ($pIndex > count($this->_cellStyleXfCollection) - 1) {
+ if ($pIndex > count($this->cellStyleXfCollection) - 1) {
throw new PHPExcel_Exception("CellStyleXf index is out of bounds.");
} else {
- array_splice($this->_cellStyleXfCollection, $pIndex, 1);
+ array_splice($this->cellStyleXfCollection, $pIndex, 1);
}
}
{
// how many references are there to each cellXf ?
$countReferencesCellXf = array();
- foreach ($this->_cellXfCollection as $index => $cellXf) {
+ foreach ($this->cellXfCollection as $index => $cellXf) {
$countReferencesCellXf[$index] = 0;
}
foreach ($this->getWorksheetIterator() as $sheet) {
-
// from cells
foreach ($sheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID);
// remove cellXfs without references and create mapping so we can update xfIndex
// for all cells and columns
$countNeededCellXfs = 0;
- foreach ($this->_cellXfCollection as $index => $cellXf) {
+ foreach ($this->cellXfCollection as $index => $cellXf) {
if ($countReferencesCellXf[$index] > 0 || $index == 0) { // we must never remove the first cellXf
++$countNeededCellXfs;
} else {
- unset($this->_cellXfCollection[$index]);
+ unset($this->cellXfCollection[$index]);
}
$map[$index] = $countNeededCellXfs - 1;
}
- $this->_cellXfCollection = array_values($this->_cellXfCollection);
+ $this->cellXfCollection = array_values($this->cellXfCollection);
// update the index for all cellXfs
- foreach ($this->_cellXfCollection as $i => $cellXf) {
+ foreach ($this->cellXfCollection as $i => $cellXf) {
$cellXf->setIndex($i);
}
// make sure there is always at least one cellXf (there should be)
- if (empty($this->_cellXfCollection)) {
- $this->_cellXfCollection[] = new PHPExcel_Style();
+ if (empty($this->cellXfCollection)) {
+ $this->cellXfCollection[] = new PHPExcel_Style();
}
// update the xfIndex for all cells, row dimensions, column dimensions
foreach ($this->getWorksheetIterator() as $sheet) {
-
// for all cells
foreach ($sheet->getCellCollection(false) as $cellID) {
$cell = $sheet->getCell($cellID);
- $cell->setXfIndex( $map[$cell->getXfIndex()] );
+ $cell->setXfIndex($map[$cell->getXfIndex()]);
}
// for all row dimensions
foreach ($sheet->getRowDimensions() as $rowDimension) {
if ($rowDimension->getXfIndex() !== null) {
- $rowDimension->setXfIndex( $map[$rowDimension->getXfIndex()] );
+ $rowDimension->setXfIndex($map[$rowDimension->getXfIndex()]);
}
}
// for all column dimensions
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
$sheet->garbageCollect();
}
}
*
* @return string
*/
- public function getID() {
- return $this->_uniqueID;
+ public function getID()
+ {
+ return $this->uniqueID;
}
-
}
<?php
+
+PHPExcel_Autoloader::register();
+// As we always try to run the autoloader before anything else, we can use it to do a few
+// simple checks and initialisations
+//PHPExcel_Shared_ZipStreamWrapper::register();
+// check mbstring.func_overload
+if (ini_get('mbstring.func_overload') & 2) {
+ throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
+}
+PHPExcel_Shared_String::buildCharacterSets();
+
/**
* PHPExcel
*
- * Copyright (c) 2006 - 2014 PHPExcel
+ * Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* @category PHPExcel
* @package PHPExcel
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
-
-PHPExcel_Autoloader::Register();
-// As we always try to run the autoloader before anything else, we can use it to do a few
-// simple checks and initialisations
-//PHPExcel_Shared_ZipStreamWrapper::register();
-// check mbstring.func_overload
-if (ini_get('mbstring.func_overload') & 2) {
- throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
-}
-PHPExcel_Shared_String::buildCharacterSets();
-
-
-/**
- * PHPExcel_Autoloader
- *
- * @category PHPExcel
- * @package PHPExcel
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
- */
class PHPExcel_Autoloader
{
/**
* Register the Autoloader with SPL
*
*/
- public static function Register() {
+ public static function register()
+ {
if (function_exists('__autoload')) {
- // Register any existing autoloader function with SPL, so we don't get any clashes
+ // Register any existing autoloader function with SPL, so we don't get any clashes
spl_autoload_register('__autoload');
}
- // Register ourselves with SPL
- return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
- } // function Register()
-
+ // Register ourselves with SPL
+ if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
+ return spl_autoload_register(array('PHPExcel_Autoloader', 'load'), true, true);
+ } else {
+ return spl_autoload_register(array('PHPExcel_Autoloader', 'load'));
+ }
+ }
/**
* Autoload a class identified by name
*
* @param string $pClassName Name of the object to load
*/
- public static function Load($pClassName){
- if ((class_exists($pClassName,FALSE)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
- // Either already loaded, or not a PHPExcel class request
- return FALSE;
+ public static function load($pClassName)
+ {
+ if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
+ // Either already loaded, or not a PHPExcel class request
+ return false;
}
$pClassFilePath = PHPEXCEL_ROOT .
- str_replace('_',DIRECTORY_SEPARATOR,$pClassName) .
- '.php';
+ str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
+ '.php';
- if ((file_exists($pClassFilePath) === FALSE) || (is_readable($pClassFilePath) === FALSE)) {
- // Can't load
- return FALSE;
+ if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
+ // Can't load
+ return false;
}
require($pClassFilePath);
- } // function Load()
-
+ }
}
<?php
+
/**
- * PHPExcel
+ * PHPExcel_CachedObjectStorage_APC
*
- * Copyright (c) 2006 - 2014 PHPExcel
+ * Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
-
-
-/**
- * PHPExcel_CachedObjectStorage_APC
- *
- * @category PHPExcel
- * @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
- */
-class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
-
+class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
+{
/**
* Prefix used to uniquely identify cache data for this worksheet
*
* @access private
* @var string
*/
- private $_cachePrefix = null;
+ private $cachePrefix = null;
/**
* Cache timeout
* @access private
* @var integer
*/
- private $_cacheTime = 600;
-
+ private $cacheTime = 600;
/**
* Store cell data in cache for the current cell object if it's "dirty",
* @return void
* @throws PHPExcel_Exception
*/
- protected function _storeData() {
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
- $this->_currentObject->detach();
-
- if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
+ protected function storeData()
+ {
+ if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
+ $this->currentObject->detach();
+
+ if (!apc_store(
+ $this->cachePrefix . $this->currentObjectID . '.cache',
+ serialize($this->currentObject),
+ $this->cacheTime
+ )) {
$this->__destruct();
- throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in APC');
+ throw new PHPExcel_Exception('Failed to store cell ' . $this->currentObjectID . ' in APC');
}
- $this->_currentCellIsDirty = false;
+ $this->currentCellIsDirty = false;
}
- $this->_currentObjectID = $this->_currentObject = null;
- } // function _storeData()
-
+ $this->currentObjectID = $this->currentObject = null;
+ }
/**
* Add or Update a cell in cache identified by coordinate address
* @access public
* @param string $pCoord Coordinate address of the cell to update
* @param PHPExcel_Cell $cell Cell to update
- * @return void
+ * @return PHPExcel_Cell
* @throws PHPExcel_Exception
*/
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
- $this->_storeData();
+ public function addCacheData($pCoord, PHPExcel_Cell $cell)
+ {
+ if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
+ $this->storeData();
}
- $this->_cellCache[$pCoord] = true;
+ $this->cellCache[$pCoord] = true;
- $this->_currentObjectID = $pCoord;
- $this->_currentObject = $cell;
- $this->_currentCellIsDirty = true;
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = $cell;
+ $this->currentCellIsDirty = true;
return $cell;
- } // function addCacheData()
-
+ }
/**
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
*
* @access public
* @param string $pCoord Coordinate address of the cell to check
- * @return void
+ * @throws PHPExcel_Exception
* @return boolean
*/
- public function isDataSet($pCoord) {
+ public function isDataSet($pCoord)
+ {
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
- if ($this->_currentObjectID == $pCoord) {
+ if ($this->currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in apc
- $success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
- if ($success === FALSE) {
+ $success = apc_fetch($this->cachePrefix.$pCoord.'.cache');
+ if ($success === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
return true;
}
return false;
- } // function isDataSet()
-
+ }
/**
* Get cell at a specific coordinate
* @throws PHPExcel_Exception
* @return PHPExcel_Cell Cell that was found, or null if not found
*/
- public function getCacheData($pCoord) {
- if ($pCoord === $this->_currentObjectID) {
- return $this->_currentObject;
+ public function getCacheData($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ return $this->currentObject;
}
- $this->_storeData();
+ $this->storeData();
// Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) {
- $obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
- if ($obj === FALSE) {
+ $obj = apc_fetch($this->cachePrefix . $pCoord . '.cache');
+ if ($obj === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($pCoord);
throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
}
// Set current entry to the requested entry
- $this->_currentObjectID = $pCoord;
- $this->_currentObject = unserialize($obj);
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = unserialize($obj);
// Re-attach this as the cell's parent
- $this->_currentObject->attach($this);
+ $this->currentObject->attach($this);
// Return requested entry
- return $this->_currentObject;
- } // function getCacheData()
-
-
- /**
- * Get a list of all cell addresses currently held in cache
- *
- * @return array of string
- */
- public function getCellList() {
- if ($this->_currentObjectID !== null) {
- $this->_storeData();
- }
+ return $this->currentObject;
+ }
- return parent::getCellList();
- }
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return string[]
+ */
+ public function getCellList()
+ {
+ if ($this->currentObjectID !== null) {
+ $this->storeData();
+ }
+ return parent::getCellList();
+ }
/**
* Delete a cell in cache identified by coordinate address
* @param string $pCoord Coordinate address of the cell to delete
* @throws PHPExcel_Exception
*/
- public function deleteCacheData($pCoord) {
+ public function deleteCacheData($pCoord)
+ {
// Delete the entry from APC
- apc_delete($this->_cachePrefix.$pCoord.'.cache');
+ apc_delete($this->cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
parent::deleteCacheData($pCoord);
- } // function deleteCacheData()
-
+ }
/**
* Clone the cell collection
* @throws PHPExcel_Exception
* @return void
*/
- public function copyCellCollection(PHPExcel_Worksheet $parent) {
+ public function copyCellCollection(PHPExcel_Worksheet $parent)
+ {
parent::copyCellCollection($parent);
// Get a new id for the new file name
- $baseUnique = $this->_getUniqueID();
- $newCachePrefix = substr(md5($baseUnique),0,8).'.';
+ $baseUnique = $this->getUniqueID();
+ $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
$cacheList = $this->getCellList();
- foreach($cacheList as $cellID) {
- if ($cellID != $this->_currentObjectID) {
- $obj = apc_fetch($this->_cachePrefix.$cellID.'.cache');
- if ($obj === FALSE) {
+ foreach ($cacheList as $cellID) {
+ if ($cellID != $this->currentObjectID) {
+ $obj = apc_fetch($this->cachePrefix . $cellID . '.cache');
+ if ($obj === false) {
// Entry no longer exists in APC, so clear it from the cache array
parent::deleteCacheData($cellID);
- throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in APC');
+ throw new PHPExcel_Exception('Cell entry ' . $cellID . ' no longer exists in APC');
}
- if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) {
+ if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) {
$this->__destruct();
- throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC');
+ throw new PHPExcel_Exception('Failed to store cell ' . $cellID . ' in APC');
}
}
}
- $this->_cachePrefix = $newCachePrefix;
- } // function copyCellCollection()
-
+ $this->cachePrefix = $newCachePrefix;
+ }
/**
* Clear the cell collection and disconnect from our parent
*
* @return void
*/
- public function unsetWorksheetCells() {
- if ($this->_currentObject !== NULL) {
- $this->_currentObject->detach();
- $this->_currentObject = $this->_currentObjectID = null;
+ public function unsetWorksheetCells()
+ {
+ if ($this->currentObject !== null) {
+ $this->currentObject->detach();
+ $this->currentObject = $this->currentObjectID = null;
}
// Flush the APC cache
$this->__destruct();
- $this->_cellCache = array();
+ $this->cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
- $this->_parent = null;
- } // function unsetWorksheetCells()
-
+ $this->parent = null;
+ }
/**
* Initialise this new cell collection
* @param PHPExcel_Worksheet $parent The worksheet for this cell collection
* @param array of mixed $arguments Additional initialisation arguments
*/
- public function __construct(PHPExcel_Worksheet $parent, $arguments) {
+ public function __construct(PHPExcel_Worksheet $parent, $arguments)
+ {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
- if ($this->_cachePrefix === NULL) {
- $baseUnique = $this->_getUniqueID();
- $this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
- $this->_cacheTime = $cacheTime;
+ if ($this->cachePrefix === null) {
+ $baseUnique = $this->getUniqueID();
+ $this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
+ $this->cacheTime = $cacheTime;
parent::__construct($parent);
}
- } // function __construct()
-
+ }
/**
* Destroy this cell collection
*/
- public function __destruct() {
+ public function __destruct()
+ {
$cacheList = $this->getCellList();
- foreach($cacheList as $cellID) {
- apc_delete($this->_cachePrefix.$cellID.'.cache');
+ foreach ($cacheList as $cellID) {
+ apc_delete($this->cachePrefix . $cellID . '.cache');
}
- } // function __destruct()
-
+ }
/**
* Identify whether the caching method is currently available
*
* @return boolean
*/
- public static function cacheMethodIsAvailable() {
+ public static function cacheMethodIsAvailable()
+ {
if (!function_exists('apc_store')) {
- return FALSE;
+ return false;
}
- if (apc_sma_info() === FALSE) {
- return FALSE;
+ if (apc_sma_info() === false) {
+ return false;
}
- return TRUE;
+ return true;
}
-
}
-<?php\r
-/**\r
- * PHPExcel\r
- *\r
- * Copyright (c) 2006 - 2014 PHPExcel\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL\r
- * @version ##VERSION##, ##DATE##\r
- */\r
-\r
-\r
-/**\r
- * PHPExcel_CachedObjectStorage_CacheBase\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- */\r
-abstract class PHPExcel_CachedObjectStorage_CacheBase {\r
-\r
- /**\r
- * Parent worksheet\r
- *\r
- * @var PHPExcel_Worksheet\r
- */\r
- protected $_parent;\r
-\r
- /**\r
- * The currently active Cell\r
- *\r
- * @var PHPExcel_Cell\r
- */\r
- protected $_currentObject = null;\r
-\r
- /**\r
- * Coordinate address of the currently active Cell\r
- *\r
- * @var string\r
- */\r
- protected $_currentObjectID = null;\r
-\r
-\r
- /**\r
- * Flag indicating whether the currently active Cell requires saving\r
- *\r
- * @var boolean\r
- */\r
- protected $_currentCellIsDirty = true;\r
-\r
- /**\r
- * An array of cells or cell pointers for the worksheet cells held in this cache,\r
- * and indexed by their coordinate address within the worksheet\r
- *\r
- * @var array of mixed\r
- */\r
- protected $_cellCache = array();\r
-\r
-\r
- /**\r
- * Initialise this new cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The worksheet for this cell collection\r
- */\r
- public function __construct(PHPExcel_Worksheet $parent) {\r
- // Set our parent worksheet.\r
- // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when\r
- // they are woken from a serialized state\r
- $this->_parent = $parent;\r
- } // function __construct()\r
-\r
-\r
- /**\r
- * Return the parent worksheet for this cell collection\r
- *\r
- * @return PHPExcel_Worksheet\r
- */\r
- public function getParent()\r
- {\r
- return $this->_parent;\r
- }\r
-\r
- /**\r
- * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?\r
- *\r
- * @param string $pCoord Coordinate address of the cell to check\r
- * @return boolean\r
- */\r
- public function isDataSet($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- return true;\r
- }\r
- // Check if the requested entry exists in the cache\r
- return isset($this->_cellCache[$pCoord]);\r
- } // function isDataSet()\r
-\r
-\r
- /**\r
- * Move a cell object from one address to another\r
- *\r
- * @param string $fromAddress Current address of the cell to move\r
- * @param string $toAddress Destination address of the cell to move\r
- * @return boolean\r
- */\r
- public function moveCell($fromAddress, $toAddress) {\r
- if ($fromAddress === $this->_currentObjectID) {\r
- $this->_currentObjectID = $toAddress;\r
- }\r
- $this->_currentCellIsDirty = true;\r
- if (isset($this->_cellCache[$fromAddress])) {\r
- $this->_cellCache[$toAddress] = &$this->_cellCache[$fromAddress];\r
- unset($this->_cellCache[$fromAddress]);\r
- }\r
-\r
- return TRUE;\r
- } // function moveCell()\r
-\r
-\r
- /**\r
- * Add or Update a cell in cache\r
- *\r
- * @param PHPExcel_Cell $cell Cell to update\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- public function updateCacheData(PHPExcel_Cell $cell) {\r
- return $this->addCacheData($cell->getCoordinate(),$cell);\r
- } // function updateCacheData()\r
-\r
-\r
- /**\r
- * Delete a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to delete\r
- * @throws PHPExcel_Exception\r
- */\r
- public function deleteCacheData($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- $this->_currentObject->detach();\r
- $this->_currentObjectID = $this->_currentObject = null;\r
- }\r
-\r
- if (is_object($this->_cellCache[$pCoord])) {\r
- $this->_cellCache[$pCoord]->detach();\r
- unset($this->_cellCache[$pCoord]);\r
- }\r
- $this->_currentCellIsDirty = false;\r
- } // function deleteCacheData()\r
-\r
-\r
- /**\r
- * Get a list of all cell addresses currently held in cache\r
- *\r
- * @return array of string\r
- */\r
- public function getCellList() {\r
- return array_keys($this->_cellCache);\r
- } // function getCellList()\r
-\r
-\r
- /**\r
- * Sort the list of all cell addresses currently held in cache by row and column\r
- *\r
- * @return void\r
- */\r
- public function getSortedCellList() {\r
- $sortKeys = array();\r
- foreach ($this->getCellList() as $coord) {\r
- sscanf($coord,'%[A-Z]%d', $column, $row);\r
- $sortKeys[sprintf('%09d%3s',$row,$column)] = $coord;\r
- }\r
- ksort($sortKeys);\r
-\r
- return array_values($sortKeys);\r
- } // function sortCellList()\r
-\r
-\r
-\r
- /**\r
- * Get highest worksheet column and highest row that have cell records\r
- *\r
- * @return array Highest column name and highest row number\r
- */\r
- public function getHighestRowAndColumn()\r
- {\r
- // Lookup highest column and highest row\r
- $col = array('A' => '1A');\r
- $row = array(1);\r
- foreach ($this->getCellList() as $coord) {\r
- sscanf($coord,'%[A-Z]%d', $c, $r);\r
- $row[$r] = $r;\r
- $col[$c] = strlen($c).$c;\r
- }\r
- if (!empty($row)) {\r
- // Determine highest column and row\r
- $highestRow = max($row);\r
- $highestColumn = substr(max($col),1);\r
- }\r
-\r
- return array( 'row' => $highestRow,\r
- 'column' => $highestColumn\r
- );\r
- }\r
-\r
-\r
- /**\r
- * Return the cell address of the currently active cell object\r
- *\r
- * @return string\r
- */\r
- public function getCurrentAddress()\r
- {\r
- return $this->_currentObjectID;\r
- }\r
-\r
- /**\r
- * Return the column address of the currently active cell object\r
- *\r
- * @return string\r
- */\r
- public function getCurrentColumn()\r
- {\r
- sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);\r
- return $column;\r
- }\r
-\r
- /**\r
- * Return the row address of the currently active cell object\r
- *\r
- * @return string\r
- */\r
- public function getCurrentRow()\r
- {\r
- sscanf($this->_currentObjectID, '%[A-Z]%d', $column, $row);\r
- return $row;\r
- }\r
-\r
- /**\r
- * Get highest worksheet column\r
- *\r
- * @param string $row Return the highest column for the specified row,\r
- * or the highest column of any row if no row number is passed\r
- * @return string Highest column name\r
- */\r
- public function getHighestColumn($row = null)\r
- {\r
- if ($row == null) {\r
- $colRow = $this->getHighestRowAndColumn();\r
- return $colRow['column'];\r
- }\r
-\r
- $columnList = array(1);\r
- foreach ($this->getCellList() as $coord) {\r
- sscanf($coord,'%[A-Z]%d', $c, $r);\r
- if ($r != $row) {\r
- continue;\r
- }\r
- $columnList[] = PHPExcel_Cell::columnIndexFromString($c);\r
- }\r
- return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1);\r
- }\r
-\r
- /**\r
- * Get highest worksheet row\r
- *\r
- * @param string $column Return the highest row for the specified column,\r
- * or the highest row of any column if no column letter is passed\r
- * @return int Highest row number\r
- */\r
- public function getHighestRow($column = null)\r
- {\r
- if ($column == null) {\r
- $colRow = $this->getHighestRowAndColumn();\r
- return $colRow['row'];\r
- }\r
-\r
- $rowList = array(0);\r
- foreach ($this->getCellList() as $coord) {\r
- sscanf($coord,'%[A-Z]%d', $c, $r);\r
- if ($c != $column) {\r
- continue;\r
- }\r
- $rowList[] = $r;\r
- }\r
-\r
- return max($rowList);\r
- }\r
-\r
-\r
- /**\r
- * Generate a unique ID for cache referencing\r
- *\r
- * @return string Unique Reference\r
- */\r
- protected function _getUniqueID() {\r
- if (function_exists('posix_getpid')) {\r
- $baseUnique = posix_getpid();\r
- } else {\r
- $baseUnique = mt_rand();\r
- }\r
- return uniqid($baseUnique,true);\r
- }\r
-\r
- /**\r
- * Clone the cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The new worksheet\r
- * @return void\r
- */\r
- public function copyCellCollection(PHPExcel_Worksheet $parent) {\r
- $this->_currentCellIsDirty;\r
- $this->_storeData();\r
-\r
- $this->_parent = $parent;\r
- if (($this->_currentObject !== NULL) && (is_object($this->_currentObject))) {\r
- $this->_currentObject->attach($this);\r
- }\r
- } // function copyCellCollection()\r
-\r
-\r
- /**\r
- * Identify whether the caching method is currently available\r
- * Some methods are dependent on the availability of certain extensions being enabled in the PHP build\r
- *\r
- * @return boolean\r
- */\r
- public static function cacheMethodIsAvailable() {\r
- return true;\r
- }\r
-\r
-}\r
+<?php
+
+/**
+ * PHPExcel_CachedObjectStorage_CacheBase
+ *
+ * Copyright (c) 2006 - 2015 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version ##VERSION##, ##DATE##
+ */
+abstract class PHPExcel_CachedObjectStorage_CacheBase
+{
+ /**
+ * Parent worksheet
+ *
+ * @var PHPExcel_Worksheet
+ */
+ protected $parent;
+
+ /**
+ * The currently active Cell
+ *
+ * @var PHPExcel_Cell
+ */
+ protected $currentObject = null;
+
+ /**
+ * Coordinate address of the currently active Cell
+ *
+ * @var string
+ */
+ protected $currentObjectID = null;
+
+ /**
+ * Flag indicating whether the currently active Cell requires saving
+ *
+ * @var boolean
+ */
+ protected $currentCellIsDirty = true;
+
+ /**
+ * An array of cells or cell pointers for the worksheet cells held in this cache,
+ * and indexed by their coordinate address within the worksheet
+ *
+ * @var array of mixed
+ */
+ protected $cellCache = array();
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ */
+ public function __construct(PHPExcel_Worksheet $parent)
+ {
+ // Set our parent worksheet.
+ // This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
+ // they are woken from a serialized state
+ $this->parent = $parent;
+ }
+
+ /**
+ * Return the parent worksheet for this cell collection
+ *
+ * @return PHPExcel_Worksheet
+ */
+ public function getParent()
+ {
+ return $this->parent;
+ }
+
+ /**
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
+ */
+ public function isDataSet($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ return true;
+ }
+ // Check if the requested entry exists in the cache
+ return isset($this->cellCache[$pCoord]);
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Add or Update a cell in cache
+ *
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
+ */
+ public function updateCacheData(PHPExcel_Cell $cell)
+ {
+ return $this->addCacheData($cell->getCoordinate(), $cell);
+ }
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws PHPExcel_Exception
+ */
+ public function deleteCacheData($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID && !is_null($this->currentObject)) {
+ $this->currentObject->detach();
+ $this->currentObjectID = $this->currentObject = null;
+ }
+
+ if (is_object($this->cellCache[$pCoord])) {
+ $this->cellCache[$pCoord]->detach();
+ unset($this->cellCache[$pCoord]);
+ }
+ $this->currentCellIsDirty = false;
+ }
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return string[]
+ */
+ public function getCellList()
+ {
+ return array_keys($this->cellCache);
+ }
+
+ /**
+ * Sort the list of all cell addresses currently held in cache by row and column
+ *
+ * @return string[]
+ */
+ public function getSortedCellList()
+ {
+ $sortKeys = array();
+ foreach ($this->getCellList() as $coord) {
+ sscanf($coord, '%[A-Z]%d', $column, $row);
+ $sortKeys[sprintf('%09d%3s', $row, $column)] = $coord;
+ }
+ ksort($sortKeys);
+
+ return array_values($sortKeys);
+ }
+
+ /**
+ * Get highest worksheet column and highest row that have cell records
+ *
+ * @return array Highest column name and highest row number
+ */
+ public function getHighestRowAndColumn()
+ {
+ // Lookup highest column and highest row
+ $col = array('A' => '1A');
+ $row = array(1);
+ foreach ($this->getCellList() as $coord) {
+ sscanf($coord, '%[A-Z]%d', $c, $r);
+ $row[$r] = $r;
+ $col[$c] = strlen($c).$c;
+ }
+ if (!empty($row)) {
+ // Determine highest column and row
+ $highestRow = max($row);
+ $highestColumn = substr(max($col), 1);
+ }
+
+ return array(
+ 'row' => $highestRow,
+ 'column' => $highestColumn
+ );
+ }
+
+ /**
+ * Return the cell address of the currently active cell object
+ *
+ * @return string
+ */
+ public function getCurrentAddress()
+ {
+ return $this->currentObjectID;
+ }
+
+ /**
+ * Return the column address of the currently active cell object
+ *
+ * @return string
+ */
+ public function getCurrentColumn()
+ {
+ sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
+ return $column;
+ }
+
+ /**
+ * Return the row address of the currently active cell object
+ *
+ * @return integer
+ */
+ public function getCurrentRow()
+ {
+ sscanf($this->currentObjectID, '%[A-Z]%d', $column, $row);
+ return (integer) $row;
+ }
+
+ /**
+ * Get highest worksheet column
+ *
+ * @param string $row Return the highest column for the specified row,
+ * or the highest column of any row if no row number is passed
+ * @return string Highest column name
+ */
+ public function getHighestColumn($row = null)
+ {
+ if ($row == null) {
+ $colRow = $this->getHighestRowAndColumn();
+ return $colRow['column'];
+ }
+
+ $columnList = array(1);
+ foreach ($this->getCellList() as $coord) {
+ sscanf($coord, '%[A-Z]%d', $c, $r);
+ if ($r != $row) {
+ continue;
+ }
+ $columnList[] = PHPExcel_Cell::columnIndexFromString($c);
+ }
+ return PHPExcel_Cell::stringFromColumnIndex(max($columnList) - 1);
+ }
+
+ /**
+ * Get highest worksheet row
+ *
+ * @param string $column Return the highest row for the specified column,
+ * or the highest row of any column if no column letter is passed
+ * @return int Highest row number
+ */
+ public function getHighestRow($column = null)
+ {
+ if ($column == null) {
+ $colRow = $this->getHighestRowAndColumn();
+ return $colRow['row'];
+ }
+
+ $rowList = array(0);
+ foreach ($this->getCellList() as $coord) {
+ sscanf($coord, '%[A-Z]%d', $c, $r);
+ if ($c != $column) {
+ continue;
+ }
+ $rowList[] = $r;
+ }
+
+ return max($rowList);
+ }
+
+ /**
+ * Generate a unique ID for cache referencing
+ *
+ * @return string Unique Reference
+ */
+ protected function getUniqueID()
+ {
+ if (function_exists('posix_getpid')) {
+ $baseUnique = posix_getpid();
+ } else {
+ $baseUnique = mt_rand();
+ }
+ return uniqid($baseUnique, true);
+ }
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent)
+ {
+ $this->currentCellIsDirty;
+ $this->storeData();
+
+ $this->parent = $parent;
+ if (($this->currentObject !== null) && (is_object($this->currentObject))) {
+ $this->currentObject->attach($this);
+ }
+ } // function copyCellCollection()
+
+ /**
+ * Remove a row, deleting all cells in that row
+ *
+ * @param string $row Row number to remove
+ * @return void
+ */
+ public function removeRow($row)
+ {
+ foreach ($this->getCellList() as $coord) {
+ sscanf($coord, '%[A-Z]%d', $c, $r);
+ if ($r == $row) {
+ $this->deleteCacheData($coord);
+ }
+ }
+ }
+
+ /**
+ * Remove a column, deleting all cells in that column
+ *
+ * @param string $column Column ID to remove
+ * @return void
+ */
+ public function removeColumn($column)
+ {
+ foreach ($this->getCellList() as $coord) {
+ sscanf($coord, '%[A-Z]%d', $c, $r);
+ if ($c == $column) {
+ $this->deleteCacheData($coord);
+ }
+ }
+ }
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable()
+ {
+ return true;
+ }
+}
-<?php\r
-/**\r
- * PHPExcel\r
- *\r
- * Copyright (c) 2006 - 2014 PHPExcel\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL\r
- * @version ##VERSION##, ##DATE##\r
- */\r
-\r
-\r
-/**\r
- * PHPExcel_CachedObjectStorage_DiscISAM\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- */\r
-class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {\r
-\r
- /**\r
- * Name of the file for this cache\r
- *\r
- * @var string\r
- */\r
- private $_fileName = NULL;\r
-\r
- /**\r
- * File handle for this cache file\r
- *\r
- * @var resource\r
- */\r
- private $_fileHandle = NULL;\r
-\r
- /**\r
- * Directory/Folder where the cache file is located\r
- *\r
- * @var string\r
- */\r
- private $_cacheDirectory = NULL;\r
-\r
-\r
- /**\r
- * Store cell data in cache for the current cell object if it's "dirty",\r
- * and the 'nullify' the current cell object\r
- *\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- protected function _storeData() {\r
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {\r
- $this->_currentObject->detach();\r
-\r
- fseek($this->_fileHandle,0,SEEK_END);\r
- $offset = ftell($this->_fileHandle);\r
- fwrite($this->_fileHandle, serialize($this->_currentObject));\r
- $this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,\r
- 'sz' => ftell($this->_fileHandle) - $offset\r
- );\r
- $this->_currentCellIsDirty = false;\r
- }\r
- $this->_currentObjectID = $this->_currentObject = null;\r
- } // function _storeData()\r
-\r
-\r
- /**\r
- * Add or Update a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to update\r
- * @param PHPExcel_Cell $cell Cell to update\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {\r
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {\r
- $this->_storeData();\r
- }\r
-\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = $cell;\r
- $this->_currentCellIsDirty = true;\r
-\r
- return $cell;\r
- } // function addCacheData()\r
-\r
-\r
- /**\r
- * Get cell at a specific coordinate\r
- *\r
- * @param string $pCoord Coordinate of the cell\r
- * @throws PHPExcel_Exception\r
- * @return PHPExcel_Cell Cell that was found, or null if not found\r
- */\r
- public function getCacheData($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- return $this->_currentObject;\r
- }\r
- $this->_storeData();\r
-\r
- // Check if the entry that has been requested actually exists\r
- if (!isset($this->_cellCache[$pCoord])) {\r
- // Return null if requested entry doesn't exist in cache\r
- return null;\r
- }\r
-\r
- // Set current entry to the requested entry\r
- $this->_currentObjectID = $pCoord;\r
- fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);\r
- $this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));\r
- // Re-attach this as the cell's parent\r
- $this->_currentObject->attach($this);\r
-\r
- // Return requested entry\r
- return $this->_currentObject;\r
- } // function getCacheData()\r
-\r
-\r
- /**\r
- * Get a list of all cell addresses currently held in cache\r
- *\r
- * @return array of string\r
- */\r
- public function getCellList() {\r
- if ($this->_currentObjectID !== null) {\r
- $this->_storeData();\r
- }\r
-\r
- return parent::getCellList();\r
- }\r
-\r
-\r
- /**\r
- * Clone the cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The new worksheet\r
- * @return void\r
- */\r
- public function copyCellCollection(PHPExcel_Worksheet $parent) {\r
- parent::copyCellCollection($parent);\r
- // Get a new id for the new file name\r
- $baseUnique = $this->_getUniqueID();\r
- $newFileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';\r
- // Copy the existing cell cache file\r
- copy ($this->_fileName,$newFileName);\r
- $this->_fileName = $newFileName;\r
- // Open the copied cell cache file\r
- $this->_fileHandle = fopen($this->_fileName,'a+');\r
- } // function copyCellCollection()\r
-\r
-\r
- /**\r
- * Clear the cell collection and disconnect from our parent\r
- *\r
- * @return void\r
- */\r
- public function unsetWorksheetCells() {\r
- if(!is_null($this->_currentObject)) {\r
- $this->_currentObject->detach();\r
- $this->_currentObject = $this->_currentObjectID = null;\r
- }\r
- $this->_cellCache = array();\r
-\r
- // detach ourself from the worksheet, so that it can then delete this object successfully\r
- $this->_parent = null;\r
-\r
- // Close down the temporary cache file\r
- $this->__destruct();\r
- } // function unsetWorksheetCells()\r
-\r
-\r
- /**\r
- * Initialise this new cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The worksheet for this cell collection\r
- * @param array of mixed $arguments Additional initialisation arguments\r
- */\r
- public function __construct(PHPExcel_Worksheet $parent, $arguments) {\r
- $this->_cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== NULL))\r
- ? $arguments['dir']\r
- : PHPExcel_Shared_File::sys_get_temp_dir();\r
-\r
- parent::__construct($parent);\r
- if (is_null($this->_fileHandle)) {\r
- $baseUnique = $this->_getUniqueID();\r
- $this->_fileName = $this->_cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';\r
- $this->_fileHandle = fopen($this->_fileName,'a+');\r
- }\r
- } // function __construct()\r
-\r
-\r
- /**\r
- * Destroy this cell collection\r
- */\r
- public function __destruct() {\r
- if (!is_null($this->_fileHandle)) {\r
- fclose($this->_fileHandle);\r
- unlink($this->_fileName);\r
- }\r
- $this->_fileHandle = null;\r
- } // function __destruct()\r
-\r
-}\r
+<?php
+
+/**
+ * PHPExcel_CachedObjectStorage_DiscISAM
+ *
+ * Copyright (c) 2006 - 2015 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version ##VERSION##, ##DATE##
+ */
+class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
+{
+ /**
+ * Name of the file for this cache
+ *
+ * @var string
+ */
+ private $fileName = null;
+
+ /**
+ * File handle for this cache file
+ *
+ * @var resource
+ */
+ private $fileHandle = null;
+
+ /**
+ * Directory/Folder where the cache file is located
+ *
+ * @var string
+ */
+ private $cacheDirectory = null;
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws PHPExcel_Exception
+ */
+ protected function storeData()
+ {
+ if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
+ $this->currentObject->detach();
+
+ fseek($this->fileHandle, 0, SEEK_END);
+
+ $this->cellCache[$this->currentObjectID] = array(
+ 'ptr' => ftell($this->fileHandle),
+ 'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
+ );
+ $this->currentCellIsDirty = false;
+ }
+ $this->currentObjectID = $this->currentObject = null;
+ }
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell)
+ {
+ if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
+ $this->storeData();
+ }
+
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = $cell;
+ $this->currentCellIsDirty = true;
+
+ return $cell;
+ }
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws PHPExcel_Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ return $this->currentObject;
+ }
+ $this->storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->currentObjectID = $pCoord;
+ fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
+ $this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
+ // Re-attach this as the cell's parent
+ $this->currentObject->attach($this);
+
+ // Return requested entry
+ return $this->currentObject;
+ }
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return string[]
+ */
+ public function getCellList()
+ {
+ if ($this->currentObjectID !== null) {
+ $this->storeData();
+ }
+
+ return parent::getCellList();
+ }
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent)
+ {
+ parent::copyCellCollection($parent);
+ // Get a new id for the new file name
+ $baseUnique = $this->getUniqueID();
+ $newFileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
+ // Copy the existing cell cache file
+ copy($this->fileName, $newFileName);
+ $this->fileName = $newFileName;
+ // Open the copied cell cache file
+ $this->fileHandle = fopen($this->fileName, 'a+');
+ }
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ */
+ public function unsetWorksheetCells()
+ {
+ if (!is_null($this->currentObject)) {
+ $this->currentObject->detach();
+ $this->currentObject = $this->currentObjectID = null;
+ }
+ $this->cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->parent = null;
+
+ // Close down the temporary cache file
+ $this->__destruct();
+ }
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
+ public function __construct(PHPExcel_Worksheet $parent, $arguments)
+ {
+ $this->cacheDirectory = ((isset($arguments['dir'])) && ($arguments['dir'] !== null))
+ ? $arguments['dir']
+ : PHPExcel_Shared_File::sys_get_temp_dir();
+
+ parent::__construct($parent);
+ if (is_null($this->fileHandle)) {
+ $baseUnique = $this->getUniqueID();
+ $this->fileName = $this->cacheDirectory.'/PHPExcel.'.$baseUnique.'.cache';
+ $this->fileHandle = fopen($this->fileName, 'a+');
+ }
+ }
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct()
+ {
+ if (!is_null($this->fileHandle)) {
+ fclose($this->fileHandle);
+ unlink($this->fileName);
+ }
+ $this->fileHandle = null;
+ }
+}
<?php
+
/**
- * PHPExcel
+ * PHPExcel_CachedObjectStorage_ICache
*
- * Copyright (c) 2006 - 2014 PHPExcel
+ * Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* @category PHPExcel
* @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
-
-
-/**
- * PHPExcel_CachedObjectStorage_ICache
- *
- * @category PHPExcel
- * @package PHPExcel_CachedObjectStorage
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
- */
interface PHPExcel_CachedObjectStorage_ICache
{
/**
* Add or Update a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to update
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws PHPExcel_Exception
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
*/
- public function addCacheData($pCoord, PHPExcel_Cell $cell);
+ public function addCacheData($pCoord, PHPExcel_Cell $cell);
/**
* Add or Update a cell in cache
*
- * @param PHPExcel_Cell $cell Cell to update
- * @return void
- * @throws PHPExcel_Exception
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
*/
- public function updateCacheData(PHPExcel_Cell $cell);
+ public function updateCacheData(PHPExcel_Cell $cell);
/**
* Fetch a cell from cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to retrieve
- * @return PHPExcel_Cell Cell that was found, or null if not found
- * @throws PHPExcel_Exception
+ * @param string $pCoord Coordinate address of the cell to retrieve
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ * @throws PHPExcel_Exception
*/
- public function getCacheData($pCoord);
+ public function getCacheData($pCoord);
/**
* Delete a cell in cache identified by coordinate address
*
- * @param string $pCoord Coordinate address of the cell to delete
- * @throws PHPExcel_Exception
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws PHPExcel_Exception
*/
- public function deleteCacheData($pCoord);
+ public function deleteCacheData($pCoord);
- /**
- * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
- *
- * @param string $pCoord Coordinate address of the cell to check
- * @return boolean
- */
- public function isDataSet($pCoord);
-
- /**
- * Get a list of all cell addresses currently held in cache
- *
- * @return array of string
- */
- public function getCellList();
+ /**
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
+ */
+ public function isDataSet($pCoord);
- /**
- * Get the list of all cell addresses currently held in cache sorted by column and row
- *
- * @return void
- */
- public function getSortedCellList();
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return string[]
+ */
+ public function getCellList();
- /**
- * Clone the cell collection
- *
- * @param PHPExcel_Worksheet $parent The new worksheet
- * @return void
- */
- public function copyCellCollection(PHPExcel_Worksheet $parent);
+ /**
+ * Get the list of all cell addresses currently held in cache sorted by column and row
+ *
+ * @return string[]
+ */
+ public function getSortedCellList();
- /**
- * Identify whether the caching method is currently available
- * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
- *
- * @return boolean
- */
- public static function cacheMethodIsAvailable();
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent);
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable();
}
-<?php\r
-/**\r
- * PHPExcel\r
- *\r
- * Copyright (c) 2006 - 2014 PHPExcel\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL\r
- * @version ##VERSION##, ##DATE##\r
- */\r
-\r
-\r
-/**\r
- * PHPExcel_CachedObjectStorage_Igbinary\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- */\r
-class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {\r
-\r
- /**\r
- * Store cell data in cache for the current cell object if it's "dirty",\r
- * and the 'nullify' the current cell object\r
- *\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- protected function _storeData() {\r
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {\r
- $this->_currentObject->detach();\r
-\r
- $this->_cellCache[$this->_currentObjectID] = igbinary_serialize($this->_currentObject);\r
- $this->_currentCellIsDirty = false;\r
- }\r
- $this->_currentObjectID = $this->_currentObject = null;\r
- } // function _storeData()\r
-\r
-\r
- /**\r
- * Add or Update a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to update\r
- * @param PHPExcel_Cell $cell Cell to update\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {\r
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {\r
- $this->_storeData();\r
- }\r
-\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = $cell;\r
- $this->_currentCellIsDirty = true;\r
-\r
- return $cell;\r
- } // function addCacheData()\r
-\r
-\r
- /**\r
- * Get cell at a specific coordinate\r
- *\r
- * @param string $pCoord Coordinate of the cell\r
- * @throws PHPExcel_Exception\r
- * @return PHPExcel_Cell Cell that was found, or null if not found\r
- */\r
- public function getCacheData($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- return $this->_currentObject;\r
- }\r
- $this->_storeData();\r
-\r
- // Check if the entry that has been requested actually exists\r
- if (!isset($this->_cellCache[$pCoord])) {\r
- // Return null if requested entry doesn't exist in cache\r
- return null;\r
- }\r
-\r
- // Set current entry to the requested entry\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = igbinary_unserialize($this->_cellCache[$pCoord]);\r
- // Re-attach this as the cell's parent\r
- $this->_currentObject->attach($this);\r
-\r
- // Return requested entry\r
- return $this->_currentObject;\r
- } // function getCacheData()\r
-\r
-\r
- /**\r
- * Get a list of all cell addresses currently held in cache\r
- *\r
- * @return array of string\r
- */\r
- public function getCellList() {\r
- if ($this->_currentObjectID !== null) {\r
- $this->_storeData();\r
- }\r
-\r
- return parent::getCellList();\r
- }\r
-\r
-\r
- /**\r
- * Clear the cell collection and disconnect from our parent\r
- *\r
- * @return void\r
- */\r
- public function unsetWorksheetCells() {\r
- if(!is_null($this->_currentObject)) {\r
- $this->_currentObject->detach();\r
- $this->_currentObject = $this->_currentObjectID = null;\r
- }\r
- $this->_cellCache = array();\r
-\r
- // detach ourself from the worksheet, so that it can then delete this object successfully\r
- $this->_parent = null;\r
- } // function unsetWorksheetCells()\r
-\r
-\r
- /**\r
- * Identify whether the caching method is currently available\r
- * Some methods are dependent on the availability of certain extensions being enabled in the PHP build\r
- *\r
- * @return boolean\r
- */\r
- public static function cacheMethodIsAvailable() {\r
- if (!function_exists('igbinary_serialize')) {\r
- return false;\r
- }\r
-\r
- return true;\r
- }\r
-\r
-}\r
+<?php
+
+/**
+ * PHPExcel_CachedObjectStorage_Igbinary
+ *
+ * Copyright (c) 2006 - 2015 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version ##VERSION##, ##DATE##
+ */
+class PHPExcel_CachedObjectStorage_Igbinary extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
+{
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws PHPExcel_Exception
+ */
+ protected function storeData()
+ {
+ if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
+ $this->currentObject->detach();
+
+ $this->cellCache[$this->currentObjectID] = igbinary_serialize($this->currentObject);
+ $this->currentCellIsDirty = false;
+ }
+ $this->currentObjectID = $this->currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell)
+ {
+ if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
+ $this->storeData();
+ }
+
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = $cell;
+ $this->currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws PHPExcel_Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ return $this->currentObject;
+ }
+ $this->storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = igbinary_unserialize($this->cellCache[$pCoord]);
+ // Re-attach this as the cell's parent
+ $this->currentObject->attach($this);
+
+ // Return requested entry
+ return $this->currentObject;
+ } // function getCacheData()
+
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return string[]
+ */
+ public function getCellList()
+ {
+ if ($this->currentObjectID !== null) {
+ $this->storeData();
+ }
+
+ return parent::getCellList();
+ }
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells()
+ {
+ if (!is_null($this->currentObject)) {
+ $this->currentObject->detach();
+ $this->currentObject = $this->currentObjectID = null;
+ }
+ $this->cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->parent = null;
+ } // function unsetWorksheetCells()
+
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable()
+ {
+ if (!function_exists('igbinary_serialize')) {
+ return false;
+ }
+
+ return true;
+ }
+}
-<?php\r
-/**\r
- * PHPExcel\r
- *\r
- * Copyright (c) 2006 - 2014 PHPExcel\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL\r
- * @version ##VERSION##, ##DATE##\r
- */\r
-\r
-\r
-/**\r
- * PHPExcel_CachedObjectStorage_Memcache\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- */\r
-class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {\r
-\r
- /**\r
- * Prefix used to uniquely identify cache data for this worksheet\r
- *\r
- * @var string\r
- */\r
- private $_cachePrefix = null;\r
-\r
- /**\r
- * Cache timeout\r
- *\r
- * @var integer\r
- */\r
- private $_cacheTime = 600;\r
-\r
- /**\r
- * Memcache interface\r
- *\r
- * @var resource\r
- */\r
- private $_memcache = null;\r
-\r
-\r
- /**\r
- * Store cell data in cache for the current cell object if it's "dirty",\r
- * and the 'nullify' the current cell object\r
- *\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- protected function _storeData() {\r
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {\r
- $this->_currentObject->detach();\r
-\r
- $obj = serialize($this->_currentObject);\r
- if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {\r
- if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {\r
- $this->__destruct();\r
- throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache');\r
- }\r
- }\r
- $this->_currentCellIsDirty = false;\r
- }\r
- $this->_currentObjectID = $this->_currentObject = null;\r
- } // function _storeData()\r
-\r
-\r
- /**\r
- * Add or Update a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to update\r
- * @param PHPExcel_Cell $cell Cell to update\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {\r
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {\r
- $this->_storeData();\r
- }\r
- $this->_cellCache[$pCoord] = true;\r
-\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = $cell;\r
- $this->_currentCellIsDirty = true;\r
-\r
- return $cell;\r
- } // function addCacheData()\r
-\r
-\r
- /**\r
- * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?\r
- *\r
- * @param string $pCoord Coordinate address of the cell to check\r
- * @return void\r
- * @return boolean\r
- */\r
- public function isDataSet($pCoord) {\r
- // Check if the requested entry is the current object, or exists in the cache\r
- if (parent::isDataSet($pCoord)) {\r
- if ($this->_currentObjectID == $pCoord) {\r
- return true;\r
- }\r
- // Check if the requested entry still exists in Memcache\r
- $success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');\r
- if ($success === false) {\r
- // Entry no longer exists in Memcache, so clear it from the cache array\r
- parent::deleteCacheData($pCoord);\r
- throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');\r
- }\r
- return true;\r
- }\r
- return false;\r
- } // function isDataSet()\r
-\r
-\r
- /**\r
- * Get cell at a specific coordinate\r
- *\r
- * @param string $pCoord Coordinate of the cell\r
- * @throws PHPExcel_Exception\r
- * @return PHPExcel_Cell Cell that was found, or null if not found\r
- */\r
- public function getCacheData($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- return $this->_currentObject;\r
- }\r
- $this->_storeData();\r
-\r
- // Check if the entry that has been requested actually exists\r
- if (parent::isDataSet($pCoord)) {\r
- $obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');\r
- if ($obj === false) {\r
- // Entry no longer exists in Memcache, so clear it from the cache array\r
- parent::deleteCacheData($pCoord);\r
- throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');\r
- }\r
- } else {\r
- // Return null if requested entry doesn't exist in cache\r
- return null;\r
- }\r
-\r
- // Set current entry to the requested entry\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = unserialize($obj);\r
- // Re-attach this as the cell's parent\r
- $this->_currentObject->attach($this);\r
-\r
- // Return requested entry\r
- return $this->_currentObject;\r
- } // function getCacheData()\r
-\r
-\r
- /**\r
- * Get a list of all cell addresses currently held in cache\r
- *\r
- * @return array of string\r
- */\r
- public function getCellList() {\r
- if ($this->_currentObjectID !== null) {\r
- $this->_storeData();\r
- }\r
-\r
- return parent::getCellList();\r
- }\r
-\r
-\r
- /**\r
- * Delete a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to delete\r
- * @throws PHPExcel_Exception\r
- */\r
- public function deleteCacheData($pCoord) {\r
- // Delete the entry from Memcache\r
- $this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');\r
-\r
- // Delete the entry from our cell address array\r
- parent::deleteCacheData($pCoord);\r
- } // function deleteCacheData()\r
-\r
-\r
- /**\r
- * Clone the cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The new worksheet\r
- * @return void\r
- */\r
- public function copyCellCollection(PHPExcel_Worksheet $parent) {\r
- parent::copyCellCollection($parent);\r
- // Get a new id for the new file name\r
- $baseUnique = $this->_getUniqueID();\r
- $newCachePrefix = substr(md5($baseUnique),0,8).'.';\r
- $cacheList = $this->getCellList();\r
- foreach($cacheList as $cellID) {\r
- if ($cellID != $this->_currentObjectID) {\r
- $obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache');\r
- if ($obj === false) {\r
- // Entry no longer exists in Memcache, so clear it from the cache array\r
- parent::deleteCacheData($cellID);\r
- throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in MemCache');\r
- }\r
- if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) {\r
- $this->__destruct();\r
- throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in MemCache');\r
- }\r
- }\r
- }\r
- $this->_cachePrefix = $newCachePrefix;\r
- } // function copyCellCollection()\r
-\r
-\r
- /**\r
- * Clear the cell collection and disconnect from our parent\r
- *\r
- * @return void\r
- */\r
- public function unsetWorksheetCells() {\r
- if(!is_null($this->_currentObject)) {\r
- $this->_currentObject->detach();\r
- $this->_currentObject = $this->_currentObjectID = null;\r
- }\r
-\r
- // Flush the Memcache cache\r
- $this->__destruct();\r
-\r
- $this->_cellCache = array();\r
-\r
- // detach ourself from the worksheet, so that it can then delete this object successfully\r
- $this->_parent = null;\r
- } // function unsetWorksheetCells()\r
-\r
-\r
- /**\r
- * Initialise this new cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The worksheet for this cell collection\r
- * @param array of mixed $arguments Additional initialisation arguments\r
- */\r
- public function __construct(PHPExcel_Worksheet $parent, $arguments) {\r
- $memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';\r
- $memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;\r
- $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;\r
-\r
- if (is_null($this->_cachePrefix)) {\r
- $baseUnique = $this->_getUniqueID();\r
- $this->_cachePrefix = substr(md5($baseUnique),0,8).'.';\r
-\r
- // Set a new Memcache object and connect to the Memcache server\r
- $this->_memcache = new Memcache();\r
- if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {\r
- throw new PHPExcel_Exception('Could not connect to MemCache server at '.$memcacheServer.':'.$memcachePort);\r
- }\r
- $this->_cacheTime = $cacheTime;\r
-\r
- parent::__construct($parent);\r
- }\r
- } // function __construct()\r
-\r
-\r
- /**\r
- * Memcache error handler\r
- *\r
- * @param string $host Memcache server\r
- * @param integer $port Memcache port\r
- * @throws PHPExcel_Exception\r
- */\r
- public function failureCallback($host, $port) {\r
- throw new PHPExcel_Exception('memcache '.$host.':'.$port.' failed');\r
- }\r
-\r
-\r
- /**\r
- * Destroy this cell collection\r
- */\r
- public function __destruct() {\r
- $cacheList = $this->getCellList();\r
- foreach($cacheList as $cellID) {\r
- $this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');\r
- }\r
- } // function __destruct()\r
-\r
- /**\r
- * Identify whether the caching method is currently available\r
- * Some methods are dependent on the availability of certain extensions being enabled in the PHP build\r
- *\r
- * @return boolean\r
- */\r
- public static function cacheMethodIsAvailable() {\r
- if (!function_exists('memcache_add')) {\r
- return false;\r
- }\r
-\r
- return true;\r
- }\r
-\r
-}\r
+<?php
+
+/**
+ * PHPExcel_CachedObjectStorage_Memcache
+ *
+ * Copyright (c) 2006 - 2015 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version ##VERSION##, ##DATE##
+ */
+class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
+{
+ /**
+ * Prefix used to uniquely identify cache data for this worksheet
+ *
+ * @var string
+ */
+ private $cachePrefix = null;
+
+ /**
+ * Cache timeout
+ *
+ * @var integer
+ */
+ private $cacheTime = 600;
+
+ /**
+ * Memcache interface
+ *
+ * @var resource
+ */
+ private $memcache = null;
+
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws PHPExcel_Exception
+ */
+ protected function storeData()
+ {
+ if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
+ $this->currentObject->detach();
+
+ $obj = serialize($this->currentObject);
+ if (!$this->memcache->replace($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
+ if (!$this->memcache->add($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
+ $this->__destruct();
+ throw new PHPExcel_Exception("Failed to store cell {$this->currentObjectID} in MemCache");
+ }
+ }
+ $this->currentCellIsDirty = false;
+ }
+ $this->currentObjectID = $this->currentObject = null;
+ } // function _storeData()
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell)
+ {
+ if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
+ $this->storeData();
+ }
+ $this->cellCache[$pCoord] = true;
+
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = $cell;
+ $this->currentCellIsDirty = true;
+
+ return $cell;
+ } // function addCacheData()
+
+
+ /**
+ * Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
+ * @return boolean
+ */
+ public function isDataSet($pCoord)
+ {
+ // Check if the requested entry is the current object, or exists in the cache
+ if (parent::isDataSet($pCoord)) {
+ if ($this->currentObjectID == $pCoord) {
+ return true;
+ }
+ // Check if the requested entry still exists in Memcache
+ $success = $this->memcache->get($this->cachePrefix.$pCoord.'.cache');
+ if ($success === false) {
+ // Entry no longer exists in Memcache, so clear it from the cache array
+ parent::deleteCacheData($pCoord);
+ throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
+ }
+ return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws PHPExcel_Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ return $this->currentObject;
+ }
+ $this->storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (parent::isDataSet($pCoord)) {
+ $obj = $this->memcache->get($this->cachePrefix . $pCoord . '.cache');
+ if ($obj === false) {
+ // Entry no longer exists in Memcache, so clear it from the cache array
+ parent::deleteCacheData($pCoord);
+ throw new PHPExcel_Exception("Cell entry {$pCoord} no longer exists in MemCache");
+ }
+ } else {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = unserialize($obj);
+ // Re-attach this as the cell's parent
+ $this->currentObject->attach($this);
+
+ // Return requested entry
+ return $this->currentObject;
+ }
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return string[]
+ */
+ public function getCellList()
+ {
+ if ($this->currentObjectID !== null) {
+ $this->storeData();
+ }
+
+ return parent::getCellList();
+ }
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws PHPExcel_Exception
+ */
+ public function deleteCacheData($pCoord)
+ {
+ // Delete the entry from Memcache
+ $this->memcache->delete($this->cachePrefix . $pCoord . '.cache');
+
+ // Delete the entry from our cell address array
+ parent::deleteCacheData($pCoord);
+ }
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent)
+ {
+ parent::copyCellCollection($parent);
+ // Get a new id for the new file name
+ $baseUnique = $this->getUniqueID();
+ $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
+ $cacheList = $this->getCellList();
+ foreach ($cacheList as $cellID) {
+ if ($cellID != $this->currentObjectID) {
+ $obj = $this->memcache->get($this->cachePrefix.$cellID.'.cache');
+ if ($obj === false) {
+ // Entry no longer exists in Memcache, so clear it from the cache array
+ parent::deleteCacheData($cellID);
+ throw new PHPExcel_Exception("Cell entry {$cellID} no longer exists in MemCache");
+ }
+ if (!$this->memcache->add($newCachePrefix . $cellID . '.cache', $obj, null, $this->cacheTime)) {
+ $this->__destruct();
+ throw new PHPExcel_Exception("Failed to store cell {$cellID} in MemCache");
+ }
+ }
+ }
+ $this->cachePrefix = $newCachePrefix;
+ }
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells()
+ {
+ if (!is_null($this->currentObject)) {
+ $this->currentObject->detach();
+ $this->currentObject = $this->currentObjectID = null;
+ }
+
+ // Flush the Memcache cache
+ $this->__destruct();
+
+ $this->cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->parent = null;
+ }
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
+ public function __construct(PHPExcel_Worksheet $parent, $arguments)
+ {
+ $memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
+ $memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
+ $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
+
+ if (is_null($this->cachePrefix)) {
+ $baseUnique = $this->getUniqueID();
+ $this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
+
+ // Set a new Memcache object and connect to the Memcache server
+ $this->memcache = new Memcache();
+ if (!$this->memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
+ throw new PHPExcel_Exception("Could not connect to MemCache server at {$memcacheServer}:{$memcachePort}");
+ }
+ $this->cacheTime = $cacheTime;
+
+ parent::__construct($parent);
+ }
+ }
+
+ /**
+ * Memcache error handler
+ *
+ * @param string $host Memcache server
+ * @param integer $port Memcache port
+ * @throws PHPExcel_Exception
+ */
+ public function failureCallback($host, $port)
+ {
+ throw new PHPExcel_Exception("memcache {$host}:{$port} failed");
+ }
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct()
+ {
+ $cacheList = $this->getCellList();
+ foreach ($cacheList as $cellID) {
+ $this->memcache->delete($this->cachePrefix.$cellID . '.cache');
+ }
+ }
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable()
+ {
+ if (!function_exists('memcache_add')) {
+ return false;
+ }
+
+ return true;
+ }
+}
-<?php\r
-/**\r
- * PHPExcel\r
- *\r
- * Copyright (c) 2006 - 2014 PHPExcel\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL\r
- * @version ##VERSION##, ##DATE##\r
- */\r
-\r
-\r
-/**\r
- * PHPExcel_CachedObjectStorage_Memory\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- */\r
-class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {\r
-\r
- /**\r
- * Dummy method callable from CacheBase, but unused by Memory cache\r
- *\r
- * @return void\r
- */\r
- protected function _storeData() {\r
- } // function _storeData()\r
-\r
- /**\r
- * Add or Update a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to update\r
- * @param PHPExcel_Cell $cell Cell to update\r
- * @return PHPExcel_Cell\r
- * @throws PHPExcel_Exception\r
- */\r
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {\r
- $this->_cellCache[$pCoord] = $cell;\r
-\r
- // Set current entry to the new/updated entry\r
- $this->_currentObjectID = $pCoord;\r
-\r
- return $cell;\r
- } // function addCacheData()\r
-\r
-\r
- /**\r
- * Get cell at a specific coordinate\r
- *\r
- * @param string $pCoord Coordinate of the cell\r
- * @throws PHPExcel_Exception\r
- * @return PHPExcel_Cell Cell that was found, or null if not found\r
- */\r
- public function getCacheData($pCoord) {\r
- // Check if the entry that has been requested actually exists\r
- if (!isset($this->_cellCache[$pCoord])) {\r
- $this->_currentObjectID = NULL;\r
- // Return null if requested entry doesn't exist in cache\r
- return null;\r
- }\r
-\r
- // Set current entry to the requested entry\r
- $this->_currentObjectID = $pCoord;\r
-\r
- // Return requested entry\r
- return $this->_cellCache[$pCoord];\r
- } // function getCacheData()\r
-\r
-\r
- /**\r
- * Clone the cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The new worksheet\r
- * @return void\r
- */\r
- public function copyCellCollection(PHPExcel_Worksheet $parent) {\r
- parent::copyCellCollection($parent);\r
-\r
- $newCollection = array();\r
- foreach($this->_cellCache as $k => &$cell) {\r
- $newCollection[$k] = clone $cell;\r
- $newCollection[$k]->attach($this);\r
- }\r
-\r
- $this->_cellCache = $newCollection;\r
- }\r
-\r
-\r
- /**\r
- * Clear the cell collection and disconnect from our parent\r
- *\r
- * @return void\r
- */\r
- public function unsetWorksheetCells() {\r
- // Because cells are all stored as intact objects in memory, we need to detach each one from the parent\r
- foreach($this->_cellCache as $k => &$cell) {\r
- $cell->detach();\r
- $this->_cellCache[$k] = null;\r
- }\r
- unset($cell);\r
-\r
- $this->_cellCache = array();\r
-\r
- // detach ourself from the worksheet, so that it can then delete this object successfully\r
- $this->_parent = null;\r
- } // function unsetWorksheetCells()\r
-\r
-}\r
+<?php
+
+/**
+ * PHPExcel_CachedObjectStorage_Memory
+ *
+ * Copyright (c) 2006 - 2015 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version ##VERSION##, ##DATE##
+ */
+class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
+{
+ /**
+ * Dummy method callable from CacheBase, but unused by Memory cache
+ *
+ * @return void
+ */
+ protected function storeData()
+ {
+ }
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell)
+ {
+ $this->cellCache[$pCoord] = $cell;
+
+ // Set current entry to the new/updated entry
+ $this->currentObjectID = $pCoord;
+
+ return $cell;
+ }
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws PHPExcel_Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord)
+ {
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->cellCache[$pCoord])) {
+ $this->currentObjectID = null;
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->currentObjectID = $pCoord;
+
+ // Return requested entry
+ return $this->cellCache[$pCoord];
+ }
+
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent)
+ {
+ parent::copyCellCollection($parent);
+
+ $newCollection = array();
+ foreach ($this->cellCache as $k => &$cell) {
+ $newCollection[$k] = clone $cell;
+ $newCollection[$k]->attach($this);
+ }
+
+ $this->cellCache = $newCollection;
+ }
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ */
+ public function unsetWorksheetCells()
+ {
+ // Because cells are all stored as intact objects in memory, we need to detach each one from the parent
+ foreach ($this->cellCache as $k => &$cell) {
+ $cell->detach();
+ $this->cellCache[$k] = null;
+ }
+ unset($cell);
+
+ $this->cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->parent = null;
+ }
+}
-<?php\r
-/**\r
- * PHPExcel\r
- *\r
- * Copyright (c) 2006 - 2014 PHPExcel\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL\r
- * @version ##VERSION##, ##DATE##\r
- */\r
-\r
-\r
-/**\r
- * PHPExcel_CachedObjectStorage_MemoryGZip\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- */\r
-class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {\r
-\r
- /**\r
- * Store cell data in cache for the current cell object if it's "dirty",\r
- * and the 'nullify' the current cell object\r
- *\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- protected function _storeData() {\r
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {\r
- $this->_currentObject->detach();\r
-\r
- $this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));\r
- $this->_currentCellIsDirty = false;\r
- }\r
- $this->_currentObjectID = $this->_currentObject = null;\r
- } // function _storeData()\r
-\r
-\r
- /**\r
- * Add or Update a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to update\r
- * @param PHPExcel_Cell $cell Cell to update\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {\r
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {\r
- $this->_storeData();\r
- }\r
-\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = $cell;\r
- $this->_currentCellIsDirty = true;\r
-\r
- return $cell;\r
- } // function addCacheData()\r
-\r
-\r
- /**\r
- * Get cell at a specific coordinate\r
- *\r
- * @param string $pCoord Coordinate of the cell\r
- * @throws PHPExcel_Exception\r
- * @return PHPExcel_Cell Cell that was found, or null if not found\r
- */\r
- public function getCacheData($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- return $this->_currentObject;\r
- }\r
- $this->_storeData();\r
-\r
- // Check if the entry that has been requested actually exists\r
- if (!isset($this->_cellCache[$pCoord])) {\r
- // Return null if requested entry doesn't exist in cache\r
- return null;\r
- }\r
-\r
- // Set current entry to the requested entry\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));\r
- // Re-attach this as the cell's parent\r
- $this->_currentObject->attach($this);\r
-\r
- // Return requested entry\r
- return $this->_currentObject;\r
- } // function getCacheData()\r
-\r
-\r
- /**\r
- * Get a list of all cell addresses currently held in cache\r
- *\r
- * @return array of string\r
- */\r
- public function getCellList() {\r
- if ($this->_currentObjectID !== null) {\r
- $this->_storeData();\r
- }\r
-\r
- return parent::getCellList();\r
- }\r
-\r
-\r
- /**\r
- * Clear the cell collection and disconnect from our parent\r
- *\r
- * @return void\r
- */\r
- public function unsetWorksheetCells() {\r
- if(!is_null($this->_currentObject)) {\r
- $this->_currentObject->detach();\r
- $this->_currentObject = $this->_currentObjectID = null;\r
- }\r
- $this->_cellCache = array();\r
-\r
- // detach ourself from the worksheet, so that it can then delete this object successfully\r
- $this->_parent = null;\r
- } // function unsetWorksheetCells()\r
-\r
-}\r
+<?php
+
+/**
+ * PHPExcel_CachedObjectStorage_MemoryGZip
+ *
+ * Copyright (c) 2006 - 2015 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version ##VERSION##, ##DATE##
+ */
+class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
+{
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws PHPExcel_Exception
+ */
+ protected function storeData()
+ {
+ if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
+ $this->currentObject->detach();
+
+ $this->cellCache[$this->currentObjectID] = gzdeflate(serialize($this->currentObject));
+ $this->currentCellIsDirty = false;
+ }
+ $this->currentObjectID = $this->currentObject = null;
+ }
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell)
+ {
+ if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
+ $this->storeData();
+ }
+
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = $cell;
+ $this->currentCellIsDirty = true;
+
+ return $cell;
+ }
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws PHPExcel_Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ return $this->currentObject;
+ }
+ $this->storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = unserialize(gzinflate($this->cellCache[$pCoord]));
+ // Re-attach this as the cell's parent
+ $this->currentObject->attach($this);
+
+ // Return requested entry
+ return $this->currentObject;
+ }
+
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return string[]
+ */
+ public function getCellList()
+ {
+ if ($this->currentObjectID !== null) {
+ $this->storeData();
+ }
+
+ return parent::getCellList();
+ }
+
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells()
+ {
+ if (!is_null($this->currentObject)) {
+ $this->currentObject->detach();
+ $this->currentObject = $this->currentObjectID = null;
+ }
+ $this->cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->parent = null;
+ }
+}
-<?php\r
-/**\r
- * PHPExcel\r
- *\r
- * Copyright (c) 2006 - 2014 PHPExcel\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL\r
- * @version ##VERSION##, ##DATE##\r
- */\r
-\r
-\r
-/**\r
- * PHPExcel_CachedObjectStorage_MemorySerialized\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- */\r
-class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {\r
-\r
- /**\r
- * Store cell data in cache for the current cell object if it's "dirty",\r
- * and the 'nullify' the current cell object\r
- *\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- protected function _storeData() {\r
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {\r
- $this->_currentObject->detach();\r
-\r
- $this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);\r
- $this->_currentCellIsDirty = false;\r
- }\r
- $this->_currentObjectID = $this->_currentObject = null;\r
- } // function _storeData()\r
-\r
-\r
- /**\r
- * Add or Update a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to update\r
- * @param PHPExcel_Cell $cell Cell to update\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {\r
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {\r
- $this->_storeData();\r
- }\r
-\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = $cell;\r
- $this->_currentCellIsDirty = true;\r
-\r
- return $cell;\r
- } // function addCacheData()\r
-\r
-\r
- /**\r
- * Get cell at a specific coordinate\r
- *\r
- * @param string $pCoord Coordinate of the cell\r
- * @throws PHPExcel_Exception\r
- * @return PHPExcel_Cell Cell that was found, or null if not found\r
- */\r
- public function getCacheData($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- return $this->_currentObject;\r
- }\r
- $this->_storeData();\r
-\r
- // Check if the entry that has been requested actually exists\r
- if (!isset($this->_cellCache[$pCoord])) {\r
- // Return null if requested entry doesn't exist in cache\r
- return null;\r
- }\r
-\r
- // Set current entry to the requested entry\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = unserialize($this->_cellCache[$pCoord]);\r
- // Re-attach this as the cell's parent\r
- $this->_currentObject->attach($this);\r
-\r
- // Return requested entry\r
- return $this->_currentObject;\r
- } // function getCacheData()\r
-\r
-\r
- /**\r
- * Get a list of all cell addresses currently held in cache\r
- *\r
- * @return array of string\r
- */\r
- public function getCellList() {\r
- if ($this->_currentObjectID !== null) {\r
- $this->_storeData();\r
- }\r
-\r
- return parent::getCellList();\r
- }\r
-\r
-\r
- /**\r
- * Clear the cell collection and disconnect from our parent\r
- *\r
- * @return void\r
- */\r
- public function unsetWorksheetCells() {\r
- if(!is_null($this->_currentObject)) {\r
- $this->_currentObject->detach();\r
- $this->_currentObject = $this->_currentObjectID = null;\r
- }\r
- $this->_cellCache = array();\r
-\r
- // detach ourself from the worksheet, so that it can then delete this object successfully\r
- $this->_parent = null;\r
- } // function unsetWorksheetCells()\r
-\r
-}\r
+<?php
+
+/**
+ * PHPExcel_CachedObjectStorage_MemorySerialized
+ *
+ * Copyright (c) 2006 - 2015 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version ##VERSION##, ##DATE##
+ */
+class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
+{
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws PHPExcel_Exception
+ */
+ protected function storeData()
+ {
+ if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
+ $this->currentObject->detach();
+
+ $this->cellCache[$this->currentObjectID] = serialize($this->currentObject);
+ $this->currentCellIsDirty = false;
+ }
+ $this->currentObjectID = $this->currentObject = null;
+ }
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell)
+ {
+ if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
+ $this->storeData();
+ }
+
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = $cell;
+ $this->currentCellIsDirty = true;
+
+ return $cell;
+ }
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws PHPExcel_Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ return $this->currentObject;
+ }
+ $this->storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = unserialize($this->cellCache[$pCoord]);
+ // Re-attach this as the cell's parent
+ $this->currentObject->attach($this);
+
+ // Return requested entry
+ return $this->currentObject;
+ }
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return string[]
+ */
+ public function getCellList()
+ {
+ if ($this->currentObjectID !== null) {
+ $this->storeData();
+ }
+
+ return parent::getCellList();
+ }
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells()
+ {
+ if (!is_null($this->currentObject)) {
+ $this->currentObject->detach();
+ $this->currentObject = $this->currentObjectID = null;
+ }
+ $this->cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->parent = null;
+ }
+}
-<?php\r
-/**\r
- * PHPExcel\r
- *\r
- * Copyright (c) 2006 - 2014 PHPExcel\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL\r
- * @version ##VERSION##, ##DATE##\r
- */\r
-\r
-\r
-/**\r
- * PHPExcel_CachedObjectStorage_PHPTemp\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- */\r
-class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {\r
-\r
- /**\r
- * Name of the file for this cache\r
- *\r
- * @var string\r
- */\r
- private $_fileHandle = null;\r
-\r
- /**\r
- * Memory limit to use before reverting to file cache\r
- *\r
- * @var integer\r
- */\r
- private $_memoryCacheSize = null;\r
-\r
- /**\r
- * Store cell data in cache for the current cell object if it's "dirty",\r
- * and the 'nullify' the current cell object\r
- *\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- protected function _storeData() {\r
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {\r
- $this->_currentObject->detach();\r
-\r
- fseek($this->_fileHandle,0,SEEK_END);\r
- $offset = ftell($this->_fileHandle);\r
- fwrite($this->_fileHandle, serialize($this->_currentObject));\r
- $this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,\r
- 'sz' => ftell($this->_fileHandle) - $offset\r
- );\r
- $this->_currentCellIsDirty = false;\r
- }\r
- $this->_currentObjectID = $this->_currentObject = null;\r
- } // function _storeData()\r
-\r
-\r
- /**\r
- * Add or Update a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to update\r
- * @param PHPExcel_Cell $cell Cell to update\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {\r
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {\r
- $this->_storeData();\r
- }\r
-\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = $cell;\r
- $this->_currentCellIsDirty = true;\r
-\r
- return $cell;\r
- } // function addCacheData()\r
-\r
-\r
- /**\r
- * Get cell at a specific coordinate\r
- *\r
- * @param string $pCoord Coordinate of the cell\r
- * @throws PHPExcel_Exception\r
- * @return PHPExcel_Cell Cell that was found, or null if not found\r
- */\r
- public function getCacheData($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- return $this->_currentObject;\r
- }\r
- $this->_storeData();\r
-\r
- // Check if the entry that has been requested actually exists\r
- if (!isset($this->_cellCache[$pCoord])) {\r
- // Return null if requested entry doesn't exist in cache\r
- return null;\r
- }\r
-\r
- // Set current entry to the requested entry\r
- $this->_currentObjectID = $pCoord;\r
- fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);\r
- $this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));\r
- // Re-attach this as the cell's parent\r
- $this->_currentObject->attach($this);\r
-\r
- // Return requested entry\r
- return $this->_currentObject;\r
- } // function getCacheData()\r
-\r
-\r
- /**\r
- * Get a list of all cell addresses currently held in cache\r
- *\r
- * @return array of string\r
- */\r
- public function getCellList() {\r
- if ($this->_currentObjectID !== null) {\r
- $this->_storeData();\r
- }\r
-\r
- return parent::getCellList();\r
- }\r
-\r
-\r
- /**\r
- * Clone the cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The new worksheet\r
- * @return void\r
- */\r
- public function copyCellCollection(PHPExcel_Worksheet $parent) {\r
- parent::copyCellCollection($parent);\r
- // Open a new stream for the cell cache data\r
- $newFileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');\r
- // Copy the existing cell cache data to the new stream\r
- fseek($this->_fileHandle,0);\r
- while (!feof($this->_fileHandle)) {\r
- fwrite($newFileHandle,fread($this->_fileHandle, 1024));\r
- }\r
- $this->_fileHandle = $newFileHandle;\r
- } // function copyCellCollection()\r
-\r
-\r
- /**\r
- * Clear the cell collection and disconnect from our parent\r
- *\r
- * @return void\r
- */\r
- public function unsetWorksheetCells() {\r
- if(!is_null($this->_currentObject)) {\r
- $this->_currentObject->detach();\r
- $this->_currentObject = $this->_currentObjectID = null;\r
- }\r
- $this->_cellCache = array();\r
-\r
- // detach ourself from the worksheet, so that it can then delete this object successfully\r
- $this->_parent = null;\r
-\r
- // Close down the php://temp file\r
- $this->__destruct();\r
- } // function unsetWorksheetCells()\r
-\r
-\r
- /**\r
- * Initialise this new cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The worksheet for this cell collection\r
- * @param array of mixed $arguments Additional initialisation arguments\r
- */\r
- public function __construct(PHPExcel_Worksheet $parent, $arguments) {\r
- $this->_memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';\r
-\r
- parent::__construct($parent);\r
- if (is_null($this->_fileHandle)) {\r
- $this->_fileHandle = fopen('php://temp/maxmemory:'.$this->_memoryCacheSize,'a+');\r
- }\r
- } // function __construct()\r
-\r
-\r
- /**\r
- * Destroy this cell collection\r
- */\r
- public function __destruct() {\r
- if (!is_null($this->_fileHandle)) {\r
- fclose($this->_fileHandle);\r
- }\r
- $this->_fileHandle = null;\r
- } // function __destruct()\r
-\r
-}\r
+<?php
+
+/**
+ * PHPExcel_CachedObjectStorage_PHPTemp
+ *
+ * Copyright (c) 2006 - 2015 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version ##VERSION##, ##DATE##
+ */
+class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
+{
+ /**
+ * Name of the file for this cache
+ *
+ * @var string
+ */
+ private $fileHandle = null;
+
+ /**
+ * Memory limit to use before reverting to file cache
+ *
+ * @var integer
+ */
+ private $memoryCacheSize = null;
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws PHPExcel_Exception
+ */
+ protected function storeData()
+ {
+ if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
+ $this->currentObject->detach();
+
+ fseek($this->fileHandle, 0, SEEK_END);
+
+ $this->cellCache[$this->currentObjectID] = array(
+ 'ptr' => ftell($this->fileHandle),
+ 'sz' => fwrite($this->fileHandle, serialize($this->currentObject))
+ );
+ $this->currentCellIsDirty = false;
+ }
+ $this->currentObjectID = $this->currentObject = null;
+ }
+
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell)
+ {
+ if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
+ $this->storeData();
+ }
+
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = $cell;
+ $this->currentCellIsDirty = true;
+
+ return $cell;
+ }
+
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws PHPExcel_Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ return $this->currentObject;
+ }
+ $this->storeData();
+
+ // Check if the entry that has been requested actually exists
+ if (!isset($this->cellCache[$pCoord])) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->currentObjectID = $pCoord;
+ fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
+ $this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
+ // Re-attach this as the cell's parent
+ $this->currentObject->attach($this);
+
+ // Return requested entry
+ return $this->currentObject;
+ }
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return string[]
+ */
+ public function getCellList()
+ {
+ if ($this->currentObjectID !== null) {
+ $this->storeData();
+ }
+
+ return parent::getCellList();
+ }
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent)
+ {
+ parent::copyCellCollection($parent);
+ // Open a new stream for the cell cache data
+ $newFileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
+ // Copy the existing cell cache data to the new stream
+ fseek($this->fileHandle, 0);
+ while (!feof($this->fileHandle)) {
+ fwrite($newFileHandle, fread($this->fileHandle, 1024));
+ }
+ $this->fileHandle = $newFileHandle;
+ }
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells()
+ {
+ if (!is_null($this->currentObject)) {
+ $this->currentObject->detach();
+ $this->currentObject = $this->currentObjectID = null;
+ }
+ $this->cellCache = array();
+
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->parent = null;
+
+ // Close down the php://temp file
+ $this->__destruct();
+ }
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ * @param array of mixed $arguments Additional initialisation arguments
+ */
+ public function __construct(PHPExcel_Worksheet $parent, $arguments)
+ {
+ $this->memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
+
+ parent::__construct($parent);
+ if (is_null($this->fileHandle)) {
+ $this->fileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
+ }
+ }
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct()
+ {
+ if (!is_null($this->fileHandle)) {
+ fclose($this->fileHandle);
+ }
+ $this->fileHandle = null;
+ }
+}
-<?php\r
-/**\r
- * PHPExcel\r
- *\r
- * Copyright (c) 2006 - 2014 PHPExcel\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL\r
- * @version ##VERSION##, ##DATE##\r
- */\r
-\r
-\r
-/**\r
- * PHPExcel_CachedObjectStorage_SQLite\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- */\r
-class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {\r
-\r
- /**\r
- * Database table name\r
- *\r
- * @var string\r
- */\r
- private $_TableName = null;\r
-\r
- /**\r
- * Database handle\r
- *\r
- * @var resource\r
- */\r
- private $_DBHandle = null;\r
-\r
- /**\r
- * Store cell data in cache for the current cell object if it's "dirty",\r
- * and the 'nullify' the current cell object\r
- *\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- protected function _storeData() {\r
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {\r
- $this->_currentObject->detach();\r
-\r
- if (!$this->_DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES('".$this->_currentObjectID."','".sqlite_escape_string(serialize($this->_currentObject))."')"))\r
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));\r
- $this->_currentCellIsDirty = false;\r
- }\r
- $this->_currentObjectID = $this->_currentObject = null;\r
- } // function _storeData()\r
-\r
-\r
- /**\r
- * Add or Update a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to update\r
- * @param PHPExcel_Cell $cell Cell to update\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {\r
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {\r
- $this->_storeData();\r
- }\r
-\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = $cell;\r
- $this->_currentCellIsDirty = true;\r
-\r
- return $cell;\r
- } // function addCacheData()\r
-\r
-\r
- /**\r
- * Get cell at a specific coordinate\r
- *\r
- * @param string $pCoord Coordinate of the cell\r
- * @throws PHPExcel_Exception\r
- * @return PHPExcel_Cell Cell that was found, or null if not found\r
- */\r
- public function getCacheData($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- return $this->_currentObject;\r
- }\r
- $this->_storeData();\r
-\r
- $query = "SELECT value FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";\r
- $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);\r
- if ($cellResultSet === false) {\r
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));\r
- } elseif ($cellResultSet->numRows() == 0) {\r
- // Return null if requested entry doesn't exist in cache\r
- return null;\r
- }\r
-\r
- // Set current entry to the requested entry\r
- $this->_currentObjectID = $pCoord;\r
-\r
- $cellResult = $cellResultSet->fetchSingle();\r
- $this->_currentObject = unserialize($cellResult);\r
- // Re-attach this as the cell's parent\r
- $this->_currentObject->attach($this);\r
-\r
- // Return requested entry\r
- return $this->_currentObject;\r
- } // function getCacheData()\r
-\r
-\r
- /**\r
- * Is a value set for an indexed cell?\r
- *\r
- * @param string $pCoord Coordinate address of the cell to check\r
- * @return boolean\r
- */\r
- public function isDataSet($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- return true;\r
- }\r
-\r
- // Check if the requested entry exists in the cache\r
- $query = "SELECT id FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";\r
- $cellResultSet = $this->_DBHandle->query($query,SQLITE_ASSOC);\r
- if ($cellResultSet === false) {\r
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));\r
- } elseif ($cellResultSet->numRows() == 0) {\r
- // Return null if requested entry doesn't exist in cache\r
- return false;\r
- }\r
- return true;\r
- } // function isDataSet()\r
-\r
-\r
- /**\r
- * Delete a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to delete\r
- * @throws PHPExcel_Exception\r
- */\r
- public function deleteCacheData($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- $this->_currentObject->detach();\r
- $this->_currentObjectID = $this->_currentObject = null;\r
- }\r
-\r
- // Check if the requested entry exists in the cache\r
- $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$pCoord."'";\r
- if (!$this->_DBHandle->queryExec($query))\r
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));\r
-\r
- $this->_currentCellIsDirty = false;\r
- } // function deleteCacheData()\r
-\r
-\r
- /**\r
- * Move a cell object from one address to another\r
- *\r
- * @param string $fromAddress Current address of the cell to move\r
- * @param string $toAddress Destination address of the cell to move\r
- * @return boolean\r
- */\r
- public function moveCell($fromAddress, $toAddress) {\r
- if ($fromAddress === $this->_currentObjectID) {\r
- $this->_currentObjectID = $toAddress;\r
- }\r
-\r
- $query = "DELETE FROM kvp_".$this->_TableName." WHERE id='".$toAddress."'";\r
- $result = $this->_DBHandle->exec($query);\r
- if ($result === false)\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
-\r
- $query = "UPDATE kvp_".$this->_TableName." SET id='".$toAddress."' WHERE id='".$fromAddress."'";\r
- $result = $this->_DBHandle->exec($query);\r
- if ($result === false)\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
-\r
- return TRUE;\r
- } // function moveCell()\r
-\r
-\r
- /**\r
- * Get a list of all cell addresses currently held in cache\r
- *\r
- * @return array of string\r
- */\r
- public function getCellList() {\r
- if ($this->_currentObjectID !== null) {\r
- $this->_storeData();\r
- }\r
-\r
- $query = "SELECT id FROM kvp_".$this->_TableName;\r
- $cellIdsResult = $this->_DBHandle->unbufferedQuery($query,SQLITE_ASSOC);\r
- if ($cellIdsResult === false)\r
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));\r
-\r
- $cellKeys = array();\r
- foreach($cellIdsResult as $row) {\r
- $cellKeys[] = $row['id'];\r
- }\r
-\r
- return $cellKeys;\r
- } // function getCellList()\r
-\r
-\r
- /**\r
- * Clone the cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The new worksheet\r
- * @return void\r
- */\r
- public function copyCellCollection(PHPExcel_Worksheet $parent) {\r
- $this->_currentCellIsDirty;\r
- $this->_storeData();\r
-\r
- // Get a new id for the new table name\r
- $tableName = str_replace('.','_',$this->_getUniqueID());\r
- if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)\r
- AS SELECT * FROM kvp_'.$this->_TableName))\r
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));\r
-\r
- // Copy the existing cell cache file\r
- $this->_TableName = $tableName;\r
- } // function copyCellCollection()\r
-\r
-\r
- /**\r
- * Clear the cell collection and disconnect from our parent\r
- *\r
- * @return void\r
- */\r
- public function unsetWorksheetCells() {\r
- if(!is_null($this->_currentObject)) {\r
- $this->_currentObject->detach();\r
- $this->_currentObject = $this->_currentObjectID = null;\r
- }\r
- // detach ourself from the worksheet, so that it can then delete this object successfully\r
- $this->_parent = null;\r
-\r
- // Close down the temporary cache file\r
- $this->__destruct();\r
- } // function unsetWorksheetCells()\r
-\r
-\r
- /**\r
- * Initialise this new cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The worksheet for this cell collection\r
- */\r
- public function __construct(PHPExcel_Worksheet $parent) {\r
- parent::__construct($parent);\r
- if (is_null($this->_DBHandle)) {\r
- $this->_TableName = str_replace('.','_',$this->_getUniqueID());\r
- $_DBName = ':memory:';\r
-\r
- $this->_DBHandle = new SQLiteDatabase($_DBName);\r
- if ($this->_DBHandle === false)\r
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));\r
- if (!$this->_DBHandle->queryExec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))\r
- throw new PHPExcel_Exception(sqlite_error_string($this->_DBHandle->lastError()));\r
- }\r
- } // function __construct()\r
-\r
-\r
- /**\r
- * Destroy this cell collection\r
- */\r
- public function __destruct() {\r
- if (!is_null($this->_DBHandle)) {\r
- $this->_DBHandle->queryExec('DROP TABLE kvp_'.$this->_TableName);\r
- }\r
- $this->_DBHandle = null;\r
- } // function __destruct()\r
-\r
-\r
- /**\r
- * Identify whether the caching method is currently available\r
- * Some methods are dependent on the availability of certain extensions being enabled in the PHP build\r
- *\r
- * @return boolean\r
- */\r
- public static function cacheMethodIsAvailable() {\r
- if (!function_exists('sqlite_open')) {\r
- return false;\r
- }\r
-\r
- return true;\r
- }\r
-\r
-}\r
+<?php
+
+/**
+ * PHPExcel_CachedObjectStorage_SQLite
+ *
+ * Copyright (c) 2006 - 2015 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version ##VERSION##, ##DATE##
+ */
+class PHPExcel_CachedObjectStorage_SQLite extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
+{
+ /**
+ * Database table name
+ *
+ * @var string
+ */
+ private $TableName = null;
+
+ /**
+ * Database handle
+ *
+ * @var resource
+ */
+ private $DBHandle = null;
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws PHPExcel_Exception
+ */
+ protected function storeData()
+ {
+ if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
+ $this->currentObject->detach();
+
+ if (!$this->DBHandle->queryExec("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES('".$this->currentObjectID."','".sqlite_escape_string(serialize($this->currentObject))."')")) {
+ throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
+ }
+ $this->currentCellIsDirty = false;
+ }
+ $this->currentObjectID = $this->currentObject = null;
+ }
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell)
+ {
+ if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
+ $this->storeData();
+ }
+
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = $cell;
+ $this->currentCellIsDirty = true;
+
+ return $cell;
+ }
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws PHPExcel_Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ return $this->currentObject;
+ }
+ $this->storeData();
+
+ $query = "SELECT value FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
+ $cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
+ if ($cellResultSet === false) {
+ throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
+ } elseif ($cellResultSet->numRows() == 0) {
+ // Return null if requested entry doesn't exist in cache
+ return null;
+ }
+
+ // Set current entry to the requested entry
+ $this->currentObjectID = $pCoord;
+
+ $cellResult = $cellResultSet->fetchSingle();
+ $this->currentObject = unserialize($cellResult);
+ // Re-attach this as the cell's parent
+ $this->currentObject->attach($this);
+
+ // Return requested entry
+ return $this->currentObject;
+ }
+
+ /**
+ * Is a value set for an indexed cell?
+ *
+ * @param string $pCoord Coordinate address of the cell to check
+ * @return boolean
+ */
+ public function isDataSet($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ return true;
+ }
+
+ // Check if the requested entry exists in the cache
+ $query = "SELECT id FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
+ $cellResultSet = $this->DBHandle->query($query, SQLITE_ASSOC);
+ if ($cellResultSet === false) {
+ throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
+ } elseif ($cellResultSet->numRows() == 0) {
+ // Return null if requested entry doesn't exist in cache
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Delete a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to delete
+ * @throws PHPExcel_Exception
+ */
+ public function deleteCacheData($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ $this->currentObject->detach();
+ $this->currentObjectID = $this->currentObject = null;
+ }
+
+ // Check if the requested entry exists in the cache
+ $query = "DELETE FROM kvp_".$this->TableName." WHERE id='".$pCoord."'";
+ if (!$this->DBHandle->queryExec($query)) {
+ throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
+ }
+
+ $this->currentCellIsDirty = false;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Get a list of all cell addresses currently held in cache
+ *
+ * @return string[]
+ */
+ public function getCellList()
+ {
+ if ($this->currentObjectID !== null) {
+ $this->storeData();
+ }
+
+ $query = "SELECT id FROM kvp_".$this->TableName;
+ $cellIdsResult = $this->DBHandle->unbufferedQuery($query, SQLITE_ASSOC);
+ if ($cellIdsResult === false) {
+ throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
+ }
+
+ $cellKeys = array();
+ foreach ($cellIdsResult as $row) {
+ $cellKeys[] = $row['id'];
+ }
+
+ return $cellKeys;
+ }
+
+ /**
+ * Clone the cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The new worksheet
+ * @return void
+ */
+ public function copyCellCollection(PHPExcel_Worksheet $parent)
+ {
+ $this->currentCellIsDirty;
+ $this->storeData();
+
+ // Get a new id for the new table name
+ $tableName = str_replace('.', '_', $this->getUniqueID());
+ if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
+ AS SELECT * FROM kvp_'.$this->TableName)
+ ) {
+ throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
+ }
+
+ // Copy the existing cell cache file
+ $this->TableName = $tableName;
+ }
+
+ /**
+ * Clear the cell collection and disconnect from our parent
+ *
+ * @return void
+ */
+ public function unsetWorksheetCells()
+ {
+ if (!is_null($this->currentObject)) {
+ $this->currentObject->detach();
+ $this->currentObject = $this->currentObjectID = null;
+ }
+ // detach ourself from the worksheet, so that it can then delete this object successfully
+ $this->parent = null;
+
+ // Close down the temporary cache file
+ $this->__destruct();
+ }
+
+ /**
+ * Initialise this new cell collection
+ *
+ * @param PHPExcel_Worksheet $parent The worksheet for this cell collection
+ */
+ public function __construct(PHPExcel_Worksheet $parent)
+ {
+ parent::__construct($parent);
+ if (is_null($this->DBHandle)) {
+ $this->TableName = str_replace('.', '_', $this->getUniqueID());
+ $_DBName = ':memory:';
+
+ $this->DBHandle = new SQLiteDatabase($_DBName);
+ if ($this->DBHandle === false) {
+ throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
+ }
+ if (!$this->DBHandle->queryExec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
+ throw new PHPExcel_Exception(sqlite_error_string($this->DBHandle->lastError()));
+ }
+ }
+ }
+
+ /**
+ * Destroy this cell collection
+ */
+ public function __destruct()
+ {
+ if (!is_null($this->DBHandle)) {
+ $this->DBHandle->queryExec('DROP TABLE kvp_'.$this->TableName);
+ }
+ $this->DBHandle = null;
+ }
+
+ /**
+ * Identify whether the caching method is currently available
+ * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
+ *
+ * @return boolean
+ */
+ public static function cacheMethodIsAvailable()
+ {
+ if (!function_exists('sqlite_open')) {
+ return false;
+ }
+
+ return true;
+ }
+}
-<?php\r
-/**\r
- * PHPExcel\r
- *\r
- * Copyright (c) 2006 - 2014 PHPExcel\r
- *\r
- * This library is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU Lesser General Public\r
- * License as published by the Free Software Foundation; either\r
- * version 2.1 of the License, or (at your option) any later version.\r
- *\r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL\r
- * @version ##VERSION##, ##DATE##\r
- */\r
-\r
-\r
-/**\r
- * PHPExcel_CachedObjectStorage_SQLite3\r
- *\r
- * @category PHPExcel\r
- * @package PHPExcel_CachedObjectStorage\r
- * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)\r
- */\r
-class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {\r
-\r
- /**\r
- * Database table name\r
- *\r
- * @var string\r
- */\r
- private $_TableName = null;\r
-\r
- /**\r
- * Database handle\r
- *\r
- * @var resource\r
- */\r
- private $_DBHandle = null;\r
-\r
- /**\r
- * Prepared statement for a SQLite3 select query\r
- *\r
- * @var SQLite3Stmt\r
- */\r
- private $_selectQuery;\r
-\r
- /**\r
- * Prepared statement for a SQLite3 insert query\r
- *\r
- * @var SQLite3Stmt\r
- */\r
- private $_insertQuery;\r
-\r
- /**\r
- * Prepared statement for a SQLite3 update query\r
- *\r
- * @var SQLite3Stmt\r
- */\r
- private $_updateQuery;\r
-\r
- /**\r
- * Prepared statement for a SQLite3 delete query\r
- *\r
- * @var SQLite3Stmt\r
- */\r
- private $_deleteQuery;\r
-\r
- /**\r
- * Store cell data in cache for the current cell object if it's "dirty",\r
- * and the 'nullify' the current cell object\r
- *\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- protected function _storeData() {\r
- if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {\r
- $this->_currentObject->detach();\r
-\r
- $this->_insertQuery->bindValue('id',$this->_currentObjectID,SQLITE3_TEXT);\r
- $this->_insertQuery->bindValue('data',serialize($this->_currentObject),SQLITE3_BLOB);\r
- $result = $this->_insertQuery->execute();\r
- if ($result === false)\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
- $this->_currentCellIsDirty = false;\r
- }\r
- $this->_currentObjectID = $this->_currentObject = null;\r
- } // function _storeData()\r
-\r
-\r
- /**\r
- * Add or Update a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to update\r
- * @param PHPExcel_Cell $cell Cell to update\r
- * @return void\r
- * @throws PHPExcel_Exception\r
- */\r
- public function addCacheData($pCoord, PHPExcel_Cell $cell) {\r
- if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {\r
- $this->_storeData();\r
- }\r
-\r
- $this->_currentObjectID = $pCoord;\r
- $this->_currentObject = $cell;\r
- $this->_currentCellIsDirty = true;\r
-\r
- return $cell;\r
- } // function addCacheData()\r
-\r
-\r
- /**\r
- * Get cell at a specific coordinate\r
- *\r
- * @param string $pCoord Coordinate of the cell\r
- * @throws PHPExcel_Exception\r
- * @return PHPExcel_Cell Cell that was found, or null if not found\r
- */\r
- public function getCacheData($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- return $this->_currentObject;\r
- }\r
- $this->_storeData();\r
-\r
- $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);\r
- $cellResult = $this->_selectQuery->execute();\r
- if ($cellResult === FALSE) {\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
- }\r
- $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);\r
- if ($cellData === FALSE) {\r
- // Return null if requested entry doesn't exist in cache\r
- return NULL;\r
- }\r
-\r
- // Set current entry to the requested entry\r
- $this->_currentObjectID = $pCoord;\r
-\r
- $this->_currentObject = unserialize($cellData['value']);\r
- // Re-attach this as the cell's parent\r
- $this->_currentObject->attach($this);\r
-\r
- // Return requested entry\r
- return $this->_currentObject;\r
- } // function getCacheData()\r
-\r
-\r
- /**\r
- * Is a value set for an indexed cell?\r
- *\r
- * @param string $pCoord Coordinate address of the cell to check\r
- * @return boolean\r
- */\r
- public function isDataSet($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- return TRUE;\r
- }\r
-\r
- // Check if the requested entry exists in the cache\r
- $this->_selectQuery->bindValue('id',$pCoord,SQLITE3_TEXT);\r
- $cellResult = $this->_selectQuery->execute();\r
- if ($cellResult === FALSE) {\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
- }\r
- $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);\r
-\r
- return ($cellData === FALSE) ? FALSE : TRUE;\r
- } // function isDataSet()\r
-\r
-\r
- /**\r
- * Delete a cell in cache identified by coordinate address\r
- *\r
- * @param string $pCoord Coordinate address of the cell to delete\r
- * @throws PHPExcel_Exception\r
- */\r
- public function deleteCacheData($pCoord) {\r
- if ($pCoord === $this->_currentObjectID) {\r
- $this->_currentObject->detach();\r
- $this->_currentObjectID = $this->_currentObject = NULL;\r
- }\r
-\r
- // Check if the requested entry exists in the cache\r
- $this->_deleteQuery->bindValue('id',$pCoord,SQLITE3_TEXT);\r
- $result = $this->_deleteQuery->execute();\r
- if ($result === FALSE)\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
-\r
- $this->_currentCellIsDirty = FALSE;\r
- } // function deleteCacheData()\r
-\r
-\r
- /**\r
- * Move a cell object from one address to another\r
- *\r
- * @param string $fromAddress Current address of the cell to move\r
- * @param string $toAddress Destination address of the cell to move\r
- * @return boolean\r
- */\r
- public function moveCell($fromAddress, $toAddress) {\r
- if ($fromAddress === $this->_currentObjectID) {\r
- $this->_currentObjectID = $toAddress;\r
- }\r
-\r
- $this->_deleteQuery->bindValue('id',$toAddress,SQLITE3_TEXT);\r
- $result = $this->_deleteQuery->execute();\r
- if ($result === false)\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
-\r
- $this->_updateQuery->bindValue('toid',$toAddress,SQLITE3_TEXT);\r
- $this->_updateQuery->bindValue('fromid',$fromAddress,SQLITE3_TEXT);\r
- $result = $this->_updateQuery->execute();\r
- if ($result === false)\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
-\r
- return TRUE;\r
- } // function moveCell()\r
-\r
-\r
- /**\r
- * Get a list of all cell addresses currently held in cache\r
- *\r
- * @return array of string\r
- */\r
- public function getCellList() {\r
- if ($this->_currentObjectID !== null) {\r
- $this->_storeData();\r
- }\r
-\r
- $query = "SELECT id FROM kvp_".$this->_TableName;\r
- $cellIdsResult = $this->_DBHandle->query($query);\r
- if ($cellIdsResult === false)\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
-\r
- $cellKeys = array();\r
- while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {\r
- $cellKeys[] = $row['id'];\r
- }\r
-\r
- return $cellKeys;\r
- } // function getCellList()\r
-\r
-\r
- /**\r
- * Clone the cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The new worksheet\r
- * @return void\r
- */\r
- public function copyCellCollection(PHPExcel_Worksheet $parent) {\r
- $this->_currentCellIsDirty;\r
- $this->_storeData();\r
-\r
- // Get a new id for the new table name\r
- $tableName = str_replace('.','_',$this->_getUniqueID());\r
- if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)\r
- AS SELECT * FROM kvp_'.$this->_TableName))\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
-\r
- // Copy the existing cell cache file\r
- $this->_TableName = $tableName;\r
- } // function copyCellCollection()\r
-\r
-\r
- /**\r
- * Clear the cell collection and disconnect from our parent\r
- *\r
- * @return void\r
- */\r
- public function unsetWorksheetCells() {\r
- if(!is_null($this->_currentObject)) {\r
- $this->_currentObject->detach();\r
- $this->_currentObject = $this->_currentObjectID = null;\r
- }\r
- // detach ourself from the worksheet, so that it can then delete this object successfully\r
- $this->_parent = null;\r
-\r
- // Close down the temporary cache file\r
- $this->__destruct();\r
- } // function unsetWorksheetCells()\r
-\r
-\r
- /**\r
- * Initialise this new cell collection\r
- *\r
- * @param PHPExcel_Worksheet $parent The worksheet for this cell collection\r
- */\r
- public function __construct(PHPExcel_Worksheet $parent) {\r
- parent::__construct($parent);\r
- if (is_null($this->_DBHandle)) {\r
- $this->_TableName = str_replace('.','_',$this->_getUniqueID());\r
- $_DBName = ':memory:';\r
-\r
- $this->_DBHandle = new SQLite3($_DBName);\r
- if ($this->_DBHandle === false)\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
- if (!$this->_DBHandle->exec('CREATE TABLE kvp_'.$this->_TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)'))\r
- throw new PHPExcel_Exception($this->_DBHandle->lastErrorMsg());\r
- }\r
-\r
- $this->_selectQuery = $this->_DBHandle->prepare("SELECT value FROM kvp_".$this->_TableName." WHERE id = :id");\r
- $this->_insertQuery = $this->_DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->_TableName." VALUES(:id,:data)");\r
- $this->_updateQuery = $this->_DBHandle->prepare("UPDATE kvp_".$this->_TableName." SET id=:toId WHERE id=:fromId");\r
- $this->_deleteQuery = $this->_DBHandle->prepare("DELETE FROM kvp_".$this->_TableName." WHERE id = :id");\r
- } // function __construct()\r
-\r
-\r
- /**\r
- * Destroy this cell collection\r
- */\r
- public function __destruct() {\r
- if (!is_null($this->_DBHandle)) {\r
- $this->_DBHandle->exec('DROP TABLE kvp_'.$this->_TableName);\r
- $this->_DBHandle->close();\r
- }\r
- $this->_DBHandle = null;\r
- } // function __destruct()\r
-\r
-\r
- /**\r
- * Identify whether the caching method is currently available\r
- * Some methods are dependent on the availability of certain extensions being enabled in the PHP build\r
- *\r
- * @return boolean\r
- */\r
- public static function cacheMethodIsAvailable() {\r
- if (!class_exists('SQLite3',FALSE)) {\r
- return false;\r
- }\r
-\r
- return true;\r
- }\r
-\r
-}\r
+<?php
+
+/**
+ * PHPExcel_CachedObjectStorage_SQLite3
+ *
+ * Copyright (c) 2006 - 2015 PHPExcel
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * @category PHPExcel
+ * @package PHPExcel_CachedObjectStorage
+ * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
+ * @version ##VERSION##, ##DATE##
+ */
+class PHPExcel_CachedObjectStorage_SQLite3 extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache
+{
+ /**
+ * Database table name
+ *
+ * @var string
+ */
+ private $TableName = null;
+
+ /**
+ * Database handle
+ *
+ * @var resource
+ */
+ private $DBHandle = null;
+
+ /**
+ * Prepared statement for a SQLite3 select query
+ *
+ * @var SQLite3Stmt
+ */
+ private $selectQuery;
+
+ /**
+ * Prepared statement for a SQLite3 insert query
+ *
+ * @var SQLite3Stmt
+ */
+ private $insertQuery;
+
+ /**
+ * Prepared statement for a SQLite3 update query
+ *
+ * @var SQLite3Stmt
+ */
+ private $updateQuery;
+
+ /**
+ * Prepared statement for a SQLite3 delete query
+ *
+ * @var SQLite3Stmt
+ */
+ private $deleteQuery;
+
+ /**
+ * Store cell data in cache for the current cell object if it's "dirty",
+ * and the 'nullify' the current cell object
+ *
+ * @return void
+ * @throws PHPExcel_Exception
+ */
+ protected function storeData()
+ {
+ if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
+ $this->currentObject->detach();
+
+ $this->insertQuery->bindValue('id', $this->currentObjectID, SQLITE3_TEXT);
+ $this->insertQuery->bindValue('data', serialize($this->currentObject), SQLITE3_BLOB);
+ $result = $this->insertQuery->execute();
+ if ($result === false) {
+ throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
+ }
+ $this->currentCellIsDirty = false;
+ }
+ $this->currentObjectID = $this->currentObject = null;
+ }
+
+ /**
+ * Add or Update a cell in cache identified by coordinate address
+ *
+ * @param string $pCoord Coordinate address of the cell to update
+ * @param PHPExcel_Cell $cell Cell to update
+ * @return PHPExcel_Cell
+ * @throws PHPExcel_Exception
+ */
+ public function addCacheData($pCoord, PHPExcel_Cell $cell)
+ {
+ if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
+ $this->storeData();
+ }
+
+ $this->currentObjectID = $pCoord;
+ $this->currentObject = $cell;
+ $this->currentCellIsDirty = true;
+
+ return $cell;
+ }
+
+ /**
+ * Get cell at a specific coordinate
+ *
+ * @param string $pCoord Coordinate of the cell
+ * @throws PHPExcel_Exception
+ * @return PHPExcel_Cell Cell that was found, or null if not found
+ */
+ public function getCacheData($pCoord)
+ {
+ if ($pCoord === $this->currentObjectID) {
+ return $this->currentObject;
+ }
+ $this->storeData();
+
+ $this->selectQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
+ $cellResult = $this->selectQuery->execute();
+ if ($cellResult === false) {
+ throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
+ }
+ $cellData = $cellResult->fetchArray(SQLITE3_ASSOC);
+&