lib/adodb/
lib/bennu/
lib/evalmath/
-lib/phpexcel/
+lib/phpspreadsheet/
lib/google/
lib/htmlpurifier/
lib/jabber/
lib/adodb/
lib/bennu/
lib/evalmath/
-lib/phpexcel/
+lib/phpspreadsheet/
lib/google/
lib/htmlpurifier/
lib/jabber/
defined('MOODLE_INTERNAL') || die();
+require_once("$CFG->libdir/phpspreadsheet/vendor/autoload.php");
+
+use \PhpOffice\PhpSpreadsheet\Spreadsheet;
+use \PhpOffice\PhpSpreadsheet\IOFactory;
+use \PhpOffice\PhpSpreadsheet\Cell\Coordinate;
+use \PhpOffice\PhpSpreadsheet\Cell\DataType;
+use \PhpOffice\PhpSpreadsheet\Shared\Date;
+use \PhpOffice\PhpSpreadsheet\Style\Alignment;
+use \PhpOffice\PhpSpreadsheet\Style\Border;
+use \PhpOffice\PhpSpreadsheet\Style\Fill;
+use \PhpOffice\PhpSpreadsheet\Style\Font;
+use \PhpOffice\PhpSpreadsheet\Style\NumberFormat;
+use \PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
+use \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
+
/**
* Define and operate over one Moodle Workbook.
*
* @package moodlecore
*/
class MoodleExcelWorkbook {
- /** @var PHPExcel */
- protected $objPHPExcel;
+ /** @var PhpSpreadsheet */
+ protected $objspreadsheet;
/** @var string */
protected $filename;
* Constructs one Moodle Workbook.
*
* @param string $filename The name of the file
- * @param string $type file format type used to be 'Excel5 or Excel2007' but now only 'Excel2007'
+ * @param string $type file format type used to be 'Xls or Xlsx' but now only 'Xlsx'
*/
- public function __construct($filename, $type = 'Excel2007') {
+ public function __construct($filename, $type = 'Xlsx') {
global $CFG;
- require_once("$CFG->libdir/phpexcel/PHPExcel.php");
- $this->objPHPExcel = new PHPExcel();
- $this->objPHPExcel->removeSheetByIndex(0);
+ $this->objspreadsheet = new Spreadsheet();
+ $this->objspreadsheet->removeSheetByIndex(0);
$this->filename = $filename;
- if (strtolower($type) === 'excel5') {
- debugging('Excel5 is no longer supported, using Excel2007 instead');
- $this->type = 'Excel2007';
+ if (strtolower($type) === 'Xls') {
+ debugging('Xls is no longer supported, using Xlsx instead');
+ $this->type = 'Xlsx';
} else {
- $this->type = 'Excel2007';
+ $this->type = 'Xlsx';
}
}
* @return MoodleExcelWorksheet
*/
public function add_worksheet($name = '') {
- return new MoodleExcelWorksheet($name, $this->objPHPExcel);
+ return new MoodleExcelWorksheet($name, $this->objspreadsheet);
}
/**
public function close() {
global $CFG;
- foreach ($this->objPHPExcel->getAllSheets() as $sheet){
+ foreach ($this->objspreadsheet->getAllSheets() as $sheet){
$sheet->setSelectedCells('A1');
}
- $this->objPHPExcel->setActiveSheetIndex(0);
+ $this->objspreadsheet->setActiveSheetIndex(0);
$filename = preg_replace('/\.xlsx?$/i', '', $this->filename);
header('Content-Type: '.$mimetype);
header('Content-Disposition: attachment;filename="'.$filename.'"');
- $objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, $this->type);
+ $objWriter = IOFactory::createWriter($this->objspreadsheet, $this->type);
$objWriter->save('php://output');
}
* @package core
*/
class MoodleExcelWorksheet {
- /** @var PHPExcel_Worksheet */
+ /** @var Worksheet */
protected $worksheet;
/**
* Constructs one Moodle Worksheet.
*
* @param string $name The name of the file
- * @param PHPExcel $workbook The internal Workbook object we are creating.
+ * @param Spreadsheet $workbook The internal Workbook object we are creating.
*/
- public function __construct($name, PHPExcel $workbook) {
+ public function __construct($name, Spreadsheet $workbook) {
// Replace any characters in the name that Excel cannot cope with.
$name = strtr(trim($name, "'"), '[]*/\?:', ' ');
// Shorten the title if necessary.
$name = 'Sheet'.($workbook->getSheetCount()+1);
}
- $this->worksheet = new PHPExcel_Worksheet($workbook, $name);
+ $this->worksheet = new Worksheet($workbook, $name);
$this->worksheet->setPrintGridlines(false);
$workbook->addSheet($this->worksheet);
* @param mixed $format The XF format for the cell
*/
public function write_string($row, $col, $str, $format = null) {
- $this->worksheet->getStyleByColumnAndRow($col, $row+1)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
- $this->worksheet->setCellValueExplicitByColumnAndRow($col, $row+1, $str, PHPExcel_Cell_DataType::TYPE_STRING);
+ // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
+ $col += 1;
+
+ $this->worksheet->getStyleByColumnAndRow($col, $row+1)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
+ $this->worksheet->setCellValueExplicitByColumnAndRow($col, $row+1, $str, DataType::TYPE_STRING);
$this->apply_format($row, $col, $format);
}
* @param mixed $format The XF format for the cell
*/
public function write_number($row, $col, $num, $format = null) {
- $this->worksheet->getStyleByColumnAndRow($col, $row+1)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_GENERAL);
- $this->worksheet->setCellValueExplicitByColumnAndRow($col, $row+1, $num, PHPExcel_Cell_DataType::TYPE_NUMERIC);
+ // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
+ $col += 1;
+
+ $this->worksheet->getStyleByColumnAndRow($col, $row+1)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_GENERAL);
+ $this->worksheet->setCellValueExplicitByColumnAndRow($col, $row+1, $num, DataType::TYPE_NUMERIC);
$this->apply_format($row, $col, $format);
}
* @param mixed $format The XF format for the cell
*/
public function write_url($row, $col, $url, $format = null) {
+ // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
+ $col += 1;
+
$this->worksheet->setCellValueByColumnAndRow($col, $row+1, $url);
$this->worksheet->getCellByColumnAndRow($col, $row+1)->getHyperlink()->setUrl($url);
$this->apply_format($row, $col, $format);
* @param mixed $format The XF format for the cell
*/
public function write_date($row, $col, $date, $format = null) {
+ // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
+ $col += 1;
+
$getdate = usergetdate($date);
- $exceldate = PHPExcel_Shared_Date::FormattedPHPToExcel(
+ $exceldate = Date::FormattedPHPToExcel(
$getdate['year'],
$getdate['mon'],
$getdate['mday'],
);
$this->worksheet->setCellValueByColumnAndRow($col, $row+1, $exceldate);
- $this->worksheet->getStyleByColumnAndRow($col, $row+1)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX22);
+ $this->worksheet->getStyleByColumnAndRow($col, $row+1)->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_DATE_XLSX22);
$this->apply_format($row, $col, $format);
}
* @param mixed $format The XF format for the cell
*/
public function write_formula($row, $col, $formula, $format = null) {
- $this->worksheet->setCellValueExplicitByColumnAndRow($col, $row+1, $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
+ // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
+ $col += 1;
+
+ $this->worksheet->setCellValueExplicitByColumnAndRow($col, $row+1, $formula, DataType::TYPE_FORMULA);
$this->apply_format($row, $col, $format);
}
* @param mixed $format The XF format for the cell
*/
public function write_blank($row, $col, $format = null) {
+ // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
+ $col += 1;
+
$this->worksheet->setCellValueByColumnAndRow($col, $row+1, '');
$this->apply_format($row, $col, $format);
}
} else if ($level > 7) {
$level = 7;
}
- $i = $firstcol;
- while($i <= $lastcol) {
+ // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
+ $i = $firstcol + 1;
+ while($i <= $lastcol + 1) {
if (isset($width)) {
$this->worksheet->getColumnDimensionByColumn($i)->setWidth($width);
}
* @param integer $scale_y The vertical scale
*/
public function insert_bitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1) {
- $objDrawing = new PHPExcel_Worksheet_Drawing();
+ // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
+ $col += 1;
+
+ $objDrawing = new Drawing();
$objDrawing->setPath($bitmap);
- $objDrawing->setCoordinates(PHPExcel_Cell::stringFromColumnIndex($col) . ($row+1));
+ $objDrawing->setCoordinates(Coordinate::stringFromColumnIndex($col) . ($row+1));
$objDrawing->setOffsetX($x);
$objDrawing->setOffsetY($y);
$objDrawing->setWorksheet($this->worksheet);
* @param integer $last_col Last column of the area to merge
*/
public function merge_cells($first_row, $first_col, $last_row, $last_col) {
- $this->worksheet->mergeCellsByColumnAndRow($first_col, $first_row+1, $last_col, $last_row+1);
+ // For PhpSpreadsheet library, the column indexes start on 1 (instead of 0 as before).
+ $this->worksheet->mergeCellsByColumnAndRow($first_col + 1, $first_row+1, $last_col + 1, $last_row+1);
}
protected function apply_format($row, $col, $format = null) {
} else if (is_array($format)) {
$format = new MoodleExcelFormat($format);
}
- $this->worksheet->getStyle(PHPExcel_Cell::stringFromColumnIndex($col))->applyFromArray($format->get_format_array());
+ $this->worksheet->getStyle(Coordinate::stringFromColumnIndex($col))->applyFromArray($format->get_format_array());
}
protected function apply_row_format($row, $format = null) {
*/
public function set_underline($underline) {
if ($underline == 1) {
- $this->format['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE;
+ $this->format['font']['underline'] = Font::UNDERLINE_SINGLE;
} else if ($underline == 2) {
- $this->format['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_DOUBLE;
+ $this->format['font']['underline'] = Font::UNDERLINE_DOUBLE;
} else {
- $this->format['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE;
+ $this->format['font']['underline'] = Font::UNDERLINE_NONE;
}
}
* Set strikeout of the format.
*/
public function set_strikeout() {
- $this->format['font']['strike'] = true;
+ $this->format['font']['strikethrough'] = true;
}
/**
*/
public function set_script($script) {
if ($script == 1) {
- $this->format['font']['superScript'] = true;
+ $this->format['font']['superscript'] = true;
} else if ($script == 2) {
- $this->format['font']['subScript'] = true;
+ $this->format['font']['subscript'] = true;
} else {
- $this->format['font']['superScript'] = false;
- $this->format['font']['subScript'] = false;
+ $this->format['font']['superscript'] = false;
+ $this->format['font']['subscript'] = false;
}
}
* @param mixed $color either a string (like 'blue'), or an integer (range is [8...63])
*/
public function set_bg_color($color) {
- if (!isset($this->format['fill']['type'])) {
- $this->format['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
+ if (!isset($this->format['fill']['fillType'])) {
+ $this->format['fill']['fillType'] = Fill::FILL_SOLID;
}
$this->format['fill']['color']['rgb'] = $this->parse_color($color);
}
}
} else {
unset($this->format['fill']['color']['rgb']);
- unset($this->format['fill']['type']);
+ unset($this->format['fill']['fillType']);
}
}
* Set text wrap of the format.
*/
public function set_text_wrap() {
- $this->format['alignment']['wrap'] = true;
+ $this->format['alignment']['wrapText'] = true;
}
/**
public function set_h_align($location) {
switch ($location) {
case 'left':
- $this->format['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_LEFT;
+ $this->format['alignment']['horizontal'] = Alignment::HORIZONTAL_LEFT;
break;
case 'center':
case 'centre':
- $this->format['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_CENTER;
+ $this->format['alignment']['horizontal'] = Alignment::HORIZONTAL_CENTER;
break;
case 'right':
- $this->format['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_RIGHT;
+ $this->format['alignment']['horizontal'] = Alignment::HORIZONTAL_RIGHT;
break;
case 'justify':
- $this->format['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY;
+ $this->format['alignment']['horizontal'] = Alignment::HORIZONTAL_JUSTIFY;
break;
default:
- $this->format['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
+ $this->format['alignment']['horizontal'] = Alignment::HORIZONTAL_GENERAL;
}
}
public function set_v_align($location) {
switch ($location) {
case 'top':
- $this->format['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP;
+ $this->format['alignment']['vertical'] = Alignment::VERTICAL_TOP;
break;
case 'vcentre':
case 'vcenter':
case 'centre':
case 'center':
- $this->format['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_CENTER;
+ $this->format['alignment']['vertical'] = Alignment::VERTICAL_CENTER;
break;
case 'vjustify':
case 'justify':
- $this->format['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_JUSTIFY;
+ $this->format['alignment']['vertical'] = Alignment::VERTICAL_JUSTIFY;
break;
default:
- $this->format['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
+ $this->format['alignment']['vertical'] = Alignment::VERTICAL_BOTTOM;
}
}
*/
public function set_top($style) {
if ($style == 1) {
- $this->format['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
+ $this->format['borders']['top']['borderStyle'] = Border::BORDER_THIN;
} else if ($style == 2) {
- $this->format['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THICK;
+ $this->format['borders']['top']['borderStyle'] = Border::BORDER_THICK;
} else {
- $this->format['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_NONE;
+ $this->format['borders']['top']['borderStyle'] = Border::BORDER_NONE;
}
}
*/
public function set_bottom($style) {
if ($style == 1) {
- $this->format['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
+ $this->format['borders']['bottom']['borderStyle'] = Border::BORDER_THIN;
} else if ($style == 2) {
- $this->format['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THICK;
+ $this->format['borders']['bottom']['borderStyle'] = Border::BORDER_THICK;
} else {
- $this->format['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_NONE;
+ $this->format['borders']['bottom']['borderStyle'] = Border::BORDER_NONE;
}
}
*/
public function set_left($style) {
if ($style == 1) {
- $this->format['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
+ $this->format['borders']['left']['borderStyle'] = Border::BORDER_THIN;
} else if ($style == 2) {
- $this->format['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THICK;
+ $this->format['borders']['left']['borderStyle'] = Border::BORDER_THICK;
} else {
- $this->format['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_NONE;
+ $this->format['borders']['left']['borderStyle'] = Border::BORDER_NONE;
}
}
*/
public function set_right($style) {
if ($style == 1) {
- $this->format['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
+ $this->format['borders']['right']['borderStyle'] = Border::BORDER_THIN;
} else if ($style == 2) {
- $this->format['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THICK;
+ $this->format['borders']['right']['borderStyle'] = Border::BORDER_THICK;
} else {
- $this->format['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_NONE;
+ $this->format['borders']['right']['borderStyle'] = Border::BORDER_NONE;
}
}
$numbers[49] = '@';
if ($num_format !== 0 and in_array($num_format, $numbers)) {
- $this->format['numberformat']['code'] = $num_format;
+ $this->format['numberFormat']['formatCode'] = $num_format;
}
if (!isset($numbers[$num_format])) {
return;
}
- $this->format['numberformat']['code'] = $numbers[$num_format];
+ $this->format['numberFormat']['formatCode'] = $numbers[$num_format];
}
}
+++ /dev/null
-<?php
-
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
- require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
-}
-
-/**
- * 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
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * @category PHPExcel
- * @package PHPExcel
- * @copyright Copyright (c) 2006 - 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
-{
- /**
- * Unique ID
- *
- * @var string
- */
- private $uniqueID;
-
- /**
- * Document properties
- *
- * @var PHPExcel_DocumentProperties
- */
- private $properties;
-
- /**
- * Document security
- *
- * @var PHPExcel_DocumentSecurity
- */
- private $security;
-
- /**
- * Collection of Worksheet objects
- *
- * @var PHPExcel_Worksheet[]
- */
- private $workSheetCollection = array();
-
- /**
- * Calculation Engine
- *
- * @var PHPExcel_Calculation
- */
- private $calculationEngine;
-
- /**
- * Active sheet index
- *
- * @var integer
- */
- private $activeSheetIndex = 0;
-
- /**
- * Named ranges
- *
- * @var PHPExcel_NamedRange[]
- */
- private $namedRanges = array();
-
- /**
- * CellXf supervisor
- *
- * @var PHPExcel_Style
- */
- private $cellXfSupervisor;
-
- /**
- * CellXf collection
- *
- * @var PHPExcel_Style[]
- */
- 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;
- /**
- * 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
- * @return boolean
- */
- public function sheetCodeNameExists($pSheetCodeName)
- {
- 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;
-
- // Create document properties
- $this->properties = new PHPExcel_DocumentProperties();
-
- // Create document security
- $this->security = new PHPExcel_DocumentSecurity();
-
- // Set named ranges
- $this->namedRanges = array();
-
- // Create the cellXf supervisor
- $this->cellXfSupervisor = new PHPExcel_Style(true);
- $this->cellXfSupervisor->bindParent($this);
-
- // Create the default style
- $this->addCellXf(new PHPExcel_Style);
- $this->addCellStyleXf(new PHPExcel_Style);
- }
-
- /**
- * Code to execute when this worksheet is unset()
- *
- */
- public function __destruct()
- {
- PHPExcel_Calculation::unsetInstance($this);
- $this->disconnectWorksheets();
- }
-
- /**
- * Disconnect all worksheets from this PHPExcel workbook object,
- * typically so that the PHPExcel object can be unset
- *
- */
- public function disconnectWorksheets()
- {
- $worksheet = null;
- foreach ($this->workSheetCollection as $k => &$worksheet) {
- $worksheet->disconnectCells();
- $this->workSheetCollection[$k] = null;
- }
- unset($worksheet);
- $this->workSheetCollection = array();
- }
-
- /**
- * Return the calculation engine for this worksheet
- *
- * @return PHPExcel_Calculation
- */
- public function getCalculationEngine()
- {
- return $this->calculationEngine;
- } // function getCellCacheController()
-
- /**
- * Get properties
- *
- * @return PHPExcel_DocumentProperties
- */
- public function getProperties()
- {
- return $this->properties;
- }
-
- /**
- * Set properties
- *
- * @param PHPExcel_DocumentProperties $pValue
- */
- public function setProperties(PHPExcel_DocumentProperties $pValue)
- {
- $this->properties = $pValue;
- }
-
- /**
- * Get security
- *
- * @return PHPExcel_DocumentSecurity
- */
- public function getSecurity()
- {
- return $this->security;
- }
-
- /**
- * Set security
- *
- * @param PHPExcel_DocumentSecurity $pValue
- */
- public function setSecurity(PHPExcel_DocumentSecurity $pValue)
- {
- $this->security = $pValue;
- }
-
- /**
- * Get active sheet
- *
- * @return PHPExcel_Worksheet
- *
- * @throws PHPExcel_Exception
- */
- public function getActiveSheet()
- {
- return $this->getSheet($this->activeSheetIndex);
- }
-
- /**
- * Create sheet and add it to this workbook
- *
- * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
- * @return PHPExcel_Worksheet
- * @throws PHPExcel_Exception
- */
- public function createSheet($iSheetIndex = null)
- {
- $newSheet = new PHPExcel_Worksheet($this);
- $this->addSheet($newSheet, $iSheetIndex);
- return $newSheet;
- }
-
- /**
- * Check if a sheet with a specified name already exists
- *
- * @param string $pSheetName Name of the worksheet to check
- * @return boolean
- */
- public function sheetNameExists($pSheetName)
- {
- return ($this->getSheetByName($pSheetName) !== null);
- }
-
- /**
- * Add sheet
- *
- * @param PHPExcel_Worksheet $pSheet
- * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
- * @return PHPExcel_Worksheet
- * @throws PHPExcel_Exception
- */
- 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."
- );
- }
-
- if ($iSheetIndex === null) {
- if ($this->activeSheetIndex < 0) {
- $this->activeSheetIndex = 0;
- }
- $this->workSheetCollection[] = $pSheet;
- } else {
- // Insert the sheet at the requested index
- array_splice(
- $this->workSheetCollection,
- $iSheetIndex,
- 0,
- array($pSheet)
- );
-
- // Adjust active sheet index if necessary
- if ($this->activeSheetIndex >= $iSheetIndex) {
- ++$this->activeSheetIndex;
- }
- }
-
- if ($pSheet->getParent() === null) {
- $pSheet->rebindParent($this);
- }
-
- return $pSheet;
- }
-
- /**
- * Remove sheet by index
- *
- * @param int $pIndex Active sheet index
- * @throws PHPExcel_Exception
- */
- public function removeSheetByIndex($pIndex = 0)
- {
-
- $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}."
- );
- } else {
- array_splice($this->workSheetCollection, $pIndex, 1);
- }
- // Adjust active sheet index if necessary
- if (($this->activeSheetIndex >= $pIndex) &&
- ($pIndex > count($this->workSheetCollection) - 1)) {
- --$this->activeSheetIndex;
- }
-
- }
-
- /**
- * Get sheet by index
- *
- * @param int $pIndex Sheet index
- * @return PHPExcel_Worksheet
- * @throws PHPExcel_Exception
- */
- public function getSheet($pIndex = 0)
- {
- 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}."
- );
- }
-
- return $this->workSheetCollection[$pIndex];
- }
-
- /**
- * Get all sheets
- *
- * @return PHPExcel_Worksheet[]
- */
- public function getAllSheets()
- {
- return $this->workSheetCollection;
- }
-
- /**
- * Get sheet by name
- *
- * @param string $pName Sheet name
- * @return PHPExcel_Worksheet
- */
- public function getSheetByName($pName = '')
- {
- $worksheetCount = count($this->workSheetCollection);
- for ($i = 0; $i < $worksheetCount; ++$i) {
- if ($this->workSheetCollection[$i]->getTitle() === $pName) {
- return $this->workSheetCollection[$i];
- }
- }
-
- return null;
- }
-
- /**
- * Get index for sheet
- *
- * @param PHPExcel_Worksheet $pSheet
- * @return Sheet index
- * @throws PHPExcel_Exception
- */
- public function getIndex(PHPExcel_Worksheet $pSheet)
- {
- foreach ($this->workSheetCollection as $key => $value) {
- if ($value->getHashCode() == $pSheet->getHashCode()) {
- return $key;
- }
- }
-
- throw new PHPExcel_Exception("Sheet does not exist.");
- }
-
- /**
- * Set index for sheet by sheet name.
- *
- * @param string $sheetName Sheet name to modify index for
- * @param int $newIndex New index for the sheet
- * @return New sheet index
- * @throws PHPExcel_Exception
- */
- public function setIndexByName($sheetName, $newIndex)
- {
- $oldIndex = $this->getIndex($this->getSheetByName($sheetName));
- $pSheet = array_splice(
- $this->workSheetCollection,
- $oldIndex,
- 1
- );
- array_splice(
- $this->workSheetCollection,
- $newIndex,
- 0,
- $pSheet
- );
- return $newIndex;
- }
-
- /**
- * Get sheet count
- *
- * @return int
- */
- public function getSheetCount()
- {
- return count($this->workSheetCollection);
- }
-
- /**
- * Get active sheet index
- *
- * @return int Active sheet index
- */
- public function getActiveSheetIndex()
- {
- return $this->activeSheetIndex;
- }
-
- /**
- * Set active sheet index
- *
- * @param int $pIndex Active sheet index
- * @throws PHPExcel_Exception
- * @return PHPExcel_Worksheet
- */
- public function setActiveSheetIndex($pIndex = 0)
- {
- $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}."
- );
- } else {
- $this->activeSheetIndex = $pIndex;
- }
- return $this->getActiveSheet();
- }
-
- /**
- * Set active sheet index by name
- *
- * @param string $pValue Sheet title
- * @return PHPExcel_Worksheet
- * @throws PHPExcel_Exception
- */
- public function setActiveSheetIndexByName($pValue = '')
- {
- if (($worksheet = $this->getSheetByName($pValue)) instanceof PHPExcel_Worksheet) {
- $this->setActiveSheetIndex($this->getIndex($worksheet));
- return $worksheet;
- }
-
- throw new PHPExcel_Exception('Workbook does not contain sheet:' . $pValue);
- }
-
- /**
- * Get sheet names
- *
- * @return string[]
- */
- public function getSheetNames()
- {
- $returnValue = array();
- $worksheetCount = $this->getSheetCount();
- for ($i = 0; $i < $worksheetCount; ++$i) {
- $returnValue[] = $this->getSheet($i)->getTitle();
- }
-
- return $returnValue;
- }
-
- /**
- * Add external sheet
- *
- * @param PHPExcel_Worksheet $pSheet External sheet to add
- * @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
- * @throws PHPExcel_Exception
- * @return PHPExcel_Worksheet
- */
- 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);
-
- // copy all the shared cellXfs from the external workbook and append them to the current
- foreach ($pSheet->getParent()->getCellXfCollection() as $cellXf) {
- $this->addCellXf(clone $cellXf);
- }
-
- // move sheet to this workbook
- $pSheet->rebindParent($this);
-
- // update the cellXfs
- foreach ($pSheet->getCellCollection(false) as $cellID) {
- $cell = $pSheet->getCell($cellID);
- $cell->setXfIndex($cell->getXfIndex() + $countCellXfs);
- }
-
- return $this->addSheet($pSheet, $iSheetIndex);
- }
-
- /**
- * Get named ranges
- *
- * @return PHPExcel_NamedRange[]
- */
- public function getNamedRanges()
- {
- return $this->namedRanges;
- }
-
- /**
- * Add named range
- *
- * @param PHPExcel_NamedRange $namedRange
- * @return PHPExcel
- */
- public function addNamedRange(PHPExcel_NamedRange $namedRange)
- {
- if ($namedRange->getScope() == null) {
- // global scope
- $this->namedRanges[$namedRange->getName()] = $namedRange;
- } else {
- // local scope
- $this->namedRanges[$namedRange->getScope()->getTitle().'!'.$namedRange->getName()] = $namedRange;
- }
- return true;
- }
-
- /**
- * Get named range
- *
- * @param string $namedRange
- * @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
- * @return PHPExcel_NamedRange|null
- */
- public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null)
- {
- $returnValue = null;
-
- if ($namedRange != '' && ($namedRange !== null)) {
- // first look for global defined name
- 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];
- }
- }
-
- return $returnValue;
- }
-
- /**
- * Remove named range
- *
- * @param string $namedRange
- * @param PHPExcel_Worksheet|null $pSheet Scope: use null for global scope.
- * @return PHPExcel
- */
- public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null)
- {
- if ($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]);
- }
- }
- return $this;
- }
-
- /**
- * Get worksheet iterator
- *
- * @return PHPExcel_WorksheetIterator
- */
- public function getWorksheetIterator()
- {
- return new PHPExcel_WorksheetIterator($this);
- }
-
- /**
- * Copy workbook (!= clone!)
- *
- * @return PHPExcel
- */
- public function copy()
- {
- $copied = clone $this;
-
- $worksheetCount = count($this->workSheetCollection);
- for ($i = 0; $i < $worksheetCount; ++$i) {
- $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) {
- if (is_object($val) || (is_array($val))) {
- $this->{$key} = unserialize(serialize($val));
- }
- }
- }
-
- /**
- * Get the workbook collection of cellXfs
- *
- * @return PHPExcel_Style[]
- */
- public function getCellXfCollection()
- {
- return $this->cellXfCollection;
- }
-
- /**
- * Get cellXf by index
- *
- * @param int $pIndex
- * @return PHPExcel_Style
- */
- public function getCellXfByIndex($pIndex = 0)
- {
- return $this->cellXfCollection[$pIndex];
- }
-
- /**
- * Get cellXf by hash code
- *
- * @param string $pValue
- * @return PHPExcel_Style|false
- */
- public function getCellXfByHashCode($pValue = '')
- {
- foreach ($this->cellXfCollection as $cellXf) {
- if ($cellXf->getHashCode() == $pValue) {
- return $cellXf;
- }
- }
- return false;
- }
-
- /**
- * Check if style exists in style collection
- *
- * @param PHPExcel_Style $pCellStyle
- * @return boolean
- */
- public function cellXfExists($pCellStyle = null)
- {
- return in_array($pCellStyle, $this->cellXfCollection, true);
- }
-
- /**
- * Get default style
- *
- * @return PHPExcel_Style
- * @throws PHPExcel_Exception
- */
- public function getDefaultStyle()
- {
- if (isset($this->cellXfCollection[0])) {
- return $this->cellXfCollection[0];
- }
- throw new PHPExcel_Exception('No default style found for this workbook');
- }
-
- /**
- * Add a cellXf to the workbook
- *
- * @param PHPExcel_Style $style
- */
- public function addCellXf(PHPExcel_Style $style)
- {
- $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 integer $pIndex Index to cellXf
- * @throws PHPExcel_Exception
- */
- public function removeCellXfByIndex($pIndex = 0)
- {
- 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);
-
- // then update cellXf indexes for cells
- foreach ($this->workSheetCollection as $worksheet) {
- foreach ($worksheet->getCellCollection(false) as $cellID) {
- $cell = $worksheet->getCell($cellID);
- $xfIndex = $cell->getXfIndex();
- if ($xfIndex > $pIndex) {
- // decrease xf index by 1
- $cell->setXfIndex($xfIndex - 1);
- } elseif ($xfIndex == $pIndex) {
- // set to default xf index 0
- $cell->setXfIndex(0);
- }
- }
- }
- }
- }
-
- /**
- * Get the cellXf supervisor
- *
- * @return PHPExcel_Style
- */
- public function getCellXfSupervisor()
- {
- return $this->cellXfSupervisor;
- }
-
- /**
- * Get the workbook collection of cellStyleXfs
- *
- * @return PHPExcel_Style[]
- */
- public function getCellStyleXfCollection()
- {
- return $this->cellStyleXfCollection;
- }
-
- /**
- * Get cellStyleXf by index
- *
- * @param integer $pIndex Index to cellXf
- * @return PHPExcel_Style
- */
- public function getCellStyleXfByIndex($pIndex = 0)
- {
- return $this->cellStyleXfCollection[$pIndex];
- }
-
- /**
- * Get cellStyleXf by hash code
- *
- * @param string $pValue
- * @return PHPExcel_Style|false
- */
- public function getCellStyleXfByHashCode($pValue = '')
- {
- foreach ($this->cellStyleXfCollection as $cellStyleXf) {
- if ($cellStyleXf->getHashCode() == $pValue) {
- return $cellStyleXf;
- }
- }
- return false;
- }
-
- /**
- * Add a cellStyleXf to the workbook
- *
- * @param PHPExcel_Style $pStyle
- */
- public function addCellStyleXf(PHPExcel_Style $pStyle)
- {
- $this->cellStyleXfCollection[] = $pStyle;
- $pStyle->setIndex(count($this->cellStyleXfCollection) - 1);
- }
-
- /**
- * Remove cellStyleXf by index
- *
- * @param integer $pIndex Index to cellXf
- * @throws PHPExcel_Exception
- */
- public function removeCellStyleXfByIndex($pIndex = 0)
- {
- if ($pIndex > count($this->cellStyleXfCollection) - 1) {
- throw new PHPExcel_Exception("CellStyleXf index is out of bounds.");
- } else {
- array_splice($this->cellStyleXfCollection, $pIndex, 1);
- }
- }
-
- /**
- * Eliminate all unneeded cellXf and afterwards update the xfIndex for all cells
- * and columns in the workbook
- */
- public function garbageCollect()
- {
- // how many references are there to each cellXf ?
- $countReferencesCellXf = array();
- 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);
- ++$countReferencesCellXf[$cell->getXfIndex()];
- }
-
- // from row dimensions
- foreach ($sheet->getRowDimensions() as $rowDimension) {
- if ($rowDimension->getXfIndex() !== null) {
- ++$countReferencesCellXf[$rowDimension->getXfIndex()];
- }
- }
-
- // from column dimensions
- foreach ($sheet->getColumnDimensions() as $columnDimension) {
- ++$countReferencesCellXf[$columnDimension->getXfIndex()];
- }
- }
-
- // 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) {
- if ($countReferencesCellXf[$index] > 0 || $index == 0) { // we must never remove the first cellXf
- ++$countNeededCellXfs;
- } else {
- unset($this->cellXfCollection[$index]);
- }
- $map[$index] = $countNeededCellXfs - 1;
- }
- $this->cellXfCollection = array_values($this->cellXfCollection);
-
- // update the index for all cellXfs
- 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();
- }
-
- // 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()]);
- }
-
- // for all row dimensions
- foreach ($sheet->getRowDimensions() as $rowDimension) {
- if ($rowDimension->getXfIndex() !== null) {
- $rowDimension->setXfIndex($map[$rowDimension->getXfIndex()]);
- }
- }
-
- // for all column dimensions
- foreach ($sheet->getColumnDimensions() as $columnDimension) {
- $columnDimension->setXfIndex($map[$columnDimension->getXfIndex()]);
- }
-
- // also do garbage collection for all the sheets
- $sheet->garbageCollect();
- }
- }
-
- /**
- * Return the unique ID value assigned to this spreadsheet workbook
- *
- * @return string
- */
- public function getID()
- {
- return $this->uniqueID;
- }
-}
+++ /dev/null
-<?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 - 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
- * @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_Autoloader
-{
- /**
- * Register the Autoloader with SPL
- *
- */
- public static function register()
- {
- if (function_exists('__autoload')) {
- // Register any existing autoloader function with SPL, so we don't get any clashes
- spl_autoload_register('__autoload');
- }
- // 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;
- }
-
- $pClassFilePath = PHPEXCEL_ROOT .
- str_replace('_', DIRECTORY_SEPARATOR, $pClassName) .
- '.php';
-
- if ((file_exists($pClassFilePath) === false) || (is_readable($pClassFilePath) === false)) {
- // Can't load
- return false;
- }
-
- require($pClassFilePath);
- }
-}
+++ /dev/null
-<?php
-
-/**
- * PHPExcel_CachedObjectStorage_APC
- *
- * 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_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;
-
- /**
- * Cache timeout
- *
- * @access private
- * @var integer
- */
- private $cacheTime = 600;
-
- /**
- * Store cell data in cache for the current cell object if it's "dirty",
- * and the 'nullify' the current cell object
- *
- * @access private
- * @return void
- * @throws 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
- )) {
- $this->__destruct();
- throw new PHPExcel_Exception('Failed to store cell ' . $this->currentObjectID . ' in APC');
- }
- $this->currentCellIsDirty = false;
- }
- $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 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;
- }
-
- /**
- * 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
- * @throws PHPExcel_Exception
- * @return boolean
- */
- public function isDataSet($pCoord)
- {
- // Check if the requested entry is the current object, or exists in the cache
- if (parent::isDataSet($pCoord)) {
- if ($this->currentObjectID == $pCoord) {
- return true;
- }
- // Check if the requested entry still exists in apc
- $success = apc_fetch($this->cachePrefix.$pCoord.'.cache');
- if ($success === false) {
- // Entry no longer exists in APC, so clear it from the cache array
- parent::deleteCacheData($pCoord);
- throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
- }
- return true;
- }
- return false;
- }
-
- /**
- * Get cell at a specific coordinate
- *
- * @access public
- * @param string $pCoord Coordinate of the cell
- * @throws PHPExcel_Exception
- * @return PHPExcel_Cell Cell that was found, or null if not found
- */
- public function getCacheData($pCoord)
- {
- if ($pCoord === $this->currentObjectID) {
- return $this->currentObject;
- }
- $this->storeData();
-
- // Check if the entry that has been requested actually exists
- if (parent::isDataSet($pCoord)) {
- $obj = apc_fetch($this->cachePrefix . $pCoord . '.cache');
- if ($obj === false) {
- // Entry no longer exists in APC, so clear it from the cache array
- parent::deleteCacheData($pCoord);
- throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in APC cache');
- }
- } else {
- // Return null if requested entry doesn't exist in cache
- return null;
- }
-
- // Set current entry to the requested entry
- $this->currentObjectID = $pCoord;
- $this->currentObject = unserialize($obj);
- // Re-attach 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
- *
- * @access public
- * @param string $pCoord Coordinate address of the cell to delete
- * @throws PHPExcel_Exception
- */
- public function deleteCacheData($pCoord)
- {
- // Delete the entry from APC
- apc_delete($this->cachePrefix.$pCoord.'.cache');
-
- // Delete the entry from our cell address array
- parent::deleteCacheData($pCoord);
- }
-
- /**
- * Clone the cell collection
- *
- * @access public
- * @param PHPExcel_Worksheet $parent The new worksheet
- * @throws PHPExcel_Exception
- * @return void
- */
- public function copyCellCollection(PHPExcel_Worksheet $parent)
- {
- parent::copyCellCollection($parent);
- // Get a new id for the new file name
- $baseUnique = $this->getUniqueID();
- $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
- $cacheList = $this->getCellList();
- foreach ($cacheList as $cellID) {
- if ($cellID != $this->currentObjectID) {
- $obj = apc_fetch($this->cachePrefix . $cellID . '.cache');
- if ($obj === false) {
- // Entry no longer exists in APC, so clear it from the cache array
- parent::deleteCacheData($cellID);
- throw new PHPExcel_Exception('Cell entry ' . $cellID . ' no longer exists in APC');
- }
- if (!apc_store($newCachePrefix . $cellID . '.cache', $obj, $this->cacheTime)) {
- $this->__destruct();
- throw new PHPExcel_Exception('Failed to store cell ' . $cellID . ' in APC');
- }
- }
- }
- $this->cachePrefix = $newCachePrefix;
- }
-
- /**
- * Clear the cell collection and disconnect from our parent
- *
- * @return void
- */
- public function unsetWorksheetCells()
- {
- if ($this->currentObject !== null) {
- $this->currentObject->detach();
- $this->currentObject = $this->currentObjectID = null;
- }
-
- // Flush the APC cache
- $this->__destruct();
-
- $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)
- {
- $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
-
- if ($this->cachePrefix === null) {
- $baseUnique = $this->getUniqueID();
- $this->cachePrefix = substr(md5($baseUnique), 0, 8) . '.';
- $this->cacheTime = $cacheTime;
-
- parent::__construct($parent);
- }
- }
-
- /**
- * Destroy this cell collection
- */
- public function __destruct()
- {
- $cacheList = $this->getCellList();
- foreach ($cacheList as $cellID) {
- apc_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('apc_store')) {
- return false;
- }
- if (apc_sma_info() === false) {
- return false;
- }
-
- return true;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?php
-
-/**
- * PHPExcel_CachedObjectStorage_ICache
- *
- * 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##
- */
-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 PHPExcel_Cell
- * @throws PHPExcel_Exception
- */
- public function addCacheData($pCoord, PHPExcel_Cell $cell);
-
- /**
- * 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);
-
- /**
- * 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
- */
- 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
- */
- 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 string[]
- */
- public function getCellList();
-
- /**
- * Get the list of all cell addresses currently held in cache sorted by column and row
- *
- * @return string[]
- */
- public function getSortedCellList();
-
- /**
- * 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();
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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);
- if ($cellData === false) {
- // 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($cellData['value']);
- // 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
- $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);
-
- return ($cellData === false) ? false : 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
- $this->deleteQuery->bindValue('id', $pCoord, SQLITE3_TEXT);
- $result = $this->deleteQuery->execute();
- if ($result === false) {
- throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
- }
-
- $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;
- }
-
- $this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT);
- $result = $this->deleteQuery->execute();
- if ($result === false) {
- throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
- }
-
- $this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT);
- $this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT);
- $result = $this->updateQuery->execute();
- 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->query($query);
- if ($cellIdsResult === false) {
- throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
- }
-
- $cellKeys = array();
- while ($row = $cellIdsResult->fetchArray(SQLITE3_ASSOC)) {
- $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->exec('CREATE TABLE kvp_'.$tableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)
- AS SELECT * FROM kvp_'.$this->TableName)
- ) {
- throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
- }
-
- // 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 SQLite3($_DBName);
- if ($this->DBHandle === false) {
- throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
- }
- if (!$this->DBHandle->exec('CREATE TABLE kvp_'.$this->TableName.' (id VARCHAR(12) PRIMARY KEY, value BLOB)')) {
- throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
- }
- }
-
- $this->selectQuery = $this->DBHandle->prepare("SELECT value FROM kvp_".$this->TableName." WHERE id = :id");
- $this->insertQuery = $this->DBHandle->prepare("INSERT OR REPLACE INTO kvp_".$this->TableName." VALUES(:id,:data)");
- $this->updateQuery = $this->DBHandle->prepare("UPDATE kvp_".$this->TableName." SET id=:toId WHERE id=:fromId");
- $this->deleteQuery = $this->DBHandle->prepare("DELETE FROM kvp_".$this->TableName." WHERE id = :id");
- }
-
- /**
- * Destroy this cell collection
- */
- public function __destruct()
- {
- if (!is_null($this->DBHandle)) {
- $this->DBHandle->exec('DROP TABLE kvp_'.$this->TableName);
- $this->DBHandle->close();
- }
- $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 (!class_exists('SQLite3', false)) {
- return false;
- }
-
- return true;
- }
-}
+++ /dev/null
-<?php
-
-/**
- * PHPExcel_CachedObjectStorage_Wincache
- *
- * 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_Wincache 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;
-
-
- /**
- * 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 (wincache_ucache_exists($this->cachePrefix.$this->currentObjectID.'.cache')) {
- if (!wincache_ucache_set($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
- $this->__destruct();
- throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
- }
- } else {
- if (!wincache_ucache_add($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
- $this->__destruct();
- throw new PHPExcel_Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
- }
- }
- $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->cellCache[$pCoord] = true;
-
- $this->currentObjectID = $pCoord;
- $this->currentObject = $cell;
- $this->currentCellIsDirty = true;
-
- return $cell;
- }
-
- /**
- * 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)
- {
- // Check if the requested entry is the current object, or exists in the cache
- if (parent::isDataSet($pCoord)) {
- if ($this->currentObjectID == $pCoord) {
- return true;
- }
- // Check if the requested entry still exists in cache
- $success = wincache_ucache_exists($this->cachePrefix.$pCoord.'.cache');
- if ($success === false) {
- // Entry no longer exists in Wincache, so clear it from the cache array
- parent::deleteCacheData($pCoord);
- throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
- }
- 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
- $obj = null;
- if (parent::isDataSet($pCoord)) {
- $success = false;
- $obj = wincache_ucache_get($this->cachePrefix.$pCoord.'.cache', $success);
- if ($success === false) {
- // Entry no longer exists in WinCache, so clear it from the cache array
- parent::deleteCacheData($pCoord);
- throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
- }
- } else {
- // Return null if requested entry doesn't exist in cache
- return null;
- }
-
- // Set current entry to the requested entry
- $this->currentObjectID = $pCoord;
- $this->currentObject = unserialize($obj);
- // Re-attach 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 Wincache
- wincache_ucache_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) {
- $success = false;
- $obj = wincache_ucache_get($this->cachePrefix.$cellID.'.cache', $success);
- if ($success === false) {
- // Entry no longer exists in WinCache, so clear it from the cache array
- parent::deleteCacheData($cellID);
- throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache');
- }
- if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->cacheTime)) {
- $this->__destruct();
- throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache');
- }
- }
- }
- $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 WinCache 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)
- {
- $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
-
- if (is_null($this->cachePrefix)) {
- $baseUnique = $this->getUniqueID();
- $this->cachePrefix = substr(md5($baseUnique), 0, 8).'.';
- $this->cacheTime = $cacheTime;
-
- parent::__construct($parent);
- }
- }
-
- /**
- * Destroy this cell collection
- */
- public function __destruct()
- {
- $cacheList = $this->getCellList();
- foreach ($cacheList as $cellID) {
- wincache_ucache_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('wincache_ucache_add')) {
- return false;
- }
-
- return true;
- }
-}
+++ /dev/null
-<?php
-
-/**
- * PHPExcel_CachedObjectStorageFactory
- *
- * 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_CachedObjectStorageFactory
-{
- const cache_in_memory = 'Memory';
- const cache_in_memory_gzip = 'MemoryGZip';
- const cache_in_memory_serialized = 'MemorySerialized';
- const cache_igbinary = 'Igbinary';
- const cache_to_discISAM = 'DiscISAM';
- const cache_to_apc = 'APC';
- const cache_to_memcache = 'Memcache';
- const cache_to_phpTemp = 'PHPTemp';
- const cache_to_wincache = 'Wincache';
- const cache_to_sqlite = 'SQLite';
- const cache_to_sqlite3 = 'SQLite3';
-
- /**
- * Name of the method used for cell cacheing
- *
- * @var string
- */
- private static $cacheStorageMethod = null;
-
- /**
- * Name of the class used for cell cacheing
- *
- * @var string
- */
- private static $cacheStorageClass = null;
-
- /**
- * List of all possible cache storage methods
- *
- * @var string[]
- */
- private static $storageMethods = array(
- self::cache_in_memory,
- self::cache_in_memory_gzip,
- self::cache_in_memory_serialized,
- self::cache_igbinary,
- self::cache_to_phpTemp,
- self::cache_to_discISAM,
- self::cache_to_apc,
- self::cache_to_memcache,
- self::cache_to_wincache,
- self::cache_to_sqlite,
- self::cache_to_sqlite3,
- );
-
- /**
- * Default arguments for each cache storage method
- *
- * @var array of mixed array
- */
- private static $storageMethodDefaultParameters = array(
- self::cache_in_memory => array(
- ),
- self::cache_in_memory_gzip => array(
- ),
- self::cache_in_memory_serialized => array(
- ),
- self::cache_igbinary => array(
- ),
- self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
- ),
- self::cache_to_discISAM => array( 'dir' => null
- ),
- self::cache_to_apc => array( 'cacheTime' => 600
- ),
- self::cache_to_memcache => array( 'memcacheServer' => 'localhost',
- 'memcachePort' => 11211,
- 'cacheTime' => 600
- ),
- self::cache_to_wincache => array( 'cacheTime' => 600
- ),
- self::cache_to_sqlite => array(
- ),
- self::cache_to_sqlite3 => array(
- ),
- );
-
- /**
- * Arguments for the active cache storage method
- *
- * @var array of mixed array
- */
- private static $storageMethodParameters = array();
-
- /**
- * Return the current cache storage method
- *
- * @return string|null
- **/
- public static function getCacheStorageMethod()
- {
- return self::$cacheStorageMethod;
- }
-
- /**
- * Return the current cache storage class
- *
- * @return PHPExcel_CachedObjectStorage_ICache|null
- **/
- public static function getCacheStorageClass()
- {
- return self::$cacheStorageClass;
- }
-
- /**
- * Return the list of all possible cache storage methods
- *
- * @return string[]
- **/
- public static function getAllCacheStorageMethods()
- {
- return self::$storageMethods;
- }
-
- /**
- * Return the list of all available cache storage methods
- *
- * @return string[]
- **/
- public static function getCacheStorageMethods()
- {
- $activeMethods = array();
- foreach (self::$storageMethods as $storageMethod) {
- $cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $storageMethod;
- if (call_user_func(array($cacheStorageClass, 'cacheMethodIsAvailable'))) {
- $activeMethods[] = $storageMethod;
- }
- }
- return $activeMethods;
- }
-
- /**
- * Identify the cache storage method to use
- *
- * @param string $method Name of the method to use for cell cacheing
- * @param array of mixed $arguments Additional arguments to pass to the cell caching class
- * when instantiating
- * @return boolean
- **/
- public static function initialize($method = self::cache_in_memory, $arguments = array())
- {
- if (!in_array($method, self::$storageMethods)) {
- return false;
- }
-
- $cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
- if (!call_user_func(array( $cacheStorageClass,
- 'cacheMethodIsAvailable'))) {
- return false;
- }
-
- self::$storageMethodParameters[$method] = self::$storageMethodDefaultParameters[$method];
- foreach ($arguments as $k => $v) {
- if (array_key_exists($k, self::$storageMethodParameters[$method])) {
- self::$storageMethodParameters[$method][$k] = $v;
- }
- }
-
- if (self::$cacheStorageMethod === null) {
- self::$cacheStorageClass = 'PHPExcel_CachedObjectStorage_' . $method;
- self::$cacheStorageMethod = $method;
- }
- return true;
- }
-
- /**
- * Initialise the cache storage
- *
- * @param PHPExcel_Worksheet $parent Enable cell caching for this worksheet
- * @return PHPExcel_CachedObjectStorage_ICache
- **/
- public static function getInstance(PHPExcel_Worksheet $parent)
- {
- $cacheMethodIsAvailable = true;
- if (self::$cacheStorageMethod === null) {
- $cacheMethodIsAvailable = self::initialize();
- }
-
- if ($cacheMethodIsAvailable) {
- $instance = new self::$cacheStorageClass(
- $parent,
- self::$storageMethodParameters[self::$cacheStorageMethod]
- );
- if ($instance !== null) {
- return $instance;
- }
- }
-
- return false;
- }
-
- /**
- * Clear the cache storage
- *
- **/
- public static function finalize()
- {
- self::$cacheStorageMethod = null;
- self::$cacheStorageClass = null;
- self::$storageMethodParameters = array();
- }
-}
+++ /dev/null
-<?php
-
-/**
- * PHPExcel_CalcEngine_CyclicReferenceStack
- *
- * 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_Calculation
- * @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_CalcEngine_CyclicReferenceStack
-{
- /**
- * The call stack for calculated cells
- *
- * @var mixed[]
- */
- private $stack = array();
-
- /**
- * Return the number of entries on the stack
- *
- * @return integer
- */
- public function count()
- {
- return count($this->stack);
- }
-
- /**
- * Push a new entry onto the stack
- *
- * @param mixed $value
- */
- public function push($value)
- {
- $this->stack[$value] = $value;
- }
-
- /**
- * Pop the last entry from the stack
- *
- * @return mixed
- */
- public function pop()
- {
- return array_pop($this->stack);
- }
-
- /**
- * Test to see if a specified entry exists on the stack
- *
- * @param mixed $value The value to test
- */
- public function onStack($value)
- {
- return isset($this->stack[$value]);
- }
-
- /**
- * Clear the stack
- */
- public function clear()
- {
- $this->stack = array();
- }
-
- /**
- * Return an array of all entries on the stack
- *
- * @return mixed[]
- */
- public function showStack()
- {
- return $this->stack;
- }
-}
+++ /dev/null
-<?php
-
-/**
- * PHPExcel_CalcEngine_Logger
- *
- * 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_Calculation
- * @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_CalcEngine_Logger
-{
- /**
- * Flag to determine whether a debug log should be generated by the calculation engine
- * If true, then a debug log will be generated
- * If false, then a debug log will not be generated
- *
- * @var boolean
- */
- private $writeDebugLog = false;
-
- /**
- * Flag to determine whether a debug log should be echoed by the calculation engine
- * If true, then a debug log will be echoed
- * If false, then a debug log will not be echoed
- * A debug log can only be echoed if it is generated
- *
- * @var boolean
- */
- private $echoDebugLog = false;
-
- /**
- * The debug log generated by the calculation engine
- *
- * @var string[]
- */
- private $debugLog = array();
-
- /**
- * The calculation engine cell reference stack
- *
- * @var PHPExcel_CalcEngine_CyclicReferenceStack
- */
- private $cellStack;
-
- /**
- * Instantiate a Calculation engine logger
- *
- * @param PHPExcel_CalcEngine_CyclicReferenceStack $stack
- */
- public function __construct(PHPExcel_CalcEngine_CyclicReferenceStack $stack)
- {
- $this->cellStack = $stack;
- }
-
- /**
- * Enable/Disable Calculation engine logging
- *
- * @param boolean $pValue
- */
- public function setWriteDebugLog($pValue = false)
- {
- $this->writeDebugLog = $pValue;
- }
-
- /**
- * Return whether calculation engine logging is enabled or disabled
- *
- * @return boolean
- */
- public function getWriteDebugLog()
- {
- return $this->writeDebugLog;
- }
-
- /**
- * Enable/Disable echoing of debug log information
- *
- * @param boolean $pValue
- */
- public function setEchoDebugLog($pValue = false)
- {
- $this->echoDebugLog = $pValue;
- }
-
- /**
- * Return whether echoing of debug log information is enabled or disabled
- *
- * @return boolean
- */
- public function getEchoDebugLog()
- {
- return $this->echoDebugLog;
- }
-
- /**
- * Write an entry to the calculation engine debug log
- */
- public function writeDebugLog()
- {
- // Only write the debug log if logging is enabled
- if ($this->writeDebugLog) {
- $message = implode(func_get_args());
- $cellReference = implode(' -> ', $this->cellStack->showStack());
- if ($this->echoDebugLog) {
- echo $cellReference,
- ($this->cellStack->count() > 0 ? ' => ' : ''),
- $message,
- PHP_EOL;
- }
- $this->debugLog[] = $cellReference .
- ($this->cellStack->count() > 0 ? ' => ' : '') .
- $message;
- }
- }
-
- /**
- * Clear the calculation engine debug log
- */
- public function clearLog()
- {
- $this->debugLog = array();
- }
-
- /**
- * Return the calculation engine debug log
- *
- * @return string[]
- */
- public function getLog()
- {
- return $this->debugLog;
- }
-}
+++ /dev/null
-<?php
-
-/** PHPExcel root directory */
-if (!defined('PHPEXCEL_ROOT')) {
- /**
- * @ignore
- */
- define('PHPEXCEL_ROOT', dirname(__FILE__)&nb