Dateien nach "includes/PHPExcel/Classes/PHPExcel" hochladen
This commit is contained in:
parent
f6cf82ae7f
commit
ee03e17d1e
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
PHPExcel_Autoloader::Register();
|
||||
// As we always try to run the autoloader before anything else, we can use it to do a few
|
||||
// simple checks and initialisations
|
||||
//PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new PHPExcel_Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
PHPExcel_Shared_String::buildCharacterSets();
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Autoloader
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Autoloader
|
||||
{
|
||||
/**
|
||||
* Register the Autoloader with SPL
|
||||
*
|
||||
*/
|
||||
public static function Register() {
|
||||
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'));
|
||||
}
|
||||
} // function Register()
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
} // function Load()
|
||||
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorageFactory
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
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;
|
||||
} // function getCacheStorageMethod()
|
||||
|
||||
|
||||
/**
|
||||
* Return the current cache storage class
|
||||
*
|
||||
* @return PHPExcel_CachedObjectStorage_ICache|NULL
|
||||
**/
|
||||
public static function getCacheStorageClass()
|
||||
{
|
||||
return self::$_cacheStorageClass;
|
||||
} // function getCacheStorageClass()
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of all possible cache storage methods
|
||||
*
|
||||
* @return string[]
|
||||
**/
|
||||
public static function getAllCacheStorageMethods()
|
||||
{
|
||||
return self::$_storageMethods;
|
||||
} // function getCacheStorageMethods()
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
} // function getCacheStorageMethods()
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
} // function initialize()
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
} // function getInstance()
|
||||
|
||||
|
||||
/**
|
||||
* Clear the cache storage
|
||||
*
|
||||
**/
|
||||
public static function finalize()
|
||||
{
|
||||
self::$_cacheStorageMethod = NULL;
|
||||
self::$_cacheStorageClass = NULL;
|
||||
self::$_storageMethodParameters = array();
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,635 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Chart
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Chart
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Chart
|
||||
{
|
||||
/**
|
||||
* Chart Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_name = '';
|
||||
|
||||
/**
|
||||
* Worksheet
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
private $_worksheet = null;
|
||||
|
||||
/**
|
||||
* Chart Title
|
||||
*
|
||||
* @var PHPExcel_Chart_Title
|
||||
*/
|
||||
private $_title = null;
|
||||
|
||||
/**
|
||||
* Chart Legend
|
||||
*
|
||||
* @var PHPExcel_Chart_Legend
|
||||
*/
|
||||
private $_legend = null;
|
||||
|
||||
/**
|
||||
* X-Axis Label
|
||||
*
|
||||
* @var PHPExcel_Chart_Title
|
||||
*/
|
||||
private $_xAxisLabel = null;
|
||||
|
||||
/**
|
||||
* Y-Axis Label
|
||||
*
|
||||
* @var PHPExcel_Chart_Title
|
||||
*/
|
||||
private $_yAxisLabel = null;
|
||||
|
||||
/**
|
||||
* Chart Plot Area
|
||||
*
|
||||
* @var PHPExcel_Chart_PlotArea
|
||||
*/
|
||||
private $_plotArea = null;
|
||||
|
||||
/**
|
||||
* Plot Visible Only
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_plotVisibleOnly = true;
|
||||
|
||||
/**
|
||||
* Display Blanks as
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_displayBlanksAs = '0';
|
||||
|
||||
/**
|
||||
* Chart Asix Y as
|
||||
*
|
||||
* @var PHPExcel_Chart_Axis
|
||||
*/
|
||||
private $_yAxis = null;
|
||||
|
||||
/**
|
||||
* Chart Asix X as
|
||||
*
|
||||
* @var PHPExcel_Chart_Axis
|
||||
*/
|
||||
private $_xAxis = null;
|
||||
|
||||
/**
|
||||
* Chart Major Gridlines as
|
||||
*
|
||||
* @var PHPExcel_Chart_GridLines
|
||||
*/
|
||||
private $_majorGridlines = null;
|
||||
|
||||
/**
|
||||
* Chart Minor Gridlines as
|
||||
*
|
||||
* @var PHPExcel_Chart_GridLines
|
||||
*/
|
||||
private $_minorGridlines = null;
|
||||
|
||||
/**
|
||||
* Top-Left Cell Position
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_topLeftCellRef = 'A1';
|
||||
|
||||
|
||||
/**
|
||||
* Top-Left X-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_topLeftXOffset = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Top-Left Y-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_topLeftYOffset = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right Cell Position
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_bottomRightCellRef = 'A1';
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right X-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_bottomRightXOffset = 10;
|
||||
|
||||
|
||||
/**
|
||||
* Bottom-Right Y-Offset
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $_bottomRightYOffset = 10;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Chart
|
||||
*/
|
||||
public function __construct($name, PHPExcel_Chart_Title $title = null, PHPExcel_Chart_Legend $legend = null, PHPExcel_Chart_PlotArea $plotArea = null, $plotVisibleOnly = true, $displayBlanksAs = '0', PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null, PHPExcel_Chart_Axis $xAxis = null, PHPExcel_Chart_Axis $yAxis = null, PHPExcel_Chart_GridLines $majorGridlines = null, PHPExcel_Chart_GridLines $minorGridlines = null)
|
||||
{
|
||||
$this->_name = $name;
|
||||
$this->_title = $title;
|
||||
$this->_legend = $legend;
|
||||
$this->_xAxisLabel = $xAxisLabel;
|
||||
$this->_yAxisLabel = $yAxisLabel;
|
||||
$this->_plotArea = $plotArea;
|
||||
$this->_plotVisibleOnly = $plotVisibleOnly;
|
||||
$this->_displayBlanksAs = $displayBlanksAs;
|
||||
$this->_xAxis = $xAxis;
|
||||
$this->_yAxis = $yAxis;
|
||||
$this->_majorGridlines = $majorGridlines;
|
||||
$this->_minorGridlines = $minorGridlines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Worksheet
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function getWorksheet() {
|
||||
return $this->_worksheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Worksheet
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pValue
|
||||
* @throws PHPExcel_Chart_Exception
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setWorksheet(PHPExcel_Worksheet $pValue = null) {
|
||||
$this->_worksheet = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return PHPExcel_Chart_Title
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param PHPExcel_Chart_Title $title
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setTitle(PHPExcel_Chart_Title $title) {
|
||||
$this->_title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Legend
|
||||
*
|
||||
* @return PHPExcel_Chart_Legend
|
||||
*/
|
||||
public function getLegend() {
|
||||
return $this->_legend;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Legend
|
||||
*
|
||||
* @param PHPExcel_Chart_Legend $legend
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setLegend(PHPExcel_Chart_Legend $legend) {
|
||||
$this->_legend = $legend;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get X-Axis Label
|
||||
*
|
||||
* @return PHPExcel_Chart_Title
|
||||
*/
|
||||
public function getXAxisLabel() {
|
||||
return $this->_xAxisLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set X-Axis Label
|
||||
*
|
||||
* @param PHPExcel_Chart_Title $label
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setXAxisLabel(PHPExcel_Chart_Title $label) {
|
||||
$this->_xAxisLabel = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Y-Axis Label
|
||||
*
|
||||
* @return PHPExcel_Chart_Title
|
||||
*/
|
||||
public function getYAxisLabel() {
|
||||
return $this->_yAxisLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Y-Axis Label
|
||||
*
|
||||
* @param PHPExcel_Chart_Title $label
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setYAxisLabel(PHPExcel_Chart_Title $label) {
|
||||
$this->_yAxisLabel = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Area
|
||||
*
|
||||
* @return PHPExcel_Chart_PlotArea
|
||||
*/
|
||||
public function getPlotArea() {
|
||||
return $this->_plotArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Plot Visible Only
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getPlotVisibleOnly() {
|
||||
return $this->_plotVisibleOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Plot Visible Only
|
||||
*
|
||||
* @param boolean $plotVisibleOnly
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setPlotVisibleOnly($plotVisibleOnly = true) {
|
||||
$this->_plotVisibleOnly = $plotVisibleOnly;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Display Blanks as
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayBlanksAs() {
|
||||
return $this->_displayBlanksAs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Display Blanks as
|
||||
*
|
||||
* @param string $displayBlanksAs
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setDisplayBlanksAs($displayBlanksAs = '0') {
|
||||
$this->_displayBlanksAs = $displayBlanksAs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get yAxis
|
||||
*
|
||||
* @return PHPExcel_Chart_Axis
|
||||
*/
|
||||
public function getChartAxisY() {
|
||||
if($this->_yAxis !== NULL){
|
||||
return $this->_yAxis;
|
||||
}
|
||||
|
||||
return new PHPExcel_Chart_Axis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get xAxis
|
||||
*
|
||||
* @return PHPExcel_Chart_Axis
|
||||
*/
|
||||
public function getChartAxisX() {
|
||||
if($this->_xAxis !== NULL){
|
||||
return $this->_xAxis;
|
||||
}
|
||||
|
||||
return new PHPExcel_Chart_Axis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Major Gridlines
|
||||
*
|
||||
* @return PHPExcel_Chart_GridLines
|
||||
*/
|
||||
public function getMajorGridlines() {
|
||||
if($this->_majorGridlines !== NULL){
|
||||
return $this->_majorGridlines;
|
||||
}
|
||||
|
||||
return new PHPExcel_Chart_GridLines();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Minor Gridlines
|
||||
*
|
||||
* @return PHPExcel_Chart_GridLines
|
||||
*/
|
||||
public function getMinorGridlines() {
|
||||
if($this->_minorGridlines !== NULL){
|
||||
return $this->_minorGridlines;
|
||||
}
|
||||
|
||||
return new PHPExcel_Chart_GridLines();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the Top Left position for the chart
|
||||
*
|
||||
* @param string $cell
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setTopLeftPosition($cell, $xOffset=null, $yOffset=null) {
|
||||
$this->_topLeftCellRef = $cell;
|
||||
if (!is_null($xOffset))
|
||||
$this->setTopLeftXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setTopLeftYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the top left position of the chart
|
||||
*
|
||||
* @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
|
||||
*/
|
||||
public function getTopLeftPosition() {
|
||||
return array( 'cell' => $this->_topLeftCellRef,
|
||||
'xOffset' => $this->_topLeftXOffset,
|
||||
'yOffset' => $this->_topLeftYOffset
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell address where the top left of the chart is fixed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopLeftCell() {
|
||||
return $this->_topLeftCellRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Top Left cell position for the chart
|
||||
*
|
||||
* @param string $cell
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setTopLeftCell($cell) {
|
||||
$this->_topLeftCellRef = $cell;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the offset position within the Top Left cell for the chart
|
||||
*
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setTopLeftOffset($xOffset=null,$yOffset=null) {
|
||||
if (!is_null($xOffset))
|
||||
$this->setTopLeftXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setTopLeftYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offset position within the Top Left cell for the chart
|
||||
*
|
||||
* @return integer[]
|
||||
*/
|
||||
public function getTopLeftOffset() {
|
||||
return array( 'X' => $this->_topLeftXOffset,
|
||||
'Y' => $this->_topLeftYOffset
|
||||
);
|
||||
}
|
||||
|
||||
public function setTopLeftXOffset($xOffset) {
|
||||
$this->_topLeftXOffset = $xOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTopLeftXOffset() {
|
||||
return $this->_topLeftXOffset;
|
||||
}
|
||||
|
||||
public function setTopLeftYOffset($yOffset) {
|
||||
$this->_topLeftYOffset = $yOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTopLeftYOffset() {
|
||||
return $this->_topLeftYOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Bottom Right position of the chart
|
||||
*
|
||||
* @param string $cell
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setBottomRightPosition($cell, $xOffset=null, $yOffset=null) {
|
||||
$this->_bottomRightCellRef = $cell;
|
||||
if (!is_null($xOffset))
|
||||
$this->setBottomRightXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setBottomRightYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bottom right position of the chart
|
||||
*
|
||||
* @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell
|
||||
*/
|
||||
public function getBottomRightPosition() {
|
||||
return array( 'cell' => $this->_bottomRightCellRef,
|
||||
'xOffset' => $this->_bottomRightXOffset,
|
||||
'yOffset' => $this->_bottomRightYOffset
|
||||
);
|
||||
}
|
||||
|
||||
public function setBottomRightCell($cell) {
|
||||
$this->_bottomRightCellRef = $cell;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cell address where the bottom right of the chart is fixed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBottomRightCell() {
|
||||
return $this->_bottomRightCellRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the offset position within the Bottom Right cell for the chart
|
||||
*
|
||||
* @param integer $xOffset
|
||||
* @param integer $yOffset
|
||||
* @return PHPExcel_Chart
|
||||
*/
|
||||
public function setBottomRightOffset($xOffset=null,$yOffset=null) {
|
||||
if (!is_null($xOffset))
|
||||
$this->setBottomRightXOffset($xOffset);
|
||||
if (!is_null($yOffset))
|
||||
$this->setBottomRightYOffset($yOffset);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the offset position within the Bottom Right cell for the chart
|
||||
*
|
||||
* @return integer[]
|
||||
*/
|
||||
public function getBottomRightOffset() {
|
||||
return array( 'X' => $this->_bottomRightXOffset,
|
||||
'Y' => $this->_bottomRightYOffset
|
||||
);
|
||||
}
|
||||
|
||||
public function setBottomRightXOffset($xOffset) {
|
||||
$this->_bottomRightXOffset = $xOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBottomRightXOffset() {
|
||||
return $this->_bottomRightXOffset;
|
||||
}
|
||||
|
||||
public function setBottomRightYOffset($yOffset) {
|
||||
$this->_bottomRightYOffset = $yOffset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBottomRightYOffset() {
|
||||
return $this->_bottomRightYOffset;
|
||||
}
|
||||
|
||||
|
||||
public function refresh() {
|
||||
if ($this->_worksheet !== NULL) {
|
||||
$this->_plotArea->refresh($this->_worksheet);
|
||||
}
|
||||
}
|
||||
|
||||
public function render($outputDestination = null) {
|
||||
$libraryName = PHPExcel_Settings::getChartRendererName();
|
||||
if (is_null($libraryName)) {
|
||||
return false;
|
||||
}
|
||||
// Ensure that data series values are up-to-date before we render
|
||||
$this->refresh();
|
||||
|
||||
$libraryPath = PHPExcel_Settings::getChartRendererPath();
|
||||
$includePath = str_replace('\\','/',get_include_path());
|
||||
$rendererPath = str_replace('\\','/',$libraryPath);
|
||||
if (strpos($rendererPath,$includePath) === false) {
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath);
|
||||
}
|
||||
|
||||
$rendererName = 'PHPExcel_Chart_Renderer_'.$libraryName;
|
||||
$renderer = new $rendererName($this);
|
||||
|
||||
if ($outputDestination == 'php://output') {
|
||||
$outputDestination = null;
|
||||
}
|
||||
return $renderer->render($outputDestination);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,327 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Comment
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
{
|
||||
/**
|
||||
* Author
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_author;
|
||||
|
||||
/**
|
||||
* Rich text comment
|
||||
*
|
||||
* @var PHPExcel_RichText
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
/**
|
||||
* Comment width (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_width = '96pt';
|
||||
|
||||
/**
|
||||
* Left margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_marginLeft = '59.25pt';
|
||||
|
||||
/**
|
||||
* Top margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_marginTop = '1.5pt';
|
||||
|
||||
/**
|
||||
* Visible
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_visible = false;
|
||||
|
||||
/**
|
||||
* Comment height (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_height = '55.5pt';
|
||||
|
||||
/**
|
||||
* Comment fill color
|
||||
*
|
||||
* @var PHPExcel_Style_Color
|
||||
*/
|
||||
private $_fillColor;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_alignment;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Comment
|
||||
*
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_author = 'Author';
|
||||
$this->_text = new PHPExcel_RichText();
|
||||
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
|
||||
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthor() {
|
||||
return $this->_author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Author
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setAuthor($pValue = '') {
|
||||
$this->_author = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rich text comment
|
||||
*
|
||||
* @return PHPExcel_RichText
|
||||
*/
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rich text comment
|
||||
*
|
||||
* @param PHPExcel_RichText $pValue
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setText(PHPExcel_RichText $pValue) {
|
||||
$this->_text = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment width (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWidth() {
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment width (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setWidth($value = '96pt') {
|
||||
$this->_width = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment height (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeight() {
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment height (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setHeight($value = '55.5pt') {
|
||||
$this->_height = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get left margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMarginLeft() {
|
||||
return $this->_marginLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set left margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setMarginLeft($value = '59.25pt') {
|
||||
$this->_marginLeft = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get top margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMarginTop() {
|
||||
return $this->_marginTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set top margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setMarginTop($value = '1.5pt') {
|
||||
$this->_marginTop = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the comment visible by default?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getVisible() {
|
||||
return $this->_visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment default visibility
|
||||
*
|
||||
* @param boolean $value
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setVisible($value = false) {
|
||||
$this->_visible = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fill color
|
||||
*
|
||||
* @return PHPExcel_Style_Color
|
||||
*/
|
||||
public function getFillColor() {
|
||||
return $this->_fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Alignment
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setAlignment($pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL) {
|
||||
$this->_alignment = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Alignment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAlignment() {
|
||||
return $this->_alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_author
|
||||
. $this->_text->getHashCode()
|
||||
. $this->_width
|
||||
. $this->_height
|
||||
. $this->_marginLeft
|
||||
. $this->_marginTop
|
||||
. ($this->_visible ? 1 : 0)
|
||||
. $this->_fillColor->getHashCode()
|
||||
. $this->_alignment
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->_text->getPlainText();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,587 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_DocumentProperties
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_DocumentProperties
|
||||
{
|
||||
/** constants */
|
||||
const PROPERTY_TYPE_BOOLEAN = 'b';
|
||||
const PROPERTY_TYPE_INTEGER = 'i';
|
||||
const PROPERTY_TYPE_FLOAT = 'f';
|
||||
const PROPERTY_TYPE_DATE = 'd';
|
||||
const PROPERTY_TYPE_STRING = 's';
|
||||
const PROPERTY_TYPE_UNKNOWN = 'u';
|
||||
|
||||
/**
|
||||
* Creator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_creator = 'Unknown Creator';
|
||||
|
||||
/**
|
||||
* LastModifiedBy
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_lastModifiedBy;
|
||||
|
||||
/**
|
||||
* Created
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_created;
|
||||
|
||||
/**
|
||||
* Modified
|
||||
*
|
||||
* @var datetime
|
||||
*/
|
||||
private $_modified;
|
||||
|
||||
/**
|
||||
* Title
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_title = 'Untitled Spreadsheet';
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_description = '';
|
||||
|
||||
/**
|
||||
* Subject
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_subject = '';
|
||||
|
||||
/**
|
||||
* Keywords
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_keywords = '';
|
||||
|
||||
/**
|
||||
* Category
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_category = '';
|
||||
|
||||
/**
|
||||
* Manager
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_manager = '';
|
||||
|
||||
/**
|
||||
* Company
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_company = 'Microsoft Corporation';
|
||||
|
||||
/**
|
||||
* Custom Properties
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_customProperties = array();
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_lastModifiedBy = $this->_creator;
|
||||
$this->_created = time();
|
||||
$this->_modified = time();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Creator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCreator() {
|
||||
return $this->_creator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Creator
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCreator($pValue = '') {
|
||||
$this->_creator = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Last Modified By
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastModifiedBy() {
|
||||
return $this->_lastModifiedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Last Modified By
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setLastModifiedBy($pValue = '') {
|
||||
$this->_lastModifiedBy = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Created
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getCreated() {
|
||||
return $this->_created;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Created
|
||||
*
|
||||
* @param datetime $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCreated($pValue = null) {
|
||||
if ($pValue === NULL) {
|
||||
$pValue = time();
|
||||
} elseif (is_string($pValue)) {
|
||||
if (is_numeric($pValue)) {
|
||||
$pValue = intval($pValue);
|
||||
} else {
|
||||
$pValue = strtotime($pValue);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_created = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Modified
|
||||
*
|
||||
* @return datetime
|
||||
*/
|
||||
public function getModified() {
|
||||
return $this->_modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Modified
|
||||
*
|
||||
* @param datetime $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setModified($pValue = null) {
|
||||
if ($pValue === NULL) {
|
||||
$pValue = time();
|
||||
} elseif (is_string($pValue)) {
|
||||
if (is_numeric($pValue)) {
|
||||
$pValue = intval($pValue);
|
||||
} else {
|
||||
$pValue = strtotime($pValue);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_modified = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Title
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setTitle($pValue = '') {
|
||||
$this->_title = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() {
|
||||
return $this->_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Description
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setDescription($pValue = '') {
|
||||
$this->_description = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Subject
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubject() {
|
||||
return $this->_subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Subject
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setSubject($pValue = '') {
|
||||
$this->_subject = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Keywords
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeywords() {
|
||||
return $this->_keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Keywords
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setKeywords($pValue = '') {
|
||||
$this->_keywords = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategory() {
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Category
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCategory($pValue = '') {
|
||||
$this->_category = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Company
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCompany() {
|
||||
return $this->_company;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Company
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCompany($pValue = '') {
|
||||
$this->_company = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Manager
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getManager() {
|
||||
return $this->_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Manager
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setManager($pValue = '') {
|
||||
$this->_manager = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a List of Custom Property Names
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCustomProperties() {
|
||||
return array_keys($this->_customProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Custom Property is defined
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return boolean
|
||||
*/
|
||||
public function isCustomPropertySet($propertyName) {
|
||||
return isset($this->_customProperties[$propertyName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Custom Property Value
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomPropertyValue($propertyName) {
|
||||
if (isset($this->_customProperties[$propertyName])) {
|
||||
return $this->_customProperties[$propertyName]['value'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Custom Property Type
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return string
|
||||
*/
|
||||
public function getCustomPropertyType($propertyName) {
|
||||
if (isset($this->_customProperties[$propertyName])) {
|
||||
return $this->_customProperties[$propertyName]['type'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a Custom Property
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @param mixed $propertyValue
|
||||
* @param string $propertyType
|
||||
* 'i' : Integer
|
||||
* 'f' : Floating Point
|
||||
* 's' : String
|
||||
* 'd' : Date/Time
|
||||
* 'b' : Boolean
|
||||
* @return PHPExcel_DocumentProperties
|
||||
*/
|
||||
public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
|
||||
if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
|
||||
self::PROPERTY_TYPE_FLOAT,
|
||||
self::PROPERTY_TYPE_STRING,
|
||||
self::PROPERTY_TYPE_DATE,
|
||||
self::PROPERTY_TYPE_BOOLEAN)))) {
|
||||
if ($propertyValue === NULL) {
|
||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||
} elseif (is_float($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_FLOAT;
|
||||
} elseif(is_int($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_INTEGER;
|
||||
} elseif (is_bool($propertyValue)) {
|
||||
$propertyType = self::PROPERTY_TYPE_BOOLEAN;
|
||||
} else {
|
||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function convertProperty($propertyValue,$propertyType) {
|
||||
switch ($propertyType) {
|
||||
case 'empty' : // Empty
|
||||
return '';
|
||||
break;
|
||||
case 'null' : // Null
|
||||
return NULL;
|
||||
break;
|
||||
case 'i1' : // 1-Byte Signed Integer
|
||||
case 'i2' : // 2-Byte Signed Integer
|
||||
case 'i4' : // 4-Byte Signed Integer
|
||||
case 'i8' : // 8-Byte Signed Integer
|
||||
case 'int' : // Integer
|
||||
return (int) $propertyValue;
|
||||
break;
|
||||
case 'ui1' : // 1-Byte Unsigned Integer
|
||||
case 'ui2' : // 2-Byte Unsigned Integer
|
||||
case 'ui4' : // 4-Byte Unsigned Integer
|
||||
case 'ui8' : // 8-Byte Unsigned Integer
|
||||
case 'uint' : // Unsigned Integer
|
||||
return abs((int) $propertyValue);
|
||||
break;
|
||||
case 'r4' : // 4-Byte Real Number
|
||||
case 'r8' : // 8-Byte Real Number
|
||||
case 'decimal' : // Decimal
|
||||
return (float) $propertyValue;
|
||||
break;
|
||||
case 'lpstr' : // LPSTR
|
||||
case 'lpwstr' : // LPWSTR
|
||||
case 'bstr' : // Basic String
|
||||
return $propertyValue;
|
||||
break;
|
||||
case 'date' : // Date and Time
|
||||
case 'filetime' : // File Time
|
||||
return strtotime($propertyValue);
|
||||
break;
|
||||
case 'bool' : // Boolean
|
||||
return ($propertyValue == 'true') ? True : False;
|
||||
break;
|
||||
case 'cy' : // Currency
|
||||
case 'error' : // Error Status Code
|
||||
case 'vector' : // Vector
|
||||
case 'array' : // Array
|
||||
case 'blob' : // Binary Blob
|
||||
case 'oblob' : // Binary Blob Object
|
||||
case 'stream' : // Binary Stream
|
||||
case 'ostream' : // Binary Stream Object
|
||||
case 'storage' : // Binary Storage
|
||||
case 'ostorage' : // Binary Storage Object
|
||||
case 'vstream' : // Binary Versioned Stream
|
||||
case 'clsid' : // Class ID
|
||||
case 'cf' : // Clipboard Data
|
||||
return $propertyValue;
|
||||
break;
|
||||
}
|
||||
return $propertyValue;
|
||||
}
|
||||
|
||||
public static function convertPropertyType($propertyType) {
|
||||
switch ($propertyType) {
|
||||
case 'i1' : // 1-Byte Signed Integer
|
||||
case 'i2' : // 2-Byte Signed Integer
|
||||
case 'i4' : // 4-Byte Signed Integer
|
||||
case 'i8' : // 8-Byte Signed Integer
|
||||
case 'int' : // Integer
|
||||
case 'ui1' : // 1-Byte Unsigned Integer
|
||||
case 'ui2' : // 2-Byte Unsigned Integer
|
||||
case 'ui4' : // 4-Byte Unsigned Integer
|
||||
case 'ui8' : // 8-Byte Unsigned Integer
|
||||
case 'uint' : // Unsigned Integer
|
||||
return self::PROPERTY_TYPE_INTEGER;
|
||||
break;
|
||||
case 'r4' : // 4-Byte Real Number
|
||||
case 'r8' : // 8-Byte Real Number
|
||||
case 'decimal' : // Decimal
|
||||
return self::PROPERTY_TYPE_FLOAT;
|
||||
break;
|
||||
case 'empty' : // Empty
|
||||
case 'null' : // Null
|
||||
case 'lpstr' : // LPSTR
|
||||
case 'lpwstr' : // LPWSTR
|
||||
case 'bstr' : // Basic String
|
||||
return self::PROPERTY_TYPE_STRING;
|
||||
break;
|
||||
case 'date' : // Date and Time
|
||||
case 'filetime' : // File Time
|
||||
return self::PROPERTY_TYPE_DATE;
|
||||
break;
|
||||
case 'bool' : // Boolean
|
||||
return self::PROPERTY_TYPE_BOOLEAN;
|
||||
break;
|
||||
case 'cy' : // Currency
|
||||
case 'error' : // Error Status Code
|
||||
case 'vector' : // Vector
|
||||
case 'array' : // Array
|
||||
case 'blob' : // Binary Blob
|
||||
case 'oblob' : // Binary Blob Object
|
||||
case 'stream' : // Binary Stream
|
||||
case 'ostream' : // Binary Stream Object
|
||||
case 'storage' : // Binary Storage
|
||||
case 'ostorage' : // Binary Storage Object
|
||||
case 'vstream' : // Binary Versioned Stream
|
||||
case 'clsid' : // Class ID
|
||||
case 'cf' : // Clipboard Data
|
||||
return self::PROPERTY_TYPE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
return self::PROPERTY_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,218 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_DocumentSecurity
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_DocumentSecurity
|
||||
{
|
||||
/**
|
||||
* LockRevision
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_lockRevision;
|
||||
|
||||
/**
|
||||
* LockStructure
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_lockStructure;
|
||||
|
||||
/**
|
||||
* LockWindows
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_lockWindows;
|
||||
|
||||
/**
|
||||
* RevisionsPassword
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_revisionsPassword;
|
||||
|
||||
/**
|
||||
* WorkbookPassword
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_workbookPassword;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_DocumentSecurity
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise values
|
||||
$this->_lockRevision = false;
|
||||
$this->_lockStructure = false;
|
||||
$this->_lockWindows = false;
|
||||
$this->_revisionsPassword = '';
|
||||
$this->_workbookPassword = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Is some sort of dcument security enabled?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function isSecurityEnabled() {
|
||||
return $this->_lockRevision ||
|
||||
$this->_lockStructure ||
|
||||
$this->_lockWindows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LockRevision
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLockRevision() {
|
||||
return $this->_lockRevision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LockRevision
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setLockRevision($pValue = false) {
|
||||
$this->_lockRevision = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LockStructure
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLockStructure() {
|
||||
return $this->_lockStructure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LockStructure
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setLockStructure($pValue = false) {
|
||||
$this->_lockStructure = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LockWindows
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getLockWindows() {
|
||||
return $this->_lockWindows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set LockWindows
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setLockWindows($pValue = false) {
|
||||
$this->_lockWindows = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get RevisionsPassword (hashed)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getRevisionsPassword() {
|
||||
return $this->_revisionsPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set RevisionsPassword
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) {
|
||||
if (!$pAlreadyHashed) {
|
||||
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
||||
}
|
||||
$this->_revisionsPassword = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WorkbookPassword (hashed)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getWorkbookPassword() {
|
||||
return $this->_workbookPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set WorkbookPassword
|
||||
*
|
||||
* @param string $pValue
|
||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||
* @return PHPExcel_DocumentSecurity
|
||||
*/
|
||||
function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) {
|
||||
if (!$pAlreadyHashed) {
|
||||
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
||||
}
|
||||
$this->_workbookPassword = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Exception
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Exception extends Exception {
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @param mixed $context
|
||||
*/
|
||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
||||
$e = new self($string, $code);
|
||||
$e->line = $line;
|
||||
$e->file = $file;
|
||||
throw $e;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,202 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_HashTable
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_HashTable
|
||||
{
|
||||
/**
|
||||
* HashTable elements
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_items = array();
|
||||
|
||||
/**
|
||||
* HashTable key map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_keyMap = array();
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_HashTable
|
||||
*
|
||||
* @param PHPExcel_IComparable[] $pSource Optional source array to create HashTable from
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function __construct($pSource = null)
|
||||
{
|
||||
if ($pSource !== NULL) {
|
||||
// Create HashTable
|
||||
$this->addFromSource($pSource);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable items from source
|
||||
*
|
||||
* @param PHPExcel_IComparable[] $pSource Source array to create HashTable from
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function addFromSource($pSource = null) {
|
||||
// Check if an array was passed
|
||||
if ($pSource == null) {
|
||||
return;
|
||||
} else if (!is_array($pSource)) {
|
||||
throw new PHPExcel_Exception('Invalid array parameter passed.');
|
||||
}
|
||||
|
||||
foreach ($pSource as $item) {
|
||||
$this->add($item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add HashTable item
|
||||
*
|
||||
* @param PHPExcel_IComparable $pSource Item to add
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function add(PHPExcel_IComparable $pSource = null) {
|
||||
$hash = $pSource->getHashCode();
|
||||
if (!isset($this->_items[$hash])) {
|
||||
$this->_items[$hash] = $pSource;
|
||||
$this->_keyMap[count($this->_items) - 1] = $hash;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove HashTable item
|
||||
*
|
||||
* @param PHPExcel_IComparable $pSource Item to remove
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function remove(PHPExcel_IComparable $pSource = null) {
|
||||
$hash = $pSource->getHashCode();
|
||||
if (isset($this->_items[$hash])) {
|
||||
unset($this->_items[$hash]);
|
||||
|
||||
$deleteKey = -1;
|
||||
foreach ($this->_keyMap as $key => $value) {
|
||||
if ($deleteKey >= 0) {
|
||||
$this->_keyMap[$key - 1] = $value;
|
||||
}
|
||||
|
||||
if ($value == $hash) {
|
||||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->_keyMap[count($this->_keyMap) - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear HashTable
|
||||
*
|
||||
*/
|
||||
public function clear() {
|
||||
$this->_items = array();
|
||||
$this->_keyMap = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->_items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index for hash code
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return int Index
|
||||
*/
|
||||
public function getIndexForHashCode($pHashCode = '') {
|
||||
return array_search($pHashCode, $this->_keyMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by index
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return PHPExcel_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByIndex($pIndex = 0) {
|
||||
if (isset($this->_keyMap[$pIndex])) {
|
||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get by hashcode
|
||||
*
|
||||
* @param string $pHashCode
|
||||
* @return PHPExcel_IComparable
|
||||
*
|
||||
*/
|
||||
public function getByHashCode($pHashCode = '') {
|
||||
if (isset($this->_items[$pHashCode])) {
|
||||
return $this->_items[$pHashCode];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* HashTable to array
|
||||
*
|
||||
* @return PHPExcel_IComparable[]
|
||||
*/
|
||||
public function toArray() {
|
||||
return $this->_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_IComparable
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_IComparable
|
||||
{
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
|
||||
}
|
|
@ -0,0 +1,288 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_IOFactory
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_IOFactory
|
||||
{
|
||||
/**
|
||||
* Search locations
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @static
|
||||
*/
|
||||
private static $_searchLocations = array(
|
||||
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
|
||||
array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'PHPExcel_Reader_{0}' )
|
||||
);
|
||||
|
||||
/**
|
||||
* Autoresolve classes
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @static
|
||||
*/
|
||||
private static $_autoResolveClasses = array(
|
||||
'Excel2007',
|
||||
'Excel5',
|
||||
'Excel2003XML',
|
||||
'OOCalc',
|
||||
'SYLK',
|
||||
'Gnumeric',
|
||||
'HTML',
|
||||
'CSV',
|
||||
);
|
||||
|
||||
/**
|
||||
* Private constructor for PHPExcel_IOFactory
|
||||
*/
|
||||
private function __construct() { }
|
||||
|
||||
/**
|
||||
* Get search locations
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function getSearchLocations() {
|
||||
return self::$_searchLocations;
|
||||
} // function getSearchLocations()
|
||||
|
||||
/**
|
||||
* Set search locations
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param array $value
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function setSearchLocations($value) {
|
||||
if (is_array($value)) {
|
||||
self::$_searchLocations = $value;
|
||||
} else {
|
||||
throw new PHPExcel_Reader_Exception('Invalid parameter passed.');
|
||||
}
|
||||
} // function setSearchLocations()
|
||||
|
||||
/**
|
||||
* Add search location
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $type Example: IWriter
|
||||
* @param string $location Example: PHPExcel/Writer/{0}.php
|
||||
* @param string $classname Example: PHPExcel_Writer_{0}
|
||||
*/
|
||||
public static function addSearchLocation($type = '', $location = '', $classname = '') {
|
||||
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
||||
} // function addSearchLocation()
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Writer_IWriter
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param PHPExcel $phpExcel
|
||||
* @param string $writerType Example: Excel2007
|
||||
* @return PHPExcel_Writer_IWriter
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function createWriter(PHPExcel $phpExcel, $writerType = '') {
|
||||
// Search type
|
||||
$searchType = 'IWriter';
|
||||
|
||||
// Include class
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $writerType, $searchLocation['class']);
|
||||
|
||||
$instance = new $className($phpExcel);
|
||||
if ($instance !== NULL) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found...
|
||||
throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType");
|
||||
} // function createWriter()
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Reader_IReader
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $readerType Example: Excel2007
|
||||
* @return PHPExcel_Reader_IReader
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function createReader($readerType = '') {
|
||||
// Search type
|
||||
$searchType = 'IReader';
|
||||
|
||||
// Include class
|
||||
foreach (self::$_searchLocations as $searchLocation) {
|
||||
if ($searchLocation['type'] == $searchType) {
|
||||
$className = str_replace('{0}', $readerType, $searchLocation['class']);
|
||||
|
||||
$instance = new $className();
|
||||
if ($instance !== NULL) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing found...
|
||||
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
|
||||
} // function createReader()
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFilename The name of the spreadsheet file
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function load($pFilename) {
|
||||
$reader = self::createReaderForFile($pFilename);
|
||||
return $reader->load($pFilename);
|
||||
} // function load()
|
||||
|
||||
/**
|
||||
* Identify file type using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFilename The name of the spreadsheet file to identify
|
||||
* @return string
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function identify($pFilename) {
|
||||
$reader = self::createReaderForFile($pFilename);
|
||||
$className = get_class($reader);
|
||||
$classType = explode('_',$className);
|
||||
unset($reader);
|
||||
return array_pop($classType);
|
||||
} // function identify()
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFilename The name of the spreadsheet file
|
||||
* @return PHPExcel_Reader_IReader
|
||||
* @throws PHPExcel_Reader_Exception
|
||||
*/
|
||||
public static function createReaderForFile($pFilename) {
|
||||
|
||||
// First, lucky guess by inspecting file extension
|
||||
$pathinfo = pathinfo($pFilename);
|
||||
|
||||
$extensionType = NULL;
|
||||
if (isset($pathinfo['extension'])) {
|
||||
switch (strtolower($pathinfo['extension'])) {
|
||||
case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet
|
||||
case 'xlsm': // Excel (OfficeOpenXML) Macro Spreadsheet (macros will be discarded)
|
||||
case 'xltx': // Excel (OfficeOpenXML) Template
|
||||
case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded)
|
||||
$extensionType = 'Excel2007';
|
||||
break;
|
||||
case 'xls': // Excel (BIFF) Spreadsheet
|
||||
case 'xlt': // Excel (BIFF) Template
|
||||
$extensionType = 'Excel5';
|
||||
break;
|
||||
case 'ods': // Open/Libre Offic Calc
|
||||
case 'ots': // Open/Libre Offic Calc Template
|
||||
$extensionType = 'OOCalc';
|
||||
break;
|
||||
case 'slk':
|
||||
$extensionType = 'SYLK';
|
||||
break;
|
||||
case 'xml': // Excel 2003 SpreadSheetML
|
||||
$extensionType = 'Excel2003XML';
|
||||
break;
|
||||
case 'gnumeric':
|
||||
$extensionType = 'Gnumeric';
|
||||
break;
|
||||
case 'htm':
|
||||
case 'html':
|
||||
$extensionType = 'HTML';
|
||||
break;
|
||||
case 'csv':
|
||||
// Do nothing
|
||||
// We must not try to use CSV reader since it loads
|
||||
// all files including Excel files etc.
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ($extensionType !== NULL) {
|
||||
$reader = self::createReader($extensionType);
|
||||
// Let's see if we are lucky
|
||||
if (isset($reader) && $reader->canRead($pFilename)) {
|
||||
return $reader;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we reach here then "lucky guess" didn't give any result
|
||||
// Try walking through all the options in self::$_autoResolveClasses
|
||||
foreach (self::$_autoResolveClasses as $autoResolveClass) {
|
||||
// Ignore our original guess, we know that won't work
|
||||
if ($autoResolveClass !== $extensionType) {
|
||||
$reader = self::createReader($autoResolveClass);
|
||||
if ($reader->canRead($pFilename)) {
|
||||
return $reader;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new PHPExcel_Reader_Exception('Unable to identify a reader for this file');
|
||||
} // function createReaderForFile()
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_NamedRange
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_NamedRange
|
||||
{
|
||||
/**
|
||||
* Range name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_name;
|
||||
|
||||
/**
|
||||
* Worksheet on which the named range can be resolved
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
private $_worksheet;
|
||||
|
||||
/**
|
||||
* Range of the referenced cells
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_range;
|
||||
|
||||
/**
|
||||
* Is the named range local? (i.e. can only be used on $this->_worksheet)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_localOnly;
|
||||
|
||||
/**
|
||||
* Scope
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
private $_scope;
|
||||
|
||||
/**
|
||||
* Create a new NamedRange
|
||||
*
|
||||
* @param string $pName
|
||||
* @param PHPExcel_Worksheet $pWorksheet
|
||||
* @param string $pRange
|
||||
* @param bool $pLocalOnly
|
||||
* @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
|
||||
{
|
||||
// Validate data
|
||||
if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
|
||||
throw new PHPExcel_Exception('Parameters can not be null.');
|
||||
}
|
||||
|
||||
// Set local members
|
||||
$this->_name = $pName;
|
||||
$this->_worksheet = $pWorksheet;
|
||||
$this->_range = $pRange;
|
||||
$this->_localOnly = $pLocalOnly;
|
||||
$this->_scope = ($pLocalOnly == true) ?
|
||||
(($pScope == null) ? $pWorksheet : $pScope) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setName($value = null) {
|
||||
if ($value !== NULL) {
|
||||
// Old title
|
||||
$oldTitle = $this->_name;
|
||||
|
||||
// Re-attach
|
||||
if ($this->_worksheet !== NULL) {
|
||||
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
|
||||
}
|
||||
$this->_name = $value;
|
||||
|
||||
if ($this->_worksheet !== NULL) {
|
||||
$this->_worksheet->getParent()->addNamedRange($this);
|
||||
}
|
||||
|
||||
// New title
|
||||
$newTitle = $this->_name;
|
||||
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_worksheet->getParent(), $oldTitle, $newTitle);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get worksheet
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function getWorksheet() {
|
||||
return $this->_worksheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set worksheet
|
||||
*
|
||||
* @param PHPExcel_Worksheet $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setWorksheet(PHPExcel_Worksheet $value = null) {
|
||||
if ($value !== NULL) {
|
||||
$this->_worksheet = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get range
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRange() {
|
||||
return $this->_range;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set range
|
||||
*
|
||||
* @param string $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setRange($value = null) {
|
||||
if ($value !== NULL) {
|
||||
$this->_range = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get localOnly
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getLocalOnly() {
|
||||
return $this->_localOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set localOnly
|
||||
*
|
||||
* @param bool $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setLocalOnly($value = false) {
|
||||
$this->_localOnly = $value;
|
||||
$this->_scope = $value ? $this->_worksheet : null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scope
|
||||
*
|
||||
* @return PHPExcel_Worksheet|null
|
||||
*/
|
||||
public function getScope() {
|
||||
return $this->_scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set scope
|
||||
*
|
||||
* @param PHPExcel_Worksheet|null $value
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public function setScope(PHPExcel_Worksheet $value = null) {
|
||||
$this->_scope = $value;
|
||||
$this->_localOnly = ($value == null) ? false : true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a named range to a regular cell range
|
||||
*
|
||||
* @param string $pNamedRange Named range
|
||||
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) {
|
||||
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,922 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_ReferenceHelper (Singleton)
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_ReferenceHelper
|
||||
{
|
||||
/** Constants */
|
||||
/** Regular Expressions */
|
||||
const REFHELPER_REGEXP_CELLREF = '((\w*|\'[^!]*\')!)?(?<![:a-z\$])(\$?[a-z]{1,3}\$?\d+)(?=[^:!\d\'])';
|
||||
const REFHELPER_REGEXP_CELLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}\$?\d+):(\$?[a-z]{1,3}\$?\d+)';
|
||||
const REFHELPER_REGEXP_ROWRANGE = '((\w*|\'[^!]*\')!)?(\$?\d+):(\$?\d+)';
|
||||
const REFHELPER_REGEXP_COLRANGE = '((\w*|\'[^!]*\')!)?(\$?[a-z]{1,3}):(\$?[a-z]{1,3})';
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var PHPExcel_ReferenceHelper
|
||||
*/
|
||||
private static $_instance;
|
||||
|
||||
/**
|
||||
* Get an instance of this class
|
||||
*
|
||||
* @return PHPExcel_ReferenceHelper
|
||||
*/
|
||||
public static function getInstance() {
|
||||
if (!isset(self::$_instance) || (self::$_instance === NULL)) {
|
||||
self::$_instance = new PHPExcel_ReferenceHelper();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_ReferenceHelper
|
||||
*/
|
||||
protected function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two column addresses
|
||||
* Intended for use as a Callback function for sorting column addresses by column
|
||||
*
|
||||
* @param string $a First column to test (e.g. 'AA')
|
||||
* @param string $b Second column to test (e.g. 'Z')
|
||||
* @return integer
|
||||
*/
|
||||
public static function columnSort($a, $b) {
|
||||
return strcasecmp(strlen($a) . $a, strlen($b) . $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two column addresses
|
||||
* Intended for use as a Callback function for reverse sorting column addresses by column
|
||||
*
|
||||
* @param string $a First column to test (e.g. 'AA')
|
||||
* @param string $b Second column to test (e.g. 'Z')
|
||||
* @return integer
|
||||
*/
|
||||
public static function columnReverseSort($a, $b) {
|
||||
return 1 - strcasecmp(strlen($a) . $a, strlen($b) . $b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two cell addresses
|
||||
* Intended for use as a Callback function for sorting cell addresses by column and row
|
||||
*
|
||||
* @param string $a First cell to test (e.g. 'AA1')
|
||||
* @param string $b Second cell to test (e.g. 'Z1')
|
||||
* @return integer
|
||||
*/
|
||||
public static function cellSort($a, $b) {
|
||||
sscanf($a,'%[A-Z]%d', $ac, $ar);
|
||||
sscanf($b,'%[A-Z]%d', $bc, $br);
|
||||
|
||||
if ($ar == $br) {
|
||||
return strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
|
||||
}
|
||||
return ($ar < $br) ? -1 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two cell addresses
|
||||
* Intended for use as a Callback function for sorting cell addresses by column and row
|
||||
*
|
||||
* @param string $a First cell to test (e.g. 'AA1')
|
||||
* @param string $b Second cell to test (e.g. 'Z1')
|
||||
* @return integer
|
||||
*/
|
||||
public static function cellReverseSort($a, $b) {
|
||||
sscanf($a,'%[A-Z]%d', $ac, $ar);
|
||||
sscanf($b,'%[A-Z]%d', $bc, $br);
|
||||
|
||||
if ($ar == $br) {
|
||||
return 1 - strcasecmp(strlen($ac) . $ac, strlen($bc) . $bc);
|
||||
}
|
||||
return ($ar < $br) ? 1 : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether a cell address falls within a defined range of cells
|
||||
*
|
||||
* @param string $cellAddress Address of the cell we're testing
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @return boolean
|
||||
*/
|
||||
private static function cellAddressInDeleteRange($cellAddress, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols) {
|
||||
list($cellColumn, $cellRow) = PHPExcel_Cell::coordinateFromString($cellAddress);
|
||||
$cellColumnIndex = PHPExcel_Cell::columnIndexFromString($cellColumn);
|
||||
// Is cell within the range of rows/columns if we're deleting
|
||||
if ($pNumRows < 0 &&
|
||||
($cellRow >= ($beforeRow + $pNumRows)) &&
|
||||
($cellRow < $beforeRow)) {
|
||||
return TRUE;
|
||||
} elseif ($pNumCols < 0 &&
|
||||
($cellColumnIndex >= ($beforeColumnIndex + $pNumCols)) &&
|
||||
($cellColumnIndex < $beforeColumnIndex)) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update page breaks when inserting/deleting rows/columns
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function _adjustPageBreaks(PHPExcel_Worksheet $pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aBreaks = $pSheet->getBreaks();
|
||||
($pNumCols > 0 || $pNumRows > 0) ?
|
||||
uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||
uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||
|
||||
foreach ($aBreaks as $key => $value) {
|
||||
if (self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) {
|
||||
// If we're deleting, then clear any defined breaks that are within the range
|
||||
// of rows/columns that we're deleting
|
||||
$pSheet->setBreak($key, PHPExcel_Worksheet::BREAK_NONE);
|
||||
} else {
|
||||
// Otherwise update any affected breaks by inserting a new break at the appropriate point
|
||||
// and removing the old affected break
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
if ($key != $newReference) {
|
||||
$pSheet->setBreak($newReference, $value)
|
||||
->setBreak($key, PHPExcel_Worksheet::BREAK_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update cell comments when inserting/deleting rows/columns
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function _adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aComments = $pSheet->getComments();
|
||||
$aNewComments = array(); // the new array of all comments
|
||||
|
||||
foreach ($aComments as $key => &$value) {
|
||||
// Any comments inside a deleted range will be ignored
|
||||
if (!self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) {
|
||||
// Otherwise build a new array of comments indexed by the adjusted cell reference
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
$aNewComments[$newReference] = $value;
|
||||
}
|
||||
}
|
||||
// Replace the comments array with the new set of comments
|
||||
$pSheet->setComments($aNewComments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update hyperlinks when inserting/deleting rows/columns
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function _adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aHyperlinkCollection = $pSheet->getHyperlinkCollection();
|
||||
($pNumCols > 0 || $pNumRows > 0) ?
|
||||
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||
|
||||
foreach ($aHyperlinkCollection as $key => $value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
if ($key != $newReference) {
|
||||
$pSheet->setHyperlink( $newReference, $value );
|
||||
$pSheet->setHyperlink( $key, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update data validations when inserting/deleting rows/columns
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function _adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aDataValidationCollection = $pSheet->getDataValidationCollection();
|
||||
($pNumCols > 0 || $pNumRows > 0) ?
|
||||
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||
foreach ($aDataValidationCollection as $key => $value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
if ($key != $newReference) {
|
||||
$pSheet->setDataValidation( $newReference, $value );
|
||||
$pSheet->setDataValidation( $key, null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update merged cells when inserting/deleting rows/columns
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function _adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aMergeCells = $pSheet->getMergeCells();
|
||||
$aNewMergeCells = array(); // the new array of all merge cells
|
||||
foreach ($aMergeCells as $key => &$value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
$aNewMergeCells[$newReference] = $newReference;
|
||||
}
|
||||
$pSheet->setMergeCells($aNewMergeCells); // replace the merge cells array
|
||||
}
|
||||
|
||||
/**
|
||||
* Update protected cells when inserting/deleting rows/columns
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function _adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aProtectedCells = $pSheet->getProtectedCells();
|
||||
($pNumCols > 0 || $pNumRows > 0) ?
|
||||
uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||
uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||
foreach ($aProtectedCells as $key => $value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
if ($key != $newReference) {
|
||||
$pSheet->protectCells( $newReference, $value, true );
|
||||
$pSheet->unprotectCells( $key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update column dimensions when inserting/deleting rows/columns
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function _adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aColumnDimensions = array_reverse($pSheet->getColumnDimensions(), true);
|
||||
if (!empty($aColumnDimensions)) {
|
||||
foreach ($aColumnDimensions as $objColumnDimension) {
|
||||
$newReference = $this->updateCellReference($objColumnDimension->getColumnIndex() . '1', $pBefore, $pNumCols, $pNumRows);
|
||||
list($newReference) = PHPExcel_Cell::coordinateFromString($newReference);
|
||||
if ($objColumnDimension->getColumnIndex() != $newReference) {
|
||||
$objColumnDimension->setColumnIndex($newReference);
|
||||
}
|
||||
}
|
||||
$pSheet->refreshColumnDimensions();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update row dimensions when inserting/deleting rows/columns
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||
* @param string $pBefore Insert/Delete before this cell address (e.g. 'A1')
|
||||
* @param integer $beforeColumnIndex Index number of the column we're inserting/deleting before
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $beforeRow Number of the row we're inserting/deleting before
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
*/
|
||||
protected function _adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows)
|
||||
{
|
||||
$aRowDimensions = array_reverse($pSheet->getRowDimensions(), true);
|
||||
if (!empty($aRowDimensions)) {
|
||||
foreach ($aRowDimensions as $objRowDimension) {
|
||||
$newReference = $this->updateCellReference('A' . $objRowDimension->getRowIndex(), $pBefore, $pNumCols, $pNumRows);
|
||||
list(, $newReference) = PHPExcel_Cell::coordinateFromString($newReference);
|
||||
if ($objRowDimension->getRowIndex() != $newReference) {
|
||||
$objRowDimension->setRowIndex($newReference);
|
||||
}
|
||||
}
|
||||
$pSheet->refreshRowDimensions();
|
||||
|
||||
$copyDimension = $pSheet->getRowDimension($beforeRow - 1);
|
||||
for ($i = $beforeRow; $i <= $beforeRow - 1 + $pNumRows; ++$i) {
|
||||
$newDimension = $pSheet->getRowDimension($i);
|
||||
$newDimension->setRowHeight($copyDimension->getRowHeight());
|
||||
$newDimension->setVisible($copyDimension->getVisible());
|
||||
$newDimension->setOutlineLevel($copyDimension->getOutlineLevel());
|
||||
$newDimension->setCollapsed($copyDimension->getCollapsed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new column or row, updating all possible related data
|
||||
*
|
||||
* @param string $pBefore Insert before this cell address (e.g. 'A1')
|
||||
* @param integer $pNumCols Number of columns to insert/delete (negative values indicate deletion)
|
||||
* @param integer $pNumRows Number of rows to insert/delete (negative values indicate deletion)
|
||||
* @param PHPExcel_Worksheet $pSheet The worksheet that we're editing
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = NULL)
|
||||
{
|
||||
$remove = ($pNumCols < 0 || $pNumRows < 0);
|
||||
$aCellCollection = $pSheet->getCellCollection();
|
||||
|
||||
// Get coordinates of $pBefore
|
||||
$beforeColumn = 'A';
|
||||
$beforeRow = 1;
|
||||
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString($pBefore);
|
||||
$beforeColumnIndex = PHPExcel_Cell::columnIndexFromString($beforeColumn);
|
||||
|
||||
// Clear cells if we are removing columns or rows
|
||||
$highestColumn = $pSheet->getHighestColumn();
|
||||
$highestRow = $pSheet->getHighestRow();
|
||||
|
||||
// 1. Clear column strips if we are removing columns
|
||||
if ($pNumCols < 0 && $beforeColumnIndex - 2 + $pNumCols > 0) {
|
||||
for ($i = 1; $i <= $highestRow - 1; ++$i) {
|
||||
for ($j = $beforeColumnIndex - 1 + $pNumCols; $j <= $beforeColumnIndex - 2; ++$j) {
|
||||
$coordinate = PHPExcel_Cell::stringFromColumnIndex($j) . $i;
|
||||
$pSheet->removeConditionalStyles($coordinate);
|
||||
if ($pSheet->cellExists($coordinate)) {
|
||||
$pSheet->getCell($coordinate)->setValueExplicit('', PHPExcel_Cell_DataType::TYPE_NULL);
|
||||
$pSheet->getCell($coordinate)->setXfIndex(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Clear row strips if we are removing rows
|
||||
if ($pNumRows < 0 && $beforeRow - 1 + $pNumRows > 0) {
|
||||
for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
|
||||
for ($j = $beforeRow + $pNumRows; $j <= $beforeRow - 1; ++$j) {
|
||||
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . $j;
|
||||
$pSheet->removeConditionalStyles($coordinate);
|
||||
if ($pSheet->cellExists($coordinate)) {
|
||||
$pSheet->getCell($coordinate)->setValueExplicit('', PHPExcel_Cell_DataType::TYPE_NULL);
|
||||
$pSheet->getCell($coordinate)->setXfIndex(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through cells, bottom-up, and change cell coordinates
|
||||
if($remove) {
|
||||
// It's faster to reverse and pop than to use unshift, especially with large cell collections
|
||||
$aCellCollection = array_reverse($aCellCollection);
|
||||
}
|
||||
while ($cellID = array_pop($aCellCollection)) {
|
||||
$cell = $pSheet->getCell($cellID);
|
||||
$cellIndex = PHPExcel_Cell::columnIndexFromString($cell->getColumn());
|
||||
|
||||
if ($cellIndex-1 + $pNumCols < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// New coordinates
|
||||
$newCoordinates = PHPExcel_Cell::stringFromColumnIndex($cellIndex-1 + $pNumCols) . ($cell->getRow() + $pNumRows);
|
||||
|
||||
// Should the cell be updated? Move value and cellXf index from one cell to another.
|
||||
if (($cellIndex >= $beforeColumnIndex) &&
|
||||
($cell->getRow() >= $beforeRow)) {
|
||||
|
||||
// Update cell styles
|
||||
$pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex());
|
||||
|
||||
// Insert this cell at its new location
|
||||
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||
// Formula should be adjusted
|
||||
$pSheet->getCell($newCoordinates)
|
||||
->setValue($this->updateFormulaReferences($cell->getValue(),
|
||||
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
|
||||
} else {
|
||||
// Formula should not be adjusted
|
||||
$pSheet->getCell($newCoordinates)->setValue($cell->getValue());
|
||||
}
|
||||
|
||||
// Clear the original cell
|
||||
$pSheet->getCellCacheController()->deleteCacheData($cellID);
|
||||
|
||||
} else {
|
||||
/* We don't need to update styles for rows/columns before our insertion position,
|
||||
but we do still need to adjust any formulae in those cells */
|
||||
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||
// Formula should be adjusted
|
||||
$cell->setValue($this->updateFormulaReferences($cell->getValue(),
|
||||
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Duplicate styles for the newly inserted cells
|
||||
$highestColumn = $pSheet->getHighestColumn();
|
||||
$highestRow = $pSheet->getHighestRow();
|
||||
|
||||
if ($pNumCols > 0 && $beforeColumnIndex - 2 > 0) {
|
||||
for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
|
||||
|
||||
// Style
|
||||
$coordinate = PHPExcel_Cell::stringFromColumnIndex( $beforeColumnIndex - 2 ) . $i;
|
||||
if ($pSheet->cellExists($coordinate)) {
|
||||
$xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
|
||||
$conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ?
|
||||
$pSheet->getConditionalStyles($coordinate) : false;
|
||||
for ($j = $beforeColumnIndex - 1; $j <= $beforeColumnIndex - 2 + $pNumCols; ++$j) {
|
||||
$pSheet->getCellByColumnAndRow($j, $i)->setXfIndex($xfIndex);
|
||||
if ($conditionalStyles) {
|
||||
$cloned = array();
|
||||
foreach ($conditionalStyles as $conditionalStyle) {
|
||||
$cloned[] = clone $conditionalStyle;
|
||||
}
|
||||
$pSheet->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($j) . $i, $cloned);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($pNumRows > 0 && $beforeRow - 1 > 0) {
|
||||
for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
|
||||
|
||||
// Style
|
||||
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1);
|
||||
if ($pSheet->cellExists($coordinate)) {
|
||||
$xfIndex = $pSheet->getCell($coordinate)->getXfIndex();
|
||||
$conditionalStyles = $pSheet->conditionalStylesExists($coordinate) ?
|
||||
$pSheet->getConditionalStyles($coordinate) : false;
|
||||
for ($j = $beforeRow; $j <= $beforeRow - 1 + $pNumRows; ++$j) {
|
||||
$pSheet->getCell(PHPExcel_Cell::stringFromColumnIndex($i) . $j)->setXfIndex($xfIndex);
|
||||
if ($conditionalStyles) {
|
||||
$cloned = array();
|
||||
foreach ($conditionalStyles as $conditionalStyle) {
|
||||
$cloned[] = clone $conditionalStyle;
|
||||
}
|
||||
$pSheet->setConditionalStyles(PHPExcel_Cell::stringFromColumnIndex($i) . $j, $cloned);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update worksheet: column dimensions
|
||||
$this->_adjustColumnDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||
|
||||
// Update worksheet: row dimensions
|
||||
$this->_adjustRowDimensions($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||
|
||||
// Update worksheet: page breaks
|
||||
$this->_adjustPageBreaks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||
|
||||
// Update worksheet: comments
|
||||
$this->_adjustComments($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||
|
||||
// Update worksheet: hyperlinks
|
||||
$this->_adjustHyperlinks($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||
|
||||
// Update worksheet: data validations
|
||||
$this->_adjustDataValidations($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||
|
||||
// Update worksheet: merge cells
|
||||
$this->_adjustMergeCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||
|
||||
// Update worksheet: protected cells
|
||||
$this->_adjustProtectedCells($pSheet, $pBefore, $beforeColumnIndex, $pNumCols, $beforeRow, $pNumRows);
|
||||
|
||||
// Update worksheet: autofilter
|
||||
$autoFilter = $pSheet->getAutoFilter();
|
||||
$autoFilterRange = $autoFilter->getRange();
|
||||
if (!empty($autoFilterRange)) {
|
||||
if ($pNumCols != 0) {
|
||||
$autoFilterColumns = array_keys($autoFilter->getColumns());
|
||||
if (count($autoFilterColumns) > 0) {
|
||||
sscanf($pBefore,'%[A-Z]%d', $column, $row);
|
||||
$columnIndex = PHPExcel_Cell::columnIndexFromString($column);
|
||||
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
|
||||
if ($columnIndex <= $rangeEnd[0]) {
|
||||
if ($pNumCols < 0) {
|
||||
// If we're actually deleting any columns that fall within the autofilter range,
|
||||
// then we delete any rules for those columns
|
||||
$deleteColumn = $columnIndex + $pNumCols - 1;
|
||||
$deleteCount = abs($pNumCols);
|
||||
for ($i = 1; $i <= $deleteCount; ++$i) {
|
||||
if (in_array(PHPExcel_Cell::stringFromColumnIndex($deleteColumn),$autoFilterColumns)) {
|
||||
$autoFilter->clearColumn(PHPExcel_Cell::stringFromColumnIndex($deleteColumn));
|
||||
}
|
||||
++$deleteColumn;
|
||||
}
|
||||
}
|
||||
$startCol = ($columnIndex > $rangeStart[0]) ? $columnIndex : $rangeStart[0];
|
||||
|
||||
// Shuffle columns in autofilter range
|
||||
if ($pNumCols > 0) {
|
||||
// For insert, we shuffle from end to beginning to avoid overwriting
|
||||
$startColID = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||
$toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1);
|
||||
$endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]);
|
||||
|
||||
$startColRef = $startCol;
|
||||
$endColRef = $rangeEnd[0];
|
||||
$toColRef = $rangeEnd[0]+$pNumCols;
|
||||
|
||||
do {
|
||||
$autoFilter->shiftColumn(PHPExcel_Cell::stringFromColumnIndex($endColRef-1),PHPExcel_Cell::stringFromColumnIndex($toColRef-1));
|
||||
--$endColRef;
|
||||
--$toColRef;
|
||||
} while ($startColRef <= $endColRef);
|
||||
} else {
|
||||
// For delete, we shuffle from beginning to end to avoid overwriting
|
||||
$startColID = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||
$toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1);
|
||||
$endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]);
|
||||
do {
|
||||
$autoFilter->shiftColumn($startColID,$toColID);
|
||||
++$startColID;
|
||||
++$toColID;
|
||||
} while ($startColID != $endColID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$pSheet->setAutoFilter( $this->updateCellReference($autoFilterRange, $pBefore, $pNumCols, $pNumRows) );
|
||||
}
|
||||
|
||||
// Update worksheet: freeze pane
|
||||
if ($pSheet->getFreezePane() != '') {
|
||||
$pSheet->freezePane( $this->updateCellReference($pSheet->getFreezePane(), $pBefore, $pNumCols, $pNumRows) );
|
||||
}
|
||||
|
||||
// Page setup
|
||||
if ($pSheet->getPageSetup()->isPrintAreaSet()) {
|
||||
$pSheet->getPageSetup()->setPrintArea( $this->updateCellReference($pSheet->getPageSetup()->getPrintArea(), $pBefore, $pNumCols, $pNumRows) );
|
||||
}
|
||||
|
||||
// Update worksheet: drawings
|
||||
$aDrawings = $pSheet->getDrawingCollection();
|
||||
foreach ($aDrawings as $objDrawing) {
|
||||
$newReference = $this->updateCellReference($objDrawing->getCoordinates(), $pBefore, $pNumCols, $pNumRows);
|
||||
if ($objDrawing->getCoordinates() != $newReference) {
|
||||
$objDrawing->setCoordinates($newReference);
|
||||
}
|
||||
}
|
||||
|
||||
// Update workbook: named ranges
|
||||
if (count($pSheet->getParent()->getNamedRanges()) > 0) {
|
||||
foreach ($pSheet->getParent()->getNamedRanges() as $namedRange) {
|
||||
if ($namedRange->getWorksheet()->getHashCode() == $pSheet->getHashCode()) {
|
||||
$namedRange->setRange(
|
||||
$this->updateCellReference($namedRange->getRange(), $pBefore, $pNumCols, $pNumRows)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Garbage collect
|
||||
$pSheet->garbageCollect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update references within formulas
|
||||
*
|
||||
* @param string $pFormula Formula to update
|
||||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to insert
|
||||
* @param int $pNumRows Number of rows to insert
|
||||
* @param string $sheetName Worksheet name/title
|
||||
* @return string Updated formula
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') {
|
||||
// Update cell references in the formula
|
||||
$formulaBlocks = explode('"',$pFormula);
|
||||
$i = false;
|
||||
foreach($formulaBlocks as &$formulaBlock) {
|
||||
// Ignore blocks that were enclosed in quotes (alternating entries in the $formulaBlocks array after the explode)
|
||||
if ($i = !$i) {
|
||||
$adjustCount = 0;
|
||||
$newCellTokens = $cellTokens = array();
|
||||
// Search for row ranges (e.g. 'Sheet1'!3:5 or 3:5) with or without $ absolutes (e.g. $3:5)
|
||||
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_ROWRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
|
||||
if ($matchCount > 0) {
|
||||
foreach($matches as $match) {
|
||||
$fromString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$fromString .= $match[3].':'.$match[4];
|
||||
$modified3 = substr($this->updateCellReference('$A'.$match[3],$pBefore,$pNumCols,$pNumRows),2);
|
||||
$modified4 = substr($this->updateCellReference('$A'.$match[4],$pBefore,$pNumCols,$pNumRows),2);
|
||||
|
||||
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
|
||||
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
|
||||
$toString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$toString .= $modified3.':'.$modified4;
|
||||
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
|
||||
$column = 100000;
|
||||
$row = 10000000+trim($match[3],'$');
|
||||
$cellIndex = $column.$row;
|
||||
|
||||
$newCellTokens[$cellIndex] = preg_quote($toString);
|
||||
$cellTokens[$cellIndex] = '/(?<!\d\$\!)'.preg_quote($fromString).'(?!\d)/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Search for column ranges (e.g. 'Sheet1'!C:E or C:E) with or without $ absolutes (e.g. $C:E)
|
||||
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_COLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
|
||||
if ($matchCount > 0) {
|
||||
foreach($matches as $match) {
|
||||
$fromString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$fromString .= $match[3].':'.$match[4];
|
||||
$modified3 = substr($this->updateCellReference($match[3].'$1',$pBefore,$pNumCols,$pNumRows),0,-2);
|
||||
$modified4 = substr($this->updateCellReference($match[4].'$1',$pBefore,$pNumCols,$pNumRows),0,-2);
|
||||
|
||||
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
|
||||
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
|
||||
$toString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$toString .= $modified3.':'.$modified4;
|
||||
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
|
||||
$column = PHPExcel_Cell::columnIndexFromString(trim($match[3],'$')) + 100000;
|
||||
$row = 10000000;
|
||||
$cellIndex = $column.$row;
|
||||
|
||||
$newCellTokens[$cellIndex] = preg_quote($toString);
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z\$\!])'.preg_quote($fromString).'(?![A-Z])/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Search for cell ranges (e.g. 'Sheet1'!A3:C5 or A3:C5) with or without $ absolutes (e.g. $A1:C$5)
|
||||
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
|
||||
if ($matchCount > 0) {
|
||||
foreach($matches as $match) {
|
||||
$fromString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$fromString .= $match[3].':'.$match[4];
|
||||
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows);
|
||||
$modified4 = $this->updateCellReference($match[4],$pBefore,$pNumCols,$pNumRows);
|
||||
|
||||
if ($match[3].$match[4] !== $modified3.$modified4) {
|
||||
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
|
||||
$toString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$toString .= $modified3.':'.$modified4;
|
||||
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]);
|
||||
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
|
||||
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
|
||||
$row = trim($row,'$') + 10000000;
|
||||
$cellIndex = $column.$row;
|
||||
|
||||
$newCellTokens[$cellIndex] = preg_quote($toString);
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z]\$\!)'.preg_quote($fromString).'(?!\d)/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Search for cell references (e.g. 'Sheet1'!A3 or C5) with or without $ absolutes (e.g. $A1 or C$5)
|
||||
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLREF.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
|
||||
|
||||
if ($matchCount > 0) {
|
||||
foreach($matches as $match) {
|
||||
$fromString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$fromString .= $match[3];
|
||||
|
||||
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows);
|
||||
if ($match[3] !== $modified3) {
|
||||
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
|
||||
$toString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$toString .= $modified3;
|
||||
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]);
|
||||
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
|
||||
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
|
||||
$row = trim($row,'$') + 10000000;
|
||||
$cellIndex = $row . $column;
|
||||
|
||||
$newCellTokens[$cellIndex] = preg_quote($toString);
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z\$\!])'.preg_quote($fromString).'(?!\d)/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($adjustCount > 0) {
|
||||
if ($pNumCols > 0 || $pNumRows > 0) {
|
||||
krsort($cellTokens);
|
||||
krsort($newCellTokens);
|
||||
} else {
|
||||
ksort($cellTokens);
|
||||
ksort($newCellTokens);
|
||||
} // Update cell references in the formula
|
||||
$formulaBlock = str_replace('\\','',preg_replace($cellTokens,$newCellTokens,$formulaBlock));
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($formulaBlock);
|
||||
|
||||
// Then rebuild the formula string
|
||||
return implode('"',$formulaBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update cell reference
|
||||
*
|
||||
* @param string $pCellRange Cell range
|
||||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to increment
|
||||
* @param int $pNumRows Number of rows to increment
|
||||
* @return string Updated cell range
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
// Is it in another worksheet? Will not have to update anything.
|
||||
if (strpos($pCellRange, "!") !== false) {
|
||||
return $pCellRange;
|
||||
// Is it a range or a single cell?
|
||||
} elseif (strpos($pCellRange, ':') === false && strpos($pCellRange, ',') === false) {
|
||||
// Single cell
|
||||
return $this->_updateSingleCellReference($pCellRange, $pBefore, $pNumCols, $pNumRows);
|
||||
} elseif (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) {
|
||||
// Range
|
||||
return $this->_updateCellRange($pCellRange, $pBefore, $pNumCols, $pNumRows);
|
||||
} else {
|
||||
// Return original
|
||||
return $pCellRange;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update named formulas (i.e. containing worksheet references / named ranges)
|
||||
*
|
||||
* @param PHPExcel $pPhpExcel Object to update
|
||||
* @param string $oldName Old name (name to replace)
|
||||
* @param string $newName New name
|
||||
*/
|
||||
public function updateNamedFormulas(PHPExcel $pPhpExcel, $oldName = '', $newName = '') {
|
||||
if ($oldName == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($pPhpExcel->getWorksheetIterator() as $sheet) {
|
||||
foreach ($sheet->getCellCollection(false) as $cellID) {
|
||||
$cell = $sheet->getCell($cellID);
|
||||
if (($cell !== NULL) && ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA)) {
|
||||
$formula = $cell->getValue();
|
||||
if (strpos($formula, $oldName) !== false) {
|
||||
$formula = str_replace("'" . $oldName . "'!", "'" . $newName . "'!", $formula);
|
||||
$formula = str_replace($oldName . "!", $newName . "!", $formula);
|
||||
$cell->setValueExplicit($formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update cell range
|
||||
*
|
||||
* @param string $pCellRange Cell range (e.g. 'B2:D4', 'B:C' or '2:3')
|
||||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to increment
|
||||
* @param int $pNumRows Number of rows to increment
|
||||
* @return string Updated cell range
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) {
|
||||
// Update range
|
||||
$range = PHPExcel_Cell::splitRange($pCellRange);
|
||||
$ic = count($range);
|
||||
for ($i = 0; $i < $ic; ++$i) {
|
||||
$jc = count($range[$i]);
|
||||
for ($j = 0; $j < $jc; ++$j) {
|
||||
if (ctype_alpha($range[$i][$j])) {
|
||||
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows));
|
||||
$range[$i][$j] = $r[0];
|
||||
} elseif(ctype_digit($range[$i][$j])) {
|
||||
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows));
|
||||
$range[$i][$j] = $r[1];
|
||||
} else {
|
||||
$range[$i][$j] = $this->_updateSingleCellReference($range[$i][$j], $pBefore, $pNumCols, $pNumRows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recreate range string
|
||||
return PHPExcel_Cell::buildRange($range);
|
||||
} else {
|
||||
throw new PHPExcel_Exception("Only cell ranges may be passed to this method.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update single cell reference
|
||||
*
|
||||
* @param string $pCellReference Single cell reference
|
||||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to increment
|
||||
* @param int $pNumRows Number of rows to increment
|
||||
* @return string Updated cell reference
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) {
|
||||
// Get coordinates of $pBefore
|
||||
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );
|
||||
|
||||
// Get coordinates of $pCellReference
|
||||
list($newColumn, $newRow) = PHPExcel_Cell::coordinateFromString( $pCellReference );
|
||||
|
||||
// Verify which parts should be updated
|
||||
$updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') &&
|
||||
PHPExcel_Cell::columnIndexFromString($newColumn) >= PHPExcel_Cell::columnIndexFromString($beforeColumn));
|
||||
$updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') &&
|
||||
$newRow >= $beforeRow);
|
||||
|
||||
// Create new column reference
|
||||
if ($updateColumn) {
|
||||
$newColumn = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($newColumn) - 1 + $pNumCols );
|
||||
}
|
||||
|
||||
// Create new row reference
|
||||
if ($updateRow) {
|
||||
$newRow = $newRow + $pNumRows;
|
||||
}
|
||||
|
||||
// Return new reference
|
||||
return $newColumn . $newRow;
|
||||
} else {
|
||||
throw new PHPExcel_Exception("Only single cell references may be passed to this method.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* __clone implementation. Cloning should not be allowed in a Singleton!
|
||||
*
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public final function __clone() {
|
||||
throw new PHPExcel_Exception("Cloning a Singleton is not allowed!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_RichText
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
{
|
||||
/**
|
||||
* Rich text elements
|
||||
*
|
||||
* @var PHPExcel_RichText_ITextElement[]
|
||||
*/
|
||||
private $_richTextElements;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_RichText instance
|
||||
*
|
||||
* @param PHPExcel_Cell $pCell
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function __construct(PHPExcel_Cell $pCell = null)
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_richTextElements = array();
|
||||
|
||||
// Rich-Text string attached to cell?
|
||||
if ($pCell !== NULL) {
|
||||
// Add cell text and style
|
||||
if ($pCell->getValue() != "") {
|
||||
$objRun = new PHPExcel_RichText_Run($pCell->getValue());
|
||||
$objRun->setFont(clone $pCell->getParent()->getStyle($pCell->getCoordinate())->getFont());
|
||||
$this->addText($objRun);
|
||||
}
|
||||
|
||||
// Set parent value
|
||||
$pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add text
|
||||
*
|
||||
* @param PHPExcel_RichText_ITextElement $pText Rich text element
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_RichText
|
||||
*/
|
||||
public function addText(PHPExcel_RichText_ITextElement $pText = null)
|
||||
{
|
||||
$this->_richTextElements[] = $pText;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return PHPExcel_RichText_TextElement
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function createText($pText = '')
|
||||
{
|
||||
$objText = new PHPExcel_RichText_TextElement($pText);
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create text run
|
||||
*
|
||||
* @param string $pText Text
|
||||
* @return PHPExcel_RichText_Run
|
||||
* @throws PHPExcel_Exception
|
||||
*/
|
||||
public function createTextRun($pText = '')
|
||||
{
|
||||
$objText = new PHPExcel_RichText_Run($pText);
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPlainText()
|
||||
{
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop through all PHPExcel_RichText_ITextElement
|
||||
foreach ($this->_richTextElements as $text) {
|
||||
$returnValue .= $text->getText();
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getPlainText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rich Text elements
|
||||
*
|
||||
* @return PHPExcel_RichText_ITextElement[]
|
||||
*/
|
||||
public function getRichTextElements()
|
||||
{
|
||||
return $this->_richTextElements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Rich Text elements
|
||||
*
|
||||
* @param PHPExcel_RichText_ITextElement[] $pElements Array of elements
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_RichText
|
||||
*/
|
||||
public function setRichTextElements($pElements = null)
|
||||
{
|
||||
if (is_array($pElements)) {
|
||||
$this->_richTextElements = $pElements;
|
||||
} else {
|
||||
throw new PHPExcel_Exception("Invalid PHPExcel_RichText_ITextElement[] array passed.");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hashElements = '';
|
||||
foreach ($this->_richTextElements as $element) {
|
||||
$hashElements .= $element->getHashCode();
|
||||
}
|
||||
|
||||
return md5(
|
||||
$hashElements
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,391 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Settings
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
|
||||
class PHPExcel_Settings
|
||||
{
|
||||
/** constants */
|
||||
/** Available Zip library classes */
|
||||
const PCLZIP = 'PHPExcel_Shared_ZipArchive';
|
||||
const ZIPARCHIVE = 'ZipArchive';
|
||||
|
||||
/** Optional Chart Rendering libraries */
|
||||
const CHART_RENDERER_JPGRAPH = 'jpgraph';
|
||||
|
||||
/** Optional PDF Rendering libraries */
|
||||
const PDF_RENDERER_TCPDF = 'tcPDF';
|
||||
const PDF_RENDERER_DOMPDF = 'DomPDF';
|
||||
const PDF_RENDERER_MPDF = 'mPDF';
|
||||
|
||||
|
||||
private static $_chartRenderers = array(
|
||||
self::CHART_RENDERER_JPGRAPH,
|
||||
);
|
||||
|
||||
private static $_pdfRenderers = array(
|
||||
self::PDF_RENDERER_TCPDF,
|
||||
self::PDF_RENDERER_DOMPDF,
|
||||
self::PDF_RENDERER_MPDF,
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Name of the class used for Zip file management
|
||||
* e.g.
|
||||
* ZipArchive
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_zipClass = self::ZIPARCHIVE;
|
||||
|
||||
|
||||
/**
|
||||
* Name of the external Library used for rendering charts
|
||||
* e.g.
|
||||
* jpgraph
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_chartRendererName = NULL;
|
||||
|
||||
/**
|
||||
* Directory Path to the external Library used for rendering charts
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_chartRendererPath = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Name of the external Library used for rendering PDF files
|
||||
* e.g.
|
||||
* mPDF
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_pdfRendererName = NULL;
|
||||
|
||||
/**
|
||||
* Directory Path to the external Library used for rendering PDF files
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_pdfRendererPath = NULL;
|
||||
|
||||
/**
|
||||
* Default options for libxml loader
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $_libXmlLoaderOptions = null;
|
||||
|
||||
/**
|
||||
* Set the Zip handler Class that PHPExcel should use for Zip file management (PCLZip or ZipArchive)
|
||||
*
|
||||
* @param string $zipClass The Zip handler class that PHPExcel should use for Zip file management
|
||||
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setZipClass($zipClass)
|
||||
{
|
||||
if (($zipClass === self::PCLZIP) ||
|
||||
($zipClass === self::ZIPARCHIVE)) {
|
||||
self::$_zipClass = $zipClass;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
} // function setZipClass()
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the Zip handler Class that PHPExcel is configured to use (PCLZip or ZipArchive)
|
||||
* or Zip file management
|
||||
*
|
||||
* @return string Name of the Zip handler Class that PHPExcel is configured to use
|
||||
* for Zip file management
|
||||
* e.g. PHPExcel_Settings::PCLZip or PHPExcel_Settings::ZipArchive
|
||||
*/
|
||||
public static function getZipClass()
|
||||
{
|
||||
return self::$_zipClass;
|
||||
} // function getZipClass()
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the method that is currently configured for cell cacheing
|
||||
*
|
||||
* @return string Name of the cacheing method
|
||||
*/
|
||||
public static function getCacheStorageMethod()
|
||||
{
|
||||
return PHPExcel_CachedObjectStorageFactory::getCacheStorageMethod();
|
||||
} // function getCacheStorageMethod()
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the class that is currently being used for cell cacheing
|
||||
*
|
||||
* @return string Name of the class currently being used for cacheing
|
||||
*/
|
||||
public static function getCacheStorageClass()
|
||||
{
|
||||
return PHPExcel_CachedObjectStorageFactory::getCacheStorageClass();
|
||||
} // function getCacheStorageClass()
|
||||
|
||||
|
||||
/**
|
||||
* Set the method that should be used for cell cacheing
|
||||
*
|
||||
* @param string $method Name of the cacheing method
|
||||
* @param array $arguments Optional configuration arguments for the cacheing method
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setCacheStorageMethod(
|
||||
$method = PHPExcel_CachedObjectStorageFactory::cache_in_memory,
|
||||
$arguments = array()
|
||||
)
|
||||
{
|
||||
return PHPExcel_CachedObjectStorageFactory::initialize($method, $arguments);
|
||||
} // function setCacheStorageMethod()
|
||||
|
||||
|
||||
/**
|
||||
* Set the locale code to use for formula translations and any special formatting
|
||||
*
|
||||
* @param string $locale The locale code to use (e.g. "fr" or "pt_br" or "en_uk")
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setLocale($locale='en_us')
|
||||
{
|
||||
return PHPExcel_Calculation::getInstance()->setLocale($locale);
|
||||
} // function setLocale()
|
||||
|
||||
|
||||
/**
|
||||
* Set details of the external library that PHPExcel should use for rendering charts
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setChartRenderer($libraryName, $libraryBaseDir)
|
||||
{
|
||||
if (!self::setChartRendererName($libraryName))
|
||||
return FALSE;
|
||||
return self::setChartRendererPath($libraryBaseDir);
|
||||
} // function setChartRenderer()
|
||||
|
||||
|
||||
/**
|
||||
* Identify to PHPExcel the external library to use for rendering charts
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setChartRendererName($libraryName)
|
||||
{
|
||||
if (!in_array($libraryName,self::$_chartRenderers)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self::$_chartRendererName = $libraryName;
|
||||
|
||||
return TRUE;
|
||||
} // function setChartRendererName()
|
||||
|
||||
|
||||
/**
|
||||
* Tell PHPExcel where to find the external library to use for rendering charts
|
||||
*
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setChartRendererPath($libraryBaseDir)
|
||||
{
|
||||
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
|
||||
return FALSE;
|
||||
}
|
||||
self::$_chartRendererPath = $libraryBaseDir;
|
||||
|
||||
return TRUE;
|
||||
} // function setChartRendererPath()
|
||||
|
||||
|
||||
/**
|
||||
* Return the Chart Rendering Library that PHPExcel is currently configured to use (e.g. jpgraph)
|
||||
*
|
||||
* @return string|NULL Internal reference name of the Chart Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
* e.g. PHPExcel_Settings::CHART_RENDERER_JPGRAPH
|
||||
*/
|
||||
public static function getChartRendererName()
|
||||
{
|
||||
return self::$_chartRendererName;
|
||||
} // function getChartRendererName()
|
||||
|
||||
|
||||
/**
|
||||
* Return the directory path to the Chart Rendering Library that PHPExcel is currently configured to use
|
||||
*
|
||||
* @return string|NULL Directory Path to the Chart Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
*/
|
||||
public static function getChartRendererPath()
|
||||
{
|
||||
return self::$_chartRendererPath;
|
||||
} // function getChartRendererPath()
|
||||
|
||||
|
||||
/**
|
||||
* Set details of the external library that PHPExcel should use for rendering PDF files
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setPdfRenderer($libraryName, $libraryBaseDir)
|
||||
{
|
||||
if (!self::setPdfRendererName($libraryName))
|
||||
return FALSE;
|
||||
return self::setPdfRendererPath($libraryBaseDir);
|
||||
} // function setPdfRenderer()
|
||||
|
||||
|
||||
/**
|
||||
* Identify to PHPExcel the external library to use for rendering PDF files
|
||||
*
|
||||
* @param string $libraryName Internal reference name of the library
|
||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||
*
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setPdfRendererName($libraryName)
|
||||
{
|
||||
if (!in_array($libraryName,self::$_pdfRenderers)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
self::$_pdfRendererName = $libraryName;
|
||||
|
||||
return TRUE;
|
||||
} // function setPdfRendererName()
|
||||
|
||||
|
||||
/**
|
||||
* Tell PHPExcel where to find the external library to use for rendering PDF files
|
||||
*
|
||||
* @param string $libraryBaseDir Directory path to the library's base folder
|
||||
* @return boolean Success or failure
|
||||
*/
|
||||
public static function setPdfRendererPath($libraryBaseDir)
|
||||
{
|
||||
if ((file_exists($libraryBaseDir) === false) || (is_readable($libraryBaseDir) === false)) {
|
||||
return FALSE;
|
||||
}
|
||||
self::$_pdfRendererPath = $libraryBaseDir;
|
||||
|
||||
return TRUE;
|
||||
} // function setPdfRendererPath()
|
||||
|
||||
|
||||
/**
|
||||
* Return the PDF Rendering Library that PHPExcel is currently configured to use (e.g. dompdf)
|
||||
*
|
||||
* @return string|NULL Internal reference name of the PDF Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
* e.g. PHPExcel_Settings::PDF_RENDERER_TCPDF,
|
||||
* PHPExcel_Settings::PDF_RENDERER_DOMPDF
|
||||
* or PHPExcel_Settings::PDF_RENDERER_MPDF
|
||||
*/
|
||||
public static function getPdfRendererName()
|
||||
{
|
||||
return self::$_pdfRendererName;
|
||||
} // function getPdfRendererName()
|
||||
|
||||
/**
|
||||
* Return the directory path to the PDF Rendering Library that PHPExcel is currently configured to use
|
||||
*
|
||||
* @return string|NULL Directory Path to the PDF Rendering Library that PHPExcel is
|
||||
* currently configured to use
|
||||
*/
|
||||
public static function getPdfRendererPath()
|
||||
{
|
||||
return self::$_pdfRendererPath;
|
||||
} // function getPdfRendererPath()
|
||||
|
||||
/**
|
||||
* Set default options for libxml loader
|
||||
*
|
||||
* @param int $options Default options for libxml loader
|
||||
*/
|
||||
public static function setLibXmlLoaderOptions($options = null)
|
||||
{
|
||||
if (is_null($options) && defined(LIBXML_DTDLOAD)) {
|
||||
$options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
|
||||
}
|
||||
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
|
||||
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
|
||||
}
|
||||
self::$_libXmlLoaderOptions = $options;
|
||||
} // function setLibXmlLoaderOptions
|
||||
|
||||
/**
|
||||
* Get default options for libxml loader.
|
||||
* Defaults to LIBXML_DTDLOAD | LIBXML_DTDATTR when not set explicitly.
|
||||
*
|
||||
* @return int Default options for libxml loader
|
||||
*/
|
||||
public static function getLibXmlLoaderOptions()
|
||||
{
|
||||
if (is_null(self::$_libXmlLoaderOptions) && defined(LIBXML_DTDLOAD)) {
|
||||
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
|
||||
}
|
||||
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
|
||||
@libxml_disable_entity_loader(self::$_libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
|
||||
}
|
||||
return self::$_libXmlLoaderOptions;
|
||||
} // function getLibXmlLoaderOptions
|
||||
}
|
|
@ -0,0 +1,668 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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_Style
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Style
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
|
||||
{
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var PHPExcel_Style_Font
|
||||
*/
|
||||
protected $_font;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
*
|
||||
* @var PHPExcel_Style_Fill
|
||||
*/
|
||||
protected $_fill;
|
||||
|
||||
/**
|
||||
* Borders
|
||||
*
|
||||
* @var PHPExcel_Style_Borders
|
||||
*/
|
||||
protected $_borders;
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var PHPExcel_Style_Alignment
|
||||
*/
|
||||
protected $_alignment;
|
||||
|
||||
/**
|
||||
* Number Format
|
||||
*
|
||||
* @var PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
protected $_numberFormat;
|
||||
|
||||
/**
|
||||
* Conditional styles
|
||||
*
|
||||
* @var PHPExcel_Style_Conditional[]
|
||||
*/
|
||||
protected $_conditionalStyles;
|
||||
|
||||
/**
|
||||
* Protection
|
||||
*
|
||||
* @var PHPExcel_Style_Protection
|
||||
*/
|
||||
protected $_protection;
|
||||
|
||||
/**
|
||||
* Index of style in collection. Only used for real style.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_index;
|
||||
|
||||
/**
|
||||
* Use Quote Prefix when displaying in cell editor. Only used for real style.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_quotePrefix = false;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Style
|
||||
*
|
||||
* @param boolean $isSupervisor Flag indicating if this is a supervisor or not
|
||||
* Leave this value at default unless you understand exactly what
|
||||
* its ramifications are
|
||||
* @param boolean $isConditional Flag indicating if this is a conditional style or not
|
||||
* Leave this value at default unless you understand exactly what
|
||||
* its ramifications are
|
||||
*/
|
||||
public function __construct($isSupervisor = false, $isConditional = false)
|
||||
{
|
||||
// Supervisor?
|
||||
$this->_isSupervisor = $isSupervisor;
|
||||
|
||||
// Initialise values
|
||||
$this->_conditionalStyles = array();
|
||||
$this->_font = new PHPExcel_Style_Font($isSupervisor, $isConditional);
|
||||
$this->_fill = new PHPExcel_Style_Fill($isSupervisor, $isConditional);
|
||||
$this->_borders = new PHPExcel_Style_Borders($isSupervisor, $isConditional);
|
||||
$this->_alignment = new PHPExcel_Style_Alignment($isSupervisor, $isConditional);
|
||||
$this->_numberFormat = new PHPExcel_Style_NumberFormat($isSupervisor, $isConditional);
|
||||
$this->_protection = new PHPExcel_Style_Protection($isSupervisor, $isConditional);
|
||||
|
||||
// bind parent if we are a supervisor
|
||||
if ($isSupervisor) {
|
||||
$this->_font->bindParent($this);
|
||||
$this->_fill->bindParent($this);
|
||||
$this->_borders->bindParent($this);
|
||||
$this->_alignment->bindParent($this);
|
||||
$this->_numberFormat->bindParent($this);
|
||||
$this->_protection->bindParent($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shared style component for the currently active cell in currently active sheet.
|
||||
* Only used for style supervisor
|
||||
*
|
||||
* @return PHPExcel_Style
|
||||
*/
|
||||
public function getSharedComponent()
|
||||
{
|
||||
$activeSheet = $this->getActiveSheet();
|
||||
$selectedCell = $this->getActiveCell(); // e.g. 'A1'
|
||||
|
||||
if ($activeSheet->cellExists($selectedCell)) {
|
||||
$xfIndex = $activeSheet->getCell($selectedCell)->getXfIndex();
|
||||
} else {
|
||||
$xfIndex = 0;
|
||||
}
|
||||
|
||||
return $this->_parent->getCellXfByIndex($xfIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent. Only used for style supervisor
|
||||
*
|
||||
* @return PHPExcel
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build style array from subcomponents
|
||||
*
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
public function getStyleArray($array)
|
||||
{
|
||||
return array('quotePrefix' => $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray(
|
||||
* array(
|
||||
* 'font' => array(
|
||||
* 'name' => 'Arial',
|
||||
* 'bold' => true,
|
||||
* 'italic' => false,
|
||||
* 'underline' => PHPExcel_Style_Font::UNDERLINE_DOUBLE,
|
||||
* 'strike' => false,
|
||||
* 'color' => array(
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* ),
|
||||
* 'borders' => array(
|
||||
* 'bottom' => array(
|
||||
* 'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
|
||||
* 'color' => array(
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* ),
|
||||
* 'top' => array(
|
||||
* 'style' => PHPExcel_Style_Border::BORDER_DASHDOT,
|
||||
* 'color' => array(
|
||||
* 'rgb' => '808080'
|
||||
* )
|
||||
* )
|
||||
* ),
|
||||
* 'quotePrefix' => true
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @param boolean $pAdvanced Advanced mode for setting borders.
|
||||
* @throws PHPExcel_Exception
|
||||
* @return PHPExcel_Style
|
||||
*/
|
||||
public function applyFromArray($pStyles = null, $pAdvanced = true)
|
||||
{
|
||||
if (is_array($pStyles)) {
|
||||
if ($this->_isSupervisor) {
|
||||
|
||||
$pRange = $this->getSelectedCells();
|
||||
|
||||
// Uppercase coordinate
|
||||
$pRange = strtoupper($pRange);
|
||||
|
||||
// Is it a cell range or a single cell?
|
||||
if (strpos($pRange, ':') === false) {
|
||||
$rangeA = $pRange;
|
||||
$rangeB = $pRange;
|
||||
} else {
|
||||
list($rangeA, $rangeB) = explode(':', $pRange);
|
||||
}
|
||||
|
||||
// Calculate range outer borders
|
||||
$rangeStart = PHPExcel_Cell::coordinateFromString($rangeA);
|
||||
$rangeEnd = PHPExcel_Cell::coordinateFromString($rangeB);
|
||||
|
||||
// Translate column into index
|
||||
$rangeStart[0] = PHPExcel_Cell::columnIndexFromString($rangeStart[0]) - 1;
|
||||
$rangeEnd[0] = PHPExcel_Cell::columnIndexFromString($rangeEnd[0]) - 1;
|
||||
|
||||
// Make sure we can loop upwards on rows and columns
|
||||
if ($rangeStart[0] > $rangeEnd[0] && $rangeStart[1] > $rangeEnd[1]) {
|
||||
$tmp = $rangeStart;
|
||||
$rangeStart = $rangeEnd;
|
||||
$rangeEnd = $tmp;
|
||||
}
|
||||
|
||||
// ADVANCED MODE:
|
||||
|
||||
if ($pAdvanced && isset($pStyles['borders'])) {
|
||||
|
||||
// 'allborders' is a shorthand property for 'outline' and 'inside' and
|
||||
// it applies to components that have not been set explicitly
|
||||
if (isset($pStyles['borders']['allborders'])) {
|
||||
foreach (array('outline', 'inside') as $component) {
|
||||
if (!isset($pStyles['borders'][$component])) {
|
||||
$pStyles['borders'][$component] = $pStyles['borders']['allborders'];
|
||||
}
|
||||
}
|
||||
unset($pStyles['borders']['allborders']); // not needed any more
|
||||
}
|
||||
|
||||
// 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left'
|
||||
// it applies to components that have not been set explicitly
|
||||
if (isset($pStyles['borders']['outline'])) {
|
||||
foreach (array('top', 'right', 'bottom', 'left') as $component) {
|
||||
if (!isset($pStyles['borders'][$component])) {
|
||||
$pStyles['borders'][$component] = $pStyles['borders']['outline'];
|
||||
}
|
||||
}
|
||||
unset($pStyles['borders']['outline']); // not needed any more
|
||||
}
|
||||
|
||||
// 'inside' is a shorthand property for 'vertical' and 'horizontal'
|
||||
// it applies to components that have not been set explicitly
|
||||
if (isset($pStyles['borders']['inside'])) {
|
||||
foreach (array('vertical', 'horizontal') as $component) {
|
||||
if (!isset($pStyles['borders'][$component])) {
|
||||
$pStyles['borders'][$component] = $pStyles['borders']['inside'];
|
||||
}
|
||||
}
|
||||
unset($pStyles['borders']['inside']); // not needed any more
|
||||
}
|
||||
|
||||
// width and height characteristics of selection, 1, 2, or 3 (for 3 or more)
|
||||
$xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3);
|
||||
$yMax = min($rangeEnd[1] - $rangeStart[1] + 1, 3);
|
||||
|
||||
// loop through up to 3 x 3 = 9 regions
|
||||
for ($x = 1; $x <= $xMax; ++$x) {
|
||||
// start column index for region
|
||||
$colStart = ($x == 3) ?
|
||||
PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0])
|
||||
: PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $x - 1);
|
||||
|
||||
// end column index for region
|
||||
$colEnd = ($x == 1) ?
|
||||
PHPExcel_Cell::stringFromColumnIndex($rangeStart[0])
|
||||
: PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0] - $xMax + $x);
|
||||
|
||||
for ($y = 1; $y <= $yMax; ++$y) {
|
||||
|
||||
// which edges are touching the region
|
||||
$edges = array();
|
||||
|
||||
// are we at left edge
|
||||
if ($x == 1) {
|
||||
$edges[] = 'left';
|
||||
}
|
||||
|
||||
// are we at right edge
|
||||
if ($x == $xMax) {
|
||||
$edges[] = 'right';
|
||||
}
|
||||
|
||||
// are we at top edge?
|
||||
if ($y == 1) {
|
||||
$edges[] = 'top';
|
||||
}
|
||||
|
||||
// are we at bottom edge?
|
||||
if ($y == $yMax) {
|
||||
$edges[] = 'bottom';
|
||||
}
|
||||
|
||||
// start row index for region
|
||||
$rowStart = ($y == 3) ?
|
||||
$rangeEnd[1] : $rangeStart[1] + $y - 1;
|
||||
|
||||
// end row index for region
|
||||
$rowEnd = ($y == 1) ?
|
||||
$rangeStart[1] : $rangeEnd[1] - $yMax + $y;
|
||||
|
||||
// build range for region
|
||||
$range = $colStart . $rowStart . ':' . $colEnd . $rowEnd;
|
||||
|
||||
// retrieve relevant style array for region
|
||||
$regionStyles = $pStyles;
|
||||
unset($regionStyles['borders']['inside']);
|
||||
|
||||
// what are the inner edges of the region when looking at the selection
|
||||
$innerEdges = array_diff( array('top', 'right', 'bottom', 'left'), $edges );
|
||||
|
||||
// inner edges that are not touching the region should take the 'inside' border properties if they have been set
|
||||
foreach ($innerEdges as $innerEdge) {
|
||||
switch ($innerEdge) {
|
||||
case 'top':
|
||||
case 'bottom':
|
||||
// should pick up 'horizontal' border property if set
|
||||
if (isset($pStyles['borders']['horizontal'])) {
|
||||
$regionStyles['borders'][$innerEdge] = $pStyles['borders']['horizontal'];
|
||||
} else {
|
||||
unset($regionStyles['borders'][$innerEdge]);
|
||||
}
|
||||
break;
|
||||
case 'left':
|
||||
case 'right':
|
||||
// should pick up 'vertical' border property if set
|
||||
if (isset($pStyles['borders']['vertical'])) {
|
||||
$regionStyles['borders'][$innerEdge] = $pStyles['borders']['vertical'];
|
||||
} else {
|
||||
unset($regionStyles['borders'][$innerEdge]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// apply region style to region by calling applyFromArray() in simple mode
|
||||
$this->getActiveSheet()->getStyle($range)->applyFromArray($regionStyles, false);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
// SIMPLE MODE:
|
||||
|
||||
// Selection type, inspect
|
||||
if (preg_match('/^[A-Z]+1:[A-Z]+1048576$/', $pRange)) {
|
||||
$selectionType = 'COLUMN';
|
||||
} else if (preg_match('/^A[0-9]+:XFD[0-9]+$/', $pRange)) {
|
||||
$selectionType = 'ROW';
|
||||
} else {
|
||||
$selectionType = 'CELL';
|
||||
}
|
||||
|
||||
// First loop through columns, rows, or cells to find out which styles are affected by this operation
|
||||
switch ($selectionType) {
|
||||
case 'COLUMN':
|
||||
$oldXfIndexes = array();
|
||||
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
|
||||
$oldXfIndexes[$this->getActiveSheet()->getColumnDimensionByColumn($col)->getXfIndex()] = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'ROW':
|
||||
$oldXfIndexes = array();
|
||||
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
|
||||
if ($this->getActiveSheet()->getRowDimension($row)->getXfIndex() == null) {
|
||||
$oldXfIndexes[0] = true; // row without explicit style should be formatted based on default style
|
||||
} else {
|
||||
$oldXfIndexes[$this->getActiveSheet()->getRowDimension($row)->getXfIndex()] = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'CELL':
|
||||
$oldXfIndexes = array();
|
||||
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
|
||||
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
|
||||
$oldXfIndexes[$this->getActiveSheet()->getCellByColumnAndRow($col, $row)->getXfIndex()] = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// clone each of the affected styles, apply the style array, and add the new styles to the workbook
|
||||
$workbook = $this->getActiveSheet()->getParent();
|
||||
foreach ($oldXfIndexes as $oldXfIndex => $dummy) {
|
||||
$style = $workbook->getCellXfByIndex($oldXfIndex);
|
||||
$newStyle = clone $style;
|
||||
$newStyle->applyFromArray($pStyles);
|
||||
|
||||
if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) {
|
||||
// there is already such cell Xf in our collection
|
||||
$newXfIndexes[$oldXfIndex] = $existingStyle->getIndex();
|
||||
} else {
|
||||
// we don't have such a cell Xf, need to add
|
||||
$workbook->addCellXf($newStyle);
|
||||
$newXfIndexes[$oldXfIndex] = $newStyle->getIndex();
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through columns, rows, or cells again and update the XF index
|
||||
switch ($selectionType) {
|
||||
case 'COLUMN':
|
||||
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
|
||||
$columnDimension = $this->getActiveSheet()->getColumnDimensionByColumn($col);
|
||||
$oldXfIndex = $columnDimension->getXfIndex();
|
||||
$columnDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'ROW':
|
||||
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
|
||||
$rowDimension = $this->getActiveSheet()->getRowDimension($row);
|
||||
$oldXfIndex = $rowDimension->getXfIndex() === null ?
|
||||
0 : $rowDimension->getXfIndex(); // row without explicit style should be formatted based on default style
|
||||
$rowDimension->setXfIndex($newXfIndexes[$oldXfIndex]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'CELL':
|
||||
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
|
||||
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
|
||||
$cell = $this->getActiveSheet()->getCellByColumnAndRow($col, $row);
|
||||
$oldXfIndex = $cell->getXfIndex();
|
||||
$cell->setXfIndex($newXfIndexes[$oldXfIndex]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
// not a supervisor, just apply the style array directly on style object
|
||||
if (array_key_exists('fill', $pStyles)) {
|
||||
$this->getFill()->applyFromArray($pStyles['fill']);
|
||||
}
|
||||
if (array_key_exists('font', $pStyles)) {
|
||||
$this->getFont()->applyFromArray($pStyles['font']);
|
||||
}
|
||||
if (array_key_exists('borders', $pStyles)) {
|
||||
$this->getBorders()->applyFromArray($pStyles['borders']);
|
||||
}
|
||||
if (array_key_exists('alignment', $pStyles)) {
|
||||
$this->getAlignment()->applyFromArray($pStyles['alignment']);
|
||||
}
|
||||
if (array_key_exists('numberformat', $pStyles)) {
|
||||
$this->getNumberFormat()->applyFromArray($pStyles['numberformat']);
|
||||
}
|
||||
if (array_key_exists('protection', $pStyles)) {
|
||||
$this->getProtection()->applyFromArray($pStyles['protection']);
|
||||
}
|
||||
if (array_key_exists('quotePrefix', $pStyles)) {
|
||||
$this->_quotePrefix = $pStyles['quotePrefix'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new PHPExcel_Exception("Invalid style array passed.");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill
|
||||
*
|
||||
* @return PHPExcel_Style_Fill
|
||||
*/
|
||||
public function getFill()
|
||||
{
|
||||
return $this->_fill;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Font
|
||||
*
|
||||
* @return PHPExcel_Style_Font
|
||||
*/
|
||||
public function getFont()
|
||||
{
|
||||
return $this->_font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param PHPExcel_Style_Font $font
|
||||
* @return PHPExcel_Style
|
||||
*/
|
||||
public function setFont(PHPExcel_Style_Font $font)
|
||||
{
|
||||
$this->_font = $font;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Borders
|
||||
*
|
||||
* @return PHPExcel_Style_Borders
|
||||
*/
|
||||
public function getBorders()
|
||||
{
|
||||
return $this->_borders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Alignment
|
||||
*
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function getAlignment()
|
||||
{
|
||||
return $this->_alignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number Format
|
||||
*
|
||||
* @return PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
public function getNumberFormat()
|
||||
{
|
||||
return $this->_numberFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Conditional Styles. Only used on supervisor.
|
||||
*
|
||||
* @return PHPExcel_Style_Conditional[]
|
||||
*/
|
||||
public function getConditionalStyles()
|
||||
{
|
||||
return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Conditional Styles. Only used on supervisor.
|
||||
*
|
||||
* @param PHPExcel_Style_Conditional[] $pValue Array of condtional styles
|
||||
* @return PHPExcel_Style
|
||||
*/
|
||||
public function setConditionalStyles($pValue = null)
|
||||
{
|
||||
if (is_array($pValue)) {
|
||||
$this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $pValue);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Protection
|
||||
*
|
||||
* @return PHPExcel_Style_Protection
|
||||
*/
|
||||
public function getProtection()
|
||||
{
|
||||
return $this->_protection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get quote prefix
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getQuotePrefix()
|
||||
{
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getQuotePrefix();
|
||||
}
|
||||
return $this->_quotePrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set quote prefix
|
||||
*
|
||||
* @param boolean $pValue
|
||||
*/
|
||||
public function setQuotePrefix($pValue)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = false;
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = array('quotePrefix' => $pValue);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_quotePrefix = (boolean) $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode()
|
||||
{
|
||||
$hashConditionals = '';
|
||||
foreach ($this->_conditionalStyles as $conditional) {
|
||||
$hashConditionals .= $conditional->getHashCode();
|
||||
}
|
||||
|
||||
return md5(
|
||||
$this->_fill->getHashCode()
|
||||
. $this->_font->getHashCode()
|
||||
. $this->_borders->getHashCode()
|
||||
. $this->_alignment->getHashCode()
|
||||
. $this->_numberFormat->getHashCode()
|
||||
. $hashConditionals
|
||||
. $this->_protection->getHashCode()
|
||||
. ($this->_quotePrefix ? 't' : 'f')
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get own index in style collection
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
return $this->_index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set own index in style collection
|
||||
*
|
||||
* @param int $pValue
|
||||
*/
|
||||
public function setIndex($pValue)
|
||||
{
|
||||
$this->_index = $pValue;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 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 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version ##VERSION##, ##DATE##
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_WorksheetIterator
|
||||
*
|
||||
* Used to iterate worksheets in PHPExcel
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_WorksheetIterator implements Iterator
|
||||
{
|
||||
/**
|
||||
* Spreadsheet to iterate
|
||||
*
|
||||
* @var PHPExcel
|
||||
*/
|
||||
private $_subject;
|
||||
|
||||
/**
|
||||
* Current iterator position
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_position = 0;
|
||||
|
||||
/**
|
||||
* Create a new worksheet iterator
|
||||
*
|
||||
* @param PHPExcel $subject
|
||||
*/
|
||||
public function __construct(PHPExcel $subject = null)
|
||||
{
|
||||
// Set subject
|
||||
$this->_subject = $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
unset($this->_subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind iterator
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->_position = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current PHPExcel_Worksheet
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return $this->_subject->getSheet($this->_position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current key
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return $this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Next value
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
++$this->_position;
|
||||
}
|
||||
|
||||
/**
|
||||
* More PHPExcel_Worksheet instances available?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return $this->_position < $this->_subject->getSheetCount();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue