Merge branch 'master' of ssh://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin
This commit is contained in:
commit
65911c57e1
@ -82,6 +82,8 @@ $Id$
|
||||
+ [doc] Incorporate synchronisation docs into main document.
|
||||
+ [core] Include Content Security Policy HTTP headers.
|
||||
- bug #3004216 [CSS] Field attributes use inline CSS
|
||||
- patch #2999595, rfe #2998130 [interface] Cleanup navigation frame.
|
||||
- [core] Update library PHPExcel to version 1.7.3c
|
||||
|
||||
3.3.4.0 (not yet released)
|
||||
- bug #2996161 [import] properly escape import value
|
||||
@ -91,6 +93,10 @@ $Id$
|
||||
+ [lang] Updated lot of translation based on work done in master branch.
|
||||
- bug #3008411 [databases] Last dropped database remains active in navi
|
||||
- bug #2986383 [parser] Not all data being shown / counted
|
||||
- bug [synchronize] Rows were deleted in target table regardless of the
|
||||
"Would you like to delete..." option
|
||||
- bug [privileges] List of tables not shown when the db name has a wildcard
|
||||
- bug #3011126 [display] Edit link missing after long query
|
||||
|
||||
3.3.3.0 (2010-05-10)
|
||||
- patch #2982480 [navi] Do not group if there would be one table in group,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,45 +20,31 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/** PHPExcel_Cell */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
|
||||
/** PHPExcel_DocumentProperties */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/DocumentProperties.php';
|
||||
|
||||
/** PHPExcel_DocumentSecurity */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/DocumentSecurity.php';
|
||||
|
||||
/** PHPExcel_Worksheet */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
|
||||
|
||||
/** PHPExcel_Shared_ZipStreamWrapper */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/ZipStreamWrapper.php';
|
||||
|
||||
/** PHPExcel_NamedRange */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/NamedRange.php';
|
||||
|
||||
/** PHPExcel_WorksheetIterator */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/WorksheetIterator.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel
|
||||
{
|
||||
@ -146,6 +132,16 @@ class PHPExcel
|
||||
$this->addCellStyleXf(new PHPExcel_Style);
|
||||
}
|
||||
|
||||
|
||||
public function disconnectWorksheets() {
|
||||
foreach($this->_workSheetCollection as $k => &$worksheet) {
|
||||
$worksheet->disconnectCells();
|
||||
$this->_workSheetCollection[$k] = null;
|
||||
}
|
||||
unset($worksheet);
|
||||
$this->_workSheetCollection = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties
|
||||
*
|
||||
@ -212,6 +208,8 @@ class PHPExcel
|
||||
* Add sheet
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet
|
||||
* @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
|
||||
* @return PHPExcel_Worksheet
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addSheet(PHPExcel_Worksheet $pSheet = null, $iSheetIndex = null)
|
||||
@ -229,7 +227,14 @@ class PHPExcel
|
||||
0,
|
||||
array($pSheet)
|
||||
);
|
||||
|
||||
// Adjust active sheet index if necessary
|
||||
if ($this->_activeSheetIndex >= $iSheetIndex) {
|
||||
++$this->_activeSheetIndex;
|
||||
}
|
||||
|
||||
}
|
||||
return $pSheet;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -370,6 +375,23 @@ class PHPExcel
|
||||
return $this->getActiveSheet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active sheet index by name
|
||||
*
|
||||
* @param string $pValue Sheet title
|
||||
* @return PHPExcel_Worksheet
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setActiveSheetIndexByName($pValue = '')
|
||||
{
|
||||
if (($worksheet = $this->getSheetByName($pValue)) instanceof PHPExcel_Worksheet) {
|
||||
$this->setActiveSheetIndex($worksheet->getParent()->getIndex($worksheet));
|
||||
return $worksheet;
|
||||
}
|
||||
|
||||
throw new Exception('Workbook does not contain sheet:' . $pValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet names
|
||||
*
|
||||
@ -390,10 +412,11 @@ class PHPExcel
|
||||
* Add external sheet
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet External sheet to add
|
||||
* @param int|null $iSheetIndex Index where sheet should go (0,1,..., or null for last)
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function addExternalSheet(PHPExcel_Worksheet $pSheet) {
|
||||
public function addExternalSheet(PHPExcel_Worksheet $pSheet, $iSheetIndex = null) {
|
||||
if (!is_null($this->getSheetByName($pSheet->getTitle()))) {
|
||||
throw new Exception("Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename the external sheet first.");
|
||||
}
|
||||
@ -410,11 +433,12 @@ class PHPExcel
|
||||
$pSheet->rebindParent($this);
|
||||
|
||||
// update the cellXfs
|
||||
foreach ($pSheet->getCellCollection(false) as $cell) {
|
||||
foreach ($pSheet->getCellCollection(false) as $cellID) {
|
||||
$cell = $sheet->getCell($cellID);
|
||||
$cell->setXfIndex( $cell->getXfIndex() + $countCellXfs );
|
||||
}
|
||||
|
||||
return $this->addSheet($pSheet);
|
||||
return $this->addSheet($pSheet, $iSheetIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -433,7 +457,13 @@ class PHPExcel
|
||||
* @return PHPExcel
|
||||
*/
|
||||
public function addNamedRange(PHPExcel_NamedRange $namedRange) {
|
||||
$this->_namedRanges[$namedRange->getWorksheet()->getTitle().'!'.$namedRange->getName()] = $namedRange;
|
||||
if ($namedRange->getScope() == null) {
|
||||
// global scope
|
||||
$this->_namedRanges[$namedRange->getName()] = $namedRange;
|
||||
} else {
|
||||
// local scope
|
||||
$this->_namedRanges[$namedRange->getScope()->getTitle().'!'.$namedRange->getName()] = $namedRange;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -441,57 +471,42 @@ class PHPExcel
|
||||
* Get named range
|
||||
*
|
||||
* @param string $namedRange
|
||||
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
|
||||
* @return PHPExcel_NamedRange|null
|
||||
*/
|
||||
public function getNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
|
||||
$returnValue = null;
|
||||
|
||||
if ($namedRange != '' && !is_null($namedRange)) {
|
||||
if (!is_null($pSheet)) {
|
||||
$key = $pSheet->getTitle().'!'.$namedRange;
|
||||
if (isset($this->_namedRanges[$key])) {
|
||||
return $this->_namedRanges[$key];
|
||||
}
|
||||
// first look for global defined name
|
||||
if (isset($this->_namedRanges[$namedRange])) {
|
||||
$returnValue = $this->_namedRanges[$namedRange];
|
||||
}
|
||||
$returnCount = 0;
|
||||
foreach($this->_namedRanges as $_namedRange) {
|
||||
if ($_namedRange->getName() == $namedRange) {
|
||||
if ((!is_null($pSheet)) && ($_namedRange->getWorksheet()->getTitle() == $pSheet->getTitle())) {
|
||||
return $_namedRange;
|
||||
} else {
|
||||
$returnCount++;
|
||||
$returnValue = $_namedRange;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($returnCount == 1) {
|
||||
return $returnValue;
|
||||
|
||||
// then look for local defined name (has priority over global defined name if both names exist)
|
||||
if (!is_null($pSheet) && isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
|
||||
$returnValue = $this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove named range
|
||||
*
|
||||
* @param string $namedRange
|
||||
* @param PHPExcel_Worksheet|null $pSheet. Scope. Use null for global scope.
|
||||
* @return PHPExcel
|
||||
*/
|
||||
public function removeNamedRange($namedRange, PHPExcel_Worksheet $pSheet = null) {
|
||||
if ($namedRange != '' && !is_null($namedRange)) {
|
||||
if (!is_null($pSheet)) {
|
||||
$key = $pSheet->getTitle().'!'.$namedRange;
|
||||
if (isset($this->_namedRanges[$key])) {
|
||||
unset($this->_namedRanges[$key]);
|
||||
}
|
||||
if (is_null($pSheet)) {
|
||||
if (isset($this->_namedRanges[$namedRange])) {
|
||||
unset($this->_namedRanges[$namedRange]);
|
||||
}
|
||||
foreach($this->_namedRanges as $_namedRange) {
|
||||
if ($_namedRange->getName() == $namedRange) {
|
||||
if ((!is_null($pSheet)) && ($_namedRange->getWorksheet()->getTitle() == $pSheet->getTitle())) {
|
||||
$key = $pSheet->getTitle().'!'.$namedRange;
|
||||
if (isset($this->_namedRanges[$key])) {
|
||||
unset($this->_namedRanges[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange])) {
|
||||
unset($this->_namedRanges[$pSheet->getTitle() . '!' . $namedRange]);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
@ -612,7 +627,8 @@ class PHPExcel
|
||||
|
||||
// then update cellXf indexes for cells
|
||||
foreach ($this->_workSheetCollection as $worksheet) {
|
||||
foreach ($worksheet->getCellCollection(false) as $cell) {
|
||||
foreach ($worksheet->getCellCollection(false) as $cellID) {
|
||||
$cell = $sheet->getCell($cellID);
|
||||
$xfIndex = $cell->getXfIndex();
|
||||
if ($xfIndex > $pIndex ) {
|
||||
// decrease xf index by 1
|
||||
@ -700,7 +716,8 @@ class PHPExcel
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminate all unneeded cellXf and afterwards update the xfIndex for all cells in the workbook
|
||||
* Eliminate all unneeded cellXf and afterwards update the xfIndex for all cells
|
||||
* and columns in the workbook
|
||||
*/
|
||||
public function garbageCollect()
|
||||
{
|
||||
@ -711,12 +728,28 @@ class PHPExcel
|
||||
}
|
||||
|
||||
foreach ($this->getWorksheetIterator() as $sheet) {
|
||||
foreach ($sheet->getCellCollection(false) as $cell) {
|
||||
|
||||
// from cells
|
||||
foreach ($sheet->getCellCollection(false) as $cellID) {
|
||||
$cell = $sheet->getCell($cellID);
|
||||
++$countReferencesCellXf[$cell->getXfIndex()];
|
||||
}
|
||||
|
||||
// from row dimensions
|
||||
foreach ($sheet->getRowDimensions() as $rowDimension) {
|
||||
if ($rowDimension->getXfIndex() !== null) {
|
||||
++$countReferencesCellXf[$rowDimension->getXfIndex()];
|
||||
}
|
||||
}
|
||||
|
||||
// from column dimensions
|
||||
foreach ($sheet->getColumnDimensions() as $columnDimension) {
|
||||
++$countReferencesCellXf[$columnDimension->getXfIndex()];
|
||||
}
|
||||
}
|
||||
|
||||
// remove those cellXfs that have zero references and create mapping so we can update xfIndex for all cells
|
||||
// remove cellXfs without references and create mapping so we can update xfIndex
|
||||
// for all cells and columns
|
||||
$countNeededCellXfs = 0;
|
||||
foreach ($this->_cellXfCollection as $index => $cellXf) {
|
||||
if ($countReferencesCellXf[$index] > 0 || $index == 0) { // we must never remove the first cellXf
|
||||
@ -728,16 +761,36 @@ class PHPExcel
|
||||
}
|
||||
$this->_cellXfCollection = array_values($this->_cellXfCollection);
|
||||
|
||||
// if we removed the first style by accident, recreate it
|
||||
// update the index for all cellXfs
|
||||
foreach ($this->_cellXfCollection as $i => $cellXf) {
|
||||
$cellXf->setIndex($i);
|
||||
}
|
||||
|
||||
// make sure there is always at least one cellXf (there should be)
|
||||
if (count($this->_cellXfCollection) == 0) {
|
||||
$this->_cellXfCollection[] = new PHPExcel_Style();
|
||||
}
|
||||
|
||||
// update the xfIndex for all cells
|
||||
// update the xfIndex for all cells, row dimensions, column dimensions
|
||||
foreach ($this->getWorksheetIterator() as $sheet) {
|
||||
foreach ($sheet->getCellCollection(false) as $cell) {
|
||||
|
||||
// for all cells
|
||||
foreach ($sheet->getCellCollection(false) as $cellID) {
|
||||
$cell = $sheet->getCell($cellID);
|
||||
$cell->setXfIndex( $map[$cell->getXfIndex()] );
|
||||
}
|
||||
|
||||
// for all row dimensions
|
||||
foreach ($sheet->getRowDimensions() as $rowDimension) {
|
||||
if ($rowDimension->getXfIndex() !== null) {
|
||||
$rowDimension->setXfIndex( $map[$rowDimension->getXfIndex()] );
|
||||
}
|
||||
}
|
||||
|
||||
// for all column dimensions
|
||||
foreach ($sheet->getColumnDimensions() as $columnDimension) {
|
||||
$columnDimension->setXfIndex( $map[$columnDimension->getXfIndex()] );
|
||||
}
|
||||
}
|
||||
|
||||
// also do garbage collection for all the sheets
|
||||
|
||||
@ -2,38 +2,50 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
class PHPExcel_Autoloader
|
||||
{
|
||||
public static function Register() {
|
||||
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'));
|
||||
} // function Register()
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** Require FPDF library */
|
||||
$k_path_url = dirname(__FILE__) . '/PDF';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PDF/tcpdf.php';
|
||||
public static function Load($pObjectName){
|
||||
if ((class_exists($pObjectName)) || (strpos($pObjectName, 'PHPExcel') === False)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pObjectFilePath = PHPEXCEL_ROOT.
|
||||
str_replace('_',DIRECTORY_SEPARATOR,$pObjectName).
|
||||
'.php';
|
||||
|
||||
if ((file_exists($pObjectFilePath) === false) || (is_readable($pObjectFilePath) === false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
require($pObjectFilePath);
|
||||
} // function Load()
|
||||
|
||||
}
|
||||
193
libraries/PHPExcel/PHPExcel/CachedObjectStorage/APC.php
Normal file
193
libraries/PHPExcel/PHPExcel/CachedObjectStorage/APC.php
Normal file
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_APC
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_APC extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
private $_cachePrefix = null;
|
||||
|
||||
private $_cacheTime = 600;
|
||||
|
||||
|
||||
private function _storeData() {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
if (!apc_store($this->_cachePrefix.$this->_currentObjectID.'.cache',serialize($this->_currentObject),$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell in APC');
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->_currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in apc
|
||||
$success = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry no longer exists in APC');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = apc_fetch($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in APC, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry no longer exists in APC');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
// Delete the entry from APC
|
||||
apc_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the APC cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if (is_null($this->_cachePrefix)) {
|
||||
if (function_exists('posix_getpid')) {
|
||||
$baseUnique = posix_getpid();
|
||||
} else {
|
||||
$baseUnique = mt_rand();
|
||||
}
|
||||
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
|
||||
$this->_cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
public function __destruct() {
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
apc_delete($this->_cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
|
||||
}
|
||||
153
libraries/PHPExcel/PHPExcel/CachedObjectStorage/CacheBase.php
Normal file
153
libraries/PHPExcel/PHPExcel/CachedObjectStorage/CacheBase.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_CacheBase
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_CacheBase {
|
||||
|
||||
/**
|
||||
* Parent worksheet
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
protected $_parent;
|
||||
|
||||
/**
|
||||
* The currently active Cell
|
||||
*
|
||||
* @var PHPExcel_Cell
|
||||
*/
|
||||
protected $_currentObject = null;
|
||||
|
||||
/**
|
||||
* Coordinate address of the currently active Cell
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_currentObjectID = null;
|
||||
|
||||
|
||||
/**
|
||||
* An array of cells or cell pointers for the worksheet cells held in this cache,
|
||||
* and indexed by their coordinate address within the worksheet
|
||||
*
|
||||
* @var array of mixed
|
||||
*/
|
||||
protected $_cellCache = array();
|
||||
|
||||
|
||||
public function __construct(PHPExcel_Worksheet $parent) {
|
||||
// Set our parent worksheet.
|
||||
// This is maintained within the cache controller to facilitate re-attaching it to PHPExcel_Cell objects when
|
||||
// they are woken from a serialized state
|
||||
$this->_parent = $parent;
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry exists in the cache
|
||||
return isset($this->_cellCache[$pCoord]);
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateCacheData(PHPExcel_Cell $cell) {
|
||||
$pCoord = $cell->getCoordinate();
|
||||
|
||||
return $this->addCacheData($pCoord,$cell);
|
||||
} // function updateCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
}
|
||||
|
||||
if (isset($this->_cellCache[$pCoord])) {
|
||||
$this->_cellCache[$pCoord]->detach();
|
||||
unset($this->_cellCache[$pCoord]);
|
||||
}
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList() {
|
||||
return array_keys($this->_cellCache);
|
||||
} // function getCellList()
|
||||
|
||||
|
||||
/**
|
||||
* Sort the list of all cell addresses currently held in cache by row and column
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSortedCellList() {
|
||||
$sortKeys = array();
|
||||
foreach ($this->_cellCache as $coord => $value) {
|
||||
preg_match('/^(\w+)(\d+)$/U',$coord,$matches);
|
||||
list(,$colNum,$rowNum) = $matches;
|
||||
$sortKeys[$coord] = str_pad($rowNum . str_pad($colNum,3,'@',STR_PAD_LEFT),12,'0',STR_PAD_LEFT);
|
||||
}
|
||||
asort($sortKeys);
|
||||
|
||||
return array_keys($sortKeys);
|
||||
} // function sortCellList()
|
||||
|
||||
}
|
||||
143
libraries/PHPExcel/PHPExcel/CachedObjectStorage/DiscISAM.php
Normal file
143
libraries/PHPExcel/PHPExcel/CachedObjectStorage/DiscISAM.php
Normal file
@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_DiscISAM
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
private $_fileName = null;
|
||||
private $_fileHandle = null;
|
||||
|
||||
|
||||
private function _storeData() {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
fseek($this->_fileHandle,0,SEEK_END);
|
||||
$offset = ftell($this->_fileHandle);
|
||||
fwrite($this->_fileHandle, serialize($this->_currentObject));
|
||||
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
|
||||
'sz' => ftell($this->_fileHandle) - $offset
|
||||
);
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
||||
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
|
||||
// Close down the temporary cache file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
public function __construct(PHPExcel_Worksheet $parent) {
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_fileHandle)) {
|
||||
if (function_exists('posix_getpid')) {
|
||||
$baseUnique = posix_getpid();
|
||||
} else {
|
||||
$baseUnique = mt_rand();
|
||||
}
|
||||
$this->_fileName = sys_get_temp_dir().'/PHPExcel.'.uniqid($baseUnique,true).'.cache';
|
||||
$this->_fileHandle = fopen($this->_fileName,'a+');
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
public function __destruct() {
|
||||
if (!is_null($this->_fileHandle)) {
|
||||
fclose($this->_fileHandle);
|
||||
unlink($this->_fileName);
|
||||
}
|
||||
$this->_fileHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
}
|
||||
97
libraries/PHPExcel/PHPExcel/CachedObjectStorage/ICache.php
Normal file
97
libraries/PHPExcel/PHPExcel/CachedObjectStorage/ICache.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_ICache
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_CachedObjectStorage_ICache
|
||||
{
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell);
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache
|
||||
*
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateCacheData(PHPExcel_Cell $cell);
|
||||
|
||||
/**
|
||||
* Fetch a cell from cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to retrieve
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getCacheData($pCoord);
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord);
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord);
|
||||
|
||||
/**
|
||||
* Get a list of all cell addresses currently held in cache
|
||||
*
|
||||
* @return array of string
|
||||
*/
|
||||
public function getCellList();
|
||||
|
||||
/**
|
||||
* Get the list of all cell addresses currently held in cache sorted by column and row
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSortedCellList();
|
||||
|
||||
}
|
||||
214
libraries/PHPExcel/PHPExcel/CachedObjectStorage/Memcache.php
Normal file
214
libraries/PHPExcel/PHPExcel/CachedObjectStorage/Memcache.php
Normal file
@ -0,0 +1,214 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Memcache
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Memcache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
private $_cachePrefix = null;
|
||||
|
||||
private $_cacheTime = 600;
|
||||
|
||||
private $_memcache = null;
|
||||
|
||||
|
||||
private function _storeData() {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$obj = serialize($this->_currentObject);
|
||||
if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
|
||||
if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.'.cache',$obj,NULL,$this->_cacheTime)) {
|
||||
$this->__destruct();
|
||||
throw new Exception('Failed to store cell in Memcache');
|
||||
}
|
||||
}
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->_currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in apc
|
||||
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry no longer exists in Memcache');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($obj === false) {
|
||||
// Entry no longer exists in Memcache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry no longer exists in Memcache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
// Delete the entry from Memcache
|
||||
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the Memcache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
|
||||
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if (is_null($this->_cachePrefix)) {
|
||||
if (function_exists('posix_getpid')) {
|
||||
$baseUnique = posix_getpid();
|
||||
} else {
|
||||
$baseUnique = mt_rand();
|
||||
}
|
||||
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
|
||||
|
||||
// Set a new Memcache object and connect to the Memcache server
|
||||
$this->_memcache = new Memcache();
|
||||
if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback')) {
|
||||
throw new Exception('Could not connect to Memcache server at '.$memcacheServer.':'.$memcachePort);
|
||||
}
|
||||
$this->_cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
public function failureCallback($host, $port) {
|
||||
throw new Exception('memcache '.$host.':'.$port' failed');
|
||||
}
|
||||
|
||||
|
||||
public function __destruct() {
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
85
libraries/PHPExcel/PHPExcel/CachedObjectStorage/Memory.php
Normal file
85
libraries/PHPExcel/PHPExcel/CachedObjectStorage/Memory.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Memory
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Memory extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
$this->_cellCache[$pCoord] = $cell;
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return requested entry
|
||||
return $this->_cellCache[$pCoord];
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
public function unsetWorksheetCells() {
|
||||
// Because cells are all stored as intact objects in memory, we need to detach each one from the parent
|
||||
foreach($this->_cellCache as $k => &$cell) {
|
||||
$cell->detach();
|
||||
$this->_cellCache[$k] = null;
|
||||
}
|
||||
unset($cell);
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
}
|
||||
107
libraries/PHPExcel/PHPExcel/CachedObjectStorage/MemoryGZip.php
Normal file
107
libraries/PHPExcel/PHPExcel/CachedObjectStorage/MemoryGZip.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_MemoryGZip
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_MemoryGZip extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
private function _storeData() {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize(gzinflate($this->_cellCache[$pCoord]));
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
}
|
||||
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_MemorySerialized
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_MemorySerialized extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
private function _storeData() {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$this->_cellCache[$this->_currentObjectID] = serialize($this->_currentObject);
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($this->_cellCache[$pCoord]);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
}
|
||||
137
libraries/PHPExcel/PHPExcel/CachedObjectStorage/PHPTemp.php
Normal file
137
libraries/PHPExcel/PHPExcel/CachedObjectStorage/PHPTemp.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_PHPTemp
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_PHPTemp extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
private $_fileHandle = null;
|
||||
|
||||
|
||||
private function _storeData() {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
fseek($this->_fileHandle,0,SEEK_END);
|
||||
$offset = ftell($this->_fileHandle);
|
||||
fwrite($this->_fileHandle, serialize($this->_currentObject));
|
||||
$this->_cellCache[$this->_currentObjectID] = array('ptr' => $offset,
|
||||
'sz' => ftell($this->_fileHandle) - $offset
|
||||
);
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
if (!isset($this->_cellCache[$pCoord])) {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
fseek($this->_fileHandle,$this->_cellCache[$pCoord]['ptr']);
|
||||
$this->_currentObject = unserialize(fread($this->_fileHandle,$this->_cellCache[$pCoord]['sz']));
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
|
||||
// Close down the php://temp file
|
||||
$this->__destruct();
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
public function __construct(PHPExcel_Worksheet $parent, $memoryCacheSize = '1MB') {
|
||||
$memoryCacheSize = (isset($arguments['memoryCacheSize'])) ? $arguments['memoryCacheSize'] : '1MB';
|
||||
|
||||
parent::__construct($parent);
|
||||
if (is_null($this->_fileHandle)) {
|
||||
$this->_fileHandle = fopen('php://temp/maxmemory:'.$memoryCacheSize,'a+');
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
public function __destruct() {
|
||||
if (!is_null($this->_fileHandle)) {
|
||||
fclose($this->_fileHandle);
|
||||
}
|
||||
$this->_fileHandle = null;
|
||||
} // function __destruct()
|
||||
|
||||
}
|
||||
201
libraries/PHPExcel/PHPExcel/CachedObjectStorage/Wincache.php
Normal file
201
libraries/PHPExcel/PHPExcel/CachedObjectStorage/Wincache.php
Normal file
@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_CachedObjectStorage_Wincache
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_CachedObjectStorage
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_CachedObjectStorage_Wincache extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {
|
||||
|
||||
private $_cachePrefix = null;
|
||||
|
||||
private $_cacheTime = 600;
|
||||
|
||||
|
||||
private function _storeData() {
|
||||
$this->_currentObject->detach();
|
||||
|
||||
$obj = serialize($this->_currentObject);
|
||||
if (wincache_ucache_exists($this->_cachePrefix.$this->_currentObjectID.'.cache')) {
|
||||
wincache_ucache_set($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime);
|
||||
} else {
|
||||
wincache_ucache_add($this->_cachePrefix.$this->_currentObjectID.'.cache', $obj, $this->_cacheTime);
|
||||
}
|
||||
|
||||
$this->_currentObjectID = $this->_currentObject = null;
|
||||
} // function _storeData()
|
||||
|
||||
|
||||
/**
|
||||
* Add or Update a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to update
|
||||
* @param PHPExcel_Cell $cell Cell to update
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCacheData($pCoord, PHPExcel_Cell $cell) {
|
||||
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
|
||||
$this->_storeData();
|
||||
}
|
||||
$this->_cellCache[$pCoord] = true;
|
||||
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = $cell;
|
||||
|
||||
return $cell;
|
||||
} // function addCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to check
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function isDataSet($pCoord) {
|
||||
// Check if the requested entry is the current object, or exists in the cache
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
if ($this->_currentObjectID == $pCoord) {
|
||||
return true;
|
||||
}
|
||||
// Check if the requested entry still exists in cache
|
||||
$success = wincache_ucache_exists($this->_cachePrefix.$pCoord.'.cache');
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in Wincache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry no longer exists in Wincache');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function isDataSet()
|
||||
|
||||
|
||||
/**
|
||||
* Get cell at a specific coordinate
|
||||
*
|
||||
* @param string $pCoord Coordinate of the cell
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Cell Cell that was found, or null if not found
|
||||
*/
|
||||
public function getCacheData($pCoord) {
|
||||
if ($pCoord === $this->_currentObjectID) {
|
||||
return $this->_currentObject;
|
||||
}
|
||||
$this->_storeData();
|
||||
|
||||
// Check if the entry that has been requested actually exists
|
||||
$obj = null;
|
||||
if (parent::isDataSet($pCoord)) {
|
||||
$success = false;
|
||||
$obj = wincache_ucache_get($this->_cachePrefix.$pCoord.'.cache', $success);
|
||||
if ($success === false) {
|
||||
// Entry no longer exists in Wincache, so clear it from the cache array
|
||||
parent::deleteCacheData($pCoord);
|
||||
throw new Exception('Cell entry no longer exists in Wincache');
|
||||
}
|
||||
} else {
|
||||
// Return null if requested entry doesn't exist in cache
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set current entry to the requested entry
|
||||
$this->_currentObjectID = $pCoord;
|
||||
$this->_currentObject = unserialize($obj);
|
||||
// Re-attach the parent worksheet
|
||||
$this->_currentObject->attach($this->_parent);
|
||||
|
||||
// Return requested entry
|
||||
return $this->_currentObject;
|
||||
} // function getCacheData()
|
||||
|
||||
|
||||
/**
|
||||
* Delete a cell in cache identified by coordinate address
|
||||
*
|
||||
* @param string $pCoord Coordinate address of the cell to delete
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteCacheData($pCoord) {
|
||||
// Delete the entry from Wincache
|
||||
wincache_ucache_delete($this->_cachePrefix.$pCoord.'.cache');
|
||||
|
||||
// Delete the entry from our cell address array
|
||||
parent::deleteCacheData($pCoord);
|
||||
} // function deleteCacheData()
|
||||
|
||||
|
||||
public function unsetWorksheetCells() {
|
||||
if(!is_null($this->_currentObject)) {
|
||||
$this->_currentObject->detach();
|
||||
$this->_currentObject = $this->_currentObjectID = null;
|
||||
}
|
||||
|
||||
// Flush the Wincache cache
|
||||
$this->__destruct();
|
||||
|
||||
$this->_cellCache = array();
|
||||
|
||||
// detach ourself from the worksheet, so that it can then delete this object successfully
|
||||
$this->_parent = null;
|
||||
} // function unsetWorksheetCells()
|
||||
|
||||
|
||||
public function __construct(PHPExcel_Worksheet $parent, $arguments) {
|
||||
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
|
||||
|
||||
if (is_null($this->_cachePrefix)) {
|
||||
if (function_exists('posix_getpid')) {
|
||||
$baseUnique = posix_getpid();
|
||||
} else {
|
||||
$baseUnique = mt_rand();
|
||||
}
|
||||
$this->_cachePrefix = substr(md5(uniqid($baseUnique,true)),0,8).'.';
|
||||
$this->_cacheTime = $cacheTime;
|
||||
|
||||
parent::__construct($parent);
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
public function __destruct() {
|
||||
$cacheList = $this->getCellList();
|
||||
foreach($cacheList as $cellID) {
|
||||
wincache_ucache_delete($this->_cachePrefix.$cellID.'.cache');
|
||||
}
|
||||
} // function __destruct()
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
131
libraries/PHPExcel/PHPExcel/CachedObjectStorageFactory.php
Normal file
131
libraries/PHPExcel/PHPExcel/CachedObjectStorageFactory.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
class PHPExcel_CachedObjectStorageFactory {
|
||||
const cache_in_memory = 'Memory';
|
||||
const cache_in_memory_gzip = 'MemoryGZip';
|
||||
const cache_in_memory_serialized = 'MemorySerialized';
|
||||
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';
|
||||
|
||||
|
||||
private static $_cacheStorageMethod = null;
|
||||
|
||||
private static $_cacheStorageClass = null;
|
||||
|
||||
|
||||
private static $_storageMethods = array(
|
||||
self::cache_in_memory,
|
||||
self::cache_in_memory_gzip,
|
||||
self::cache_in_memory_serialized,
|
||||
self::cache_to_phpTemp,
|
||||
self::cache_to_discISAM,
|
||||
self::cache_to_apc,
|
||||
self::cache_to_memcache,
|
||||
self::cache_to_wincache,
|
||||
);
|
||||
|
||||
|
||||
private static $_storageMethodDefaultParameters = array(
|
||||
self::cache_in_memory => array(
|
||||
),
|
||||
self::cache_in_memory_gzip => array(
|
||||
),
|
||||
self::cache_in_memory_serialized => array(
|
||||
),
|
||||
self::cache_to_phpTemp => array( 'memoryCacheSize' => '1MB'
|
||||
),
|
||||
self::cache_to_discISAM => array(
|
||||
),
|
||||
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
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
private static $_storageMethodParameters = array();
|
||||
|
||||
|
||||
public static function getCacheStorageMethod() {
|
||||
if (!is_null(self::$_cacheStorageMethod)) {
|
||||
return self::$_cacheStorageMethod;
|
||||
}
|
||||
return null;
|
||||
} // function getCacheStorageMethod()
|
||||
|
||||
|
||||
public static function getCacheStorageClass() {
|
||||
if (!is_null(self::$_cacheStorageClass)) {
|
||||
return self::$_cacheStorageClass;
|
||||
}
|
||||
return null;
|
||||
} // function getCacheStorageClass()
|
||||
|
||||
|
||||
public static function getCacheStorageMethods() {
|
||||
return self::$_storageMethods;
|
||||
} // function getCacheStorageMethods()
|
||||
|
||||
|
||||
public static function initialize($method = self::cache_in_memory, $arguments = array()) {
|
||||
if (!in_array($method,self::$_storageMethods)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch($method) {
|
||||
case self::cache_to_apc :
|
||||
if (!function_exists('apc_store')) {
|
||||
return false;
|
||||
}
|
||||
if (apc_sma_info() === false) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case self::cache_to_memcache :
|
||||
if (!function_exists('memcache_add')) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case self::cache_to_wincache :
|
||||
if (!function_exists('wincache_ucache_add')) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
self::$_storageMethodParameters[$method] = self::$_storageMethodDefaultParameters[$method];
|
||||
foreach($arguments as $k => $v) {
|
||||
if (isset(self::$_storageMethodParameters[$method][$k])) {
|
||||
self::$_storageMethodParameters[$method][$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null(self::$_cacheStorageMethod)) {
|
||||
self::$_cacheStorageClass = 'PHPExcel_CachedObjectStorage_'.$method;
|
||||
self::$_cacheStorageMethod = $method;
|
||||
}
|
||||
return true;
|
||||
} // function initialize()
|
||||
|
||||
|
||||
public static function getInstance(PHPExcel_Worksheet $parent) {
|
||||
if (is_null(self::$_cacheStorageMethod)) {
|
||||
self::initialize();
|
||||
}
|
||||
|
||||
$instance = new self::$_cacheStorageClass($parent,self::$_storageMethodParameters[self::$_cacheStorageMethod]);
|
||||
if (!is_null($instance)) {
|
||||
return $instance;
|
||||
}
|
||||
|
||||
return false;
|
||||
} // function getInstance()
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Exception extends Exception {
|
||||
/**
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,37 +20,26 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Calculation_Exception */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Exception.php';
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_ExceptionHandler
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_ExceptionHandler {
|
||||
class PHPExcel_Calculation_ExceptionHandler {
|
||||
/**
|
||||
* Register errorhandler
|
||||
*/
|
||||
public function __construct() {
|
||||
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
|
||||
set_error_handler(array('PHPExcel_Calculation_Exception', 'errorHandlerCallback'), E_ALL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unregister errorhandler
|
||||
*/
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -49,23 +49,12 @@ PARTLY BASED ON:
|
||||
http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Calculation_FormulaToken */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/FormulaToken.php';
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_FormulaParser
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_FormulaParser {
|
||||
/* Character constants */
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ PARTLY BASED ON:
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_FormulaToken {
|
||||
/* Token types */
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_Function {
|
||||
/* Function categories */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,51 +20,18 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Cell_DataType */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
|
||||
|
||||
/** PHPExcel_Cell_DataValidation */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataValidation.php';
|
||||
|
||||
/** PHPExcel_Cell_Hyperlink */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/Hyperlink.php';
|
||||
|
||||
/** PHPExcel_Worksheet */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
|
||||
|
||||
/** PHPExcel_Calculation */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation.php';
|
||||
|
||||
/** PHPExcel_Cell_IValueBinder */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/IValueBinder.php';
|
||||
|
||||
/** PHPExcel_Cell_DefaultValueBinder */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DefaultValueBinder.php';
|
||||
|
||||
/** PHPExcel_Shared_String */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell
|
||||
{
|
||||
@ -124,6 +91,24 @@ class PHPExcel_Cell
|
||||
*/
|
||||
private $_xfIndex;
|
||||
|
||||
|
||||
/**
|
||||
* Send notification to the cache controller
|
||||
* @return void
|
||||
**/
|
||||
public function notifyCacheController() {
|
||||
$this->_parent->getCellCacheController()->updateCacheData($this);
|
||||
}
|
||||
|
||||
public function detach() {
|
||||
$this->_parent = null;
|
||||
}
|
||||
|
||||
public function attach($parent) {
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Cell
|
||||
*
|
||||
@ -136,11 +121,6 @@ class PHPExcel_Cell
|
||||
*/
|
||||
public function __construct($pColumn = 'A', $pRow = 1, $pValue = null, $pDataType = null, PHPExcel_Worksheet $pSheet = null)
|
||||
{
|
||||
// Set value binder?
|
||||
if (is_null(self::$_valueBinder)) {
|
||||
self::$_valueBinder = new PHPExcel_Cell_DefaultValueBinder();
|
||||
}
|
||||
|
||||
// Initialise cell coordinate
|
||||
$this->_column = strtoupper($pColumn);
|
||||
$this->_row = $pRow;
|
||||
@ -171,7 +151,7 @@ class PHPExcel_Cell
|
||||
*/
|
||||
public function getColumn()
|
||||
{
|
||||
return strtoupper($this->_column);
|
||||
return $this->_column;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,26 +206,48 @@ class PHPExcel_Cell
|
||||
* @param mixed $pValue Value
|
||||
* @param string $pDataType Explicit data type
|
||||
* @return PHPExcel_Cell
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setValueExplicit($pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
|
||||
{
|
||||
// check strings that they are ok
|
||||
// TODO: fix also for RichText
|
||||
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING && !($pValue instanceof PHPExcel_RichText)) {
|
||||
// string must never be longer than 32,767 characters, truncate if necessary
|
||||
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767);
|
||||
// set the value according to data type
|
||||
switch ($pDataType) {
|
||||
case PHPExcel_Cell_DataType::TYPE_STRING:
|
||||
case PHPExcel_Cell_DataType::TYPE_NULL:
|
||||
case PHPExcel_Cell_DataType::TYPE_INLINE:
|
||||
$this->_value = PHPExcel_Cell_DataType::checkString($pValue);
|
||||
break;
|
||||
|
||||
// we require that newline is represented as "\n" in core, not as "\r\n" or "\r"
|
||||
$pValue = str_replace(array("\r\n", "\r"), "\n", $pValue);
|
||||
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
|
||||
$this->_value = (float)$pValue;
|
||||
break;
|
||||
|
||||
case PHPExcel_Cell_DataType::TYPE_FORMULA:
|
||||
$this->_value = (string)$pValue;
|
||||
break;
|
||||
|
||||
case PHPExcel_Cell_DataType::TYPE_BOOL:
|
||||
$this->_value = (bool)$pValue;
|
||||
break;
|
||||
|
||||
case PHPExcel_Cell_DataType::TYPE_ERROR:
|
||||
$this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('Invalid datatype: ' . $pDataType);
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_value = $pValue;
|
||||
$this->_dataType = $pDataType;
|
||||
return $this;
|
||||
// set the datatype
|
||||
$this->_dataType = $pDataType;
|
||||
|
||||
$this->notifyCacheController();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get caluclated cell value
|
||||
* Get calculated cell value
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@ -256,9 +258,11 @@ class PHPExcel_Cell
|
||||
try {
|
||||
// echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value<br />';
|
||||
$result = PHPExcel_Calculation::getInstance()->calculateCellValue($this,$resetLog);
|
||||
// echo $this->getCoordinate().' calculation result is '.$result.'<br />';
|
||||
} catch ( Exception $ex ) {
|
||||
// echo 'Calculation Exception: '.$ex->getMessage().'<br />';
|
||||
$result = '#N/A';
|
||||
throw(new Exception($ex->getMessage()));
|
||||
}
|
||||
|
||||
if ((is_string($result)) && ($result == '#Not Yet Implemented')) {
|
||||
@ -293,6 +297,8 @@ class PHPExcel_Cell
|
||||
if (!is_null($pValue)) {
|
||||
$this->_calculatedValue = $pValue;
|
||||
}
|
||||
|
||||
$this->notifyCacheController();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -325,6 +331,8 @@ class PHPExcel_Cell
|
||||
public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
|
||||
{
|
||||
$this->_dataType = $pDataType;
|
||||
|
||||
$this->notifyCacheController();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -371,6 +379,8 @@ class PHPExcel_Cell
|
||||
}
|
||||
|
||||
$this->_parent->setDataValidation($this->getCoordinate(), $pDataValidation);
|
||||
|
||||
$this->notifyCacheController();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -418,6 +428,8 @@ class PHPExcel_Cell
|
||||
}
|
||||
|
||||
$this->_parent->setHyperlink($this->getCoordinate(), $pHyperlink);
|
||||
|
||||
$this->notifyCacheController();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -438,6 +450,8 @@ class PHPExcel_Cell
|
||||
*/
|
||||
public function rebindParent(PHPExcel_Worksheet $parent) {
|
||||
$this->_parent = $parent;
|
||||
|
||||
$this->notifyCacheController();
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -492,22 +506,17 @@ class PHPExcel_Cell
|
||||
{
|
||||
if (strpos($pCoordinateString,':') !== false) {
|
||||
throw new Exception('Cell coordinate string can not be a range of cells.');
|
||||
|
||||
} else if ($pCoordinateString == '') {
|
||||
throw new Exception('Cell coordinate can not be zero-length string.');
|
||||
} else {
|
||||
// Column
|
||||
$column = '';
|
||||
|
||||
// Row
|
||||
$row = '';
|
||||
|
||||
// Convert a cell reference
|
||||
if (preg_match("/([$]?[A-Z]+)([$]?\d+)/", $pCoordinateString, $matches)) {
|
||||
list(, $column, $row) = $matches;
|
||||
}
|
||||
|
||||
// Return array
|
||||
} else if (preg_match("/([$]?[A-Z]+)([$]?\d+)/", $pCoordinateString, $matches)) {
|
||||
list(, $column, $row) = $matches;
|
||||
return array($column, $row);
|
||||
|
||||
} else {
|
||||
throw new Exception('Invalid cell coordinate.');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -606,6 +615,30 @@ class PHPExcel_Cell
|
||||
return array( ($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate range boundaries
|
||||
*
|
||||
* @param string $pRange Cell range (e.g. A1:A1)
|
||||
* @return array Range boundaries (staring Column, starting Row, Final Column, Final Row)
|
||||
*/
|
||||
public static function getRangeBoundaries($pRange = 'A1:A1')
|
||||
{
|
||||
// Uppercase coordinate
|
||||
$pRange = strtoupper($pRange);
|
||||
|
||||
// Extract range
|
||||
$rangeA = '';
|
||||
$rangeB = '';
|
||||
if (strpos($pRange, ':') === false) {
|
||||
$rangeA = $pRange;
|
||||
$rangeB = $pRange;
|
||||
} else {
|
||||
list($rangeA, $rangeB) = explode(':', $pRange);
|
||||
}
|
||||
|
||||
return array( self::coordinateFromString($rangeA), self::coordinateFromString($rangeB));
|
||||
}
|
||||
|
||||
/**
|
||||
* Column index from string
|
||||
*
|
||||
@ -615,6 +648,14 @@ class PHPExcel_Cell
|
||||
*/
|
||||
public static function columnIndexFromString($pString = 'A')
|
||||
{
|
||||
static $lookup = array(
|
||||
'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10, 'K' => 11, 'L' => 12, 'M' => 13,
|
||||
'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19, 'T' => 20, 'U' => 21, 'V' => 22, 'W' => 23, 'X' => 24, 'Y' => 25, 'Z' => 26
|
||||
);
|
||||
|
||||
if (isset($lookup[$pString]))
|
||||
return $lookup[$pString];
|
||||
|
||||
// Convert to uppercase
|
||||
$pString = strtoupper($pString);
|
||||
|
||||
@ -745,6 +786,10 @@ class PHPExcel_Cell
|
||||
* @return PHPExcel_Cell_IValueBinder
|
||||
*/
|
||||
public static function getValueBinder() {
|
||||
if (is_null(self::$_valueBinder)) {
|
||||
self::$_valueBinder = new PHPExcel_Cell_DefaultValueBinder();
|
||||
}
|
||||
|
||||
return self::$_valueBinder;
|
||||
}
|
||||
|
||||
@ -795,6 +840,8 @@ class PHPExcel_Cell
|
||||
public function setXfIndex($pValue = 0)
|
||||
{
|
||||
$this->_xfIndex = $pValue;
|
||||
|
||||
$this->notifyCacheController();
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@ -2,63 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Cell */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
|
||||
/** PHPExcel_Cell_IValueBinder */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/IValueBinder.php';
|
||||
|
||||
/** PHPExcel_Cell_DefaultValueBinder */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DefaultValueBinder.php';
|
||||
|
||||
/** PHPExcel_Style_NumberFormat */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
|
||||
|
||||
/** PHPExcel_Shared_Date */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
|
||||
|
||||
/** PHPExcel_Shared_String */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_AdvancedValueBinder
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
@ -78,67 +51,76 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
||||
|
||||
// Find out data type
|
||||
$dataType = parent::dataTypeForValue($value);
|
||||
|
||||
|
||||
// Style logic - strings
|
||||
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
|
||||
// Check for percentage
|
||||
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
|
||||
// Convert value to number
|
||||
$cell->setValueExplicit( (float)str_replace('%', '', $value) / 100, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
|
||||
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE );
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for time e.g. '9:45', '09:45'
|
||||
|
||||
// Check for time without seconds e.g. '9:45', '09:45'
|
||||
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d$/', $value)) {
|
||||
list($h, $m) = explode(':', $value);
|
||||
$days = $h / 24 + $m / 1440;
|
||||
|
||||
|
||||
// Convert value to number
|
||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
|
||||
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for date
|
||||
if (strtotime($value) !== false) {
|
||||
// make sure we have UTC for the sake of strtotime
|
||||
$saveTimeZone = date_default_timezone_get();
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
|
||||
// Check for time with seconds '9:45:59', '09:45:59'
|
||||
if (preg_match('/^(\d|[0-1]\d|2[0-3]):[0-5]\d:[0-5]\d$/', $value)) {
|
||||
list($h, $m, $s) = explode(':', $value);
|
||||
$days = $h / 24 + $m / 1440 + $s / 86400;
|
||||
|
||||
// Convert value to number
|
||||
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for datetime, e.g. '2008-12-31', '2008-12-31 15:59', '2008-12-31 15:59:10'
|
||||
if (($v = PHPExcel_Shared_Date::stringToExcel($value)) !== false) {
|
||||
// Convert value to Excel date
|
||||
$cell->setValueExplicit( PHPExcel_Shared_Date::PHPToExcel(strtotime($value)), PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
|
||||
$cell->setValueExplicit($v, PHPExcel_Cell_DataType::TYPE_NUMERIC);
|
||||
|
||||
// Set style. Either there is a time part or not. Look for ':'
|
||||
if (strpos($value, ':') !== false) {
|
||||
$formatCode = 'yyyy-mm-dd h:mm';
|
||||
} else {
|
||||
$formatCode = 'yyyy-mm-dd';
|
||||
}
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode($formatCode);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for newline character "\n"
|
||||
if (strpos($value, "\n") !== false) {
|
||||
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
|
||||
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2 );
|
||||
|
||||
// restore original value for timezone
|
||||
date_default_timezone_set($saveTimeZone);
|
||||
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )->getAlignment()->setWrapText(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Style logic - Numbers
|
||||
if ($dataType === PHPExcel_Cell_DataType::TYPE_NUMERIC) {
|
||||
// Leading zeroes?
|
||||
if (preg_match('/^\-?[0]+[0-9]*\.?[0-9]*$/', $value)) {
|
||||
// Convert value to string
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
|
||||
// Set style
|
||||
$cell->getParent()->getStyle( $cell->getCoordinate() )->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_TEXT );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Not bound yet? Use parent...
|
||||
return parent::bindValue($cell, $value);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,30 +20,18 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Cell_DefaultValueBinder */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DefaultValueBinder.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_DataType
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_DataType
|
||||
{
|
||||
@ -71,7 +59,7 @@ class PHPExcel_Cell_DataType
|
||||
public static function getErrorCodes() {
|
||||
return self::$_errorCodes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DataType for value
|
||||
*
|
||||
@ -82,4 +70,44 @@ class PHPExcel_Cell_DataType
|
||||
public static function dataTypeForValue($pValue = null) {
|
||||
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a string that it satisfies Excel requirements
|
||||
*
|
||||
* @param mixed Value to sanitize to an Excel string
|
||||
* @return mixed Sanitized value
|
||||
*/
|
||||
public static function checkString($pValue = null)
|
||||
{
|
||||
if ($pValue instanceof PHPExcel_RichText) {
|
||||
// TODO: Sanitize Rich-Text string (max. character count is 32,767)
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
// string must never be longer than 32,767 characters, truncate if necessary
|
||||
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 32767);
|
||||
|
||||
// we require that newline is represented as "\n" in core, not as "\r\n" or "\r"
|
||||
$pValue = str_replace(array("\r\n", "\r"), "\n", $pValue);
|
||||
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a value that it is a valid error code
|
||||
*
|
||||
* @param mixed Value to sanitize to an Excel error code
|
||||
* @return string Sanitized value
|
||||
*/
|
||||
public static function checkErrorCode($pValue = null)
|
||||
{
|
||||
$pValue = (string)$pValue;
|
||||
|
||||
if ( !array_key_exists($pValue, self::$_errorCodes) ) {
|
||||
$pValue = '#NULL!';
|
||||
}
|
||||
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_DataValidation
|
||||
{
|
||||
@ -151,20 +151,12 @@ class PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
private $_prompt;
|
||||
|
||||
/**
|
||||
* Parent cell
|
||||
*
|
||||
* @var PHPExcel_Cell
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Cell_DataValidation
|
||||
*
|
||||
* @param PHPExcel_Cell $pCell Parent cell
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(PHPExcel_Cell $pCell = null)
|
||||
public function __construct()
|
||||
{
|
||||
// Initialise member variables
|
||||
$this->_formula1 = '';
|
||||
@ -180,9 +172,6 @@ class PHPExcel_Cell_DataValidation
|
||||
$this->_error = '';
|
||||
$this->_promptTitle = '';
|
||||
$this->_prompt = '';
|
||||
|
||||
// Set cell
|
||||
$this->_parent = $pCell;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -445,26 +434,6 @@ class PHPExcel_Cell_DataValidation
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent
|
||||
*
|
||||
* @return PHPExcel_Cell
|
||||
*/
|
||||
public function getParent() {
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Parent
|
||||
*
|
||||
* @param PHPExcel_Cell $value
|
||||
* @return PHPExcel_Cell_DataValidation
|
||||
*/
|
||||
public function setParent($value = null) {
|
||||
$this->_parent = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
@ -485,7 +454,6 @@ class PHPExcel_Cell_DataValidation
|
||||
. $this->_error
|
||||
. $this->_promptTitle
|
||||
. $this->_prompt
|
||||
. $this->_parent->getCoordinate()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
@ -494,12 +462,9 @@ class PHPExcel_Cell_DataValidation
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
// unbind parent
|
||||
$this->setParent(null);
|
||||
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value) && $key != '_parent') {
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
$this->$key = $value;
|
||||
|
||||
@ -2,57 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Cell */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
|
||||
/** PHPExcel_Cell_IValueBinder */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/IValueBinder.php';
|
||||
|
||||
/** PHPExcel_Cell_DataType */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
|
||||
|
||||
/** PHPExcel_Shared_String */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_DefaultValueBinder
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
@ -72,11 +51,11 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||
|
||||
// Set value explicit
|
||||
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::dataTypeForValue($value) );
|
||||
|
||||
|
||||
// Done!
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DataType for value
|
||||
*
|
||||
@ -87,22 +66,31 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
|
||||
// Match the value against a few data types
|
||||
if (is_null($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NULL;
|
||||
|
||||
} elseif ($pValue === '') {
|
||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
|
||||
} elseif ($pValue instanceof PHPExcel_RichText) {
|
||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
} elseif ($pValue{0} === '=') {
|
||||
|
||||
} elseif ($pValue{0} === '=' && strlen($pValue) > 1) {
|
||||
return PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
|
||||
} elseif (is_bool($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
|
||||
} elseif (is_float($pValue) || is_int($pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
} elseif (preg_match('/^\-?[0-9]*\\.?[0-9]*$/', $pValue)) {
|
||||
|
||||
} elseif (preg_match('/^\-?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)$/', $pValue)) {
|
||||
return PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
|
||||
} elseif (is_string($pValue) && array_key_exists($pValue, PHPExcel_Cell_DataType::getErrorCodes())) {
|
||||
return PHPExcel_Cell_DataType::TYPE_ERROR;
|
||||
|
||||
} else {
|
||||
return PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,17 +31,10 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Cell_Hyperlink
|
||||
{
|
||||
/**
|
||||
* Cell representing the hyperlink
|
||||
*
|
||||
* @var PHPExcel_Cell
|
||||
*/
|
||||
private $_cell;
|
||||
|
||||
/**
|
||||
* URL to link the cell to
|
||||
*
|
||||
@ -59,19 +52,15 @@ class PHPExcel_Cell_Hyperlink
|
||||
/**
|
||||
* Create a new PHPExcel_Cell_Hyperlink
|
||||
*
|
||||
* @param PHPExcel_Cell $pCell Parent cell
|
||||
* @param string $pUrl Url to link the cell to
|
||||
* @param string $pTooltip Tooltip to display on the hyperlink
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(PHPExcel_Cell $pCell = null, $pUrl = '', $pTooltip = '')
|
||||
public function __construct($pUrl = '', $pTooltip = '')
|
||||
{
|
||||
// Initialise member variables
|
||||
$this->_url = $pUrl;
|
||||
$this->_tooltip = $pTooltip;
|
||||
|
||||
// Set cell
|
||||
$this->_parent = $pCell;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,26 +112,6 @@ class PHPExcel_Cell_Hyperlink
|
||||
return strpos($this->_url, 'sheet://') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent
|
||||
*
|
||||
* @return PHPExcel_Cell
|
||||
*/
|
||||
public function getParent() {
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Parent
|
||||
*
|
||||
* @param PHPExcel_Cell $value
|
||||
* @return PHPExcel_Cell_Hyperlink
|
||||
*/
|
||||
public function setParent($value = null) {
|
||||
$this->_parent = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
@ -152,7 +121,6 @@ class PHPExcel_Cell_Hyperlink
|
||||
return md5(
|
||||
$this->_url
|
||||
. $this->_tooltip
|
||||
. $this->_parent->getCoordinate()
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
@ -2,48 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Cell */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Cell_IValueBinder
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Cell
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_Cell_IValueBinder
|
||||
{
|
||||
|
||||
@ -2,54 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
}
|
||||
|
||||
/** PHPExcel_RichText */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText.php';
|
||||
|
||||
/** PHPExcel_Style_Color */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Comment
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
{
|
||||
@ -59,59 +41,59 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
* @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;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Comment
|
||||
*
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct()
|
||||
@ -121,7 +103,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
$this->_text = new PHPExcel_RichText();
|
||||
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Author
|
||||
*
|
||||
@ -130,7 +112,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
public function getAuthor() {
|
||||
return $this->_author;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Author
|
||||
*
|
||||
@ -141,7 +123,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
$this->_author = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Rich text comment
|
||||
*
|
||||
@ -150,7 +132,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Rich text comment
|
||||
*
|
||||
@ -161,7 +143,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
$this->_text = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get comment width (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
@ -170,7 +152,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
public function getWidth() {
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set comment width (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
@ -181,7 +163,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
$this->_width = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get comment height (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
@ -190,7 +172,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
public function getHeight() {
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set comment height (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
@ -201,7 +183,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
$this->_height = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get left margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
@ -210,7 +192,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
public function getMarginLeft() {
|
||||
return $this->_marginLeft;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set left margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
@ -221,7 +203,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
$this->_marginLeft = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get top margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
@ -230,7 +212,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
public function getMarginTop() {
|
||||
return $this->_marginTop;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set top margin (CSS style, i.e. XXpx or YYpt)
|
||||
*
|
||||
@ -241,7 +223,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
$this->_marginTop = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is the comment visible by default?
|
||||
*
|
||||
@ -250,7 +232,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
public function getVisible() {
|
||||
return $this->_visible;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set comment default visibility
|
||||
*
|
||||
@ -258,10 +240,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
* @return PHPExcel_Comment
|
||||
*/
|
||||
public function setVisible($value = false) {
|
||||
$this->_visible = $value;
|
||||
$this->_visible = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get fill color
|
||||
*
|
||||
@ -270,12 +252,12 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
public function getFillColor() {
|
||||
return $this->_fillColor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_author
|
||||
@ -289,38 +271,7 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_DocumentProperties
|
||||
{
|
||||
|
||||
@ -2,48 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Shared_PasswordHasher */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PasswordHasher.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_DocumentSecurity
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_DocumentSecurity
|
||||
{
|
||||
@ -53,35 +41,35 @@ class PHPExcel_DocumentSecurity
|
||||
* @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
|
||||
*/
|
||||
@ -94,7 +82,7 @@ class PHPExcel_DocumentSecurity
|
||||
$this->_revisionsPassword = '';
|
||||
$this->_workbookPassword = '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is some sort of dcument security enabled?
|
||||
*
|
||||
@ -105,7 +93,7 @@ class PHPExcel_DocumentSecurity
|
||||
$this->_lockStructure ||
|
||||
$this->_lockWindows;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get LockRevision
|
||||
*
|
||||
@ -114,7 +102,7 @@ class PHPExcel_DocumentSecurity
|
||||
function getLockRevision() {
|
||||
return $this->_lockRevision;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set LockRevision
|
||||
*
|
||||
@ -125,7 +113,7 @@ class PHPExcel_DocumentSecurity
|
||||
$this->_lockRevision = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get LockStructure
|
||||
*
|
||||
@ -134,7 +122,7 @@ class PHPExcel_DocumentSecurity
|
||||
function getLockStructure() {
|
||||
return $this->_lockStructure;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set LockStructure
|
||||
*
|
||||
@ -145,7 +133,7 @@ class PHPExcel_DocumentSecurity
|
||||
$this->_lockStructure = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get LockWindows
|
||||
*
|
||||
@ -154,7 +142,7 @@ class PHPExcel_DocumentSecurity
|
||||
function getLockWindows() {
|
||||
return $this->_lockWindows;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set LockWindows
|
||||
*
|
||||
@ -165,7 +153,7 @@ class PHPExcel_DocumentSecurity
|
||||
$this->_lockWindows = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get RevisionsPassword (hashed)
|
||||
*
|
||||
@ -174,7 +162,7 @@ class PHPExcel_DocumentSecurity
|
||||
function getRevisionsPassword() {
|
||||
return $this->_revisionsPassword;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set RevisionsPassword
|
||||
*
|
||||
@ -189,7 +177,7 @@ class PHPExcel_DocumentSecurity
|
||||
$this->_revisionsPassword = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get WorkbookPassword (hashed)
|
||||
*
|
||||
|
||||
@ -2,48 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
}
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_HashTable
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_HashTable
|
||||
{
|
||||
@ -53,14 +41,14 @@ class PHPExcel_HashTable
|
||||
* @var array
|
||||
*/
|
||||
public $_items = array();
|
||||
|
||||
|
||||
/**
|
||||
* HashTable key map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_keyMap = array();
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_HashTable
|
||||
*
|
||||
@ -74,7 +62,7 @@ class PHPExcel_HashTable
|
||||
$this->addFromSource($pSource);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add HashTable items from source
|
||||
*
|
||||
@ -88,7 +76,7 @@ class PHPExcel_HashTable
|
||||
} else if (!is_array($pSource)) {
|
||||
throw new Exception('Invalid array parameter passed.');
|
||||
}
|
||||
|
||||
|
||||
foreach ($pSource as $item) {
|
||||
$this->add($item);
|
||||
}
|
||||
@ -101,28 +89,12 @@ class PHPExcel_HashTable
|
||||
* @throws Exception
|
||||
*/
|
||||
public function add(PHPExcel_IComparable $pSource = null) {
|
||||
// Determine hashcode
|
||||
$hashCode = null;
|
||||
$hashIndex = $pSource->getHashIndex();
|
||||
if ( is_null ( $hashIndex ) ) {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
} else if ( isset ( $this->_keyMap[$hashIndex] ) ) {
|
||||
$hashCode = $this->_keyMap[$hashIndex];
|
||||
} else {
|
||||
$hashCode = $pSource->getHashCode();
|
||||
}
|
||||
|
||||
// Add value
|
||||
if (!isset($this->_items[ $hashCode ])) {
|
||||
$this->_items[ $hashCode ] = $pSource;
|
||||
$index = count($this->_items) - 1;
|
||||
$this->_keyMap[ $index ] = $hashCode;
|
||||
$pSource->setHashIndex( $index );
|
||||
} else {
|
||||
$pSource->setHashIndex( $this->_items[ $hashCode ]->getHashIndex() );
|
||||
}
|
||||
if (!isset($this->_items[ $pSource->getHashCode() ])) {
|
||||
$this->_items[ $pSource->getHashCode() ] = $pSource;
|
||||
$this->_keyMap[ count($this->_items) - 1 ] = $pSource->getHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove HashTable item
|
||||
*
|
||||
@ -132,21 +104,21 @@ class PHPExcel_HashTable
|
||||
public function remove(PHPExcel_IComparable $pSource = null) {
|
||||
if (isset($this->_items[ $pSource->getHashCode() ])) {
|
||||
unset($this->_items[ $pSource->getHashCode() ]);
|
||||
|
||||
|
||||
$deleteKey = -1;
|
||||
foreach ($this->_keyMap as $key => $value) {
|
||||
foreach ($this->_keyMap as $key => $value) {
|
||||
if ($deleteKey >= 0) {
|
||||
$this->_keyMap[$key - 1] = $value;
|
||||
}
|
||||
|
||||
|
||||
if ($value == $pSource->getHashCode()) {
|
||||
$deleteKey = $key;
|
||||
}
|
||||
}
|
||||
unset($this->_keyMap[ count($this->_keyMap) - 1 ]);
|
||||
}
|
||||
unset($this->_keyMap[ count($this->_keyMap) - 1 ]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear HashTable
|
||||
*
|
||||
@ -155,7 +127,7 @@ class PHPExcel_HashTable
|
||||
$this->_items = array();
|
||||
$this->_keyMap = array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Count
|
||||
*
|
||||
@ -164,7 +136,7 @@ class PHPExcel_HashTable
|
||||
public function count() {
|
||||
return count($this->_items);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get index for hash code
|
||||
*
|
||||
@ -174,7 +146,7 @@ class PHPExcel_HashTable
|
||||
public function getIndexForHashCode($pHashCode = '') {
|
||||
return array_search($pHashCode, $this->_keyMap);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get by index
|
||||
*
|
||||
@ -186,10 +158,10 @@ class PHPExcel_HashTable
|
||||
if (isset($this->_keyMap[$pIndex])) {
|
||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get by hashcode
|
||||
*
|
||||
@ -201,10 +173,10 @@ class PHPExcel_HashTable
|
||||
if (isset($this->_items[$pHashCode])) {
|
||||
return $this->_items[$pHashCode];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* HashTable to array
|
||||
*
|
||||
@ -213,7 +185,7 @@ class PHPExcel_HashTable
|
||||
public function toArray() {
|
||||
return $this->_items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
|
||||
@ -18,9 +18,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_IComparable
|
||||
{
|
||||
@ -39,24 +39,5 @@ interface PHPExcel_IComparable
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode();
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex();
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value);
|
||||
|
||||
}
|
||||
|
||||
@ -2,98 +2,106 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/** PHPExcel */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
|
||||
|
||||
/** PHPExcel_IWriter */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/IWriter.php';
|
||||
|
||||
/** PHPExcel_IReader */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_IOFactory
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_IOFactory
|
||||
{
|
||||
{
|
||||
/**
|
||||
* Search locations
|
||||
* Search locations
|
||||
*
|
||||
* @var array
|
||||
* @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
|
||||
* Autoresolve classes
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
* @static
|
||||
*/
|
||||
private static $_autoResolveClasses = array(
|
||||
'Excel2007',
|
||||
'Excel5',
|
||||
'Excel2003XML',
|
||||
'OOCalc',
|
||||
'SYLK',
|
||||
'Serialized',
|
||||
'CSV'
|
||||
'CSV',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Private constructor for PHPExcel_IOFactory
|
||||
* Private constructor for PHPExcel_IOFactory
|
||||
*/
|
||||
private function __construct() { }
|
||||
|
||||
|
||||
/**
|
||||
* Get search locations
|
||||
* Get search locations
|
||||
*
|
||||
* @return array
|
||||
* @static
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function getSearchLocations() {
|
||||
return self::$_searchLocations;
|
||||
}
|
||||
|
||||
} // function getSearchLocations()
|
||||
|
||||
/**
|
||||
* Set search locations
|
||||
*
|
||||
* @param array $value
|
||||
* @throws Exception
|
||||
* Set search locations
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @param array $value
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function setSearchLocations($value) {
|
||||
if (is_array($value)) {
|
||||
@ -101,101 +109,162 @@ class PHPExcel_IOFactory
|
||||
} else {
|
||||
throw new Exception('Invalid parameter passed.');
|
||||
}
|
||||
}
|
||||
|
||||
} // function setSearchLocations()
|
||||
|
||||
/**
|
||||
* Add search location
|
||||
*
|
||||
* @param string $type Example: IWriter
|
||||
* @param string $location Example: PHPExcel/Writer/{0}.php
|
||||
* @param string $classname Example: PHPExcel_Writer_{0}
|
||||
* 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
|
||||
* Create PHPExcel_Writer_IWriter
|
||||
*
|
||||
* @param PHPExcel $phpExcel
|
||||
* @param string $writerType Example: Excel2007
|
||||
* @return PHPExcel_Writer_IWriter
|
||||
* @static
|
||||
* @access public
|
||||
* @param PHPExcel $phpExcel
|
||||
* @param string $writerType Example: Excel2007
|
||||
* @return PHPExcel_Writer_IWriter
|
||||
* @throws 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']);
|
||||
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
|
||||
|
||||
if (!class_exists($className)) {
|
||||
require_once PHPEXCEL_ROOT . $classFile;
|
||||
}
|
||||
|
||||
|
||||
$instance = new $className($phpExcel);
|
||||
if (!is_null($instance)) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Nothing found...
|
||||
throw new Exception("No $searchType found for type $writerType");
|
||||
}
|
||||
|
||||
} // function createWriter()
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Reader_IReader
|
||||
* Create PHPExcel_Reader_IReader
|
||||
*
|
||||
* @param string $readerType Example: Excel2007
|
||||
* @return PHPExcel_Reader_IReader
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $readerType Example: Excel2007
|
||||
* @return PHPExcel_Reader_IReader
|
||||
* @throws 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']);
|
||||
$classFile = str_replace('{0}', $readerType, $searchLocation['path']);
|
||||
|
||||
if (!class_exists($className)) {
|
||||
require_once PHPEXCEL_ROOT . $classFile;
|
||||
}
|
||||
|
||||
|
||||
$instance = new $className();
|
||||
if (!is_null($instance)) {
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Nothing found...
|
||||
throw new Exception("No $searchType found for type $readerType");
|
||||
}
|
||||
|
||||
} // function createReader()
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
|
||||
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return PHPExcel
|
||||
*/
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFileName
|
||||
* @return PHPExcel
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function load($pFilename) {
|
||||
$reader = self::createReaderForFile($pFilename);
|
||||
return $reader->load($pFilename);
|
||||
}
|
||||
} // function load()
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
|
||||
* Identify file type using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return PHPExcel_Reader_IReader
|
||||
* @throws Exception
|
||||
*/
|
||||
* @static
|
||||
* @access public
|
||||
* @param string $pFileName
|
||||
* @return string
|
||||
* @throws 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
|
||||
* @return PHPExcel_Reader_IReader
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function createReaderForFile($pFilename) {
|
||||
|
||||
// First, lucky guess by inspecting file extension
|
||||
$pathinfo = pathinfo($pFilename);
|
||||
|
||||
if (isset($pathinfo['extension'])) {
|
||||
switch (strtolower($pathinfo['extension'])) {
|
||||
case 'xlsx':
|
||||
$reader = self::createReader('Excel2007');
|
||||
break;
|
||||
case 'xls':
|
||||
$reader = self::createReader('Excel5');
|
||||
break;
|
||||
case 'ods':
|
||||
$reader = self::createReader('OOCalc');
|
||||
break;
|
||||
case 'slk':
|
||||
$reader = self::createReader('SYLK');
|
||||
break;
|
||||
case 'xml':
|
||||
$reader = self::createReader('Excel2003XML');
|
||||
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;
|
||||
}
|
||||
|
||||
// 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 loading using self::$_autoResolveClasses
|
||||
foreach (self::$_autoResolveClasses as $autoResolveClass) {
|
||||
$reader = self::createReader($autoResolveClass);
|
||||
@ -204,6 +273,5 @@ class PHPExcel_IOFactory
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Could not automatically determine PHPExcel_Reader_IReader for file.");
|
||||
}
|
||||
} // function createReaderForFile()
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,36 +20,18 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
}
|
||||
|
||||
/** PHPExcel */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
|
||||
|
||||
/** PHPExcel_Worksheet */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
|
||||
|
||||
/** PHPExcel_ReferenceHelper */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/ReferenceHelper.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_NamedRange
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_NamedRange
|
||||
{
|
||||
@ -81,6 +63,13 @@ class PHPExcel_NamedRange
|
||||
*/
|
||||
private $_localOnly;
|
||||
|
||||
/**
|
||||
* Scope
|
||||
*
|
||||
* @var PHPExcel_Worksheet
|
||||
*/
|
||||
private $_scope;
|
||||
|
||||
/**
|
||||
* Create a new NamedRange
|
||||
*
|
||||
@ -88,8 +77,9 @@ class PHPExcel_NamedRange
|
||||
* @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.
|
||||
*/
|
||||
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false)
|
||||
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
|
||||
{
|
||||
// Validate data
|
||||
if (is_null($pName) || is_null($pWorksheet)|| is_null($pRange)) {
|
||||
@ -101,6 +91,8 @@ class PHPExcel_NamedRange
|
||||
$this->_worksheet = $pWorksheet;
|
||||
$this->_range = $pRange;
|
||||
$this->_localOnly = $pLocalOnly;
|
||||
$this->_scope = ($pLocalOnly == true) ?
|
||||
(($pScope == null) ? $pWorksheet : $pScope) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,6 +193,28 @@ class 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;
|
||||
}
|
||||
|
||||
@ -208,7 +222,7 @@ class PHPExcel_NamedRange
|
||||
* Resolve a named range to a regular cell range
|
||||
*
|
||||
* @param string $pNamedRange Named range
|
||||
* @param PHPExcel_Worksheet $pSheet Worksheet
|
||||
* @param PHPExcel_Worksheet|null $pSheet Scope. Use null for global scope
|
||||
* @return PHPExcel_NamedRange
|
||||
*/
|
||||
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -32,101 +32,109 @@ if (!defined('PHPEXCEL_ROOT')) {
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/** PHPExcel */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
|
||||
|
||||
/** PHPExcel_Reader_IReader */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
|
||||
|
||||
/** PHPExcel_Worksheet */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
|
||||
|
||||
/** PHPExcel_Cell */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
|
||||
/** PHPExcel_Reader_DefaultReadFilter */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_CSV
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Delimiter
|
||||
* Input encoding
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_inputEncoding;
|
||||
|
||||
/**
|
||||
* Delimiter
|
||||
*
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_delimiter;
|
||||
|
||||
/**
|
||||
* Enclosure
|
||||
* Enclosure
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_enclosure;
|
||||
|
||||
/**
|
||||
* Line ending
|
||||
* Line ending
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
* @var string
|
||||
*/
|
||||
private $_lineEnding;
|
||||
|
||||
/**
|
||||
* Sheet index to read
|
||||
* Sheet index to read
|
||||
*
|
||||
* @var int
|
||||
* @access private
|
||||
* @var int
|
||||
*/
|
||||
private $_sheetIndex;
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_IReadFilter instance
|
||||
* PHPExcel_Reader_IReadFilter instance
|
||||
*
|
||||
* @var PHPExcel_Reader_IReadFilter
|
||||
* @access private
|
||||
* @var PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
private $_readFilter = null;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_CSV
|
||||
* Create a new PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_inputEncoding = 'UTF-8';
|
||||
$this->_delimiter = ',';
|
||||
$this->_enclosure = '"';
|
||||
$this->_lineEnding = PHP_EOL;
|
||||
$this->_sheetIndex = 0;
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
} // function __construct()
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
* @access public
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
* @throws Exception
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Check if it is a CSV file (using file name)
|
||||
return (substr(strtolower($pFilename), -3) == 'csv');
|
||||
}
|
||||
|
||||
return true;
|
||||
} // function canRead()
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws Exception
|
||||
* @access public
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
@ -135,32 +143,60 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
} // function load()
|
||||
|
||||
/**
|
||||
* Read filter
|
||||
* Read filter
|
||||
*
|
||||
* @return PHPExcel_Reader_IReadFilter
|
||||
* @access public
|
||||
* @return PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
public function getReadFilter() {
|
||||
return $this->_readFilter;
|
||||
}
|
||||
} // function getReadFilter()
|
||||
|
||||
/**
|
||||
* Set read filter
|
||||
* Set read filter
|
||||
*
|
||||
* @param PHPExcel_Reader_IReadFilter $pValue
|
||||
* @access public
|
||||
* @param PHPExcel_Reader_IReadFilter $pValue
|
||||
*/
|
||||
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
|
||||
$this->_readFilter = $pValue;
|
||||
}
|
||||
return $this;
|
||||
} // function setReadFilter()
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
* Set input encoding
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @throws Exception
|
||||
* @access public
|
||||
* @param string $pValue Input encoding
|
||||
*/
|
||||
public function setInputEncoding($pValue = 'UTF-8')
|
||||
{
|
||||
$this->_inputEncoding = $pValue;
|
||||
return $this;
|
||||
} // function setInputEncoding()
|
||||
|
||||
/**
|
||||
* Get input encoding
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
return $this->_inputEncoding;
|
||||
} // function getInputEncoding()
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @access public
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
@ -181,7 +217,17 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
|
||||
throw new Exception("Could not open file $pFilename for reading.");
|
||||
}
|
||||
|
||||
// Loop trough file
|
||||
// Skip BOM, if any
|
||||
switch ($this->_inputEncoding) {
|
||||
case 'UTF-8':
|
||||
fgets($fileHandle, 4) == "\xEF\xBB\xBF" ?
|
||||
fseek($fileHandle, 3) : fseek($fileHandle, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Loop through file
|
||||
$currentRow = 0;
|
||||
$rowData = array();
|
||||
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
|
||||
@ -194,10 +240,13 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
|
||||
$rowData[$i] = str_replace("\\" . $this->_enclosure, $this->_enclosure, $rowData[$i]);
|
||||
$rowData[$i] = str_replace($this->_enclosure . $this->_enclosure, $this->_enclosure, $rowData[$i]);
|
||||
|
||||
// Convert encoding if necessary
|
||||
if ($this->_inputEncoding !== 'UTF-8') {
|
||||
$rowData[$i] = PHPExcel_Shared_String::ConvertEncoding($rowData[$i], 'UTF-8', $this->_inputEncoding);
|
||||
}
|
||||
|
||||
// Set cell value
|
||||
$objPHPExcel->getActiveSheet()->setCellValue(
|
||||
$columnLetter . $currentRow, $rowData[$i]
|
||||
);
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnLetter . $currentRow)->setValue($rowData[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -207,42 +256,46 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
} // function loadIntoExisting()
|
||||
|
||||
/**
|
||||
* Get delimiter
|
||||
* Get delimiter
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getDelimiter() {
|
||||
return $this->_delimiter;
|
||||
}
|
||||
} // function getDelimiter()
|
||||
|
||||
/**
|
||||
* Set delimiter
|
||||
* Set delimiter
|
||||
*
|
||||
* @param string $pValue Delimiter, defaults to ,
|
||||
* @return PHPExcel_Reader_CSV
|
||||
* @access public
|
||||
* @param string $pValue Delimiter, defaults to ,
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setDelimiter($pValue = ',') {
|
||||
$this->_delimiter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
} // function setDelimiter()
|
||||
|
||||
/**
|
||||
* Get enclosure
|
||||
* Get enclosure
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getEnclosure() {
|
||||
return $this->_enclosure;
|
||||
}
|
||||
} // function getEnclosure()
|
||||
|
||||
/**
|
||||
* Set enclosure
|
||||
* Set enclosure
|
||||
*
|
||||
* @param string $pValue Enclosure, defaults to "
|
||||
* @return PHPExcel_Reader_CSV
|
||||
* @access public
|
||||
* @param string $pValue Enclosure, defaults to "
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setEnclosure($pValue = '"') {
|
||||
if ($pValue == '') {
|
||||
@ -250,45 +303,49 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
|
||||
}
|
||||
$this->_enclosure = $pValue;
|
||||
return $this;
|
||||
}
|
||||
} // function setEnclosure()
|
||||
|
||||
/**
|
||||
* Get line ending
|
||||
* Get line ending
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getLineEnding() {
|
||||
return $this->_lineEnding;
|
||||
}
|
||||
} // function getLineEnding()
|
||||
|
||||
/**
|
||||
* Set line ending
|
||||
* Set line ending
|
||||
*
|
||||
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
|
||||
* @return PHPExcel_Reader_CSV
|
||||
* @access public
|
||||
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setLineEnding($pValue = PHP_EOL) {
|
||||
$this->_lineEnding = $pValue;
|
||||
return $this;
|
||||
}
|
||||
} // function setLineEnding()
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
* Get sheet index
|
||||
*
|
||||
* @return int
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetIndex() {
|
||||
return $this->_sheetIndex;
|
||||
}
|
||||
} // function getSheetIndex()
|
||||
|
||||
/**
|
||||
* Set sheet index
|
||||
* Set sheet index
|
||||
*
|
||||
* @param int $pValue Sheet index
|
||||
* @return PHPExcel_Reader_CSV
|
||||
* @access public
|
||||
* @param int $pValue Sheet index
|
||||
* @return PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0) {
|
||||
$this->_sheetIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
} // function setSheetIndex()
|
||||
}
|
||||
|
||||
@ -2,27 +2,27 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -32,18 +32,21 @@ if (!defined('PHPEXCEL_ROOT')) {
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/** PHPExcel_Reader_IReadFilter */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReadFilter.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_DefaultReadFilter
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
@ -54,7 +57,7 @@ class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
|
||||
* @param $row Row index
|
||||
* @param $worksheetName Optional worksheet name
|
||||
* @return boolean
|
||||
*/
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
688
libraries/PHPExcel/PHPExcel/Reader/Excel2003XML.php
Normal file
688
libraries/PHPExcel/PHPExcel/Reader/Excel2003XML.php
Normal file
@ -0,0 +1,688 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel2003XML
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Read data only?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_readDataOnly = false;
|
||||
|
||||
/**
|
||||
* Restict which sheets should be loaded?
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_loadSheetsOnly = null;
|
||||
|
||||
/**
|
||||
* Sheet index to read
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_sheetIndex;
|
||||
|
||||
/**
|
||||
* Formats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_styles = array();
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_IReadFilter instance
|
||||
*
|
||||
* @var PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
private $_readFilter = null;
|
||||
|
||||
|
||||
/**
|
||||
* Read data only?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getReadDataOnly() {
|
||||
return $this->_readDataOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set read data only
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_Reader_Excel2007
|
||||
*/
|
||||
public function setReadDataOnly($pValue = false) {
|
||||
$this->_readDataOnly = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get which sheets to load
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLoadSheetsOnly()
|
||||
{
|
||||
return $this->_loadSheetsOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set which sheets to load
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return PHPExcel_Reader_Excel2007
|
||||
*/
|
||||
public function setLoadSheetsOnly($value = null)
|
||||
{
|
||||
$this->_loadSheetsOnly = is_array($value) ?
|
||||
$value : array($value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all sheets to load
|
||||
*
|
||||
* @return PHPExcel_Reader_Excel2007
|
||||
*/
|
||||
public function setLoadAllSheets()
|
||||
{
|
||||
$this->_loadSheetsOnly = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read filter
|
||||
*
|
||||
* @return PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
public function getReadFilter() {
|
||||
return $this->_readFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set read filter
|
||||
*
|
||||
* @param PHPExcel_Reader_IReadFilter $pValue
|
||||
* @return PHPExcel_Reader_Excel2007
|
||||
*/
|
||||
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
|
||||
$this->_readFilter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_Excel2003XML
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_sheetIndex = 0;
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
|
||||
// Office xmlns:o="urn:schemas-microsoft-com:office:office"
|
||||
// Excel xmlns:x="urn:schemas-microsoft-com:office:excel"
|
||||
// XML Spreadsheet xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
|
||||
// Spreadsheet component xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"
|
||||
// XML schema xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
|
||||
// XML data type xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
|
||||
// MS-persist recordset xmlns:rs="urn:schemas-microsoft-com:rowset"
|
||||
// Rowset xmlns:z="#RowsetSchema"
|
||||
//
|
||||
|
||||
$signature = array(
|
||||
'<?xml version="1.0"?>',
|
||||
'<?mso-application progid="Excel.Sheet"?>'
|
||||
);
|
||||
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Read sample data (first 2 KB will do)
|
||||
$fh = fopen($pFilename, 'r');
|
||||
$data = fread($fh, 2048);
|
||||
fclose($fh);
|
||||
|
||||
$headers = explode("\n",$data);
|
||||
$valid = true;
|
||||
foreach($signature as $key => $match) {
|
||||
if (isset($headers[$key])) {
|
||||
$line = trim(rtrim($headers[$key], "\r\n"));
|
||||
if ($line != $match) {
|
||||
$valid = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
|
||||
$styleAttributeValue = strtolower($styleAttributeValue);
|
||||
foreach($styleList as $style) {
|
||||
if ($styleAttributeValue == strtolower($style)) {
|
||||
$styleAttributeValue = $style;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* pixel units to excel width units(units of 1/256th of a character width)
|
||||
* @param pxs
|
||||
* @return
|
||||
*/
|
||||
private static function _pixel2WidthUnits($pxs) {
|
||||
$UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219);
|
||||
|
||||
$widthUnits = 256 * ($pxs / 7);
|
||||
$widthUnits += $UNIT_OFFSET_MAP[($pxs % 7)];
|
||||
return $widthUnits;
|
||||
}
|
||||
|
||||
/**
|
||||
* excel width units(units of 1/256th of a character width) to pixel units
|
||||
* @param widthUnits
|
||||
* @return
|
||||
*/
|
||||
private static function _widthUnits2Pixel($widthUnits) {
|
||||
$pixels = ($widthUnits / 256) * 7;
|
||||
$offsetWidthUnits = $widthUnits % 256;
|
||||
$pixels += round($offsetWidthUnits / (256 / 7));
|
||||
return $pixels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
$fromFormats = array('\-', '\ ');
|
||||
$toFormats = array('-', ' ');
|
||||
|
||||
$underlineStyles = array (
|
||||
PHPExcel_Style_Font::UNDERLINE_NONE,
|
||||
PHPExcel_Style_Font::UNDERLINE_DOUBLE,
|
||||
PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING,
|
||||
PHPExcel_Style_Font::UNDERLINE_SINGLE,
|
||||
PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING
|
||||
);
|
||||
$verticalAlignmentStyles = array (
|
||||
PHPExcel_Style_Alignment::VERTICAL_BOTTOM,
|
||||
PHPExcel_Style_Alignment::VERTICAL_TOP,
|
||||
PHPExcel_Style_Alignment::VERTICAL_CENTER,
|
||||
PHPExcel_Style_Alignment::VERTICAL_JUSTIFY
|
||||
);
|
||||
$horizontalAlignmentStyles = array (
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_GENERAL,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_RIGHT,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY
|
||||
);
|
||||
|
||||
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
$xml = simplexml_load_file($pFilename);
|
||||
$namespaces = $xml->getNamespaces(true);
|
||||
// echo '<pre>';
|
||||
// print_r($namespaces);
|
||||
// echo '</pre><hr />';
|
||||
//
|
||||
// echo '<pre>';
|
||||
// print_r($xml);
|
||||
// echo '</pre><hr />';
|
||||
//
|
||||
$docProps = $objPHPExcel->getProperties();
|
||||
foreach($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
|
||||
switch ($propertyName) {
|
||||
case 'Title' :
|
||||
$docProps->setTitle($propertyValue);
|
||||
break;
|
||||
case 'Subject' :
|
||||
$docProps->setSubject($propertyValue);
|
||||
break;
|
||||
case 'Author' :
|
||||
$docProps->setCreator($propertyValue);
|
||||
break;
|
||||
case 'Created' :
|
||||
$creationDate = strtotime($propertyValue);
|
||||
$docProps->setCreated($creationDate);
|
||||
break;
|
||||
case 'LastAuthor' :
|
||||
$docProps->setLastModifiedBy($propertyValue);
|
||||
break;
|
||||
case 'Company' :
|
||||
$docProps->setCompany($propertyValue);
|
||||
break;
|
||||
case 'Category' :
|
||||
$docProps->setCategory($propertyValue);
|
||||
break;
|
||||
case 'Keywords' :
|
||||
$docProps->setKeywords($propertyValue);
|
||||
break;
|
||||
case 'Description' :
|
||||
$docProps->setDescription($propertyValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach($xml->Styles[0] as $style) {
|
||||
$style_ss = $style->attributes($namespaces['ss']);
|
||||
$styleID = (string) $style_ss['ID'];
|
||||
// echo 'Style ID = '.$styleID.'<br />';
|
||||
if ($styleID == 'Default') {
|
||||
$this->_styles['Default'] = array();
|
||||
} else {
|
||||
$this->_styles[$styleID] = $this->_styles['Default'];
|
||||
}
|
||||
foreach ($style as $styleType => $styleData) {
|
||||
$styleAttributes = $styleData->attributes($namespaces['ss']);
|
||||
// echo $styleType.'<br />';
|
||||
switch ($styleType) {
|
||||
case 'Alignment' :
|
||||
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
|
||||
$styleAttributeValue = (string) $styleAttributeValue;
|
||||
switch ($styleAttributeKey) {
|
||||
case 'Vertical' :
|
||||
if (self::identifyFixedStyleValue($verticalAlignmentStyles,$styleAttributeValue)) {
|
||||
$this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue;
|
||||
}
|
||||
break;
|
||||
case 'Horizontal' :
|
||||
if (self::identifyFixedStyleValue($horizontalAlignmentStyles,$styleAttributeValue)) {
|
||||
$this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue;
|
||||
}
|
||||
break;
|
||||
case 'WrapText' :
|
||||
$this->_styles[$styleID]['alignment']['wrap'] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Borders' :
|
||||
foreach($styleData->Border as $borderStyle) {
|
||||
$borderAttributes = $borderStyle->attributes($namespaces['ss']);
|
||||
$thisBorder = array();
|
||||
foreach($borderAttributes as $borderStyleKey => $borderStyleValue) {
|
||||
// echo $borderStyleKey.' = '.$borderStyleValue.'<br />';
|
||||
switch ($borderStyleKey) {
|
||||
case 'LineStyle' :
|
||||
$thisBorder['style'] = PHPExcel_Style_Border::BORDER_MEDIUM;
|
||||
// $thisBorder['style'] = $borderStyleValue;
|
||||
break;
|
||||
case 'Weight' :
|
||||
// $thisBorder['style'] = $borderStyleValue;
|
||||
break;
|
||||
case 'Position' :
|
||||
$borderPosition = strtolower($borderStyleValue);
|
||||
break;
|
||||
case 'Color' :
|
||||
$borderColour = substr($borderStyleValue,1);
|
||||
$thisBorder['color']['rgb'] = $borderColour;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (count($thisBorder) > 0) {
|
||||
if (($borderPosition == 'left') || ($borderPosition == 'right') || ($borderPosition == 'top') || ($borderPosition == 'bottom')) {
|
||||
$this->_styles[$styleID]['borders'][$borderPosition] = $thisBorder;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Font' :
|
||||
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
|
||||
$styleAttributeValue = (string) $styleAttributeValue;
|
||||
switch ($styleAttributeKey) {
|
||||
case 'FontName' :
|
||||
$this->_styles[$styleID]['font']['name'] = $styleAttributeValue;
|
||||
break;
|
||||
case 'Size' :
|
||||
$this->_styles[$styleID]['font']['size'] = $styleAttributeValue;
|
||||
break;
|
||||
case 'Color' :
|
||||
$this->_styles[$styleID]['font']['color']['rgb'] = substr($styleAttributeValue,1);
|
||||
break;
|
||||
case 'Bold' :
|
||||
$this->_styles[$styleID]['font']['bold'] = true;
|
||||
break;
|
||||
case 'Italic' :
|
||||
$this->_styles[$styleID]['font']['italic'] = true;
|
||||
break;
|
||||
case 'Underline' :
|
||||
if (self::identifyFixedStyleValue($underlineStyles,$styleAttributeValue)) {
|
||||
$this->_styles[$styleID]['font']['underline'] = $styleAttributeValue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Interior' :
|
||||
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
|
||||
switch ($styleAttributeKey) {
|
||||
case 'Color' :
|
||||
$this->_styles[$styleID]['fill']['color']['rgb'] = substr($styleAttributeValue,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'NumberFormat' :
|
||||
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
|
||||
$styleAttributeValue = str_replace($fromFormats,$toFormats,$styleAttributeValue);
|
||||
switch ($styleAttributeValue) {
|
||||
case 'Short Date' :
|
||||
$styleAttributeValue = 'dd/mm/yyyy';
|
||||
break;
|
||||
}
|
||||
if ($styleAttributeValue > '') {
|
||||
$this->_styles[$styleID]['numberformat']['code'] = $styleAttributeValue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Protection' :
|
||||
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// print_r($this->_styles[$styleID]);
|
||||
// echo '<hr />';
|
||||
}
|
||||
// echo '<hr />';
|
||||
|
||||
$worksheetID = 0;
|
||||
foreach($xml->Worksheet as $worksheet) {
|
||||
$worksheet_ss = $worksheet->attributes($namespaces['ss']);
|
||||
if ((isset($this->_loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
|
||||
(!in_array($worksheet_ss['Name'], $this->_loadSheetsOnly))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create new Worksheet
|
||||
$objPHPExcel->createSheet();
|
||||
$objPHPExcel->setActiveSheetIndex($worksheetID);
|
||||
if (isset($worksheet_ss['Name'])) {
|
||||
$worksheetName = (string) $worksheet_ss['Name'];
|
||||
$objPHPExcel->getActiveSheet()->setTitle($worksheetName);
|
||||
}
|
||||
|
||||
$columnID = 'A';
|
||||
foreach($worksheet->Table->Column as $columnData) {
|
||||
$columnData_ss = $columnData->attributes($namespaces['ss']);
|
||||
if (isset($columnData_ss['Index'])) {
|
||||
$columnID = PHPExcel_Cell::stringFromColumnIndex($columnData_ss['Index']-1);
|
||||
}
|
||||
if (isset($columnData_ss['Width'])) {
|
||||
$columnWidth = $columnData_ss['Width'];
|
||||
// echo '<b>Setting column width for '.$columnID.' to '.$columnWidth.'</b><br />';
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension($columnID)->setWidth($columnWidth / 5.4);
|
||||
}
|
||||
++$columnID;
|
||||
}
|
||||
|
||||
$rowID = 1;
|
||||
foreach($worksheet->Table->Row as $rowData) {
|
||||
$row_ss = $rowData->attributes($namespaces['ss']);
|
||||
if (isset($row_ss['Index'])) {
|
||||
$rowID = (integer) $row_ss['Index'];
|
||||
}
|
||||
// echo '<b>Row '.$rowID.'</b><br />';
|
||||
if (isset($row_ss['StyleID'])) {
|
||||
$rowStyle = $row_ss['StyleID'];
|
||||
}
|
||||
if (isset($row_ss['Height'])) {
|
||||
$rowHeight = $row_ss['Height'];
|
||||
// echo '<b>Setting row height to '.$rowHeight.'</b><br />';
|
||||
$objPHPExcel->getActiveSheet()->getRowDimension($rowID)->setRowHeight($rowHeight);
|
||||
}
|
||||
$columnID = 'A';
|
||||
foreach($rowData->Cell as $cell) {
|
||||
|
||||
$cell_ss = $cell->attributes($namespaces['ss']);
|
||||
if (isset($cell_ss['Index'])) {
|
||||
$columnID = PHPExcel_Cell::stringFromColumnIndex($cell_ss['Index']-1);
|
||||
}
|
||||
$cellRange = $columnID.$rowID;
|
||||
|
||||
if ((isset($cell_ss['MergeAcross'])) || (isset($cell_ss['MergeDown']))) {
|
||||
$columnTo = $columnID;
|
||||
if (isset($cell_ss['MergeAcross'])) {
|
||||
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cell_ss['MergeAcross'] -1);
|
||||
}
|
||||
$rowTo = $rowID;
|
||||
if (isset($cell_ss['MergeDown'])) {
|
||||
$rowTo = $rowTo + $cell_ss['MergeDown'];
|
||||
}
|
||||
$cellRange .= ':'.$columnTo.$rowTo;
|
||||
$objPHPExcel->getActiveSheet()->mergeCells($cellRange);
|
||||
}
|
||||
|
||||
$hasCalculatedValue = false;
|
||||
$cellDataFormula = '';
|
||||
if (isset($cell_ss['Formula'])) {
|
||||
$cellDataFormula = $cell_ss['Formula'];
|
||||
$hasCalculatedValue = true;
|
||||
}
|
||||
if (isset($cell->Data)) {
|
||||
$cellValue = $cellData = $cell->Data;
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NULL;
|
||||
$cellData_ss = $cellData->attributes($namespaces['ss']);
|
||||
if (isset($cellData_ss['Type'])) {
|
||||
$cellDataType = $cellData_ss['Type'];
|
||||
switch ($cellDataType) {
|
||||
/*
|
||||
const TYPE_STRING = 's';
|
||||
const TYPE_FORMULA = 'f';
|
||||
const TYPE_NUMERIC = 'n';
|
||||
const TYPE_BOOL = 'b';
|
||||
const TYPE_NULL = 's';
|
||||
const TYPE_INLINE = 'inlineStr';
|
||||
const TYPE_ERROR = 'e';
|
||||
*/
|
||||
case 'String' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
break;
|
||||
case 'Number' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$cellValue = (float) $cellValue;
|
||||
if (floor($cellValue) == $cellValue) {
|
||||
$cellValue = (integer) $cellValue;
|
||||
}
|
||||
break;
|
||||
case 'Boolean' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
$cellValue = ($cellValue != 0);
|
||||
break;
|
||||
case 'DateTime' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$cellValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellValue));
|
||||
break;
|
||||
case 'Error' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_ERROR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($hasCalculatedValue) {
|
||||
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
$columnNumber = PHPExcel_Cell::columnIndexFromString($columnID);
|
||||
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
||||
$temp = explode('"',$cellDataFormula);
|
||||
foreach($temp as $key => &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if (($key % 2) == 0) {
|
||||
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
|
||||
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
|
||||
// through the formula from left to right. Reversing means that we work right to left.through
|
||||
// the formula
|
||||
$cellReferences = array_reverse($cellReferences);
|
||||
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
|
||||
// then modify the formula to use that new reference
|
||||
foreach($cellReferences as $cellReference) {
|
||||
$rowReference = $cellReference[2][0];
|
||||
// Empty R reference is the current row
|
||||
if ($rowReference == '') $rowReference = $rowID;
|
||||
// Bracketed R references are relative to the current row
|
||||
if ($rowReference{0} == '[') $rowReference = $rowID + trim($rowReference,'[]');
|
||||
$columnReference = $cellReference[4][0];
|
||||
// Empty C reference is the current column
|
||||
if ($columnReference == '') $columnReference = $columnNumber;
|
||||
// Bracketed C references are relative to the current column
|
||||
if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]');
|
||||
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
|
||||
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
// Then rebuild the formula string
|
||||
$cellDataFormula = implode('"',$temp);
|
||||
}
|
||||
|
||||
// echo 'Cell '.$columnID.$rowID.' is a '.$type.' with a value of '.(($hasCalculatedValue) ? $cellDataFormula : $cellValue).'<br />';
|
||||
//
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $cellValue),$type);
|
||||
if ($hasCalculatedValue) {
|
||||
// echo 'Forumla result is '.$cellValue.'<br />';
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($cellValue);
|
||||
}
|
||||
}
|
||||
if (isset($cell_ss['StyleID'])) {
|
||||
$style = (string) $cell_ss['StyleID'];
|
||||
// echo 'Cell style for '.$columnID.$rowID.' is '.$style.'<br />';
|
||||
if ((isset($this->_styles[$style])) && (count($this->_styles[$style]) > 0)) {
|
||||
// echo 'Cell '.$columnID.$rowID.'<br />';
|
||||
// print_r($this->_styles[$style]);
|
||||
// echo '<br />';
|
||||
if (!$objPHPExcel->getActiveSheet()->cellExists($columnID.$rowID)) {
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(NULL);
|
||||
}
|
||||
$objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->_styles[$style]);
|
||||
}
|
||||
}
|
||||
++$columnID;
|
||||
}
|
||||
++$rowID;
|
||||
}
|
||||
++$worksheetID;
|
||||
}
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetIndex() {
|
||||
return $this->_sheetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sheet index
|
||||
*
|
||||
* @param int $pValue Sheet index
|
||||
* @return PHPExcel_Reader_Excel2003XML
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0) {
|
||||
$this->_sheetIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,49 +20,17 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Cell */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
|
||||
/** PHPExcel_Shared_Escher_DggContainer */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer.php';
|
||||
|
||||
/** PHPExcel_Shared_Escher_DggContainer_BstoreContainer */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer.php';
|
||||
|
||||
/** PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE.php';
|
||||
|
||||
/** PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php';
|
||||
|
||||
/** PHPExcel_Shared_Escher_DgContainer */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DgContainer.php';
|
||||
|
||||
/** PHPExcel_Shared_Escher_DgContainer_SpgrContainer */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DgContainer/SpgrContainer.php';
|
||||
|
||||
/** PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php';
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Excel5_Escher
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Excel5_Escher
|
||||
{
|
||||
@ -122,7 +90,7 @@ class PHPExcel_Reader_Excel5_Escher
|
||||
{
|
||||
$this->_object = $object;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load Escher stream data. May be a partial Escher stream.
|
||||
*
|
||||
@ -136,14 +104,14 @@ class PHPExcel_Reader_Excel5_Escher
|
||||
$this->_dataSize = strlen($this->_data);
|
||||
|
||||
$this->_pos = 0;
|
||||
|
||||
|
||||
// Parse Escher stream
|
||||
while ($this->_pos < $this->_dataSize) {
|
||||
|
||||
|
||||
|
||||
|
||||
// offset: 2; size: 2: Record Type
|
||||
$fbt = $this->_GetInt2d($this->_data, $this->_pos + 2);
|
||||
|
||||
|
||||
switch ($fbt) {
|
||||
case self::DGGCONTAINER: $this->_readDggContainer(); break;
|
||||
case self::DGG: $this->_readDgg(); break;
|
||||
@ -166,7 +134,7 @@ class PHPExcel_Reader_Excel5_Escher
|
||||
default: $this->_readDefault(); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->_object;
|
||||
}
|
||||
|
||||
@ -177,16 +145,16 @@ class PHPExcel_Reader_Excel5_Escher
|
||||
{
|
||||
// offset 0; size: 2; recVer and recInstance
|
||||
$verInstance = $this->_GetInt2d($this->_data, $this->_pos);
|
||||
|
||||
|
||||
// offset: 2; size: 2: Record Type
|
||||
$fbt = $this->_GetInt2d($this->_data, $this->_pos + 2);
|
||||
|
||||
// bit: 0-3; mask: 0x000F; recVer
|
||||
$recVer = (0x000F & $verInstance) >> 0;
|
||||
|
||||
|
||||
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
}
|
||||
@ -216,7 +184,7 @@ class PHPExcel_Reader_Excel5_Escher
|
||||
{
|
||||
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
}
|
||||
@ -245,22 +213,22 @@ class PHPExcel_Reader_Excel5_Escher
|
||||
private function _readBSE()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
|
||||
// add BSE to BstoreContainer
|
||||
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
|
||||
$this->_object->addBSE($BSE);
|
||||
|
||||
$BSE->setBLIPType($recInstance);
|
||||
|
||||
|
||||
// offset: 0; size: 1; btWin32 (MSOBLIPTYPE)
|
||||
$btWin32 = ord($recordData[0]);
|
||||
|
||||
@ -311,38 +279,38 @@ class PHPExcel_Reader_Excel5_Escher
|
||||
private function _readBlipJPEG()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
|
||||
$pos = 0;
|
||||
|
||||
|
||||
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
|
||||
$rgbUid1 = substr($recordData, 0, 16);
|
||||
$pos += 16;
|
||||
|
||||
|
||||
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
|
||||
if (in_array($recInstance, array(0x046B, 0x06E3))) {
|
||||
$rgbUid2 = substr($recordData, 16, 16);
|
||||
$pos += 16;
|
||||
}
|
||||
|
||||
|
||||
// offset: var; size: 1; tag
|
||||
$tag = ord($recordData{$pos});
|
||||
$pos += 1;
|
||||
|
||||
|
||||
// offset: var; size: var; the raw image data
|
||||
$data = substr($recordData, $pos);
|
||||
|
||||
|
||||
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
|
||||
$blip->setData($data);
|
||||
|
||||
|
||||
$this->_object->setBlip($blip);
|
||||
}
|
||||
|
||||
@ -352,38 +320,38 @@ class PHPExcel_Reader_Excel5_Escher
|
||||
private function _readBlipPNG()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
|
||||
$pos = 0;
|
||||
|
||||
|
||||
// offset: 0; size: 16; rgbUid1 (MD4 digest of)
|
||||
$rgbUid1 = substr($recordData, 0, 16);
|
||||
$pos += 16;
|
||||
|
||||
|
||||
// offset: 16; size: 16; rgbUid2 (MD4 digest), only if $recInstance = 0x46B or 0x6E3
|
||||
if ($recInstance == 0x06E1) {
|
||||
$rgbUid2 = substr($recordData, 16, 16);
|
||||
$pos += 16;
|
||||
}
|
||||
|
||||
|
||||
// offset: var; size: 1; tag
|
||||
$tag = ord($recordData{$pos});
|
||||
$pos += 1;
|
||||
|
||||
|
||||
// offset: var; size: var; the raw image data
|
||||
$data = substr($recordData, $pos);
|
||||
|
||||
|
||||
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
|
||||
$blip->setData($data);
|
||||
|
||||
|
||||
$this->_object->setBlip($blip);
|
||||
}
|
||||
|
||||
@ -393,13 +361,13 @@ class PHPExcel_Reader_Excel5_Escher
|
||||
private function _readOPT()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
@ -412,7 +380,7 @@ class PHPExcel_Reader_Excel5_Escher
|
||||
private function _readTertiaryOPT()
|
||||
{
|
||||
// offset: 0; size: 2; recVer and recInstance
|
||||
|
||||
|
||||
// bit: 4-15; mask: 0xFFF0; recInstance
|
||||
$recInstance = (0xFFF0 & $this->_GetInt2d($this->_data, $this->_pos)) >> 4;
|
||||
|
||||
@ -566,10 +534,10 @@ class PHPExcel_Reader_Excel5_Escher
|
||||
{
|
||||
$length = $this->_GetInt4d($this->_data, $this->_pos + 4);
|
||||
$recordData = substr($this->_data, $this->_pos + 8, $length);
|
||||
|
||||
|
||||
// move stream pointer to next record
|
||||
$this->_pos += 8 + $length;
|
||||
|
||||
|
||||
// offset: 2; size: 2; upper-left corner column index (0-based)
|
||||
$c1 = $this->_GetInt2d($recordData, 2);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_Reader_IReadFilter
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_Reader_IReader
|
||||
{
|
||||
|
||||
498
libraries/PHPExcel/PHPExcel/Reader/OOCalc.php
Normal file
498
libraries/PHPExcel/PHPExcel/Reader/OOCalc.php
Normal file
@ -0,0 +1,498 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_OOCalc
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Read data only?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_readDataOnly = false;
|
||||
|
||||
/**
|
||||
* Restict which sheets should be loaded?
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_loadSheetsOnly = null;
|
||||
|
||||
/**
|
||||
* Sheet index to read
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_sheetIndex;
|
||||
|
||||
/**
|
||||
* Formats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_styles = array();
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_IReadFilter instance
|
||||
*
|
||||
* @var PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
private $_readFilter = null;
|
||||
|
||||
|
||||
/**
|
||||
* Read data only?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getReadDataOnly() {
|
||||
return $this->_readDataOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set read data only
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_Reader_Excel2007
|
||||
*/
|
||||
public function setReadDataOnly($pValue = false) {
|
||||
$this->_readDataOnly = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get which sheets to load
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLoadSheetsOnly()
|
||||
{
|
||||
return $this->_loadSheetsOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set which sheets to load
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return PHPExcel_Reader_Excel2007
|
||||
*/
|
||||
public function setLoadSheetsOnly($value = null)
|
||||
{
|
||||
$this->_loadSheetsOnly = is_array($value) ?
|
||||
$value : array($value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all sheets to load
|
||||
*
|
||||
* @return PHPExcel_Reader_Excel2007
|
||||
*/
|
||||
public function setLoadAllSheets()
|
||||
{
|
||||
$this->_loadSheetsOnly = null;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read filter
|
||||
*
|
||||
* @return PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
public function getReadFilter() {
|
||||
return $this->_readFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set read filter
|
||||
*
|
||||
* @param PHPExcel_Reader_IReadFilter $pValue
|
||||
* @return PHPExcel_Reader_Excel2007
|
||||
*/
|
||||
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
|
||||
$this->_readFilter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_OOCalc
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_sheetIndex = 0;
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if zip class exists
|
||||
if (!class_exists('ZipArchive')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Load file
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($pFilename) === true) {
|
||||
// check if it is an OOXML archive
|
||||
$mimeType = $zip->getFromName("mimetype");
|
||||
|
||||
$zip->close();
|
||||
|
||||
return ($mimeType === 'application/vnd.oasis.opendocument.spreadsheet');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
|
||||
$styleAttributeValue = strtolower($styleAttributeValue);
|
||||
foreach($styleList as $style) {
|
||||
if ($styleAttributeValue == strtolower($style)) {
|
||||
$styleAttributeValue = $style;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($pFilename) === true) {
|
||||
// echo '<h1>Meta Information</h1>';
|
||||
$xml = simplexml_load_string($zip->getFromName("meta.xml"));
|
||||
$namespacesMeta = $xml->getNamespaces(true);
|
||||
// echo '<pre>';
|
||||
// print_r($namespacesMeta);
|
||||
// echo '</pre><hr />';
|
||||
|
||||
$docProps = $objPHPExcel->getProperties();
|
||||
$officeProperty = $xml->children($namespacesMeta['office']);
|
||||
foreach($officeProperty as $officePropertyData) {
|
||||
$officePropertyDC = array();
|
||||
if (isset($namespacesMeta['dc'])) {
|
||||
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
|
||||
}
|
||||
foreach($officePropertyDC as $propertyName => $propertyValue) {
|
||||
// echo $propertyName.' = '.$propertyValue.'<hr />';
|
||||
|
||||
switch ($propertyName) {
|
||||
case 'title' :
|
||||
$docProps->setTitle($propertyValue);
|
||||
break;
|
||||
case 'subject' :
|
||||
$docProps->setSubject($propertyValue);
|
||||
break;
|
||||
case 'creator' :
|
||||
$docProps->setCreator($propertyValue);
|
||||
break;
|
||||
case 'date' :
|
||||
$creationDate = strtotime($propertyValue);
|
||||
$docProps->setCreated($creationDate);
|
||||
break;
|
||||
case 'description' :
|
||||
$docProps->setDescription($propertyValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$officePropertyMeta = array();
|
||||
if (isset($namespacesMeta['dc'])) {
|
||||
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
|
||||
}
|
||||
foreach($officePropertyMeta as $propertyName => $propertyValue) {
|
||||
$propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']);
|
||||
|
||||
// echo $propertyName.' = '.$propertyValue.'<br />';
|
||||
// foreach ($propertyValueAttributes as $key => $value) {
|
||||
// echo $key.' = '.$value.'<br />';
|
||||
// }
|
||||
// echo '<hr />';
|
||||
//
|
||||
switch ($propertyName) {
|
||||
case 'keyword' :
|
||||
$docProps->setKeywords($propertyValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// echo '<h1>Workbook Content</h1>';
|
||||
$xml = simplexml_load_string($zip->getFromName("content.xml"));
|
||||
$namespacesContent = $xml->getNamespaces(true);
|
||||
// echo '<pre>';
|
||||
// print_r($namespacesContent);
|
||||
// echo '</pre><hr />';
|
||||
|
||||
$workbook = $xml->children($namespacesContent['office']);
|
||||
foreach($workbook->body->spreadsheet as $workbookData) {
|
||||
$workbookData = $workbookData->children($namespacesContent['table']);
|
||||
$worksheetID = 0;
|
||||
foreach($workbookData->table as $worksheetDataSet) {
|
||||
$worksheetData = $worksheetDataSet->children($namespacesContent['table']);
|
||||
// print_r($worksheetData);
|
||||
// echo '<br />';
|
||||
$worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
|
||||
// print_r($worksheetDataAttributes);
|
||||
// echo '<br />';
|
||||
if ((isset($this->_loadSheetsOnly)) && (isset($worksheetDataAttributes['name'])) &&
|
||||
(!in_array($worksheetDataAttributes['name'], $this->_loadSheetsOnly))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// echo '<h2>Worksheet '.$worksheetDataAttributes['name'].'</h2>';
|
||||
// Create new Worksheet
|
||||
$objPHPExcel->createSheet();
|
||||
$objPHPExcel->setActiveSheetIndex($worksheetID);
|
||||
if (isset($worksheetDataAttributes['name'])) {
|
||||
$worksheetName = (string) $worksheetDataAttributes['name'];
|
||||
$objPHPExcel->getActiveSheet()->setTitle($worksheetName);
|
||||
}
|
||||
|
||||
$rowID = 1;
|
||||
foreach($worksheetData as $key => $rowData) {
|
||||
// echo '<b>'.$key.'</b><br />';
|
||||
switch ($key) {
|
||||
case 'table-row' :
|
||||
$columnID = 'A';
|
||||
foreach($rowData as $key => $cellData) {
|
||||
// echo '<b>'.$columnID.$rowID.'</b><br />';
|
||||
$cellDataText = $cellData->children($namespacesContent['text']);
|
||||
$cellDataOfficeAttributes = $cellData->attributes($namespacesContent['office']);
|
||||
$cellDataTableAttributes = $cellData->attributes($namespacesContent['table']);
|
||||
|
||||
// echo 'Office Attributes: ';
|
||||
// print_r($cellDataOfficeAttributes);
|
||||
// echo '<br />Table Attributes: ';
|
||||
// print_r($cellDataTableAttributes);
|
||||
// echo '<br />Cell Data Text';
|
||||
// print_r($cellDataText);
|
||||
// echo '<br />';
|
||||
//
|
||||
$type = $formatting = $hyperlink = null;
|
||||
$hasCalculatedValue = false;
|
||||
$cellDataFormula = '';
|
||||
if (isset($cellDataTableAttributes['formula'])) {
|
||||
$cellDataFormula = $cellDataTableAttributes['formula'];
|
||||
$hasCalculatedValue = true;
|
||||
}
|
||||
|
||||
if (isset($cellDataText->p)) {
|
||||
// echo 'Value Type is '.$cellDataOfficeAttributes['value-type'].'<br />';
|
||||
switch ($cellDataOfficeAttributes['value-type']) {
|
||||
case 'string' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||
$dataValue = $cellDataText->p;
|
||||
if (isset($dataValue->a)) {
|
||||
$dataValue = $dataValue->a;
|
||||
$cellXLinkAttributes = $dataValue->attributes($namespacesContent['xlink']);
|
||||
$hyperlink = $cellXLinkAttributes['href'];
|
||||
}
|
||||
break;
|
||||
case 'boolean' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_BOOL;
|
||||
$dataValue = ($cellDataText->p == 'TRUE') ? True : False;
|
||||
break;
|
||||
case 'float' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$dataValue = (float) $cellDataOfficeAttributes['value'];
|
||||
if (floor($dataValue) == $dataValue) {
|
||||
$dataValue = (integer) $dataValue;
|
||||
}
|
||||
break;
|
||||
case 'date' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$dateObj = date_create($cellDataOfficeAttributes['date-value']);
|
||||
list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s'));
|
||||
$dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second);
|
||||
if ($dataValue != floor($dataValue)) {
|
||||
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
|
||||
} else {
|
||||
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15;
|
||||
}
|
||||
break;
|
||||
case 'time' :
|
||||
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
|
||||
$dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime('01-01-1970 '.implode(':',sscanf($cellDataOfficeAttributes['time-value'],'PT%dH%dM%dS'))));
|
||||
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
|
||||
break;
|
||||
}
|
||||
// echo 'Data value is '.$dataValue.'<br />';
|
||||
// if (!is_null($hyperlink)) {
|
||||
// echo 'Hyperlink is '.$hyperlink.'<br />';
|
||||
// }
|
||||
}
|
||||
|
||||
if ($hasCalculatedValue) {
|
||||
$type = PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||
// echo 'Formula: '.$cellDataFormula.'<br />';
|
||||
$cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1);
|
||||
$temp = explode('"',$cellDataFormula);
|
||||
foreach($temp as $key => &$value) {
|
||||
// Only replace in alternate array entries (i.e. non-quoted blocks)
|
||||
if (($key % 2) == 0) {
|
||||
$value = preg_replace('/\[\.(.*):\.(.*)\]/Ui','$1:$2',$value);
|
||||
$value = preg_replace('/\[\.(.*)\]/Ui','$1',$value);
|
||||
$value = PHPExcel_Calculation::_translateSeparator(';',',',$value);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
// Then rebuild the formula string
|
||||
$cellDataFormula = implode('"',$temp);
|
||||
// echo 'Adjusted Formula: '.$cellDataFormula.'<br />';
|
||||
}
|
||||
|
||||
if (!is_null($type)) {
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type);
|
||||
if ($hasCalculatedValue) {
|
||||
// echo 'Forumla result is '.$dataValue.'<br />';
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($dataValue);
|
||||
}
|
||||
if (($cellDataOfficeAttributes['value-type'] == 'date') ||
|
||||
($cellDataOfficeAttributes['value-type'] == 'time')) {
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnID.$rowID)->getNumberFormat()->setFormatCode($formatting);
|
||||
}
|
||||
if (!is_null($hyperlink)) {
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->getHyperlink()->setUrl($hyperlink);
|
||||
}
|
||||
}
|
||||
|
||||
// Merged cells
|
||||
if ((isset($cellDataTableAttributes['number-columns-spanned'])) || (isset($cellDataTableAttributes['number-rows-spanned']))) {
|
||||
$columnTo = $columnID;
|
||||
if (isset($cellDataTableAttributes['number-columns-spanned'])) {
|
||||
$columnTo = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-spanned'] -2);
|
||||
}
|
||||
$rowTo = $rowID;
|
||||
if (isset($cellDataTableAttributes['number-rows-spanned'])) {
|
||||
$rowTo = $rowTo + $cellDataTableAttributes['number-rows-spanned'] - 1;
|
||||
}
|
||||
$cellRange = $columnID.$rowID.':'.$columnTo.$rowTo;
|
||||
$objPHPExcel->getActiveSheet()->mergeCells($cellRange);
|
||||
}
|
||||
|
||||
if (isset($cellDataTableAttributes['number-columns-repeated'])) {
|
||||
// echo 'Repeated '.$cellDataTableAttributes['number-columns-repeated'].' times<br />';
|
||||
$columnID = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($columnID) + $cellDataTableAttributes['number-columns-repeated'] - 2);
|
||||
}
|
||||
++$columnID;
|
||||
}
|
||||
++$rowID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
++$worksheetID;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetIndex() {
|
||||
return $this->_sheetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sheet index
|
||||
*
|
||||
* @param int $pValue Sheet index
|
||||
* @return PHPExcel_Reader_OOCalc
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0) {
|
||||
$this->_sheetIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
509
libraries/PHPExcel/PHPExcel/Reader/SYLK.php
Normal file
509
libraries/PHPExcel/PHPExcel/Reader/SYLK.php
Normal file
@ -0,0 +1,509 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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_Reader
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_SYLK
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
|
||||
{
|
||||
/**
|
||||
* Input encoding
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_inputEncoding;
|
||||
|
||||
/**
|
||||
* Delimiter
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_delimiter;
|
||||
|
||||
/**
|
||||
* Enclosure
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_enclosure;
|
||||
|
||||
/**
|
||||
* Line ending
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_lineEnding;
|
||||
|
||||
/**
|
||||
* Sheet index to read
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_sheetIndex;
|
||||
|
||||
/**
|
||||
* Formats
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_formats = array();
|
||||
|
||||
/**
|
||||
* Format Count
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_format = 0;
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_IReadFilter instance
|
||||
*
|
||||
* @var PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
private $_readFilter = null;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Reader_SYLK
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_inputEncoding = 'ANSI';
|
||||
$this->_delimiter = ';';
|
||||
$this->_enclosure = '"';
|
||||
$this->_lineEnding = PHP_EOL;
|
||||
$this->_sheetIndex = 0;
|
||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can the current PHPExcel_Reader_IReader read the file?
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Read sample data (first 2 KB will do)
|
||||
$fh = fopen($pFilename, 'r');
|
||||
$data = fread($fh, 2048);
|
||||
fclose($fh);
|
||||
|
||||
// Count delimiters in file
|
||||
$delimiterCount = substr_count($data, ';');
|
||||
if ($delimiterCount < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Analyze first line looking for ID; signature
|
||||
$lines = explode("\n", $data);
|
||||
if (substr($lines[0],0,4) != 'ID;P') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @return PHPExcel
|
||||
* @throws Exception
|
||||
*/
|
||||
public function load($pFilename)
|
||||
{
|
||||
// Create new PHPExcel
|
||||
$objPHPExcel = new PHPExcel();
|
||||
|
||||
// Load into this instance
|
||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read filter
|
||||
*
|
||||
* @return PHPExcel_Reader_IReadFilter
|
||||
*/
|
||||
public function getReadFilter() {
|
||||
return $this->_readFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set read filter
|
||||
*
|
||||
* @param PHPExcel_Reader_IReadFilter $pValue
|
||||
*/
|
||||
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
|
||||
$this->_readFilter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set input encoding
|
||||
*
|
||||
* @param string $pValue Input encoding
|
||||
*/
|
||||
public function setInputEncoding($pValue = 'ANSI')
|
||||
{
|
||||
$this->_inputEncoding = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get input encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
return $this->_inputEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @return PHPExcel
|
||||
* @throws Exception
|
||||
*/
|
||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
// Create new PHPExcel
|
||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
||||
$objPHPExcel->createSheet();
|
||||
}
|
||||
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
|
||||
|
||||
$fromFormats = array('\-', '\ ');
|
||||
$toFormats = array('-', ' ');
|
||||
|
||||
// Open file
|
||||
$fileHandle = fopen($pFilename, 'r');
|
||||
if ($fileHandle === false) {
|
||||
throw new Exception("Could not open file $pFilename for reading.");
|
||||
}
|
||||
|
||||
// Loop through file
|
||||
$rowData = array();
|
||||
$column = $row = '';
|
||||
|
||||
// loop through one row (line) at a time in the file
|
||||
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
||||
|
||||
// convert SYLK encoded $rowData to UTF-8
|
||||
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
||||
|
||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||
// is escaped like this (;;)
|
||||
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
||||
|
||||
$dataType = array_shift($rowData);
|
||||
// Read shared styles
|
||||
if ($dataType == 'P') {
|
||||
$formatArray = array();
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats,$toFormats,substr($rowDatum,1));
|
||||
break;
|
||||
case 'E' :
|
||||
case 'F' : $formatArray['font']['name'] = substr($rowDatum,1);
|
||||
break;
|
||||
case 'L' : $formatArray['font']['size'] = substr($rowDatum,1);
|
||||
break;
|
||||
case 'S' : $styleSettings = substr($rowDatum,1);
|
||||
for ($i=0;$i<strlen($styleSettings);++$i) {
|
||||
switch ($styleSettings{$i}) {
|
||||
case 'I' : $formatArray['font']['italic'] = true;
|
||||
break;
|
||||
case 'D' : $formatArray['font']['bold'] = true;
|
||||
break;
|
||||
case 'T' : $formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'B' : $formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'L' : $formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'R' : $formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->_formats['P'.$this->_format++] = $formatArray;
|
||||
// Read cell value data
|
||||
} elseif ($dataType == 'C') {
|
||||
$hasCalculatedValue = false;
|
||||
$cellData = $cellDataFormula = '';
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' : $column = substr($rowDatum,1);
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' : $row = substr($rowDatum,1);
|
||||
break;
|
||||
case 'K' : $cellData = substr($rowDatum,1);
|
||||
break;
|
||||
case 'E' : $cellDataFormula = '='.substr($rowDatum,1);
|
||||
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
||||
$temp = explode('"',$cellDataFormula);
|
||||
foreach($temp as $key => &$value) {
|
||||
// Only count/replace in alternate array entries
|
||||
if (($key % 2) == 0) {
|
||||
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
|
||||
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
|
||||
// through the formula from left to right. Reversing means that we work right to left.through
|
||||
// the formula
|
||||
$cellReferences = array_reverse($cellReferences);
|
||||
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
|
||||
// then modify the formula to use that new reference
|
||||
foreach($cellReferences as $cellReference) {
|
||||
$rowReference = $cellReference[2][0];
|
||||
// Empty R reference is the current row
|
||||
if ($rowReference == '') $rowReference = $row;
|
||||
// Bracketed R references are relative to the current row
|
||||
if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]');
|
||||
$columnReference = $cellReference[4][0];
|
||||
// Empty C reference is the current column
|
||||
if ($columnReference == '') $columnReference = $column;
|
||||
// Bracketed C references are relative to the current column
|
||||
if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
|
||||
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
|
||||
|
||||
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
// Then rebuild the formula string
|
||||
$cellDataFormula = implode('"',$temp);
|
||||
$hasCalculatedValue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
|
||||
|
||||
// Set cell value
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
|
||||
if ($hasCalculatedValue) {
|
||||
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
|
||||
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
|
||||
}
|
||||
// Read cell formatting
|
||||
} elseif ($dataType == 'F') {
|
||||
$formatStyle = $columnWidth = $styleSettings = '';
|
||||
$styleData = array();
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' : $column = substr($rowDatum,1);
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' : $row = substr($rowDatum,1);
|
||||
break;
|
||||
case 'P' : $formatStyle = $rowDatum;
|
||||
break;
|
||||
case 'W' : list($startCol,$endCol,$columnWidth) = explode(' ',substr($rowDatum,1));
|
||||
break;
|
||||
case 'S' : $styleSettings = substr($rowDatum,1);
|
||||
for ($i=0;$i<strlen($styleSettings);++$i) {
|
||||
switch ($styleSettings{$i}) {
|
||||
case 'I' : $styleData['font']['italic'] = true;
|
||||
break;
|
||||
case 'D' : $styleData['font']['bold'] = true;
|
||||
break;
|
||||
case 'T' : $styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'B' : $styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'L' : $styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
case 'R' : $styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (($formatStyle > '') && ($column > '') && ($row > '')) {
|
||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]);
|
||||
}
|
||||
if ((count($styleData) > 0) && ($column > '') && ($row > '')) {
|
||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData);
|
||||
}
|
||||
if ($columnWidth > '') {
|
||||
if ($startCol == $endCol) {
|
||||
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
||||
} else {
|
||||
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||
$endCol = PHPExcel_Cell::stringFromColumnIndex($endCol-1);
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
||||
do {
|
||||
$objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth);
|
||||
} while ($startCol != $endCol);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach($rowData as $rowDatum) {
|
||||
switch($rowDatum{0}) {
|
||||
case 'C' :
|
||||
case 'X' : $column = substr($rowDatum,1);
|
||||
break;
|
||||
case 'R' :
|
||||
case 'Y' : $row = substr($rowDatum,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
// Return
|
||||
return $objPHPExcel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get delimiter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDelimiter() {
|
||||
return $this->_delimiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set delimiter
|
||||
*
|
||||
* @param string $pValue Delimiter, defaults to ,
|
||||
* @return PHPExcel_Reader_SYLK
|
||||
*/
|
||||
public function setDelimiter($pValue = ',') {
|
||||
$this->_delimiter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enclosure
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnclosure() {
|
||||
return $this->_enclosure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set enclosure
|
||||
*
|
||||
* @param string $pValue Enclosure, defaults to "
|
||||
* @return PHPExcel_Reader_SYLK
|
||||
*/
|
||||
public function setEnclosure($pValue = '"') {
|
||||
if ($pValue == '') {
|
||||
$pValue = '"';
|
||||
}
|
||||
$this->_enclosure = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get line ending
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLineEnding() {
|
||||
return $this->_lineEnding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line ending
|
||||
*
|
||||
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
|
||||
* @return PHPExcel_Reader_SYLK
|
||||
*/
|
||||
public function setLineEnding($pValue = PHP_EOL) {
|
||||
$this->_lineEnding = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetIndex() {
|
||||
return $this->_sheetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sheet index
|
||||
*
|
||||
* @param int $pValue Sheet index
|
||||
* @return PHPExcel_Reader_SYLK
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0) {
|
||||
$this->_sheetIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -32,24 +32,21 @@ if (!defined('PHPEXCEL_ROOT')) {
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
/** PHPExcel */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel.php';
|
||||
|
||||
/** PHPExcel_Reader_IReader */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
|
||||
|
||||
/** PHPExcel_Shared_File */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/File.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Reader_Serialized
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Reader
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Reader_Serialized implements PHPExcel_Reader_IReader
|
||||
{
|
||||
@ -58,17 +55,17 @@ class PHPExcel_Reader_Serialized implements PHPExcel_Reader_IReader
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
*/
|
||||
public function canRead($pFilename)
|
||||
{
|
||||
// Check if file exists
|
||||
if (!file_exists($pFilename)) {
|
||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||
}
|
||||
|
||||
|
||||
return $this->fileSupportsUnserializePHPExcel($pFilename);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel Serialized file
|
||||
*
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -19,49 +19,19 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Worksheet */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
|
||||
|
||||
/** PHPExcel_Cell */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
|
||||
/** PHPExcel_Cell_DataType */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
|
||||
|
||||
/** PHPExcel_Style */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style.php';
|
||||
|
||||
/** PHPExcel_Worksheet_Drawing */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing.php';
|
||||
|
||||
/** PHPExcel_Calculation_FormulaParser */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/FormulaParser.php';
|
||||
|
||||
/** PHPExcel_Calculation_FormulaToken */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/FormulaToken.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_ReferenceHelper (Singleton)
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @package PHPExcel
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_ReferenceHelper
|
||||
{
|
||||
@ -86,37 +56,31 @@ class PHPExcel_ReferenceHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Calculation
|
||||
* Create a new PHPExcel_ReferenceHelper
|
||||
*/
|
||||
protected function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a new column, updating all possible related data
|
||||
*
|
||||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to insert
|
||||
* @param int $pNumRows Number of rows to insert
|
||||
* @throws Exception
|
||||
*/
|
||||
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null) {
|
||||
// Get a copy of the cell collection
|
||||
/*$aTemp = $pSheet->getCellCollection();
|
||||
$aCellCollection = array();
|
||||
foreach ($aTemp as $key => $value) {
|
||||
$aCellCollection[$key] = clone $value;
|
||||
}*/
|
||||
/**
|
||||
* Insert a new column, updating all possible related data
|
||||
*
|
||||
* @param int $pBefore Insert before this one
|
||||
* @param int $pNumCols Number of columns to insert
|
||||
* @param int $pNumRows Number of rows to insert
|
||||
* @throws Exception
|
||||
*/
|
||||
public function insertNewBefore($pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, PHPExcel_Worksheet $pSheet = null) {
|
||||
$aCellCollection = $pSheet->getCellCollection();
|
||||
|
||||
// Get coordinates of $pBefore
|
||||
$beforeColumn = 'A';
|
||||
$beforeRow = 1;
|
||||
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );
|
||||
// Get coordinates of $pBefore
|
||||
$beforeColumn = 'A';
|
||||
$beforeRow = 1;
|
||||
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );
|
||||
|
||||
|
||||
// Clear cells if we are removing columns or rows
|
||||
$highestColumn = $pSheet->getHighestColumn();
|
||||
$highestRow = $pSheet->getHighestRow();
|
||||
$highestColumn = $pSheet->getHighestColumn();
|
||||
$highestRow = $pSheet->getHighestRow();
|
||||
|
||||
// 1. Clear column strips if we are removing columns
|
||||
if ($pNumCols < 0 && PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 + $pNumCols > 0) {
|
||||
@ -148,14 +112,16 @@ class PHPExcel_ReferenceHelper
|
||||
|
||||
|
||||
// Loop through cells, bottom-up, and change cell coordinates
|
||||
while ( ($cell = ($pNumCols < 0 || $pNumRows < 0) ? array_shift($aCellCollection) : array_pop($aCellCollection)) ) {
|
||||
while (($cellID = ($pNumCols < 0 || $pNumRows < 0) ? array_shift($aCellCollection) : array_pop($aCellCollection))) {
|
||||
$cell = $pSheet->getCell($cellID);
|
||||
|
||||
// New coordinates
|
||||
$newCoordinates = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1 + $pNumCols ) . ($cell->getRow() + $pNumRows);
|
||||
|
||||
// Should the cell be updated? Move value and cellXf index from one cell to another.
|
||||
if (
|
||||
(PHPExcel_Cell::columnIndexFromString( $cell->getColumn() ) >= PHPExcel_Cell::columnIndexFromString($beforeColumn)) &&
|
||||
($cell->getRow() >= $beforeRow)
|
||||
($cell->getRow() >= $beforeRow)
|
||||
) {
|
||||
|
||||
// Update cell styles
|
||||
@ -165,24 +131,22 @@ class PHPExcel_ReferenceHelper
|
||||
// Insert this cell at its new location
|
||||
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||
// Formula should be adjusted
|
||||
$pSheet->setCellValue(
|
||||
$newCoordinates
|
||||
, $this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows)
|
||||
);
|
||||
$pSheet->getCell($newCoordinates)
|
||||
->setValue($this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows));
|
||||
} else {
|
||||
// Formula should not be adjusted
|
||||
$pSheet->setCellValue($newCoordinates, $cell->getValue());
|
||||
$pSheet->getCell($newCoordinates)->setValue($cell->getValue());
|
||||
}
|
||||
|
||||
// Clear the original cell
|
||||
$pSheet->setCellValue($cell->getCoordinate(), '');
|
||||
$pSheet->getCell($cell->getCoordinate())->setValue('');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Duplicate styles for the newly inserted cells
|
||||
$highestColumn = $pSheet->getHighestColumn();
|
||||
$highestRow = $pSheet->getHighestRow();
|
||||
$highestColumn = $pSheet->getHighestColumn();
|
||||
$highestRow = $pSheet->getHighestRow();
|
||||
|
||||
if ($pNumCols > 0 && PHPExcel_Cell::columnIndexFromString($beforeColumn) - 2 > 0) {
|
||||
for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
|
||||
@ -303,14 +267,13 @@ class PHPExcel_ReferenceHelper
|
||||
|
||||
|
||||
// Update worksheet: merge cells
|
||||
$aMergeCells = array_reverse($pSheet->getMergeCells(), true);
|
||||
foreach ($aMergeCells as $key => $value) {
|
||||
$aMergeCells = $pSheet->getMergeCells();
|
||||
$aNewMergeCells = array(); // the new array of all merge cells
|
||||
foreach ($aMergeCells as $key => &$value) {
|
||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||
if ($key != $newReference) {
|
||||
$pSheet->mergeCells( $newReference );
|
||||
$pSheet->unmergeCells( $key );
|
||||
}
|
||||
$aNewMergeCells[$newReference] = $newReference;
|
||||
}
|
||||
$pSheet->setMergeCells($aNewMergeCells); // replace the merge cells array
|
||||
|
||||
|
||||
// Update worksheet: protected cells
|
||||
@ -365,57 +328,74 @@ class PHPExcel_ReferenceHelper
|
||||
|
||||
// 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
|
||||
* @return string Updated formula
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
// Formula stack
|
||||
$executableFormulaArray = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return string Updated formula
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
// Parse formula into a tree of tokens
|
||||
$tokenisedFormula = PHPExcel_Calculation::getInstance()->parseFormula($pFormula);
|
||||
|
||||
$newCellTokens = $cellTokens = array();
|
||||
$adjustCount = 0;
|
||||
// Build the translation table of cell tokens
|
||||
foreach($tokenisedFormula as $token) {
|
||||
$token = $token['value'];
|
||||
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $token, $matches)) {
|
||||
$newCellTokens[] = $this->updateCellReference($token, $pBefore, $pNumCols, $pNumRows);
|
||||
$cellTokens[] = '/'.$token.'/';
|
||||
list($column,$row) = PHPExcel_Cell::coordinateFromString($token);
|
||||
// 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($column) + 100000;
|
||||
$row += 10000000;
|
||||
$cellIndex = $column.$row;
|
||||
if (!isset($cellTokens[$cellIndex])) {
|
||||
$newReference = $this->updateCellReference($token, $pBefore, $pNumCols, $pNumRows);
|
||||
if ($newReference !== $token) {
|
||||
$newCellTokens[$cellIndex] = preg_quote($newReference);
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z])'.preg_quote($token).'(?!\d)/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($adjustCount == 0) {
|
||||
return $pFormula;
|
||||
}
|
||||
krsort($cellTokens);
|
||||
krsort($newCellTokens);
|
||||
|
||||
// Update cell references in the formula
|
||||
$formulaBlocks = explode('"',$pFormula);
|
||||
$i = 0;
|
||||
foreach($formulaBlocks as $formulaBlockKey => $formulaBlock) {
|
||||
foreach($formulaBlocks as $i => &$formulaBlock) {
|
||||
// Only count/replace in alternate array entries
|
||||
if (($i++ % 2) == 0) {
|
||||
$formulaBlocks[$formulaBlockKey] = preg_replace($cellTokens,$newCellTokens,$formulaBlock);
|
||||
if (($i % 2) == 0) {
|
||||
$formulaBlock = 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 Exception
|
||||
*/
|
||||
public function updateCellReference($pCellRange = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
/**
|
||||
* 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 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;
|
||||
@ -423,25 +403,30 @@ class PHPExcel_ReferenceHelper
|
||||
} elseif (strpos($pCellRange, ':') === false && strpos($pCellRange, ',') === false) {
|
||||
// Single cell
|
||||
return $this->_updateSingleCellReference($pCellRange, $pBefore, $pNumCols, $pNumRows);
|
||||
} else if (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) {
|
||||
} 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 = '') {
|
||||
foreach ($pPhpExcel->getWorksheetIterator() as $sheet) {
|
||||
foreach ($sheet->getCellCollection(false) as $cell) {
|
||||
/**
|
||||
* 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 (!is_null($cell) && $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||
$formula = $cell->getValue();
|
||||
if (strpos($formula, $oldName) !== false) {
|
||||
@ -451,56 +436,56 @@ class PHPExcel_ReferenceHelper
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update cell range
|
||||
*
|
||||
* @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 Exception
|
||||
*/
|
||||
private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) {
|
||||
/**
|
||||
* Update cell range
|
||||
*
|
||||
* @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 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);
|
||||
for ($i = 0; $i < count($range); $i++) {
|
||||
for ($j = 0; $j < count($range[$i]); $j++) {
|
||||
for ($i = 0; $i < count($range); ++$i) {
|
||||
for ($j = 0; $j < count($range[$i]); ++$j) {
|
||||
$range[$i][$j] = $this->_updateSingleCellReference($range[$i][$j], $pBefore, $pNumCols, $pNumRows);
|
||||
}
|
||||
}
|
||||
|
||||
// Recreate range string
|
||||
return PHPExcel_Cell::buildRange($range);
|
||||
} else {
|
||||
throw new Exception("Only cell ranges may be passed to this method.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new 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 Exception
|
||||
*/
|
||||
private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) {
|
||||
// Get coordinates of $pBefore
|
||||
$beforeColumn = 'A';
|
||||
$beforeRow = 1;
|
||||
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );
|
||||
/**
|
||||
* 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 Exception
|
||||
*/
|
||||
private function _updateSingleCellReference($pCellReference = 'A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0) {
|
||||
if (strpos($pCellReference, ':') === false && strpos($pCellReference, ',') === false) {
|
||||
// Get coordinates of $pBefore
|
||||
$beforeColumn = 'A';
|
||||
$beforeRow = 1;
|
||||
list($beforeColumn, $beforeRow) = PHPExcel_Cell::coordinateFromString( $pBefore );
|
||||
|
||||
// Get coordinates
|
||||
$newColumn = 'A';
|
||||
$newRow = 1;
|
||||
$newColumn = 'A';
|
||||
$newRow = 1;
|
||||
list($newColumn, $newRow) = PHPExcel_Cell::coordinateFromString( $pCellReference );
|
||||
|
||||
// Make sure the reference can be used
|
||||
@ -520,20 +505,20 @@ class PHPExcel_ReferenceHelper
|
||||
|
||||
// Create new column reference
|
||||
if ($updateColumn) {
|
||||
$newColumn = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($newColumn) - 1 + $pNumCols );
|
||||
$newColumn = PHPExcel_Cell::stringFromColumnIndex( PHPExcel_Cell::columnIndexFromString($newColumn) - 1 + $pNumCols );
|
||||
}
|
||||
|
||||
// Create new row reference
|
||||
if ($updateRow) {
|
||||
$newRow = $newRow + $pNumRows;
|
||||
$newRow = $newRow + $pNumRows;
|
||||
}
|
||||
|
||||
// Return new reference
|
||||
return $newColumn . $newRow;
|
||||
} else {
|
||||
throw new Exception("Only single cell references may be passed to this method.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Only single cell references may be passed to this method.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* __clone implementation. Cloning should not be allowed in a Singleton!
|
||||
|
||||
@ -2,65 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
}
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
/** PHPExcel_Cell */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
|
||||
/** PHPExcel_Cell_DataType */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DataType.php';
|
||||
|
||||
/** PHPExcel_RichText_ITextElement */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/ITextElement.php';
|
||||
|
||||
/** PHPExcel_RichText_TextElement */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/TextElement.php';
|
||||
|
||||
/** PHPExcel_RichText_Run */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/Run.php';
|
||||
|
||||
/** PHPExcel_Style_Font */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
{
|
||||
@ -70,14 +41,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
* @var PHPExcel_RichText_ITextElement[]
|
||||
*/
|
||||
private $_richTextElements;
|
||||
|
||||
/**
|
||||
* Parent cell
|
||||
*
|
||||
* @var PHPExcel_Cell
|
||||
*/
|
||||
private $_parent;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_RichText instance
|
||||
*
|
||||
@ -88,24 +52,21 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
{
|
||||
// Initialise variables
|
||||
$this->_richTextElements = array();
|
||||
|
||||
// Set parent?
|
||||
|
||||
// Rich-Text string attached to cell?
|
||||
if (!is_null($pCell)) {
|
||||
// Set parent cell
|
||||
$this->_parent = $pCell;
|
||||
|
||||
// Add cell text and style
|
||||
if ($this->_parent->getValue() != "") {
|
||||
$objRun = new PHPExcel_RichText_Run($this->_parent->getValue());
|
||||
$objRun->setFont(clone $this->_parent->getParent()->getStyle($this->_parent->getCoordinate())->getFont());
|
||||
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
|
||||
$this->_parent->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
$pCell->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add text
|
||||
*
|
||||
@ -118,7 +79,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
$this->_richTextElements[] = $pText;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create text
|
||||
*
|
||||
@ -132,7 +93,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create text run
|
||||
*
|
||||
@ -146,7 +107,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
$this->addText($objText);
|
||||
return $objText;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get plain text
|
||||
*
|
||||
@ -156,16 +117,16 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
{
|
||||
// Return value
|
||||
$returnValue = '';
|
||||
|
||||
// Loop trough all PHPExcel_RichText_ITextElement
|
||||
|
||||
// Loop through all PHPExcel_RichText_ITextElement
|
||||
foreach ($this->_richTextElements as $text) {
|
||||
$returnValue .= $text->getText();
|
||||
}
|
||||
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert to string
|
||||
*
|
||||
@ -174,7 +135,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
public function __toString() {
|
||||
return $this->getPlainText();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Rich Text elements
|
||||
*
|
||||
@ -184,7 +145,7 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
{
|
||||
return $this->_richTextElements;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Rich Text elements
|
||||
*
|
||||
@ -201,101 +162,30 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent
|
||||
*
|
||||
* @return PHPExcel_Cell
|
||||
*/
|
||||
public function getParent() {
|
||||
return $this->_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent
|
||||
*
|
||||
* @param PHPExcel_Cell $value
|
||||
* @return PHPExcel_RichText
|
||||
*/
|
||||
public function setParent(PHPExcel_Cell $value) {
|
||||
// Set parent
|
||||
$this->_parent = $value;
|
||||
|
||||
// Set parent value
|
||||
$this->_parent->setValueExplicit($this, PHPExcel_Cell_DataType::TYPE_STRING);
|
||||
|
||||
// Verify style information
|
||||
|
||||
$sheet = $this->_parent->getParent();
|
||||
$cellFont = $sheet->getStyle($this->_parent->getCoordinate())->getFont()->getSharedComponent();
|
||||
foreach ($this->getRichTextElements() as $element) {
|
||||
if (!($element instanceof PHPExcel_RichText_Run)) continue;
|
||||
|
||||
if ($element->getFont()->getHashCode() == $sheet->getDefaultStyle()->getFont()->getHashCode()) {
|
||||
if ($element->getFont()->getHashCode() != $cellFont->getHashCode()) {
|
||||
$element->setFont(clone $cellFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
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__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 ($key == '_parent') continue;
|
||||
|
||||
if (is_object($value)) {
|
||||
$this->$key = clone $value;
|
||||
} else {
|
||||
|
||||
@ -6,42 +6,30 @@
|
||||
* 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Style_Font */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText_ITextElement
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_RichText_ITextElement
|
||||
{
|
||||
@ -49,28 +37,28 @@ interface PHPExcel_RichText_ITextElement
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
*/
|
||||
public function getText();
|
||||
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return PHPExcel_RichText_ITextElement
|
||||
*/
|
||||
*/
|
||||
public function setText($pText = '');
|
||||
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPExcel_Style_Font
|
||||
*/
|
||||
*/
|
||||
public function getFont();
|
||||
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode();
|
||||
}
|
||||
|
||||
@ -6,58 +6,40 @@
|
||||
* 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_RichText_ITextElement */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/ITextElement.php';
|
||||
|
||||
/** PHPExcel_RichText_TextElement */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/TextElement.php';
|
||||
|
||||
/** PHPExcel_Style_Font */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText_Run
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
||||
{
|
||||
{
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var PHPExcel_Style_Font
|
||||
*/
|
||||
private $_font;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_RichText_Run instance
|
||||
*
|
||||
@ -69,33 +51,33 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
|
||||
$this->setText($pText);
|
||||
$this->_font = new PHPExcel_Style_Font();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPExcel_Style_Font
|
||||
*/
|
||||
*/
|
||||
public function getFont() {
|
||||
return $this->_font;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set font
|
||||
*
|
||||
* @param PHPExcel_Style_Font $pFont Font
|
||||
* @throws Exception
|
||||
* @return PHPExcel_RichText_ITextElement
|
||||
*/
|
||||
*/
|
||||
public function setFont(PHPExcel_Style_Font $pFont = null) {
|
||||
$this->_font = $pFont;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->getText()
|
||||
@ -103,7 +85,7 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
|
||||
@ -6,45 +6,30 @@
|
||||
* 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_RichText_ITextElement */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/RichText/ITextElement.php';
|
||||
|
||||
/** PHPExcel_Style_Font */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_RichText_TextElement
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_RichText
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
||||
{
|
||||
@ -54,7 +39,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_RichText_TextElement instance
|
||||
*
|
||||
@ -65,48 +50,48 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
||||
// Initialise variables
|
||||
$this->_text = $pText;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return string Text
|
||||
*/
|
||||
*/
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param $pText string Text
|
||||
* @return PHPExcel_RichText_ITextElement
|
||||
*/
|
||||
*/
|
||||
public function setText($pText = '') {
|
||||
$this->_text = $pText;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get font
|
||||
*
|
||||
* @return PHPExcel_Style_Font
|
||||
*/
|
||||
*/
|
||||
public function getFont() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_text
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
|
||||
65
libraries/PHPExcel/PHPExcel/Settings.php
Normal file
65
libraries/PHPExcel/PHPExcel/Settings.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
PHPExcel_Autoloader::Register();
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
// check mbstring.func_overload
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PHPExcel_Settings
|
||||
{
|
||||
public static function getCacheStorageMethod() {
|
||||
return PHPExcel_CachedObjectStorageFactory::$_cacheStorageMethod;
|
||||
} // function getCacheStorageMethod()
|
||||
|
||||
|
||||
public static function getCacheStorageClass() {
|
||||
return PHPExcel_CachedObjectStorageFactory::$_cacheStorageClass;
|
||||
} // function getCacheStorageClass()
|
||||
|
||||
|
||||
public static function setCacheStorageMethod($method = PHPExcel_CachedObjectStorageFactory::cache_in_memory, $arguments = array()) {
|
||||
return PHPExcel_CachedObjectStorageFactory::initialize($method,$arguments);
|
||||
} // function setCacheStorageMethod()
|
||||
|
||||
|
||||
public static function setLocale($locale){
|
||||
return PHPExcel_Calculation::getInstance()->setLocale($locale);
|
||||
} // function setLocale()
|
||||
|
||||
}
|
||||
94
libraries/PHPExcel/PHPExcel/Shared/CodePage.php
Normal file
94
libraries/PHPExcel/PHPExcel/Shared/CodePage.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2010 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_Shared
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_CodePage
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_CodePage
|
||||
{
|
||||
/**
|
||||
* Convert Microsoft Code Page Identifier to Code Page Name which iconv
|
||||
* and mbstring understands
|
||||
*
|
||||
* @param int $number Microsoft Code Page Indentifier
|
||||
* @return string Code Page Name
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function NumberToName($codePage = '1252')
|
||||
{
|
||||
switch ($codePage) {
|
||||
case 367: return 'ASCII'; break; // ASCII
|
||||
case 437: return 'CP437'; break; //OEM US
|
||||
case 720: throw new Exception('Code page 720 not supported.');
|
||||
break; //OEM Arabic
|
||||
case 737: return 'CP737'; break; //OEM Greek
|
||||
case 775: return 'CP775'; break; //OEM Baltic
|
||||
case 850: return 'CP850'; break; //OEM Latin I
|
||||
case 852: return 'CP852'; break; //OEM Latin II (Central European)
|
||||
case 855: return 'CP855'; break; //OEM Cyrillic
|
||||
case 857: return 'CP857'; break; //OEM Turkish
|
||||
case 858: return 'CP858'; break; //OEM Multilingual Latin I with Euro
|
||||
case 860: return 'CP860'; break; //OEM Portugese
|
||||
case 861: return 'CP861'; break; //OEM Icelandic
|
||||
case 862: return 'CP862'; break; //OEM Hebrew
|
||||
case 863: return 'CP863'; break; //OEM Canadian (French)
|
||||
case 864: return 'CP864'; break; //OEM Arabic
|
||||
case 865: return 'CP865'; break; //OEM Nordic
|
||||
case 866: return 'CP866'; break; //OEM Cyrillic (Russian)
|
||||
case 869: return 'CP869'; break; //OEM Greek (Modern)
|
||||
case 874: return 'CP874'; break; //ANSI Thai
|
||||
case 932: return 'CP932'; break; //ANSI Japanese Shift-JIS
|
||||
case 936: return 'CP936'; break; //ANSI Chinese Simplified GBK
|
||||
case 949: return 'CP949'; break; //ANSI Korean (Wansung)
|
||||
case 950: return 'CP950'; break; //ANSI Chinese Traditional BIG5
|
||||
case 1200: return 'UTF-16LE'; break; //UTF-16 (BIFF8)
|
||||
case 1250: return 'CP1250'; break; // ANSI Latin II (Central European)
|
||||
case 1251: return 'CP1251'; break; //ANSI Cyrillic
|
||||
case 1252: return 'CP1252'; break; //ANSI Latin I (BIFF4-BIFF7)
|
||||
case 1253: return 'CP1253'; break; //ANSI Greek
|
||||
case 1254: return 'CP1254'; break; //ANSI Turkish
|
||||
case 1255: return 'CP1255'; break; //ANSI Hebrew
|
||||
case 1256: return 'CP1256'; break; //ANSI Arabic
|
||||
case 1257: return 'CP1257'; break; //ANSI Baltic
|
||||
case 1258: return 'CP1258'; break; //ANSI Vietnamese
|
||||
case 1361: return 'CP1361'; break; //ANSI Korean (Johab)
|
||||
case 10000: return 'MAC'; break; //Apple Roman
|
||||
case 32768: return 'MAC'; break; //Apple Roman
|
||||
case 32769: throw new Exception('Code page 32769 not supported.');
|
||||
break; //ANSI Latin I (BIFF2-BIFF3)
|
||||
case 65001: return 'UTF-8'; break; //Unicode (UTF-8)
|
||||
}
|
||||
|
||||
throw new Exception('Unknown codepage: ' . $codePage);
|
||||
}
|
||||
|
||||
}
|
||||
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -21,33 +21,18 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Cell */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
|
||||
/** PHPExcel_Style_NumberFormat */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Date
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Date
|
||||
{
|
||||
@ -106,12 +91,15 @@ class PHPExcel_Shared_Date
|
||||
// Perform conversion
|
||||
if ($dateValue >= 1) {
|
||||
$utcDays = $dateValue - $myExcelBaseDate;
|
||||
$returnValue = (integer) round($utcDays * 24 * 60 * 60);
|
||||
$returnValue = round($utcDays * 24 * 60 * 60);
|
||||
if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
|
||||
$returnValue = (integer) $returnValue;
|
||||
}
|
||||
} else {
|
||||
$hours = round($dateValue * 24);
|
||||
$mins = round($dateValue * 24 * 60) - round($hours * 60);
|
||||
$secs = round($dateValue * 24 * 60 * 60) - round($hours * 60 * 60) - round($mins * 60);
|
||||
$returnValue = (integer) mktime($hours, $mins, $secs);
|
||||
$returnValue = (integer) gmmktime($hours, $mins, $secs);
|
||||
}
|
||||
|
||||
// Return
|
||||
@ -132,8 +120,10 @@ class PHPExcel_Shared_Date
|
||||
$hours = round($time / 3600);
|
||||
$minutes = round($time / 60) - ($hours * 60);
|
||||
$seconds = round($time) - ($hours * 3600) - ($minutes * 60);
|
||||
|
||||
$dateObj = date_create('1-Jan-1970+'.$days.' days');
|
||||
$dateObj->setTime($hours,$minutes,$seconds);
|
||||
|
||||
return $dateObj;
|
||||
} // function ExcelToPHPObject()
|
||||
|
||||
@ -274,4 +264,40 @@ class PHPExcel_Shared_Date
|
||||
// No date...
|
||||
return false;
|
||||
} // function isDateTimeFormatCode()
|
||||
|
||||
|
||||
/**
|
||||
* Convert a date/time string to Excel time
|
||||
*
|
||||
* @param string $dateValue Examples: '2009-12-31', '2009-12-31 15:59', '2009-12-31 15:59:10'
|
||||
* @return float|false Excel date/time serial value
|
||||
*/
|
||||
public static function stringToExcel($dateValue = '') {
|
||||
// restrict to dates and times like these because date_parse accepts too many strings
|
||||
// '2009-12-31'
|
||||
// '2009-12-31 15:59'
|
||||
// '2009-12-31 15:59:10'
|
||||
if (!preg_match('/^\d{4}\-\d{1,2}\-\d{1,2}( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/', $dateValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// now try with date_parse
|
||||
$PHPDateArray = date_parse($dateValue);
|
||||
|
||||
if ($PHPDateArray['error_count'] == 0) {
|
||||
$year = $PHPDateArray['year'] !== false ? $PHPDateArray['year'] : self::getExcelCalendar();
|
||||
$month = $PHPDateArray['month'] !== false ? $PHPDateArray['month'] : 1;
|
||||
$day = $PHPDateArray['day'] !== false ? $PHPDateArray['day'] : 0;
|
||||
$hour = $PHPDateArray['hour'] !== false ? $PHPDateArray['hour'] : 0;
|
||||
$minute = $PHPDateArray['minute'] !== false ? $PHPDateArray['minute'] : 0;
|
||||
$second = $PHPDateArray['second'] !== false ? $PHPDateArray['second'] : 0;
|
||||
|
||||
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second);
|
||||
|
||||
return $excelDateValue;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,27 +2,27 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Drawing
|
||||
{
|
||||
@ -44,7 +44,7 @@ class PHPExcel_Shared_Drawing
|
||||
public static function pixelsToEMU($pValue = 0) {
|
||||
return round($pValue * 9525);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert EMU to pixels
|
||||
*
|
||||
@ -58,35 +58,69 @@ class PHPExcel_Shared_Drawing
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert pixels to cell dimension. Exact algorithm not known.
|
||||
* Convert pixels to column width. Exact algorithm not known.
|
||||
* By inspection of a real Excel file using Calibri 11, one finds 1000px ~ 142.85546875
|
||||
* This gives a conversion factor of 7. Also, we assume that pixels and font size are proportional.
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @param int $pFontSize Default font size of workbook
|
||||
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
||||
* @return int Value in cell dimension
|
||||
*/
|
||||
public static function pixelsToCellDimension($pValue = 0, $pFontSize = 11) {
|
||||
return $pValue * $pFontSize / 11 / 7;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert cell width to pixels
|
||||
*
|
||||
* @param int $pValue Value in cell dimension
|
||||
* @param int $pFontSize Default font size of workbook
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function cellDimensionToPixels($pValue = 0, $pFontSize = 11) {
|
||||
if ($pValue != 0) {
|
||||
return $pValue * 7 * $pFontSize / 11;
|
||||
public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
|
||||
// Font name and size
|
||||
$name = $pDefaultFont->getName();
|
||||
$size = $pDefaultFont->getSize();
|
||||
|
||||
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
||||
// Exact width can be determined
|
||||
$colWidth = $pValue
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'];
|
||||
} else {
|
||||
return 0;
|
||||
// We don't have data for this particular font and size, use approximation by
|
||||
// extrapolating from Calibri 11
|
||||
$colWidth = $pValue * 11
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
|
||||
}
|
||||
|
||||
return $colWidth;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert column width from (intrinsic) Excel units to pixels
|
||||
*
|
||||
* @param float $pValue Value in cell dimension
|
||||
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
|
||||
// Font name and size
|
||||
$name = $pDefaultFont->getName();
|
||||
$size = $pDefaultFont->getSize();
|
||||
|
||||
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
||||
// Exact width can be determined
|
||||
$colWidth = $pValue
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
|
||||
|
||||
} else {
|
||||
// We don't have data for this particular font and size, use approximation by
|
||||
// extrapolating from Calibri 11
|
||||
$colWidth = $pValue * $size
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
|
||||
}
|
||||
|
||||
// Round pixels to closest integer
|
||||
$colWidth = (int) round($colWidth);
|
||||
|
||||
return $colWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to points
|
||||
*
|
||||
@ -96,7 +130,7 @@ class PHPExcel_Shared_Drawing
|
||||
public static function pixelsToPoints($pValue = 0) {
|
||||
return $pValue * 0.67777777;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert points to pixels
|
||||
*
|
||||
@ -120,7 +154,7 @@ class PHPExcel_Shared_Drawing
|
||||
public static function degreesToAngle($pValue = 0) {
|
||||
return (int)round($pValue * 60000);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert angle to degrees
|
||||
*
|
||||
@ -134,4 +168,105 @@ class PHPExcel_Shared_Drawing
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new image from file. By alexander at alexauto dot nl
|
||||
*
|
||||
* @link http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214
|
||||
* @param string $filename Path to Windows DIB (BMP) image
|
||||
* @return resource
|
||||
*/
|
||||
public static function imagecreatefrombmp($p_sFile)
|
||||
{
|
||||
// Load the image into a string
|
||||
$file = fopen($p_sFile,"rb");
|
||||
$read = fread($file,10);
|
||||
while(!feof($file)&&($read<>""))
|
||||
$read .= fread($file,1024);
|
||||
|
||||
$temp = unpack("H*",$read);
|
||||
$hex = $temp[1];
|
||||
$header = substr($hex,0,108);
|
||||
|
||||
// Process the header
|
||||
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
|
||||
if (substr($header,0,4)=="424d")
|
||||
{
|
||||
// Cut it in parts of 2 bytes
|
||||
$header_parts = str_split($header,2);
|
||||
|
||||
// Get the width 4 bytes
|
||||
$width = hexdec($header_parts[19].$header_parts[18]);
|
||||
|
||||
// Get the height 4 bytes
|
||||
$height = hexdec($header_parts[23].$header_parts[22]);
|
||||
|
||||
// Unset the header params
|
||||
unset($header_parts);
|
||||
}
|
||||
|
||||
// Define starting X and Y
|
||||
$x = 0;
|
||||
$y = 1;
|
||||
|
||||
// Create newimage
|
||||
$image = imagecreatetruecolor($width,$height);
|
||||
|
||||
// Grab the body from the image
|
||||
$body = substr($hex,108);
|
||||
|
||||
// Calculate if padding at the end-line is needed
|
||||
// Divided by two to keep overview.
|
||||
// 1 byte = 2 HEX-chars
|
||||
$body_size = (strlen($body)/2);
|
||||
$header_size = ($width*$height);
|
||||
|
||||
// Use end-line padding? Only when needed
|
||||
$usePadding = ($body_size>($header_size*3)+4);
|
||||
|
||||
// Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
|
||||
// Calculate the next DWORD-position in the body
|
||||
for ($i=0;$i<$body_size;$i+=3)
|
||||
{
|
||||
// Calculate line-ending and padding
|
||||
if ($x>=$width)
|
||||
{
|
||||
// If padding needed, ignore image-padding
|
||||
// Shift i to the ending of the current 32-bit-block
|
||||
if ($usePadding)
|
||||
$i += $width%4;
|
||||
|
||||
// Reset horizontal position
|
||||
$x = 0;
|
||||
|
||||
// Raise the height-position (bottom-up)
|
||||
$y++;
|
||||
|
||||
// Reached the image-height? Break the for-loop
|
||||
if ($y>$height)
|
||||
break;
|
||||
}
|
||||
|
||||
// Calculation of the RGB-pixel (defined as BGR in image-data)
|
||||
// Define $i_pos as absolute position in the body
|
||||
$i_pos = $i*2;
|
||||
$r = hexdec($body[$i_pos+4].$body[$i_pos+5]);
|
||||
$g = hexdec($body[$i_pos+2].$body[$i_pos+3]);
|
||||
$b = hexdec($body[$i_pos].$body[$i_pos+1]);
|
||||
|
||||
// Calculate and draw the pixel
|
||||
$color = imagecolorallocate($image,$r,$g,$b);
|
||||
imagesetpixel($image,$x,$height-$y,$color);
|
||||
|
||||
// Raise the horizontal position
|
||||
$x++;
|
||||
}
|
||||
|
||||
// Unset the body / free the memory
|
||||
unset($body);
|
||||
|
||||
// Return image-object
|
||||
return $image;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.6.7, 2009-04-22
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.6.7, 2009-04-22
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.6.7, 2009-04-22
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.6.7, 2009-04-22
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.6.7, 2009-04-22
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.6.7, 2009-04-22
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.6.7, 2009-04-22
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,31 +20,17 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Cell */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
|
||||
/** PHPExcel_Shared_Drawing */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Drawing.php';
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Excel5
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Excel5
|
||||
{
|
||||
@ -59,8 +45,8 @@ class PHPExcel_Shared_Excel5
|
||||
*/
|
||||
public static function sizeCol($sheet, $col = 'A')
|
||||
{
|
||||
// default font size of workbook
|
||||
$fontSize = $sheet->getParent()->getDefaultStyle()->getFont()->getSize();
|
||||
// default font of the workbook
|
||||
$font = $sheet->getParent()->getDefaultStyle()->getFont();
|
||||
|
||||
$columnDimensions = $sheet->getColumnDimensions();
|
||||
|
||||
@ -70,17 +56,19 @@ class PHPExcel_Shared_Excel5
|
||||
// then we have column dimension with explicit width
|
||||
$columnDimension = $columnDimensions[$col];
|
||||
$width = $columnDimension->getWidth();
|
||||
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $fontSize);
|
||||
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
|
||||
|
||||
} else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
|
||||
|
||||
// then we have default column dimension with explicit width
|
||||
$defaultColumnDimension = $sheet->getDefaultColumnDimension();
|
||||
$width = $defaultColumnDimension->getWidth();
|
||||
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $fontSize);
|
||||
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
|
||||
|
||||
} else {
|
||||
$pixelWidth = (int) 64 * $fontSize / 11; // here we interpolate from Calibri 11
|
||||
|
||||
// we don't even have any default column dimension. Width depends on default font
|
||||
$pixelWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($font, true);
|
||||
}
|
||||
|
||||
// now find the effective column width in pixels
|
||||
@ -104,6 +92,9 @@ class PHPExcel_Shared_Excel5
|
||||
*/
|
||||
public static function sizeRow($sheet, $row = 1)
|
||||
{
|
||||
// default font of the workbook
|
||||
$font = $sheet->getParent()->getDefaultStyle()->getFont();
|
||||
|
||||
$rowDimensions = $sheet->getRowDimensions();
|
||||
|
||||
// first find the true row height in pixels (uncollapsed and unhidden)
|
||||
@ -122,7 +113,11 @@ class PHPExcel_Shared_Excel5
|
||||
$pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight);
|
||||
|
||||
} else {
|
||||
$pixelRowHeight = 20; // here we assume Calibri 11
|
||||
|
||||
// we don't even have any default row dimension. Height depends on default font
|
||||
$pointRowHeight = PHPExcel_Shared_Font::getDefaultRowHeightByFont($font);
|
||||
$pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight);
|
||||
|
||||
}
|
||||
|
||||
// now find the effective row height in pixels
|
||||
@ -252,7 +247,7 @@ class PHPExcel_Shared_Excel5
|
||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($coordinates);
|
||||
$col_start = PHPExcel_Cell::columnIndexFromString($column) - 1;
|
||||
$row_start = $row - 1;
|
||||
|
||||
|
||||
$x1 = $offsetX;
|
||||
$y1 = $offsetY;
|
||||
|
||||
@ -301,8 +296,8 @@ class PHPExcel_Shared_Excel5
|
||||
// Convert the pixel values to the percentage value expected by Excel
|
||||
$x1 = $x1 / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) * 1024;
|
||||
$y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256;
|
||||
$x2 = $width / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object
|
||||
$y2 = $height / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object
|
||||
$x2 = ($width + 1) / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object
|
||||
$y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object
|
||||
|
||||
$startCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_start) . ($row_start + 1);
|
||||
$endCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_end) . ($row_end + 1);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_File
|
||||
{
|
||||
@ -79,7 +79,7 @@ class PHPExcel_Shared_File
|
||||
|
||||
// Found something?
|
||||
if ($returnValue == '' || is_null($returnValue)) {
|
||||
$pathArray = split('/' , $pFilename);
|
||||
$pathArray = explode('/' , $pFilename);
|
||||
while(in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
for ($i = 0; $i < count($pathArray); ++$i) {
|
||||
if ($pathArray[$i] == '..' && $i > 0) {
|
||||
@ -95,4 +95,42 @@ class PHPExcel_Shared_File
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the systems temporary directory.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function sys_get_temp_dir()
|
||||
{
|
||||
// sys_get_temp_dir is only available since PHP 5.2.1
|
||||
// http://php.net/manual/en/function.sys-get-temp-dir.php#94119
|
||||
|
||||
if ( !function_exists('sys_get_temp_dir')) {
|
||||
if( $temp = getenv('TMP') ) {
|
||||
return realpath($temp);
|
||||
}
|
||||
if( $temp = getenv('TEMP') ) {
|
||||
return realpath($temp);
|
||||
}
|
||||
if( $temp = getenv('TMPDIR') ) {
|
||||
return realpath($temp);
|
||||
}
|
||||
|
||||
// trick for creating a file in system's temporary dir
|
||||
// without knowing the path of the system's temporary dir
|
||||
$temp = tempnam(__FILE__, '');
|
||||
if (file_exists($temp)) {
|
||||
unlink($temp);
|
||||
return realpath(dirname($temp));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
// use ordinary built-in PHP function
|
||||
return realpath(sys_get_temp_dir());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,27 +2,27 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,10 +31,14 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Font
|
||||
{
|
||||
/* Methods for resolving autosize value */
|
||||
const AUTOSIZE_METHOD_APPROX = 'approx';
|
||||
const AUTOSIZE_METHOD_EXACT = 'exact';
|
||||
|
||||
/** Character set codes used by BIFF5-8 in Font records */
|
||||
const CHARSET_ANSI_LATIN = 0x00;
|
||||
const CHARSET_SYSTEM_DEFAULT = 0x01;
|
||||
@ -55,39 +59,304 @@ class PHPExcel_Shared_Font
|
||||
const CHARSET_ANSI_THAI = 0xDE;
|
||||
const CHARSET_ANSI_LATIN_II = 0xEE;
|
||||
const CHARSET_OEM_LATIN_I = 0xFF;
|
||||
|
||||
|
||||
// XXX: Constants created!
|
||||
/** Font filenames */
|
||||
const ARIAL = 'arial.ttf';
|
||||
const ARIAL_BOLD = 'arialbd.ttf';
|
||||
const ARIAL_ITALIC = 'ariali.ttf';
|
||||
const ARIAL_BOLD_ITALIC = 'arialbi.ttf';
|
||||
|
||||
const CALIBRI = 'CALIBRI.TTF';
|
||||
const CALIBRI_BOLD = 'CALIBRIB.TTF';
|
||||
const CALIBRI_ITALIC = 'CALIBRII.TTF';
|
||||
const CALIBRI_BOLD_ITALIC = 'CALIBRIZ.TTF';
|
||||
|
||||
const COMIC_SANS_MS = 'comic.ttf';
|
||||
const COMIC_SANS_MS_BOLD = 'comicbd.ttf';
|
||||
|
||||
const COURIER_NEW = 'cour.ttf';
|
||||
const COURIER_NEW_BOLD = 'courbd.ttf';
|
||||
const COURIER_NEW_ITALIC = 'couri.ttf';
|
||||
const COURIER_NEW_BOLD_ITALIC = 'courbi.ttf';
|
||||
|
||||
const GEORGIA = 'georgia.ttf';
|
||||
const GEORGIA_BOLD = 'georgiab.ttf';
|
||||
const GEORGIA_ITALIC = 'georgiai.ttf';
|
||||
const GEORGIA_BOLD_ITALIC = 'georgiaz.ttf';
|
||||
|
||||
const IMPACT = 'impact.ttf';
|
||||
|
||||
const LIBERATION_SANS = 'LiberationSans-Regular.ttf';
|
||||
const LIBERATION_SANS_BOLD = 'LiberationSans-Bold.ttf';
|
||||
const LIBERATION_SANS_ITALIC = 'LiberationSans-Italic.ttf';
|
||||
const LIBERATION_SANS_BOLD_ITALIC = 'LiberationSans-BoldItalic.ttf';
|
||||
|
||||
const LUCIDA_CONSOLE = 'lucon.ttf';
|
||||
const LUCIDA_SANS_UNICODE = 'l_10646.ttf';
|
||||
|
||||
const MICROSOFT_SANS_SERIF = 'micross.ttf';
|
||||
|
||||
const PALATINO_LINOTYPE = 'pala.ttf';
|
||||
const PALATINO_LINOTYPE_BOLD = 'palab.ttf';
|
||||
const PALATINO_LINOTYPE_ITALIC = 'palai.ttf';
|
||||
const PALATINO_LINOTYPE_BOLD_ITALIC = 'palabi.ttf';
|
||||
|
||||
const SYMBOL = 'symbol.ttf';
|
||||
|
||||
const TAHOMA = 'tahoma.ttf';
|
||||
const TAHOMA_BOLD = 'tahomabd.ttf';
|
||||
|
||||
const TIMES_NEW_ROMAN = 'times.ttf';
|
||||
const TIMES_NEW_ROMAN_BOLD = 'timesbd.ttf';
|
||||
const TIMES_NEW_ROMAN_ITALIC = 'timesi.ttf';
|
||||
const TIMES_NEW_ROMAN_BOLD_ITALIC = 'timesbi.ttf';
|
||||
|
||||
const TREBUCHET_MS = 'trebuc.ttf';
|
||||
const TREBUCHET_MS_BOLD = 'trebucbd.ttf';
|
||||
const TREBUCHET_MS_ITALIC = 'trebucit.ttf';
|
||||
const TREBUCHET_MS_BOLD_ITALIC = 'trebucbi.ttf';
|
||||
|
||||
const VERDANA = 'verdana.ttf';
|
||||
const VERDANA_BOLD = 'verdanab.ttf';
|
||||
const VERDANA_ITALIC = 'verdanai.ttf';
|
||||
const VERDANA_BOLD_ITALIC = 'verdanaz.ttf';
|
||||
|
||||
/**
|
||||
* AutoSize method
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $autoSizeMethod = self::AUTOSIZE_METHOD_APPROX;
|
||||
|
||||
/**
|
||||
* Path to folder containing TrueType font .ttf files
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $trueTypeFontPath = null;
|
||||
|
||||
/**
|
||||
* How wide is a default column for a given default font and size?
|
||||
* Empirical data found by inspecting real Excel files and reading off the pixel width
|
||||
* in Microsoft Office Excel 2007.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $defaultColumnWidths = array(
|
||||
'Arial' => array(
|
||||
1 => array('px' => 24, 'width' => 12.00000000),
|
||||
2 => array('px' => 24, 'width' => 12.00000000),
|
||||
3 => array('px' => 32, 'width' => 10.66406250),
|
||||
4 => array('px' => 32, 'width' => 10.66406250),
|
||||
5 => array('px' => 40, 'width' => 10.00000000),
|
||||
6 => array('px' => 48, 'width' => 9.59765625),
|
||||
7 => array('px' => 48, 'width' => 9.59765625),
|
||||
8 => array('px' => 56, 'width' => 9.33203125),
|
||||
9 => array('px' => 64, 'width' => 9.14062500),
|
||||
10 => array('px' => 64, 'width' => 9.14062500),
|
||||
),
|
||||
'Calibri' => array(
|
||||
1 => array('px' => 24, 'width' => 12.00000000),
|
||||
2 => array('px' => 24, 'width' => 12.00000000),
|
||||
3 => array('px' => 32, 'width' => 10.66406250),
|
||||
4 => array('px' => 32, 'width' => 10.66406250),
|
||||
5 => array('px' => 40, 'width' => 10.00000000),
|
||||
6 => array('px' => 48, 'width' => 9.59765625),
|
||||
7 => array('px' => 48, 'width' => 9.59765625),
|
||||
8 => array('px' => 56, 'width' => 9.33203125),
|
||||
9 => array('px' => 56, 'width' => 9.33203125),
|
||||
10 => array('px' => 64, 'width' => 9.14062500),
|
||||
11 => array('px' => 64, 'width' => 9.14062500),
|
||||
),
|
||||
'Verdana' => array(
|
||||
1 => array('px' => 24, 'width' => 12.00000000),
|
||||
2 => array('px' => 24, 'width' => 12.00000000),
|
||||
3 => array('px' => 32, 'width' => 10.66406250),
|
||||
4 => array('px' => 32, 'width' => 10.66406250),
|
||||
5 => array('px' => 40, 'width' => 10.00000000),
|
||||
6 => array('px' => 48, 'width' => 9.59765625),
|
||||
7 => array('px' => 48, 'width' => 9.59765625),
|
||||
8 => array('px' => 64, 'width' => 9.14062500),
|
||||
9 => array('px' => 72, 'width' => 9.00000000),
|
||||
10 => array('px' => 72, 'width' => 9.00000000),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Set autoSize method
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public static function setAutoSizeMethod($pValue = 'approx')
|
||||
{
|
||||
self::$autoSizeMethod = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get autoSize method
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getAutoSizeMethod()
|
||||
{
|
||||
return self::$autoSizeMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the path to the folder containing .ttf files. There should be a trailing slash.
|
||||
* Typical locations on variout some platforms:
|
||||
* <ul>
|
||||
* <li>C:/Windows/Fonts/</li>
|
||||
* <li>/usr/share/fonts/truetype/</li>
|
||||
* <li>~/.fonts/</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public static function setTrueTypeFontPath($pValue = '')
|
||||
{
|
||||
self::$trueTypeFontPath = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the folder containing .ttf files.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getTrueTypeFontPath()
|
||||
{
|
||||
return self::$trueTypeFontPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) OpenXML column width, based on font size and text contained
|
||||
*
|
||||
* @param int $fontSize Font size (in pixels or points)
|
||||
* @param bool $fontSizeInPixels Is the font size specified in pixels (true) or in points (false) ?
|
||||
* @param string $columnText Text to calculate width
|
||||
* @param string $cellText Text to calculate width
|
||||
* @param int $rotation Rotation angle
|
||||
* @return int Column width
|
||||
*/
|
||||
public static function calculateColumnWidth($fontSize = 9, $fontSizeInPixels = false, $columnText = '', $rotation = 0) {
|
||||
if (!$fontSizeInPixels) {
|
||||
// Translate points size to pixel size
|
||||
$fontSize = PHPExcel_Shared_Font::fontSizeToPixels($fontSize);
|
||||
public static function calculateColumnWidth(PHPExcel_Style_Font $font, $cellText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) {
|
||||
|
||||
// If it is rich text, use plain text
|
||||
if ($cellText instanceof PHPExcel_RichText) {
|
||||
$cellText = $cellText->getPlainText();
|
||||
}
|
||||
|
||||
// If it is rich text, use rich text...
|
||||
if ($columnText instanceof PHPExcel_RichText) {
|
||||
$columnText = $columnText->getPlainText();
|
||||
|
||||
// Special case if there are one or more newline characters ("\n")
|
||||
if (strpos($cellText, "\n") !== false) {
|
||||
$lineTexts = explode("\n", $cellText);
|
||||
$lineWitdhs = array();
|
||||
foreach ($lineTexts as $lineText) {
|
||||
$lineWidths[] = self::calculateColumnWidth($font, $lineText, $rotation = 0, $defaultFont);
|
||||
}
|
||||
return max($lineWidths); // width of longest line in cell
|
||||
}
|
||||
|
||||
// Only measure the part before the first newline character
|
||||
if (strpos($columnText, "\r") !== false) {
|
||||
$columnText = substr($columnText, 0, strpos($columnText, "\r"));
|
||||
|
||||
// Try to get the exact text width in pixels
|
||||
try {
|
||||
// If autosize method is set to 'approx', use approximation
|
||||
if (self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX) {
|
||||
throw new Exception('AutoSize method is set to approx');
|
||||
}
|
||||
|
||||
// Width of text in pixels excl. padding
|
||||
$columnWidth = self::getTextWidthPixelsExact($cellText, $font, $rotation);
|
||||
|
||||
// Excel adds some padding, use 1.07 of the width of an 'n' glyph
|
||||
$columnWidth += ceil(self::getTextWidthPixelsExact('0', $font, 0) * 1.07); // pixels incl. padding
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Width of text in pixels excl. padding, approximation
|
||||
$columnWidth = self::getTextWidthPixelsApprox($cellText, $font, $rotation);
|
||||
|
||||
// Excel adds some padding, just use approx width of 'n' glyph
|
||||
$columnWidth += self::getTextWidthPixelsApprox('n', $font, 0);
|
||||
}
|
||||
if (strpos($columnText, "\n") !== false) {
|
||||
$columnText = substr($columnText, 0, strpos($columnText, "\n"));
|
||||
|
||||
// Convert from pixel width to column width
|
||||
$columnWidth = PHPExcel_Shared_Drawing::pixelsToCellDimension($columnWidth, $defaultFont);
|
||||
|
||||
// Return
|
||||
return round($columnWidth, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get GD text width in pixels for a string of text in a certain font at a certain rotation angle
|
||||
*
|
||||
* @param string $text
|
||||
* @param PHPExcel_Style_Font
|
||||
* @param int $rotation
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getTextWidthPixelsExact($text, PHPExcel_Style_Font $font, $rotation = 0) {
|
||||
if (!function_exists('imagettfbbox')) {
|
||||
throw new Exception('GD library needs to be enabled');
|
||||
}
|
||||
|
||||
// font size should really be supplied in pixels in GD2,
|
||||
// but since GD2 seems to assume 72dpi, pixels and points are the same
|
||||
$fontFile = self::getTrueTypeFontFileFromFont($font);
|
||||
$textBox = imagettfbbox($font->getSize(), $rotation, $fontFile, $text);
|
||||
|
||||
// Get corners positions
|
||||
$lowerLeftCornerX = $textBox[0];
|
||||
$lowerLeftCornerY = $textBox[1];
|
||||
$lowerRightCornerX = $textBox[2];
|
||||
$lowerRightCornerY = $textBox[3];
|
||||
$upperRightCornerX = $textBox[4];
|
||||
$upperRightCornerY = $textBox[5];
|
||||
$upperLeftCornerX = $textBox[6];
|
||||
$upperLeftCornerY = $textBox[7];
|
||||
|
||||
// Consider the rotation when calculating the width
|
||||
$textWidth = max($lowerRightCornerX - $upperLeftCornerX, $upperRightCornerX - $lowerLeftCornerX);
|
||||
|
||||
return $textWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get approximate width in pixels for a string of text in a certain font at a certain rotation angle
|
||||
*
|
||||
* @param string $columnText
|
||||
* @param PHPExcel_Style_Font $font
|
||||
* @param int $rotation
|
||||
* @return int Text width in pixels (no padding added)
|
||||
*/
|
||||
public static function getTextWidthPixelsApprox($columnText, PHPExcel_Style_Font $font = null, $rotation = 0)
|
||||
{
|
||||
$fontName = $font->getName();
|
||||
$fontSize = $font->getSize();
|
||||
|
||||
// Calculate column width in pixels. We assume fixed glyph width. Result varies with font name and size.
|
||||
switch ($fontName) {
|
||||
case 'Calibri':
|
||||
// value 8.26 was found via interpolation by inspecting real Excel files with Calibri 11 font.
|
||||
$columnWidth = (int) (8.26 * PHPExcel_Shared_String::CountCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
|
||||
break;
|
||||
|
||||
case 'Arial':
|
||||
// value 7 was found via interpolation by inspecting real Excel files with Arial 10 font.
|
||||
$columnWidth = (int) (7 * PHPExcel_Shared_String::CountCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
|
||||
break;
|
||||
|
||||
case 'Verdana':
|
||||
// value 8 was found via interpolation by inspecting real Excel files with Verdana 10 font.
|
||||
$columnWidth = (int) (8 * PHPExcel_Shared_String::CountCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
|
||||
break;
|
||||
|
||||
default:
|
||||
// just assume Calibri
|
||||
$columnWidth = (int) (8.26 * PHPExcel_Shared_String::CountCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
|
||||
break;
|
||||
}
|
||||
|
||||
// Calculate column width
|
||||
// values 1.025 and 0.584 found via interpolation by inspecting real Excel files with
|
||||
// Calibri font. May need further adjustment
|
||||
$columnWidth = 1.025 * strlen($columnText) + 0.584; // Excel adds some padding
|
||||
|
||||
// Calculate approximate rotated column width
|
||||
if ($rotation !== 0) {
|
||||
@ -101,20 +370,21 @@ class PHPExcel_Shared_Font
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
return round($columnWidth, 6);
|
||||
// pixel width is an integer
|
||||
$columnWidth = (int) $columnWidth;
|
||||
return $columnWidth;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on a font points size
|
||||
*
|
||||
* @param int $fontSizeInPoints Font size (in points)
|
||||
* @return int Font size (in pixels)
|
||||
*/
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 12) {
|
||||
return ((16 / 12) * $fontSizeInPoints);
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 11) {
|
||||
return (int) ((4 / 3) * $fontSizeInPoints);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on inch size
|
||||
*
|
||||
@ -124,7 +394,7 @@ class PHPExcel_Shared_Font
|
||||
public static function inchSizeToPixels($sizeInInch = 1) {
|
||||
return ($sizeInInch * 96);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on centimeter size
|
||||
*
|
||||
@ -135,6 +405,133 @@ class PHPExcel_Shared_Font
|
||||
return ($sizeInCm * 37.795275591);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font path given the font
|
||||
*
|
||||
* @param PHPExcel_Style_Font
|
||||
* @return string Path to TrueType font file
|
||||
*/
|
||||
public static function getTrueTypeFontFileFromFont($font) {
|
||||
if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) {
|
||||
throw new Exception('Valid directory to TrueType Font files not specified');
|
||||
}
|
||||
|
||||
$name = $font->getName();
|
||||
$bold = $font->getBold();
|
||||
$italic = $font->getItalic();
|
||||
|
||||
// Check if we can map font to true type font file
|
||||
switch ($name) {
|
||||
case 'Arial':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::ARIAL_BOLD_ITALIC : self::ARIAL_BOLD)
|
||||
: ($italic ? self::ARIAL_ITALIC : self::ARIAL)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Calibri':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
|
||||
: ($italic ? self::CALIBRI_ITALIC : self::CALIBRI)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Courier New':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
|
||||
: ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Comic Sans MS':
|
||||
$fontFile = (
|
||||
$bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Georgia':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
|
||||
: ($italic ? self::GEORGIA_ITALIC : self::GEORGIA)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Impact':
|
||||
$fontFile = self::IMPACT;
|
||||
break;
|
||||
|
||||
case 'Liberation Sans':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
|
||||
: ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Lucida Console':
|
||||
$fontFile = self::LUCIDA_CONSOLE;
|
||||
break;
|
||||
|
||||
case 'Lucida Sans Unicode':
|
||||
$fontFile = self::LUCIDA_SANS_UNICODE;
|
||||
break;
|
||||
|
||||
case 'Microsoft Sans Serif':
|
||||
$fontFile = self::MICROSOFT_SANS_SERIF;
|
||||
break;
|
||||
|
||||
case 'Palatino Linotype':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
|
||||
: ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Symbol':
|
||||
$fontFile = self::SYMBOL;
|
||||
break;
|
||||
|
||||
case 'Tahoma':
|
||||
$fontFile = (
|
||||
$bold ? self::TAHOMA_BOLD : self::TAHOMA
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Times New Roman':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
|
||||
: ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Trebuchet MS':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
|
||||
: ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Verdana':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
|
||||
: ($italic ? self::VERDANA_ITALIC : self::VERDANA)
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file');
|
||||
break;
|
||||
}
|
||||
|
||||
$fontFile = self::$trueTypeFontPath . $fontFile;
|
||||
|
||||
// Check if file actually exists
|
||||
if (!file_exists($fontFile)) {
|
||||
throw New Exception('TrueType Font file not found');
|
||||
}
|
||||
|
||||
return $fontFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the associated charset for the font name.
|
||||
*
|
||||
@ -145,6 +542,7 @@ class PHPExcel_Shared_Font
|
||||
{
|
||||
switch ($name) {
|
||||
// Add more cases. Check FONT records in real Excel files.
|
||||
case 'EucrosiaUPC': return self::CHARSET_ANSI_THAI;
|
||||
case 'Wingdings': return self::CHARSET_SYMBOL;
|
||||
case 'Wingdings 2': return self::CHARSET_SYMBOL;
|
||||
case 'Wingdings 3': return self::CHARSET_SYMBOL;
|
||||
@ -152,4 +550,214 @@ class PHPExcel_Shared_Font
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the effective column width for columns without a column dimension or column with width -1
|
||||
* For example, for Calibri 11 this is 9.140625 (64 px)
|
||||
*
|
||||
* @param PHPExcel_Style_Font $font The workbooks default font
|
||||
* @param boolean $pPixels true = return column width in pixels, false = return in OOXML units
|
||||
* @return mixed Column width
|
||||
*/
|
||||
public static function getDefaultColumnWidthByFont(PHPExcel_Style_Font $font, $pPixels = false)
|
||||
{
|
||||
if (isset(self::$defaultColumnWidths[$font->getName()][$font->getSize()])) {
|
||||
// Exact width can be determined
|
||||
$columnWidth = $pPixels ?
|
||||
self::$defaultColumnWidths[$font->getName()][$font->getSize()]['px']
|
||||
: self::$defaultColumnWidths[$font->getName()][$font->getSize()]['width'];
|
||||
|
||||
} else {
|
||||
// We don't have data for this particular font and size, use approximation by
|
||||
// extrapolating from Calibri 11
|
||||
$columnWidth = $pPixels ?
|
||||
self::$defaultColumnWidths['Calibri'][11]['px']
|
||||
: self::$defaultColumnWidths['Calibri'][11]['width'];
|
||||
$columnWidth = $columnWidth * $font->getSize() / 11;
|
||||
|
||||
// Round pixels to closest integer
|
||||
if ($pPixels) {
|
||||
$columnWidth = (int) round($columnWidth);
|
||||
}
|
||||
}
|
||||
|
||||
return $columnWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the effective row height for rows without a row dimension or rows with height -1
|
||||
* For example, for Calibri 11 this is 15 points
|
||||
*
|
||||
* @param PHPExcel_Style_Font $font The workbooks default font
|
||||
* @return float Row height in points
|
||||
*/
|
||||
public static function getDefaultRowHeightByFont(PHPExcel_Style_Font $font)
|
||||
{
|
||||
switch ($font->getName()) {
|
||||
case 'Arial':
|
||||
switch ($font->getSize()) {
|
||||
case 10:
|
||||
// inspection of Arial 10 workbook says 12.75pt ~17px
|
||||
$rowHeight = 12.75;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
// inspection of Arial 9 workbook says 12.00pt ~16px
|
||||
$rowHeight = 12;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
// inspection of Arial 8 workbook says 11.25pt ~15px
|
||||
$rowHeight = 11.25;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
// inspection of Arial 7 workbook says 9.00pt ~12px
|
||||
$rowHeight = 9;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
case 5:
|
||||
// inspection of Arial 5,6 workbook says 8.25pt ~11px
|
||||
$rowHeight = 8.25;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// inspection of Arial 4 workbook says 6.75pt ~9px
|
||||
$rowHeight = 6.75;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// inspection of Arial 3 workbook says 6.00pt ~8px
|
||||
$rowHeight = 6;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 1:
|
||||
// inspection of Arial 1,2 workbook says 5.25pt ~7px
|
||||
$rowHeight = 5.25;
|
||||
break;
|
||||
|
||||
default:
|
||||
// use Arial 10 workbook as an approximation, extrapolation
|
||||
$rowHeight = 12.75 * $font->getSize() / 10;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Calibri':
|
||||
switch ($font->getSize()) {
|
||||
case 11:
|
||||
// inspection of Calibri 11 workbook says 15.00pt ~20px
|
||||
$rowHeight = 15;
|
||||
break;
|
||||
|
||||
case 10:
|
||||
// inspection of Calibri 10 workbook says 12.75pt ~17px
|
||||
$rowHeight = 12.75;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
// inspection of Calibri 9 workbook says 12.00pt ~16px
|
||||
$rowHeight = 12;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
// inspection of Calibri 8 workbook says 11.25pt ~15px
|
||||
$rowHeight = 11.25;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
// inspection of Calibri 7 workbook says 9.00pt ~12px
|
||||
$rowHeight = 9;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
case 5:
|
||||
// inspection of Calibri 5,6 workbook says 8.25pt ~11px
|
||||
$rowHeight = 8.25;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// inspection of Calibri 4 workbook says 6.75pt ~9px
|
||||
$rowHeight = 6.75;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// inspection of Calibri 3 workbook says 6.00pt ~8px
|
||||
$rowHeight = 6.00;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 1:
|
||||
// inspection of Calibri 1,2 workbook says 5.25pt ~7px
|
||||
$rowHeight = 5.25;
|
||||
break;
|
||||
|
||||
default:
|
||||
// use Calibri 11 workbook as an approximation, extrapolation
|
||||
$rowHeight = 15 * $font->getSize() / 11;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Verdana':
|
||||
switch ($font->getSize()) {
|
||||
case 10:
|
||||
// inspection of Verdana 10 workbook says 12.75pt ~17px
|
||||
$rowHeight = 12.75;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
// inspection of Verdana 9 workbook says 11.25pt ~15px
|
||||
$rowHeight = 11.25;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
// inspection of Verdana 8 workbook says 10.50pt ~14px
|
||||
$rowHeight = 10.50;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
// inspection of Verdana 7 workbook says 9.00pt ~12px
|
||||
$rowHeight = 9.00;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
case 5:
|
||||
// inspection of Verdana 5,6 workbook says 8.25pt ~11px
|
||||
$rowHeight = 8.25;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// inspection of Verdana 4 workbook says 6.75pt ~9px
|
||||
$rowHeight = 6.75;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// inspection of Verdana 3 workbook says 6.00pt ~8px
|
||||
$rowHeight = 6;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 1:
|
||||
// inspection of Verdana 1,2 workbook says 5.25pt ~7px
|
||||
$rowHeight = 5.25;
|
||||
break;
|
||||
|
||||
default:
|
||||
// use Verdana 10 workbook as an approximation, extrapolation
|
||||
$rowHeight = 12.75 * $font->getSize() / 10;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// just use Calibri as an approximation
|
||||
$rowHeight = 15 * $font->getSize() / 11;
|
||||
break;
|
||||
}
|
||||
|
||||
return $rowHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,133 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JAMA
|
||||
*
|
||||
* Cholesky decomposition class
|
||||
*
|
||||
* For a symmetric, positive definite matrix A, the Cholesky decomposition
|
||||
* is an lower triangular matrix L so that A = L*L'.
|
||||
*
|
||||
* If the matrix is not symmetric or positive definite, the constructor
|
||||
* returns a partial decomposition and sets an internal flag that may
|
||||
* be queried by the isSPD() method.
|
||||
*
|
||||
* @author Paul Meagher
|
||||
* @author Michael Bommarito
|
||||
* @version 1.2
|
||||
*/
|
||||
* @package JAMA
|
||||
*
|
||||
* Cholesky decomposition class
|
||||
*
|
||||
* For a symmetric, positive definite matrix A, the Cholesky decomposition
|
||||
* is an lower triangular matrix L so that A = L*L'.
|
||||
*
|
||||
* If the matrix is not symmetric or positive definite, the constructor
|
||||
* returns a partial decomposition and sets an internal flag that may
|
||||
* be queried by the isSPD() method.
|
||||
*
|
||||
* @author Paul Meagher
|
||||
* @author Michael Bommarito
|
||||
* @version 1.2
|
||||
*/
|
||||
class CholeskyDecomposition {
|
||||
/**
|
||||
* Decomposition storage
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $L = array();
|
||||
|
||||
/**
|
||||
* Matrix row and column dimension
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
var $m;
|
||||
|
||||
/**
|
||||
* Symmetric positive definite flag
|
||||
* @var boolean
|
||||
* @access private
|
||||
*/
|
||||
var $isspd = true;
|
||||
|
||||
/**
|
||||
* CholeskyDecomposition
|
||||
* Class constructor - decomposes symmetric positive definite matrix
|
||||
* @param mixed Matrix square symmetric positive definite matrix
|
||||
*/
|
||||
function CholeskyDecomposition( $A = null ) {
|
||||
if( is_a($A, 'Matrix') ) {
|
||||
$this->L = $A->getArray();
|
||||
$this->m = $A->getRowDimension();
|
||||
|
||||
for( $i = 0; $i < $this->m; $i++ ) {
|
||||
for( $j = $i; $j < $this->m; $j++ ) {
|
||||
for( $sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; $k-- )
|
||||
$sum -= $this->L[$i][$k] * $this->L[$j][$k];
|
||||
|
||||
if( $i == $j ) {
|
||||
if( $sum >= 0 ) {
|
||||
$this->L[$i][$i] = sqrt( $sum );
|
||||
} else {
|
||||
$this->isspd = false;
|
||||
}
|
||||
} else {
|
||||
if( $this->L[$i][$i] != 0 )
|
||||
$this->L[$j][$i] = $sum / $this->L[$i][$i];
|
||||
}
|
||||
}
|
||||
|
||||
for ($k = $i+1; $k < $this->m; $k++)
|
||||
$this->L[$i][$k] = 0.0;
|
||||
}
|
||||
} else {
|
||||
trigger_error(ArgumentTypeException, ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the matrix symmetric and positive definite?
|
||||
* @return boolean
|
||||
*/
|
||||
function isSPD () {
|
||||
return $this->isspd;
|
||||
}
|
||||
|
||||
/**
|
||||
* getL
|
||||
* Return triangular factor.
|
||||
* @return Matrix Lower triangular matrix
|
||||
*/
|
||||
function getL () {
|
||||
return new Matrix($this->L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Solve A*X = B
|
||||
* @param $B Row-equal matrix
|
||||
* @return Matrix L * L' * X = B
|
||||
*/
|
||||
function solve ( $B = null ) {
|
||||
if( is_a($B, 'Matrix') ) {
|
||||
if ($B->getRowDimension() == $this->m) {
|
||||
if ($this->isspd) {
|
||||
$X = $B->getArrayCopy();
|
||||
$nx = $B->getColumnDimension();
|
||||
|
||||
for ($k = 0; $k < $this->m; $k++) {
|
||||
for ($i = $k + 1; $i < $this->m; $i++)
|
||||
for ($j = 0; $j < $nx; $j++)
|
||||
$X[$i][$j] -= $X[$k][$j] * $this->L[$i][$k];
|
||||
|
||||
for ($j = 0; $j < $nx; $j++)
|
||||
$X[$k][$j] /= $this->L[$k][$k];
|
||||
}
|
||||
|
||||
for ($k = $this->m - 1; $k >= 0; $k--) {
|
||||
for ($j = 0; $j < $nx; $j++)
|
||||
$X[$k][$j] /= $this->L[$k][$k];
|
||||
|
||||
for ($i = 0; $i < $k; $i++)
|
||||
for ($j = 0; $j < $nx; $j++)
|
||||
$X[$i][$j] -= $X[$k][$j] * $this->L[$k][$i];
|
||||
}
|
||||
|
||||
return new Matrix($X, $this->m, $nx);
|
||||
} else {
|
||||
trigger_error(MatrixSPDException, ERROR);
|
||||
}
|
||||
} else {
|
||||
trigger_error(MatrixDimensionException, ERROR);
|
||||
}
|
||||
} else {
|
||||
trigger_error(ArgumentTypeException, ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Decomposition storage
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
private $L = array();
|
||||
|
||||
/**
|
||||
* Matrix row and column dimension
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
private $m;
|
||||
|
||||
/**
|
||||
* Symmetric positive definite flag
|
||||
* @var boolean
|
||||
* @access private
|
||||
*/
|
||||
private $isspd = true;
|
||||
|
||||
|
||||
/**
|
||||
* CholeskyDecomposition
|
||||
*
|
||||
* Class constructor - decomposes symmetric positive definite matrix
|
||||
* @param mixed Matrix square symmetric positive definite matrix
|
||||
*/
|
||||
public function __construct($A = null) {
|
||||
if ($A instanceof Matrix) {
|
||||
$this->L = $A->getArray();
|
||||
$this->m = $A->getRowDimension();
|
||||
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = $i; $j < $this->m; ++$j) {
|
||||
for($sum = $this->L[$i][$j], $k = $i - 1; $k >= 0; --$k) {
|
||||
$sum -= $this->L[$i][$k] * $this->L[$j][$k];
|
||||
}
|
||||
if ($i == $j) {
|
||||
if ($sum >= 0) {
|
||||
$this->L[$i][$i] = sqrt($sum);
|
||||
} else {
|
||||
$this->isspd = false;
|
||||
}
|
||||
} else {
|
||||
if ($this->L[$i][$i] != 0) {
|
||||
$this->L[$j][$i] = $sum / $this->L[$i][$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ($k = $i+1; $k < $this->m; ++$k) {
|
||||
$this->L[$i][$k] = 0.0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArgumentTypeException));
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Is the matrix symmetric and positive definite?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSPD() {
|
||||
return $this->isspd;
|
||||
} // function isSPD()
|
||||
|
||||
|
||||
/**
|
||||
* getL
|
||||
*
|
||||
* Return triangular factor.
|
||||
* @return Matrix Lower triangular matrix
|
||||
*/
|
||||
public function getL() {
|
||||
return new Matrix($this->L);
|
||||
} // function getL()
|
||||
|
||||
|
||||
/**
|
||||
* Solve A*X = B
|
||||
*
|
||||
* @param $B Row-equal matrix
|
||||
* @return Matrix L * L' * X = B
|
||||
*/
|
||||
public function solve($B = null) {
|
||||
if ($B instanceof Matrix) {
|
||||
if ($B->getRowDimension() == $this->m) {
|
||||
if ($this->isspd) {
|
||||
$X = $B->getArrayCopy();
|
||||
$nx = $B->getColumnDimension();
|
||||
|
||||
for ($k = 0; $k < $this->m; ++$k) {
|
||||
for ($i = $k + 1; $i < $this->m; ++$i) {
|
||||
for ($j = 0; $j < $nx; ++$j) {
|
||||
$X[$i][$j] -= $X[$k][$j] * $this->L[$i][$k];
|
||||
}
|
||||
}
|
||||
for ($j = 0; $j < $nx; ++$j) {
|
||||
$X[$k][$j] /= $this->L[$k][$k];
|
||||
}
|
||||
}
|
||||
|
||||
for ($k = $this->m - 1; $k >= 0; --$k) {
|
||||
for ($j = 0; $j < $nx; ++$j) {
|
||||
$X[$k][$j] /= $this->L[$k][$k];
|
||||
}
|
||||
for ($i = 0; $i < $k; ++$i) {
|
||||
for ($j = 0; $j < $nx; ++$j) {
|
||||
$X[$i][$j] -= $X[$k][$j] * $this->L[$k][$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Matrix($X, $this->m, $nx);
|
||||
} else {
|
||||
throw new Exception(JAMAError(MatrixSPDException));
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(MatrixDimensionException));
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArgumentTypeException));
|
||||
}
|
||||
} // function solve()
|
||||
|
||||
} // class CholeskyDecomposition
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,222 +1,255 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JAMA
|
||||
*
|
||||
* For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n
|
||||
* unit lower triangular matrix L, an n-by-n upper triangular matrix U,
|
||||
* and a permutation vector piv of length m so that A(piv,:) = L*U.
|
||||
* If m < n, then L is m-by-m and U is m-by-n.
|
||||
*
|
||||
* The LU decompostion with pivoting always exists, even if the matrix is
|
||||
* singular, so the constructor will never fail. The primary use of the
|
||||
* LU decomposition is in the solution of square systems of simultaneous
|
||||
* linear equations. This will fail if isNonsingular() returns false.
|
||||
*
|
||||
* @author Paul Meagher
|
||||
* @author Bartosz Matosiuk
|
||||
* @author Michael Bommarito
|
||||
* @version 1.1
|
||||
* @license PHP v3.0
|
||||
*/
|
||||
* @package JAMA
|
||||
*
|
||||
* For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n
|
||||
* unit lower triangular matrix L, an n-by-n upper triangular matrix U,
|
||||
* and a permutation vector piv of length m so that A(piv,:) = L*U.
|
||||
* If m < n, then L is m-by-m and U is m-by-n.
|
||||
*
|
||||
* The LU decompostion with pivoting always exists, even if the matrix is
|
||||
* singular, so the constructor will never fail. The primary use of the
|
||||
* LU decomposition is in the solution of square systems of simultaneous
|
||||
* linear equations. This will fail if isNonsingular() returns false.
|
||||
*
|
||||
* @author Paul Meagher
|
||||
* @author Bartosz Matosiuk
|
||||
* @author Michael Bommarito
|
||||
* @version 1.1
|
||||
* @license PHP v3.0
|
||||
*/
|
||||
class LUDecomposition {
|
||||
/**
|
||||
* Decomposition storage
|
||||
* @var array
|
||||
*/
|
||||
var $LU = array();
|
||||
|
||||
/**
|
||||
* Row dimension.
|
||||
* @var int
|
||||
*/
|
||||
var $m;
|
||||
|
||||
/**
|
||||
* Column dimension.
|
||||
* @var int
|
||||
*/
|
||||
var $n;
|
||||
|
||||
/**
|
||||
* Pivot sign.
|
||||
* @var int
|
||||
*/
|
||||
var $pivsign;
|
||||
/**
|
||||
* Decomposition storage
|
||||
* @var array
|
||||
*/
|
||||
private $LU = array();
|
||||
|
||||
/**
|
||||
* Internal storage of pivot vector.
|
||||
* @var array
|
||||
*/
|
||||
var $piv = array();
|
||||
|
||||
/**
|
||||
* LU Decomposition constructor.
|
||||
* @param $A Rectangular matrix
|
||||
* @return Structure to access L, U and piv.
|
||||
*/
|
||||
function LUDecomposition ($A) {
|
||||
if( is_a($A, 'Matrix') ) {
|
||||
// Use a "left-looking", dot-product, Crout/Doolittle algorithm.
|
||||
$this->LU = $A->getArrayCopy();
|
||||
$this->m = $A->getRowDimension();
|
||||
$this->n = $A->getColumnDimension();
|
||||
for ($i = 0; $i < $this->m; $i++)
|
||||
$this->piv[$i] = $i;
|
||||
$this->pivsign = 1;
|
||||
$LUrowi = array();
|
||||
$LUcolj = array();
|
||||
// Outer loop.
|
||||
for ($j = 0; $j < $this->n; $j++) {
|
||||
// Make a copy of the j-th column to localize references.
|
||||
for ($i = 0; $i < $this->m; $i++)
|
||||
$LUcolj[$i] = &$this->LU[$i][$j];
|
||||
// Apply previous transformations.
|
||||
for ($i = 0; $i < $this->m; $i++) {
|
||||
$LUrowi = $this->LU[$i];
|
||||
// Most of the time is spent in the following dot product.
|
||||
$kmax = min($i,$j);
|
||||
$s = 0.0;
|
||||
for ($k = 0; $k < $kmax; $k++)
|
||||
$s += $LUrowi[$k]*$LUcolj[$k];
|
||||
$LUrowi[$j] = $LUcolj[$i] -= $s;
|
||||
}
|
||||
// Find pivot and exchange if necessary.
|
||||
$p = $j;
|
||||
for ($i = $j+1; $i < $this->m; $i++) {
|
||||
if (abs($LUcolj[$i]) > abs($LUcolj[$p]))
|
||||
$p = $i;
|
||||
}
|
||||
if ($p != $j) {
|
||||
for ($k = 0; $k < $this->n; $k++) {
|
||||
$t = $this->LU[$p][$k];
|
||||
$this->LU[$p][$k] = $this->LU[$j][$k];
|
||||
$this->LU[$j][$k] = $t;
|
||||
}
|
||||
$k = $this->piv[$p];
|
||||
$this->piv[$p] = $this->piv[$j];
|
||||
$this->piv[$j] = $k;
|
||||
$this->pivsign = $this->pivsign * -1;
|
||||
}
|
||||
// Compute multipliers.
|
||||
if ( ($j < $this->m) AND ($this->LU[$j][$j] != 0.0) ) {
|
||||
for ($i = $j+1; $i < $this->m; $i++)
|
||||
$this->LU[$i][$j] /= $this->LU[$j][$j];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
trigger_error(ArgumentTypeException, ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lower triangular factor.
|
||||
* @return array Lower triangular factor
|
||||
*/
|
||||
function getL () {
|
||||
for ($i = 0; $i < $this->m; $i++) {
|
||||
for ($j = 0; $j < $this->n; $j++) {
|
||||
if ($i > $j)
|
||||
$L[$i][$j] = $this->LU[$i][$j];
|
||||
else if($i == $j)
|
||||
$L[$i][$j] = 1.0;
|
||||
else
|
||||
$L[$i][$j] = 0.0;
|
||||
}
|
||||
}
|
||||
return new Matrix($L);
|
||||
}
|
||||
/**
|
||||
* Row dimension.
|
||||
* @var int
|
||||
*/
|
||||
private $m;
|
||||
|
||||
/**
|
||||
* Get upper triangular factor.
|
||||
* @return array Upper triangular factor
|
||||
*/
|
||||
function getU () {
|
||||
for ($i = 0; $i < $this->n; $i++) {
|
||||
for ($j = 0; $j < $this->n; $j++) {
|
||||
if ($i <= $j)
|
||||
$U[$i][$j] = $this->LU[$i][$j];
|
||||
else
|
||||
$U[$i][$j] = 0.0;
|
||||
}
|
||||
}
|
||||
return new Matrix($U);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return pivot permutation vector.
|
||||
* @return array Pivot vector
|
||||
*/
|
||||
function getPivot () {
|
||||
return $this->piv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for getPivot
|
||||
* @see getPivot
|
||||
*/
|
||||
function getDoublePivot () {
|
||||
return $this->getPivot();
|
||||
}
|
||||
/**
|
||||
* Column dimension.
|
||||
* @var int
|
||||
*/
|
||||
private $n;
|
||||
|
||||
/**
|
||||
* Is the matrix nonsingular?
|
||||
* @return true if U, and hence A, is nonsingular.
|
||||
*/
|
||||
function isNonsingular () {
|
||||
for ($j = 0; $j < $this->n; $j++) {
|
||||
if ($this->LU[$j][$j] == 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Pivot sign.
|
||||
* @var int
|
||||
*/
|
||||
private $pivsign;
|
||||
|
||||
/**
|
||||
* Count determinants
|
||||
* @return array d matrix deterninat
|
||||
*/
|
||||
function det() {
|
||||
if ($this->m == $this->n) {
|
||||
$d = $this->pivsign;
|
||||
for ($j = 0; $j < $this->n; $j++)
|
||||
$d *= $this->LU[$j][$j];
|
||||
return $d;
|
||||
} else {
|
||||
trigger_error(MatrixDimensionException, ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Solve A*X = B
|
||||
* @param $B A Matrix with as many rows as A and any number of columns.
|
||||
* @return X so that L*U*X = B(piv,:)
|
||||
* @exception IllegalArgumentException Matrix row dimensions must agree.
|
||||
* @exception RuntimeException Matrix is singular.
|
||||
*/
|
||||
function solve($B) {
|
||||
if ($B->getRowDimension() == $this->m) {
|
||||
if ($this->isNonsingular()) {
|
||||
// Copy right hand side with pivoting
|
||||
$nx = $B->getColumnDimension();
|
||||
$X = $B->getMatrix($this->piv, 0, $nx-1);
|
||||
// Solve L*Y = B(piv,:)
|
||||
for ($k = 0; $k < $this->n; $k++)
|
||||
for ($i = $k+1; $i < $this->n; $i++)
|
||||
for ($j = 0; $j < $nx; $j++)
|
||||
$X->A[$i][$j] -= $X->A[$k][$j] * $this->LU[$i][$k];
|
||||
// Solve U*X = Y;
|
||||
for ($k = $this->n-1; $k >= 0; $k--) {
|
||||
for ($j = 0; $j < $nx; $j++)
|
||||
$X->A[$k][$j] /= $this->LU[$k][$k];
|
||||
for ($i = 0; $i < $k; $i++)
|
||||
for ($j = 0; $j < $nx; $j++)
|
||||
$X->A[$i][$j] -= $X->A[$k][$j] * $this->LU[$i][$k];
|
||||
}
|
||||
return $X;
|
||||
} else {
|
||||
trigger_error(MatrixSingularException, ERROR);
|
||||
}
|
||||
} else {
|
||||
trigger_error(MatrixSquareException, ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Internal storage of pivot vector.
|
||||
* @var array
|
||||
*/
|
||||
private $piv = array();
|
||||
|
||||
|
||||
/**
|
||||
* LU Decomposition constructor.
|
||||
*
|
||||
* @param $A Rectangular matrix
|
||||
* @return Structure to access L, U and piv.
|
||||
*/
|
||||
public function __construct($A) {
|
||||
if ($A instanceof Matrix) {
|
||||
// Use a "left-looking", dot-product, Crout/Doolittle algorithm.
|
||||
$this->LU = $A->getArrayCopy();
|
||||
$this->m = $A->getRowDimension();
|
||||
$this->n = $A->getColumnDimension();
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
$this->piv[$i] = $i;
|
||||
}
|
||||
$this->pivsign = 1;
|
||||
$LUrowi = $LUcolj = array();
|
||||
|
||||
// Outer loop.
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
// Make a copy of the j-th column to localize references.
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
$LUcolj[$i] = &$this->LU[$i][$j];
|
||||
}
|
||||
// Apply previous transformations.
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
$LUrowi = $this->LU[$i];
|
||||
// Most of the time is spent in the following dot product.
|
||||
$kmax = min($i,$j);
|
||||
$s = 0.0;
|
||||
for ($k = 0; $k < $kmax; ++$k) {
|
||||
$s += $LUrowi[$k] * $LUcolj[$k];
|
||||
}
|
||||
$LUrowi[$j] = $LUcolj[$i] -= $s;
|
||||
}
|
||||
// Find pivot and exchange if necessary.
|
||||
$p = $j;
|
||||
for ($i = $j+1; $i < $this->m; ++$i) {
|
||||
if (abs($LUcolj[$i]) > abs($LUcolj[$p])) {
|
||||
$p = $i;
|
||||
}
|
||||
}
|
||||
if ($p != $j) {
|
||||
for ($k = 0; $k < $this->n; ++$k) {
|
||||
$t = $this->LU[$p][$k];
|
||||
$this->LU[$p][$k] = $this->LU[$j][$k];
|
||||
$this->LU[$j][$k] = $t;
|
||||
}
|
||||
$k = $this->piv[$p];
|
||||
$this->piv[$p] = $this->piv[$j];
|
||||
$this->piv[$j] = $k;
|
||||
$this->pivsign = $this->pivsign * -1;
|
||||
}
|
||||
// Compute multipliers.
|
||||
if (($j < $this->m) && ($this->LU[$j][$j] != 0.0)) {
|
||||
for ($i = $j+1; $i < $this->m; ++$i) {
|
||||
$this->LU[$i][$j] /= $this->LU[$j][$j];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArgumentTypeException));
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
|
||||
/**
|
||||
* Get lower triangular factor.
|
||||
*
|
||||
* @return array Lower triangular factor
|
||||
*/
|
||||
public function getL() {
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($i > $j) {
|
||||
$L[$i][$j] = $this->LU[$i][$j];
|
||||
} elseif ($i == $j) {
|
||||
$L[$i][$j] = 1.0;
|
||||
} else {
|
||||
$L[$i][$j] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Matrix($L);
|
||||
} // function getL()
|
||||
|
||||
|
||||
/**
|
||||
* Get upper triangular factor.
|
||||
*
|
||||
* @return array Upper triangular factor
|
||||
*/
|
||||
public function getU() {
|
||||
for ($i = 0; $i < $this->n; ++$i) {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($i <= $j) {
|
||||
$U[$i][$j] = $this->LU[$i][$j];
|
||||
} else {
|
||||
$U[$i][$j] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Matrix($U);
|
||||
} // function getU()
|
||||
|
||||
|
||||
/**
|
||||
* Return pivot permutation vector.
|
||||
*
|
||||
* @return array Pivot vector
|
||||
*/
|
||||
public function getPivot() {
|
||||
return $this->piv;
|
||||
} // function getPivot()
|
||||
|
||||
|
||||
/**
|
||||
* Alias for getPivot
|
||||
*
|
||||
* @see getPivot
|
||||
*/
|
||||
public function getDoublePivot() {
|
||||
return $this->getPivot();
|
||||
} // function getDoublePivot()
|
||||
|
||||
|
||||
/**
|
||||
* Is the matrix nonsingular?
|
||||
*
|
||||
* @return true if U, and hence A, is nonsingular.
|
||||
*/
|
||||
public function isNonsingular() {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($this->LU[$j][$j] == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} // function isNonsingular()
|
||||
|
||||
|
||||
/**
|
||||
* Count determinants
|
||||
*
|
||||
* @return array d matrix deterninat
|
||||
*/
|
||||
public function det() {
|
||||
if ($this->m == $this->n) {
|
||||
$d = $this->pivsign;
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
$d *= $this->LU[$j][$j];
|
||||
}
|
||||
return $d;
|
||||
} else {
|
||||
throw new Exception(JAMAError(MatrixDimensionException));
|
||||
}
|
||||
} // function det()
|
||||
|
||||
|
||||
/**
|
||||
* Solve A*X = B
|
||||
*
|
||||
* @param $B A Matrix with as many rows as A and any number of columns.
|
||||
* @return X so that L*U*X = B(piv,:)
|
||||
* @exception IllegalArgumentException Matrix row dimensions must agree.
|
||||
* @exception RuntimeException Matrix is singular.
|
||||
*/
|
||||
public function solve($B) {
|
||||
if ($B->getRowDimension() == $this->m) {
|
||||
if ($this->isNonsingular()) {
|
||||
// Copy right hand side with pivoting
|
||||
$nx = $B->getColumnDimension();
|
||||
$X = $B->getMatrix($this->piv, 0, $nx-1);
|
||||
// Solve L*Y = B(piv,:)
|
||||
for ($k = 0; $k < $this->n; ++$k) {
|
||||
for ($i = $k+1; $i < $this->n; ++$i) {
|
||||
for ($j = 0; $j < $nx; ++$j) {
|
||||
$X->A[$i][$j] -= $X->A[$k][$j] * $this->LU[$i][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Solve U*X = Y;
|
||||
for ($k = $this->n-1; $k >= 0; --$k) {
|
||||
for ($j = 0; $j < $nx; ++$j) {
|
||||
$X->A[$k][$j] /= $this->LU[$k][$k];
|
||||
}
|
||||
for ($i = 0; $i < $k; ++$i) {
|
||||
for ($j = 0; $j < $nx; ++$j) {
|
||||
$X->A[$i][$j] -= $X->A[$k][$j] * $this->LU[$i][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $X;
|
||||
} else {
|
||||
throw new Exception(JAMAError(MatrixSingularException));
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(MatrixSquareException));
|
||||
}
|
||||
} // function solve()
|
||||
|
||||
} // class LUDecomposition
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,195 +1,232 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JAMA
|
||||
*
|
||||
* For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n
|
||||
* orthogonal matrix Q and an n-by-n upper triangular matrix R so that
|
||||
* A = Q*R.
|
||||
*
|
||||
* The QR decompostion always exists, even if the matrix does not have
|
||||
* full rank, so the constructor will never fail. The primary use of the
|
||||
* QR decomposition is in the least squares solution of nonsquare systems
|
||||
* of simultaneous linear equations. This will fail if isFullRank()
|
||||
* returns false.
|
||||
*
|
||||
* @author Paul Meagher
|
||||
* @license PHP v3.0
|
||||
* @version 1.1
|
||||
*/
|
||||
/**
|
||||
* @package JAMA
|
||||
*
|
||||
* For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n
|
||||
* orthogonal matrix Q and an n-by-n upper triangular matrix R so that
|
||||
* A = Q*R.
|
||||
*
|
||||
* The QR decompostion always exists, even if the matrix does not have
|
||||
* full rank, so the constructor will never fail. The primary use of the
|
||||
* QR decomposition is in the least squares solution of nonsquare systems
|
||||
* of simultaneous linear equations. This will fail if isFullRank()
|
||||
* returns false.
|
||||
*
|
||||
* @author Paul Meagher
|
||||
* @license PHP v3.0
|
||||
* @version 1.1
|
||||
*/
|
||||
class QRDecomposition {
|
||||
/**
|
||||
* Array for internal storage of decomposition.
|
||||
* @var array
|
||||
*/
|
||||
var $QR = array();
|
||||
|
||||
/**
|
||||
* Row dimension.
|
||||
* @var integer
|
||||
*/
|
||||
var $m;
|
||||
/**
|
||||
* Array for internal storage of decomposition.
|
||||
* @var array
|
||||
*/
|
||||
private $QR = array();
|
||||
|
||||
/**
|
||||
* Column dimension.
|
||||
* @var integer
|
||||
*/
|
||||
var $n;
|
||||
/**
|
||||
* Row dimension.
|
||||
* @var integer
|
||||
*/
|
||||
private $m;
|
||||
|
||||
/**
|
||||
* Array for internal storage of diagonal of R.
|
||||
* @var array
|
||||
*/
|
||||
var $Rdiag = array();
|
||||
/**
|
||||
* Column dimension.
|
||||
* @var integer
|
||||
*/
|
||||
private $n;
|
||||
|
||||
/**
|
||||
* QR Decomposition computed by Householder reflections.
|
||||
* @param matrix $A Rectangular matrix
|
||||
* @return Structure to access R and the Householder vectors and compute Q.
|
||||
*/
|
||||
function QRDecomposition($A) {
|
||||
if( is_a($A, 'Matrix') ) {
|
||||
// Initialize.
|
||||
$this->QR = $A->getArrayCopy();
|
||||
$this->m = $A->getRowDimension();
|
||||
$this->n = $A->getColumnDimension();
|
||||
// Main loop.
|
||||
for ($k = 0; $k < $this->n; $k++) {
|
||||
// Compute 2-norm of k-th column without under/overflow.
|
||||
$nrm = 0.0;
|
||||
for ($i = $k; $i < $this->m; $i++)
|
||||
$nrm = hypo($nrm, $this->QR[$i][$k]);
|
||||
if ($nrm != 0.0) {
|
||||
// Form k-th Householder vector.
|
||||
if ($this->QR[$k][$k] < 0)
|
||||
$nrm = -$nrm;
|
||||
for ($i = $k; $i < $this->m; $i++)
|
||||
$this->QR[$i][$k] /= $nrm;
|
||||
$this->QR[$k][$k] += 1.0;
|
||||
// Apply transformation to remaining columns.
|
||||
for ($j = $k+1; $j < $this->n; $j++) {
|
||||
$s = 0.0;
|
||||
for ($i = $k; $i < $this->m; $i++)
|
||||
$s += $this->QR[$i][$k] * $this->QR[$i][$j];
|
||||
$s = -$s/$this->QR[$k][$k];
|
||||
for ($i = $k; $i < $this->m; $i++)
|
||||
$this->QR[$i][$j] += $s * $this->QR[$i][$k];
|
||||
}
|
||||
}
|
||||
$this->Rdiag[$k] = -$nrm;
|
||||
}
|
||||
} else
|
||||
trigger_error(ArgumentTypeException, ERROR);
|
||||
}
|
||||
/**
|
||||
* Array for internal storage of diagonal of R.
|
||||
* @var array
|
||||
*/
|
||||
private $Rdiag = array();
|
||||
|
||||
/**
|
||||
* Is the matrix full rank?
|
||||
* @return boolean true if R, and hence A, has full rank, else false.
|
||||
*/
|
||||
function isFullRank() {
|
||||
for ($j = 0; $j < $this->n; $j++)
|
||||
if ($this->Rdiag[$j] == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Householder vectors
|
||||
* @return Matrix Lower trapezoidal matrix whose columns define the reflections
|
||||
*/
|
||||
function getH() {
|
||||
for ($i = 0; $i < $this->m; $i++) {
|
||||
for ($j = 0; $j < $this->n; $j++) {
|
||||
if ($i >= $j)
|
||||
$H[$i][$j] = $this->QR[$i][$j];
|
||||
else
|
||||
$H[$i][$j] = 0.0;
|
||||
}
|
||||
}
|
||||
return new Matrix($H);
|
||||
}
|
||||
/**
|
||||
* QR Decomposition computed by Householder reflections.
|
||||
*
|
||||
* @param matrix $A Rectangular matrix
|
||||
* @return Structure to access R and the Householder vectors and compute Q.
|
||||
*/
|
||||
public function __construct($A) {
|
||||
if($A instanceof Matrix) {
|
||||
// Initialize.
|
||||
$this->QR = $A->getArrayCopy();
|
||||
$this->m = $A->getRowDimension();
|
||||
$this->n = $A->getColumnDimension();
|
||||
// Main loop.
|
||||
for ($k = 0; $k < $this->n; ++$k) {
|
||||
// Compute 2-norm of k-th column without under/overflow.
|
||||
$nrm = 0.0;
|
||||
for ($i = $k; $i < $this->m; ++$i) {
|
||||
$nrm = hypo($nrm, $this->QR[$i][$k]);
|
||||
}
|
||||
if ($nrm != 0.0) {
|
||||
// Form k-th Householder vector.
|
||||
if ($this->QR[$k][$k] < 0) {
|
||||
$nrm = -$nrm;
|
||||
}
|
||||
for ($i = $k; $i < $this->m; ++$i) {
|
||||
$this->QR[$i][$k] /= $nrm;
|
||||
}
|
||||
$this->QR[$k][$k] += 1.0;
|
||||
// Apply transformation to remaining columns.
|
||||
for ($j = $k+1; $j < $this->n; ++$j) {
|
||||
$s = 0.0;
|
||||
for ($i = $k; $i < $this->m; ++$i) {
|
||||
$s += $this->QR[$i][$k] * $this->QR[$i][$j];
|
||||
}
|
||||
$s = -$s/$this->QR[$k][$k];
|
||||
for ($i = $k; $i < $this->m; ++$i) {
|
||||
$this->QR[$i][$j] += $s * $this->QR[$i][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->Rdiag[$k] = -$nrm;
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArgumentTypeException));
|
||||
}
|
||||
} // function __construct()
|
||||
|
||||
/**
|
||||
* Return the upper triangular factor
|
||||
* @return Matrix upper triangular factor
|
||||
*/
|
||||
function getR() {
|
||||
for ($i = 0; $i < $this->n; $i++) {
|
||||
for ($j = 0; $j < $this->n; $j++) {
|
||||
if ($i < $j)
|
||||
$R[$i][$j] = $this->QR[$i][$j];
|
||||
else if ($i == $j)
|
||||
$R[$i][$j] = $this->Rdiag[$i];
|
||||
else
|
||||
$R[$i][$j] = 0.0;
|
||||
}
|
||||
}
|
||||
return new Matrix($R);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and return the (economy-sized) orthogonal factor
|
||||
* @return Matrix orthogonal factor
|
||||
*/
|
||||
function getQ() {
|
||||
for ($k = $this->n-1; $k >= 0; $k--) {
|
||||
for ($i = 0; $i < $this->m; $i++)
|
||||
$Q[$i][$k] = 0.0;
|
||||
$Q[$k][$k] = 1.0;
|
||||
for ($j = $k; $j < $this->n; $j++) {
|
||||
if ($this->QR[$k][$k] != 0) {
|
||||
$s = 0.0;
|
||||
for ($i = $k; $i < $this->m; $i++)
|
||||
$s += $this->QR[$i][$k] * $Q[$i][$j];
|
||||
$s = -$s/$this->QR[$k][$k];
|
||||
for ($i = $k; $i < $this->m; $i++)
|
||||
$Q[$i][$j] += $s * $this->QR[$i][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
for( $i = 0; $i < count($Q); $i++ )
|
||||
for( $j = 0; $j < count($Q); $j++ )
|
||||
if(! isset($Q[$i][$j]) )
|
||||
$Q[$i][$j] = 0;
|
||||
*/
|
||||
return new Matrix($Q);
|
||||
}
|
||||
|
||||
/**
|
||||
* Least squares solution of A*X = B
|
||||
* @param Matrix $B A Matrix with as many rows as A and any number of columns.
|
||||
* @return Matrix Matrix that minimizes the two norm of Q*R*X-B.
|
||||
*/
|
||||
function solve($B) {
|
||||
if ($B->getRowDimension() == $this->m) {
|
||||
if ($this->isFullRank()) {
|
||||
// Copy right hand side
|
||||
$nx = $B->getColumnDimension();
|
||||
$X = $B->getArrayCopy();
|
||||
// Compute Y = transpose(Q)*B
|
||||
for ($k = 0; $k < $this->n; $k++) {
|
||||
for ($j = 0; $j < $nx; $j++) {
|
||||
$s = 0.0;
|
||||
for ($i = $k; $i < $this->m; $i++)
|
||||
$s += $this->QR[$i][$k] * $X[$i][$j];
|
||||
$s = -$s/$this->QR[$k][$k];
|
||||
for ($i = $k; $i < $this->m; $i++)
|
||||
$X[$i][$j] += $s * $this->QR[$i][$k];
|
||||
}
|
||||
}
|
||||
// Solve R*X = Y;
|
||||
for ($k = $this->n-1; $k >= 0; $k--) {
|
||||
for ($j = 0; $j < $nx; $j++)
|
||||
$X[$k][$j] /= $this->Rdiag[$k];
|
||||
for ($i = 0; $i < $k; $i++)
|
||||
for ($j = 0; $j < $nx; $j++)
|
||||
$X[$i][$j] -= $X[$k][$j]* $this->QR[$i][$k];
|
||||
}
|
||||
$X = new Matrix($X);
|
||||
return ($X->getMatrix(0, $this->n-1, 0, $nx));
|
||||
} else
|
||||
trigger_error(MatrixRankException, ERROR);
|
||||
} else
|
||||
trigger_error(MatrixDimensionException, ERROR);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Is the matrix full rank?
|
||||
*
|
||||
* @return boolean true if R, and hence A, has full rank, else false.
|
||||
*/
|
||||
public function isFullRank() {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($this->Rdiag[$j] == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} // function isFullRank()
|
||||
|
||||
|
||||
/**
|
||||
* Return the Householder vectors
|
||||
*
|
||||
* @return Matrix Lower trapezoidal matrix whose columns define the reflections
|
||||
*/
|
||||
public function getH() {
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($i >= $j) {
|
||||
$H[$i][$j] = $this->QR[$i][$j];
|
||||
} else {
|
||||
$H[$i][$j] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Matrix($H);
|
||||
} // function getH()
|
||||
|
||||
|
||||
/**
|
||||
* Return the upper triangular factor
|
||||
*
|
||||
* @return Matrix upper triangular factor
|
||||
*/
|
||||
public function getR() {
|
||||
for ($i = 0; $i < $this->n; ++$i) {
|
||||
for ($j = 0; $j < $this->n; ++$j) {
|
||||
if ($i < $j) {
|
||||
$R[$i][$j] = $this->QR[$i][$j];
|
||||
} elseif ($i == $j) {
|
||||
$R[$i][$j] = $this->Rdiag[$i];
|
||||
} else {
|
||||
$R[$i][$j] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Matrix($R);
|
||||
} // function getR()
|
||||
|
||||
|
||||
/**
|
||||
* Generate and return the (economy-sized) orthogonal factor
|
||||
*
|
||||
* @return Matrix orthogonal factor
|
||||
*/
|
||||
public function getQ() {
|
||||
for ($k = $this->n-1; $k >= 0; --$k) {
|
||||
for ($i = 0; $i < $this->m; ++$i) {
|
||||
$Q[$i][$k] = 0.0;
|
||||
}
|
||||
$Q[$k][$k] = 1.0;
|
||||
for ($j = $k; $j < $this->n; ++$j) {
|
||||
if ($this->QR[$k][$k] != 0) {
|
||||
$s = 0.0;
|
||||
for ($i = $k; $i < $this->m; ++$i) {
|
||||
$s += $this->QR[$i][$k] * $Q[$i][$j];
|
||||
}
|
||||
$s = -$s/$this->QR[$k][$k];
|
||||
for ($i = $k; $i < $this->m; ++$i) {
|
||||
$Q[$i][$j] += $s * $this->QR[$i][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
for($i = 0; $i < count($Q); ++$i) {
|
||||
for($j = 0; $j < count($Q); ++$j) {
|
||||
if(! isset($Q[$i][$j]) ) {
|
||||
$Q[$i][$j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return new Matrix($Q);
|
||||
} // function getQ()
|
||||
|
||||
|
||||
/**
|
||||
* Least squares solution of A*X = B
|
||||
*
|
||||
* @param Matrix $B A Matrix with as many rows as A and any number of columns.
|
||||
* @return Matrix Matrix that minimizes the two norm of Q*R*X-B.
|
||||
*/
|
||||
public function solve($B) {
|
||||
if ($B->getRowDimension() == $this->m) {
|
||||
if ($this->isFullRank()) {
|
||||
// Copy right hand side
|
||||
$nx = $B->getColumnDimension();
|
||||
$X = $B->getArrayCopy();
|
||||
// Compute Y = transpose(Q)*B
|
||||
for ($k = 0; $k < $this->n; ++$k) {
|
||||
for ($j = 0; $j < $nx; ++$j) {
|
||||
$s = 0.0;
|
||||
for ($i = $k; $i < $this->m; ++$i) {
|
||||
$s += $this->QR[$i][$k] * $X[$i][$j];
|
||||
}
|
||||
$s = -$s/$this->QR[$k][$k];
|
||||
for ($i = $k; $i < $this->m; ++$i) {
|
||||
$X[$i][$j] += $s * $this->QR[$i][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Solve R*X = Y;
|
||||
for ($k = $this->n-1; $k >= 0; --$k) {
|
||||
for ($j = 0; $j < $nx; ++$j) {
|
||||
$X[$k][$j] /= $this->Rdiag[$k];
|
||||
}
|
||||
for ($i = 0; $i < $k; ++$i) {
|
||||
for ($j = 0; $j < $nx; ++$j) {
|
||||
$X[$i][$j] -= $X[$k][$j]* $this->QR[$i][$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
$X = new Matrix($X);
|
||||
return ($X->getMatrix(0, $this->n-1, 0, $nx));
|
||||
} else {
|
||||
throw new Exception(JAMAError(MatrixRankException));
|
||||
}
|
||||
} else {
|
||||
throw new Exception(JAMAError(MatrixDimensionException));
|
||||
}
|
||||
} // function solve()
|
||||
|
||||
} // class QRDecomposition
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,120 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JAMA
|
||||
*
|
||||
* Error handling
|
||||
* @author Michael Bommarito
|
||||
* @version 01292005
|
||||
*/
|
||||
* @package JAMA
|
||||
*
|
||||
* Error handling
|
||||
* @author Michael Bommarito
|
||||
* @version 01292005
|
||||
*/
|
||||
|
||||
//Language constant
|
||||
define('LANG', 'EN');
|
||||
define('JAMALANG', 'EN');
|
||||
|
||||
|
||||
//Error type constants
|
||||
define('ERROR', E_USER_ERROR);
|
||||
define('WARNING', E_USER_WARNING);
|
||||
define('NOTICE', E_USER_NOTICE);
|
||||
|
||||
//All errors may be defined by the following format:
|
||||
//define('ExceptionName', N);
|
||||
//$error['lang'][N] = 'Error message';
|
||||
//$error['lang'][ExceptionName] = 'Error message';
|
||||
$error = array();
|
||||
|
||||
/*
|
||||
I've used Babelfish and a little poor knowledge of Romance/Germanic languages for the translations
|
||||
here. Feel free to correct anything that looks amiss to you.
|
||||
I've used Babelfish and a little poor knowledge of Romance/Germanic languages for the translations here.
|
||||
Feel free to correct anything that looks amiss to you.
|
||||
*/
|
||||
|
||||
define('PolymorphicArgumentException', -1);
|
||||
$error['EN'][-1] = "Invalid argument pattern for polymorphic function.";
|
||||
$error['FR'][-1] = "Modèle inadmissible d'argument pour la fonction polymorphe.".
|
||||
$error['DE'][-1] = "Unzulässiges Argumentmuster für polymorphe Funktion.";
|
||||
$error['EN'][PolymorphicArgumentException] = "Invalid argument pattern for polymorphic function.";
|
||||
$error['FR'][PolymorphicArgumentException] = "Modèle inadmissible d'argument pour la fonction polymorphe.".
|
||||
$error['DE'][PolymorphicArgumentException] = "Unzulässiges Argumentmuster für polymorphe Funktion.";
|
||||
|
||||
define('ArgumentTypeException', -2);
|
||||
$error['EN'][-2] = "Invalid argument type.";
|
||||
$error['FR'][-2] = "Type inadmissible d'argument.";
|
||||
$error['DE'][-2] = "Unzulässige Argumentart.";
|
||||
$error['EN'][ArgumentTypeException] = "Invalid argument type.";
|
||||
$error['FR'][ArgumentTypeException] = "Type inadmissible d'argument.";
|
||||
$error['DE'][ArgumentTypeException] = "Unzulässige Argumentart.";
|
||||
|
||||
define('ArgumentBoundsException', -3);
|
||||
$error['EN'][-3] = "Invalid argument range.";
|
||||
$error['FR'][-3] = "Gamme inadmissible d'argument.";
|
||||
$error['DE'][-3] = "Unzulässige Argumentstrecke.";
|
||||
$error['EN'][ArgumentBoundsException] = "Invalid argument range.";
|
||||
$error['FR'][ArgumentBoundsException] = "Gamme inadmissible d'argument.";
|
||||
$error['DE'][ArgumentBoundsException] = "Unzulässige Argumentstrecke.";
|
||||
|
||||
define('MatrixDimensionException', -4);
|
||||
$error['EN'][-4] = "Matrix dimensions are not equal.";
|
||||
$error['FR'][-4] = "Les dimensions de Matrix ne sont pas égales.";
|
||||
$error['DE'][-4] = "Matrixmaße sind nicht gleich.";
|
||||
$error['EN'][MatrixDimensionException] = "Matrix dimensions are not equal.";
|
||||
$error['FR'][MatrixDimensionException] = "Les dimensions de Matrix ne sont pas égales.";
|
||||
$error['DE'][MatrixDimensionException] = "Matrixmaße sind nicht gleich.";
|
||||
|
||||
define('PrecisionLossException', -5);
|
||||
$error['EN'][-5] = "Significant precision loss detected.";
|
||||
$error['FR'][-5] = "Perte significative de précision détectée.";
|
||||
$error['DE'][-5] = "Bedeutender Präzision Verlust ermittelte.";
|
||||
$error['EN'][PrecisionLossException] = "Significant precision loss detected.";
|
||||
$error['FR'][PrecisionLossException] = "Perte significative de précision détectée.";
|
||||
$error['DE'][PrecisionLossException] = "Bedeutender Präzision Verlust ermittelte.";
|
||||
|
||||
define('MatrixSPDException', -6);
|
||||
$error['EN'][-6] = "Can only perform operation on symmetric positive definite matrix.";
|
||||
$error['FR'][-6] = "Perte significative de précision détectée.";
|
||||
$error['DE'][-6] = "Bedeutender Präzision Verlust ermittelte.";
|
||||
$error['EN'][MatrixSPDException] = "Can only perform operation on symmetric positive definite matrix.";
|
||||
$error['FR'][MatrixSPDException] = "Perte significative de précision détectée.";
|
||||
$error['DE'][MatrixSPDException] = "Bedeutender Präzision Verlust ermittelte.";
|
||||
|
||||
define('MatrixSingularException', -7);
|
||||
$error['EN'][-7] = "Can only perform operation on singular matrix.";
|
||||
$error['EN'][MatrixSingularException] = "Can only perform operation on singular matrix.";
|
||||
|
||||
define('MatrixRankException', -8);
|
||||
$error['EN'][-8] = "Can only perform operation on full-rank matrix.";
|
||||
$error['EN'][MatrixRankException] = "Can only perform operation on full-rank matrix.";
|
||||
|
||||
define('ArrayLengthException', -9);
|
||||
$error['EN'][-9] = "Array length must be a multiple of m.";
|
||||
$error['EN'][ArrayLengthException] = "Array length must be a multiple of m.";
|
||||
|
||||
define('RowLengthException', -10);
|
||||
$error['EN'][-10] = "All rows must have the same length.";
|
||||
$error['EN'][RowLengthException] = "All rows must have the same length.";
|
||||
|
||||
/**
|
||||
* Custom error handler
|
||||
* @param int $type Error type: {ERROR, WARNING, NOTICE}
|
||||
* @param int $num Error number
|
||||
* @param string $file File in which the error occured
|
||||
* @param int $line Line on which the error occured
|
||||
*/
|
||||
function JAMAError( $type = null, $num = null, $file = null, $line = null, $context = null ) {
|
||||
global $error;
|
||||
|
||||
$lang = LANG;
|
||||
if( isset($type) && isset($num) && isset($file) && isset($line) ) {
|
||||
switch( $type ) {
|
||||
case ERROR:
|
||||
echo '<div class="errror"><b>Error:</b> ' . $error[$lang][$num] . '<br />' . $file . ' @ L' . $line . '</div>';
|
||||
die();
|
||||
break;
|
||||
|
||||
case WARNING:
|
||||
echo '<div class="warning"><b>Warning:</b> ' . $error[$lang][$num] . '<br />' . $file . ' @ L' . $line . '</div>';
|
||||
break;
|
||||
|
||||
case NOTICE:
|
||||
//echo '<div class="notice"><b>Notice:</b> ' . $error[$lang][$num] . '<br />' . $file . ' @ L' . $line . '</div>';
|
||||
break;
|
||||
* Custom error handler
|
||||
* @param int $num Error number
|
||||
*/
|
||||
function JAMAError($errorNumber = null) {
|
||||
global $error;
|
||||
|
||||
case E_NOTICE:
|
||||
//echo '<div class="errror"><b>Notice:</b> ' . $error[$lang][$num] . '<br />' . $file . ' @ L' . $line . '</div>';
|
||||
break;
|
||||
|
||||
case E_STRICT:
|
||||
break;
|
||||
|
||||
case E_WARNING:
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "<div class=\"error\"><b>Unknown Error Type:</b> $type - $file @ L{$line}</div>";
|
||||
die();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
die( "Invalid arguments to JAMAError()" );
|
||||
}
|
||||
if (isset($errorNumber)) {
|
||||
if (isset($error[JAMALANG][$errorNumber])) {
|
||||
return $error[JAMALANG][$errorNumber];
|
||||
} else {
|
||||
return $error['EN'][$errorNumber];
|
||||
}
|
||||
} else {
|
||||
return ("Invalid argument to JAMAError()");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO MarkBaker
|
||||
//set_error_handler('JAMAError');
|
||||
//error_reporting(ERROR | WARNING);
|
||||
|
||||
|
||||
@ -1,40 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JAMA
|
||||
*
|
||||
* Pythagorean Theorem:
|
||||
*
|
||||
* a = 3
|
||||
* b = 4
|
||||
* r = sqrt(square(a) + square(b))
|
||||
* r = 5
|
||||
*
|
||||
* r = sqrt(a^2 + b^2) without under/overflow.
|
||||
*/
|
||||
/**
|
||||
* @package JAMA
|
||||
*
|
||||
* Pythagorean Theorem:
|
||||
*
|
||||
* a = 3
|
||||
* b = 4
|
||||
* r = sqrt(square(a) + square(b))
|
||||
* r = 5
|
||||
*
|
||||
* r = sqrt(a^2 + b^2) without under/overflow.
|
||||
*/
|
||||
function hypo($a, $b) {
|
||||
if (abs($a) > abs($b)) {
|
||||
$r = $b/$a;
|
||||
$r = abs($a)* sqrt(1+$r*$r);
|
||||
} else if ($b != 0) {
|
||||
$r = $a/$b;
|
||||
$r = abs($b)*sqrt(1+$r*$r);
|
||||
} else
|
||||
$r = 0.0;
|
||||
return $r;
|
||||
}
|
||||
if (abs($a) > abs($b)) {
|
||||
$r = $b / $a;
|
||||
$r = abs($a) * sqrt(1 + $r * $r);
|
||||
} elseif ($b != 0) {
|
||||
$r = $a / $b;
|
||||
$r = abs($b) * sqrt(1 + $r * $r);
|
||||
} else {
|
||||
$r = 0.0;
|
||||
}
|
||||
return $r;
|
||||
} // function hypo()
|
||||
|
||||
|
||||
/**
|
||||
* Mike Bommarito's version.
|
||||
* Compute n-dimensional hyotheneuse.
|
||||
*
|
||||
* Mike Bommarito's version.
|
||||
* Compute n-dimensional hyotheneuse.
|
||||
*
|
||||
function hypot() {
|
||||
$s = 0;
|
||||
foreach (func_get_args() as $d) {
|
||||
if (is_numeric($d))
|
||||
$s += pow($d, 2);
|
||||
else
|
||||
trigger_error(ArgumentTypeException, ERROR);
|
||||
}
|
||||
return sqrt($s);
|
||||
$s = 0;
|
||||
foreach (func_get_args() as $d) {
|
||||
if (is_numeric($d)) {
|
||||
$s += pow($d, 2);
|
||||
} else {
|
||||
throw new Exception(JAMAError(ArgumentTypeException));
|
||||
}
|
||||
}
|
||||
return sqrt($s);
|
||||
}
|
||||
*/
|
||||
|
||||
@ -19,19 +19,6 @@
|
||||
//
|
||||
// $Id: OLE.php,v 1.13 2007/03/07 14:38:25 schmidt Exp $
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_PPS.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_File.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_Root.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/ChainedBlockStream.php';
|
||||
|
||||
/**
|
||||
* Array for storing OLE instances that are accessed from
|
||||
@ -527,20 +514,9 @@ class PHPExcel_Shared_OLE
|
||||
|
||||
// factor used for separating numbers into 4 bytes parts
|
||||
$factor = pow(2,32);
|
||||
$high_part = 0;
|
||||
for ($i = 0; $i < 4; ++$i) {
|
||||
list(, $high_part) = unpack('C', $string{(7 - $i)});
|
||||
if ($i < 3) {
|
||||
$high_part *= 0x100;
|
||||
}
|
||||
}
|
||||
$low_part = 0;
|
||||
for ($i = 4; $i < 8; ++$i) {
|
||||
list(, $low_part) = unpack('C', $string{(7 - $i)});
|
||||
if ($i < 7) {
|
||||
$low_part *= 0x100;
|
||||
}
|
||||
}
|
||||
list(, $high_part) = unpack('V', substr($string, 4, 4));
|
||||
list(, $low_part) = unpack('V', substr($string, 0, 4));
|
||||
|
||||
$big_date = ($high_part * $factor) + $low_part;
|
||||
// translate to seconds
|
||||
$big_date /= 10000000;
|
||||
|
||||
@ -2,18 +2,18 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (C) 2006 - 2009 PHPExcel
|
||||
* Copyright (C) 2006 - 2010 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
|
||||
@ -22,19 +22,9 @@
|
||||
* @package PHPExcel_Shared_OLE
|
||||
* @copyright Copyright (c) 2006 - 2007 Christian Schmidt
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
}
|
||||
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE.php';
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_OLE_ChainedBlockStream
|
||||
*
|
||||
|
||||
@ -20,16 +20,6 @@
|
||||
// $Id: PPS.php,v 1.7 2007/02/13 21:00:42 schmidt Exp $
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
}
|
||||
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE.php';
|
||||
|
||||
/**
|
||||
* Class for creating PPS's for OLE containers
|
||||
*
|
||||
@ -162,13 +152,13 @@ class PHPExcel_Shared_OLE_PPS
|
||||
if (!isset($this->_data)) {
|
||||
return 0;
|
||||
}
|
||||
if (isset($this->_PPS_FILE)) {
|
||||
fseek($this->_PPS_FILE, 0);
|
||||
$stats = fstat($this->_PPS_FILE);
|
||||
return $stats[7];
|
||||
} else {
|
||||
//if (isset($this->_PPS_FILE)) {
|
||||
// fseek($this->_PPS_FILE, 0);
|
||||
// $stats = fstat($this->_PPS_FILE);
|
||||
// return $stats[7];
|
||||
//} else {
|
||||
return strlen($this->_data);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -20,16 +20,6 @@
|
||||
// $Id: File.php,v 1.11 2007/02/13 21:00:42 schmidt Exp $
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
}
|
||||
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_PPS.php';
|
||||
|
||||
/**
|
||||
* Class for creating File PPS's for OLE containers
|
||||
*
|
||||
@ -39,12 +29,6 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_PPS.php';
|
||||
*/
|
||||
class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS
|
||||
{
|
||||
/**
|
||||
* The temporary dir for storing the OLE file
|
||||
* @var string
|
||||
*/
|
||||
public $_tmp_dir;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*
|
||||
@ -54,9 +38,8 @@ class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->_tmp_dir = '';
|
||||
parent::__construct(
|
||||
null,
|
||||
null,
|
||||
$name,
|
||||
PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE,
|
||||
null,
|
||||
@ -68,22 +51,6 @@ class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS
|
||||
array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the temp dir used for storing the OLE file
|
||||
*
|
||||
* @access public
|
||||
* @param string $dir The dir to be used as temp dir
|
||||
* @return true if given dir is valid, false otherwise
|
||||
*/
|
||||
public function setTempDir($dir)
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$this->_tmp_dir = $dir;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization method. Has to be called right after OLE_PPS_File().
|
||||
*
|
||||
@ -92,15 +59,6 @@ class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_File");
|
||||
$fh = fopen($this->_tmp_filename, "w+b");
|
||||
if ($fh === false) {
|
||||
throw new Exception("Can't create temporary file");
|
||||
}
|
||||
$this->_PPS_FILE = $fh;
|
||||
if ($this->_PPS_FILE) {
|
||||
fseek($this->_PPS_FILE, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -112,11 +70,7 @@ class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS
|
||||
*/
|
||||
public function append($data)
|
||||
{
|
||||
if ($this->_PPS_FILE) {
|
||||
fwrite($this->_PPS_FILE, $data);
|
||||
} else {
|
||||
$this->_data .= $data;
|
||||
}
|
||||
$this->_data .= $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -20,16 +20,6 @@
|
||||
// $Id: Root.php,v 1.9 2005/04/23 21:53:49 dufuz Exp $
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
}
|
||||
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_PPS.php';
|
||||
|
||||
/**
|
||||
* Class for creating Root PPS's for OLE containers
|
||||
*
|
||||
@ -39,19 +29,12 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/OLE/OLE_PPS.php';
|
||||
*/
|
||||
class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
||||
{
|
||||
/**
|
||||
* The temporary dir for storing the OLE file
|
||||
* @var string
|
||||
*/
|
||||
public $_tmp_dir;
|
||||
|
||||
/**
|
||||
* @param integer $time_1st A timestamp
|
||||
* @param integer $time_2nd A timestamp
|
||||
*/
|
||||
public function __construct($time_1st, $time_2nd, $raChild)
|
||||
{
|
||||
$this->_tmp_dir = '';
|
||||
parent::__construct(
|
||||
null,
|
||||
PHPExcel_Shared_OLE::Asc2Ucs('Root Entry'),
|
||||
@ -65,28 +48,14 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
||||
$raChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the temp dir used for storing the OLE file
|
||||
*
|
||||
* @access public
|
||||
* @param string $dir The dir to be used as temp dir
|
||||
* @return true if given dir is valid, false otherwise
|
||||
*/
|
||||
public function setTempDir($dir)
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$this->_tmp_dir = $dir;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for saving the whole OLE container (including files).
|
||||
* In fact, if called with an empty argument (or '-'), it saves to a
|
||||
* temporary file and then outputs it's contents to stdout.
|
||||
* If a resource pointer to a stream created by fopen() is passed
|
||||
* it will be used, but you have to close such stream by yourself.
|
||||
*
|
||||
* @param string $filename The name of the file where to save the OLE container
|
||||
* @param string|resource $filename The name of the file or stream where to save the OLE container.
|
||||
* @access public
|
||||
* @return mixed true on success
|
||||
*/
|
||||
@ -98,18 +67,19 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
||||
$this->_SMALL_BLOCK_SIZE= pow(2,
|
||||
((isset($this->_SMALL_BLOCK_SIZE))? $this->_adjust2($this->_SMALL_BLOCK_SIZE): 6));
|
||||
|
||||
// Open temp file if we are sending output to stdout
|
||||
if ($filename == '-' || $filename == '') {
|
||||
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
|
||||
$this->_FILEH_ = fopen($this->_tmp_filename,"w+b");
|
||||
if ($this->_FILEH_ == false) {
|
||||
throw new Exception("Can't create temporary file.");
|
||||
if (is_resource($filename)) {
|
||||
$this->_FILEH_ = $filename;
|
||||
} else if ($filename == '-' || $filename == '') {
|
||||
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
|
||||
$this->_FILEH_ = fopen($this->_tmp_filename,"w+b");
|
||||
if ($this->_FILEH_ == false) {
|
||||
throw new Exception("Can't create temporary file.");
|
||||
}
|
||||
} else {
|
||||
$this->_FILEH_ = fopen($filename, "wb");
|
||||
if ($this->_FILEH_ == false) {
|
||||
throw new Exception("Can't open $filename. It may be in use or protected.");
|
||||
}
|
||||
}
|
||||
if ($this->_FILEH_ == false) {
|
||||
throw new Exception("Can't open $filename. It may be in use or protected.");
|
||||
}
|
||||
// Make an array of PPS's (for Save)
|
||||
$aList = array();
|
||||
@ -128,16 +98,10 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
||||
$this->_savePps($aList);
|
||||
// Write Big Block Depot and BDList and Adding Header informations
|
||||
$this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt);
|
||||
// Close File, send it to stdout if necessary
|
||||
if (($filename == '-') || ($filename == '')) {
|
||||
fseek($this->_FILEH_, 0);
|
||||
fpassthru($this->_FILEH_);
|
||||
fclose($this->_FILEH_);
|
||||
// Delete the temporary file.
|
||||
unlink($this->_tmp_filename);
|
||||
} else {
|
||||
fclose($this->_FILEH_);
|
||||
}
|
||||
|
||||
if (!is_resource($filename)) {
|
||||
fclose($this->_FILEH_);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -248,7 +212,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
||||
. pack("V", 0)
|
||||
. pack("V", 0x1000)
|
||||
. pack("V", $iSBDcnt ? 0 : -2) //Small Block Depot
|
||||
. pack("V", 1)
|
||||
. pack("V", $iSBDcnt)
|
||||
);
|
||||
// Extra BDList Start, Count
|
||||
if ($iBdCnt < $i1stBdL) {
|
||||
@ -290,16 +254,16 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
||||
(($raList[$i]->Type == PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data)))
|
||||
{
|
||||
// Write Data
|
||||
if (isset($raList[$i]->_PPS_FILE)) {
|
||||
$iLen = 0;
|
||||
fseek($raList[$i]->_PPS_FILE, 0); // To The Top
|
||||
while($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
|
||||
$iLen += strlen($sBuff);
|
||||
fwrite($FILE, $sBuff);
|
||||
}
|
||||
} else {
|
||||
//if (isset($raList[$i]->_PPS_FILE)) {
|
||||
// $iLen = 0;
|
||||
// fseek($raList[$i]->_PPS_FILE, 0); // To The Top
|
||||
// while($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
|
||||
// $iLen += strlen($sBuff);
|
||||
// fwrite($FILE, $sBuff);
|
||||
// }
|
||||
//} else {
|
||||
fwrite($FILE, $raList[$i]->_data);
|
||||
}
|
||||
//}
|
||||
|
||||
if ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE) {
|
||||
for ($j = 0; $j < ($this->_BIG_BLOCK_SIZE - ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)); ++$j) {
|
||||
@ -313,11 +277,11 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
||||
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
|
||||
}
|
||||
// Close file for each PPS, and unlink it
|
||||
if (isset($raList[$i]->_PPS_FILE)) {
|
||||
fclose($raList[$i]->_PPS_FILE);
|
||||
$raList[$i]->_PPS_FILE = null;
|
||||
unlink($raList[$i]->_tmp_filename);
|
||||
}
|
||||
//if (isset($raList[$i]->_PPS_FILE)) {
|
||||
// fclose($raList[$i]->_PPS_FILE);
|
||||
// $raList[$i]->_PPS_FILE = null;
|
||||
// unlink($raList[$i]->_tmp_filename);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -349,15 +313,15 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
||||
}
|
||||
fwrite($FILE, pack("V", -2));
|
||||
|
||||
// Add to Data String(this will be written for RootEntry)
|
||||
if ($raList[$i]->_PPS_FILE) {
|
||||
fseek($raList[$i]->_PPS_FILE, 0); // To The Top
|
||||
while ($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
|
||||
$sRes .= $sBuff;
|
||||
}
|
||||
} else {
|
||||
//// Add to Data String(this will be written for RootEntry)
|
||||
//if ($raList[$i]->_PPS_FILE) {
|
||||
// fseek($raList[$i]->_PPS_FILE, 0); // To The Top
|
||||
// while ($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
|
||||
// $sRes .= $sBuff;
|
||||
// }
|
||||
//} else {
|
||||
$sRes .= $raList[$i]->_data;
|
||||
}
|
||||
//}
|
||||
if ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) {
|
||||
for ($j = 0; $j < ($this->_SMALL_BLOCK_SIZE - ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)); ++$j) {
|
||||
$sRes .= "\x00";
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1));
|
||||
@ -162,7 +162,6 @@ class PHPExcel_Shared_OLERead {
|
||||
$this->entry = $this->_readData($block);
|
||||
|
||||
$this->_readPropertySets();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,6 +212,58 @@ class PHPExcel_Shared_OLERead {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract binary stream data, summary information
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSummaryInformation()
|
||||
{
|
||||
if (!isset($this->summaryInformation)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->props[$this->summaryInformation]['size'] < self::SMALL_BLOCK_THRESHOLD){
|
||||
$rootdata = $this->_readData($this->props[$this->rootentry]['startBlock']);
|
||||
|
||||
$streamData = '';
|
||||
$block = $this->props[$this->summaryInformation]['startBlock'];
|
||||
|
||||
$pos = 0;
|
||||
while ($block != -2) {
|
||||
$pos = $block * self::SMALL_BLOCK_SIZE;
|
||||
$streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);
|
||||
|
||||
$block = $this->smallBlockChain[$block];
|
||||
}
|
||||
|
||||
return $streamData;
|
||||
|
||||
|
||||
} else {
|
||||
$numBlocks = $this->props[$this->summaryInformation]['size'] / self::BIG_BLOCK_SIZE;
|
||||
if ($this->props[$this->summaryInformation]['size'] % self::BIG_BLOCK_SIZE != 0) {
|
||||
++$numBlocks;
|
||||
}
|
||||
|
||||
if ($numBlocks == 0) return '';
|
||||
|
||||
|
||||
$streamData = '';
|
||||
$block = $this->props[$this->summaryInformation]['startBlock'];
|
||||
|
||||
$pos = 0;
|
||||
|
||||
while ($block != -2) {
|
||||
$pos = ($block + 1) * self::BIG_BLOCK_SIZE;
|
||||
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE);
|
||||
$block = $this->bigBlockChain[$block];
|
||||
}
|
||||
|
||||
return $streamData;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a standard stream (by joining sectors using information from SAT)
|
||||
*
|
||||
@ -271,7 +322,7 @@ class PHPExcel_Shared_OLERead {
|
||||
'size' => $size);
|
||||
|
||||
// Workbook directory entry (BIFF5 uses Book, BIFF8 uses Workbook)
|
||||
if (($name == 'Workbook') || ($name == 'Book') || ($name == 'WORKBOOK')) {
|
||||
if (($name == 'Workbook') || ($name == 'Book') || ($name == 'WORKBOOK') || ($name == 'BOOK')) {
|
||||
$this->wrkbook = count($this->props) - 1;
|
||||
}
|
||||
|
||||
@ -280,6 +331,11 @@ class PHPExcel_Shared_OLERead {
|
||||
$this->rootentry = count($this->props) - 1;
|
||||
}
|
||||
|
||||
// Summary information
|
||||
if ($name == chr(5) . 'SummaryInformation') {
|
||||
$this->summaryInformation = count($this->props) - 1;
|
||||
}
|
||||
|
||||
$offset += self::PROPERTY_STORAGE_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_PasswordHasher
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,10 +31,16 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_String
|
||||
{
|
||||
/** Constants */
|
||||
/** Regular Expressions */
|
||||
// Fraction
|
||||
const STRING_REGEXP_FRACTION = '(-?)(\d+)\s+(\d+\/\d+)';
|
||||
|
||||
|
||||
/**
|
||||
* Control characters array
|
||||
*
|
||||
@ -42,6 +48,27 @@ class PHPExcel_Shared_String
|
||||
*/
|
||||
private static $_controlCharacters = array();
|
||||
|
||||
/**
|
||||
* SYLK Characters array
|
||||
*
|
||||
* $var array
|
||||
*/
|
||||
private static $_SYLKCharacters = array();
|
||||
|
||||
/**
|
||||
* Decimal separator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_decimalSeparator;
|
||||
|
||||
/**
|
||||
* Thousands separator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_thousandsSeparator;
|
||||
|
||||
/**
|
||||
* Is mbstring extension avalable?
|
||||
*
|
||||
@ -60,7 +87,7 @@ class PHPExcel_Shared_String
|
||||
* Build control characters array
|
||||
*/
|
||||
private static function _buildControlCharacters() {
|
||||
for ($i = 0; $i <= 19; ++$i) {
|
||||
for ($i = 0; $i <= 31; ++$i) {
|
||||
if ($i != 9 && $i != 10 && $i != 13) {
|
||||
$find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
|
||||
$replace = chr($i);
|
||||
@ -69,6 +96,171 @@ class PHPExcel_Shared_String
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build SYLK characters array
|
||||
*/
|
||||
private static function _buildSYLKCharacters()
|
||||
{
|
||||
self::$_SYLKCharacters = array(
|
||||
"\x1B 0" => chr(0),
|
||||
"\x1B 1" => chr(1),
|
||||
"\x1B 2" => chr(2),
|
||||
"\x1B 3" => chr(3),
|
||||
"\x1B 4" => chr(4),
|
||||
"\x1B 5" => chr(5),
|
||||
"\x1B 6" => chr(6),
|
||||
"\x1B 7" => chr(7),
|
||||
"\x1B 8" => chr(8),
|
||||
"\x1B 9" => chr(9),
|
||||
"\x1B :" => chr(10),
|
||||
"\x1B ;" => chr(11),
|
||||
"\x1B <" => chr(12),
|
||||
"\x1B :" => chr(13),
|
||||
"\x1B >" => chr(14),
|
||||
"\x1B ?" => chr(15),
|
||||
"\x1B!0" => chr(16),
|
||||
"\x1B!1" => chr(17),
|
||||
"\x1B!2" => chr(18),
|
||||
"\x1B!3" => chr(19),
|
||||
"\x1B!4" => chr(20),
|
||||
"\x1B!5" => chr(21),
|
||||
"\x1B!6" => chr(22),
|
||||
"\x1B!7" => chr(23),
|
||||
"\x1B!8" => chr(24),
|
||||
"\x1B!9" => chr(25),
|
||||
"\x1B!:" => chr(26),
|
||||
"\x1B!;" => chr(27),
|
||||
"\x1B!<" => chr(28),
|
||||
"\x1B!=" => chr(29),
|
||||
"\x1B!>" => chr(30),
|
||||
"\x1B!?" => chr(31),
|
||||
"\x1B'?" => chr(127),
|
||||
"\x1B(0" => '€', // 128 in CP1252
|
||||
"\x1B(2" => '‚', // 130 in CP1252
|
||||
"\x1B(3" => 'ƒ', // 131 in CP1252
|
||||
"\x1B(4" => '„', // 132 in CP1252
|
||||
"\x1B(5" => '…', // 133 in CP1252
|
||||
"\x1B(6" => '†', // 134 in CP1252
|
||||
"\x1B(7" => '‡', // 135 in CP1252
|
||||
"\x1B(8" => 'ˆ', // 136 in CP1252
|
||||
"\x1B(9" => '‰', // 137 in CP1252
|
||||
"\x1B(:" => 'Š', // 138 in CP1252
|
||||
"\x1B(;" => '‹', // 139 in CP1252
|
||||
"\x1BNj" => 'Œ', // 140 in CP1252
|
||||
"\x1B(>" => 'Ž', // 142 in CP1252
|
||||
"\x1B)1" => '‘', // 145 in CP1252
|
||||
"\x1B)2" => '’', // 146 in CP1252
|
||||
"\x1B)3" => '“', // 147 in CP1252
|
||||
"\x1B)4" => '”', // 148 in CP1252
|
||||
"\x1B)5" => '•', // 149 in CP1252
|
||||
"\x1B)6" => '–', // 150 in CP1252
|
||||
"\x1B)7" => '—', // 151 in CP1252
|
||||
"\x1B)8" => '˜', // 152 in CP1252
|
||||
"\x1B)9" => '™', // 153 in CP1252
|
||||
"\x1B):" => 'š', // 154 in CP1252
|
||||
"\x1B);" => '›', // 155 in CP1252
|
||||
"\x1BNz" => 'œ', // 156 in CP1252
|
||||
"\x1B)>" => 'ž', // 158 in CP1252
|
||||
"\x1B)?" => 'Ÿ', // 159 in CP1252
|
||||
"\x1B*0" => ' ', // 160 in CP1252
|
||||
"\x1BN!" => '¡', // 161 in CP1252
|
||||
"\x1BN\"" => '¢', // 162 in CP1252
|
||||
"\x1BN#" => '£', // 163 in CP1252
|
||||
"\x1BN(" => '¤', // 164 in CP1252
|
||||
"\x1BN%" => '¥', // 165 in CP1252
|
||||
"\x1B*6" => '¦', // 166 in CP1252
|
||||
"\x1BN'" => '§', // 167 in CP1252
|
||||
"\x1BNH " => '¨', // 168 in CP1252
|
||||
"\x1BNS" => '©', // 169 in CP1252
|
||||
"\x1BNc" => 'ª', // 170 in CP1252
|
||||
"\x1BN+" => '«', // 171 in CP1252
|
||||
"\x1B*<" => '¬', // 172 in CP1252
|
||||
"\x1B*=" => '', // 173 in CP1252
|
||||
"\x1BNR" => '®', // 174 in CP1252
|
||||
"\x1B*?" => '¯', // 175 in CP1252
|
||||
"\x1BN0" => '°', // 176 in CP1252
|
||||
"\x1BN1" => '±', // 177 in CP1252
|
||||
"\x1BN2" => '²', // 178 in CP1252
|
||||
"\x1BN3" => '³', // 179 in CP1252
|
||||
"\x1BNB " => '´', // 180 in CP1252
|
||||
"\x1BN5" => 'µ', // 181 in CP1252
|
||||
"\x1BN6" => '¶', // 182 in CP1252
|
||||
"\x1BN7" => '·', // 183 in CP1252
|
||||
"\x1B+8" => '¸', // 184 in CP1252
|
||||
"\x1BNQ" => '¹', // 185 in CP1252
|
||||
"\x1BNk" => 'º', // 186 in CP1252
|
||||
"\x1BN;" => '»', // 187 in CP1252
|
||||
"\x1BN<" => '¼', // 188 in CP1252
|
||||
"\x1BN=" => '½', // 189 in CP1252
|
||||
"\x1BN>" => '¾', // 190 in CP1252
|
||||
"\x1BN?" => '¿', // 191 in CP1252
|
||||
"\x1BNAA" => 'À', // 192 in CP1252
|
||||
"\x1BNBA" => 'Á', // 193 in CP1252
|
||||
"\x1BNCA" => 'Â', // 194 in CP1252
|
||||
"\x1BNDA" => 'Ã', // 195 in CP1252
|
||||
"\x1BNHA" => 'Ä', // 196 in CP1252
|
||||
"\x1BNJA" => 'Å', // 197 in CP1252
|
||||
"\x1BNa" => 'Æ', // 198 in CP1252
|
||||
"\x1BNKC" => 'Ç', // 199 in CP1252
|
||||
"\x1BNAE" => 'È', // 200 in CP1252
|
||||
"\x1BNBE" => 'É', // 201 in CP1252
|
||||
"\x1BNCE" => 'Ê', // 202 in CP1252
|
||||
"\x1BNHE" => 'Ë', // 203 in CP1252
|
||||
"\x1BNAI" => 'Ì', // 204 in CP1252
|
||||
"\x1BNBI" => 'Í', // 205 in CP1252
|
||||
"\x1BNCI" => 'Î', // 206 in CP1252
|
||||
"\x1BNHI" => 'Ï', // 207 in CP1252
|
||||
"\x1BNb" => 'Ð', // 208 in CP1252
|
||||
"\x1BNDN" => 'Ñ', // 209 in CP1252
|
||||
"\x1BNAO" => 'Ò', // 210 in CP1252
|
||||
"\x1BNBO" => 'Ó', // 211 in CP1252
|
||||
"\x1BNCO" => 'Ô', // 212 in CP1252
|
||||
"\x1BNDO" => 'Õ', // 213 in CP1252
|
||||
"\x1BNHO" => 'Ö', // 214 in CP1252
|
||||
"\x1B-7" => '×', // 215 in CP1252
|
||||
"\x1BNi" => 'Ø', // 216 in CP1252
|
||||
"\x1BNAU" => 'Ù', // 217 in CP1252
|
||||
"\x1BNBU" => 'Ú', // 218 in CP1252
|
||||
"\x1BNCU" => 'Û', // 219 in CP1252
|
||||
"\x1BNHU" => 'Ü', // 220 in CP1252
|
||||
"\x1B-=" => 'Ý', // 221 in CP1252
|
||||
"\x1BNl" => 'Þ', // 222 in CP1252
|
||||
"\x1BN{" => 'ß', // 223 in CP1252
|
||||
"\x1BNAa" => 'à', // 224 in CP1252
|
||||
"\x1BNBa" => 'á', // 225 in CP1252
|
||||
"\x1BNCa" => 'â', // 226 in CP1252
|
||||
"\x1BNDa" => 'ã', // 227 in CP1252
|
||||
"\x1BNHa" => 'ä', // 228 in CP1252
|
||||
"\x1BNJa" => 'å', // 229 in CP1252
|
||||
"\x1BNq" => 'æ', // 230 in CP1252
|
||||
"\x1BNKc" => 'ç', // 231 in CP1252
|
||||
"\x1BNAe" => 'è', // 232 in CP1252
|
||||
"\x1BNBe" => 'é', // 233 in CP1252
|
||||
"\x1BNCe" => 'ê', // 234 in CP1252
|
||||
"\x1BNHe" => 'ë', // 235 in CP1252
|
||||
"\x1BNAi" => 'ì', // 236 in CP1252
|
||||
"\x1BNBi" => 'í', // 237 in CP1252
|
||||
"\x1BNCi" => 'î', // 238 in CP1252
|
||||
"\x1BNHi" => 'ï', // 239 in CP1252
|
||||
"\x1BNs" => 'ð', // 240 in CP1252
|
||||
"\x1BNDn" => 'ñ', // 241 in CP1252
|
||||
"\x1BNAo" => 'ò', // 242 in CP1252
|
||||
"\x1BNBo" => 'ó', // 243 in CP1252
|
||||
"\x1BNCo" => 'ô', // 244 in CP1252
|
||||
"\x1BNDo" => 'õ', // 245 in CP1252
|
||||
"\x1BNHo" => 'ö', // 246 in CP1252
|
||||
"\x1B/7" => '÷', // 247 in CP1252
|
||||
"\x1BNy" => 'ø', // 248 in CP1252
|
||||
"\x1BNAu" => 'ù', // 249 in CP1252
|
||||
"\x1BNBu" => 'ú', // 250 in CP1252
|
||||
"\x1BNCu" => 'û', // 251 in CP1252
|
||||
"\x1BNHu" => 'ü', // 252 in CP1252
|
||||
"\x1B/=" => 'ý', // 253 in CP1252
|
||||
"\x1BN|" => 'þ', // 254 in CP1252
|
||||
"\x1BNHy" => 'ÿ', // 255 in CP1252
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether mbstring extension is available
|
||||
*
|
||||
@ -97,14 +289,37 @@ class PHPExcel_Shared_String
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
|
||||
// IBM AIX iconv() does not work
|
||||
self::$_isIconvEnabled = function_exists('iconv') &&
|
||||
!(defined('PHP_OS') && @stristr(PHP_OS, 'AIX') && defined('ICONV_IMPL')
|
||||
&& (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && defined('ICONV_VERSION')
|
||||
&& (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) ?
|
||||
true : false;
|
||||
// Fail if iconv doesn't exist
|
||||
if (!function_exists('iconv')) {
|
||||
self::$_isIconvEnabled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
return self::$_isIconvEnabled;
|
||||
// Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
|
||||
if (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
|
||||
self::$_isIconvEnabled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0
|
||||
// we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773)
|
||||
if (!@iconv('UTF-8', 'UTF-16LE', 'x')) {
|
||||
self::$_isIconvEnabled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// CUSTOM: IBM AIX iconv() does not work
|
||||
if ( defined('PHP_OS') && @stristr(PHP_OS, 'AIX')
|
||||
&& defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0)
|
||||
&& defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0) )
|
||||
{
|
||||
self::$_isIconvEnabled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we reach here no problems were detected with iconv
|
||||
self::$_isIconvEnabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,7 +387,7 @@ class PHPExcel_Shared_String
|
||||
// else, no conversion
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a string contains UTF8 data
|
||||
*
|
||||
@ -213,7 +428,7 @@ class PHPExcel_Shared_String
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
|
||||
// option flags
|
||||
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
|
||||
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
|
||||
// characters
|
||||
@ -239,7 +454,7 @@ class PHPExcel_Shared_String
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
|
||||
// option flags
|
||||
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
|
||||
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
|
||||
// characters
|
||||
@ -250,7 +465,7 @@ class PHPExcel_Shared_String
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert string from one encoding to another. First try mbstring, then iconv, or no convertion
|
||||
* Convert string from one encoding to another. First try iconv, then mbstring, or no convertion
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $to Encoding to convert to, e.g. 'UTF-8'
|
||||
@ -268,11 +483,46 @@ class PHPExcel_Shared_String
|
||||
$value = mb_convert_encoding($value, $to, $from);
|
||||
return $value;
|
||||
}
|
||||
|
||||
if($from == 'UTF-16LE'){
|
||||
return self::utf16_decode($value, false);
|
||||
}else if($from == 'UTF-16BE'){
|
||||
return self::utf16_decode($value);
|
||||
}
|
||||
// else, no conversion
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode UTF-16 encoded strings.
|
||||
*
|
||||
* Can handle both BOM'ed data and un-BOM'ed data.
|
||||
* Assumes Big-Endian byte order if no BOM is available.
|
||||
* This function was taken from http://php.net/manual/en/function.utf8-decode.php
|
||||
* and $bom_be parameter added.
|
||||
*
|
||||
* @param string $str UTF-16 encoded data to decode.
|
||||
* @return string UTF-8 / ISO encoded data.
|
||||
* @access public
|
||||
* @version 0.2 / 2010-05-13
|
||||
* @author Rasmus Andersson {@link http://rasmusandersson.se/}
|
||||
* @author vadik56
|
||||
*/
|
||||
function utf16_decode( $str, $bom_be=true ) {
|
||||
if( strlen($str) < 2 ) return $str;
|
||||
$c0 = ord($str{0});
|
||||
$c1 = ord($str{1});
|
||||
if( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); }
|
||||
elseif( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; }
|
||||
$len = strlen($str);
|
||||
$newstr = '';
|
||||
for($i=0;$i<$len;$i+=2) {
|
||||
if( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); }
|
||||
else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); }
|
||||
$newstr .= ($val == 0x228) ? "\n" : chr($val);
|
||||
}
|
||||
return $newstr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get character count. First try mbstring, then iconv, finally strlen
|
||||
*
|
||||
@ -322,4 +572,106 @@ class PHPExcel_Shared_String
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether a string contains a fractional numeric value,
|
||||
* and convert it to a numeric if it is
|
||||
*
|
||||
* @param string &$operand string value to test
|
||||
* @return boolean
|
||||
*/
|
||||
public static function convertToNumberIfFraction(&$operand) {
|
||||
if (preg_match('/^'.self::STRING_REGEXP_FRACTION.'$/i', $operand, $match)) {
|
||||
$sign = ($match[1] == '-') ? '-' : '+';
|
||||
$fractionFormula = '='.$sign.$match[2].$sign.$match[3];
|
||||
$operand = PHPExcel_Calculation::getInstance()->_calculateFormulaValue($fractionFormula);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function convertToNumberIfFraction()
|
||||
|
||||
/**
|
||||
* Get the decimal separator. If it has not yet been set explicitly, try to obtain number
|
||||
* formatting information from locale.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDecimalSeparator()
|
||||
{
|
||||
if (!isset(self::$_decimalSeparator)) {
|
||||
$localeconv = localeconv();
|
||||
self::$_decimalSeparator = $localeconv['decimal_point'] != ''
|
||||
? $localeconv['decimal_point'] : $localeconv['mon_decimal_point'];
|
||||
|
||||
if (self::$_decimalSeparator == '')
|
||||
{
|
||||
// Default to .
|
||||
self::$_decimalSeparator = '.';
|
||||
}
|
||||
}
|
||||
return self::$_decimalSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the decimal separator. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
|
||||
* to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
|
||||
*
|
||||
* @param string $pValue Character for decimal separator
|
||||
*/
|
||||
public static function setDecimalSeparator($pValue = '.')
|
||||
{
|
||||
self::$_decimalSeparator = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the thousands separator. If it has not yet been set explicitly, try to obtain number
|
||||
* formatting information from locale.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getThousandsSeparator()
|
||||
{
|
||||
if (!isset(self::$_thousandsSeparator)) {
|
||||
$localeconv = localeconv();
|
||||
self::$_thousandsSeparator = $localeconv['thousands_sep'] != ''
|
||||
? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep'];
|
||||
}
|
||||
return self::$_thousandsSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the thousands separator. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
|
||||
* to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
|
||||
*
|
||||
* @param string $pValue Character for thousands separator
|
||||
*/
|
||||
public static function setThousandsSeparator($pValue = ',')
|
||||
{
|
||||
self::$_thousandsSeparator = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert SYLK encoded string to UTF-8
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return string UTF-8 encoded string
|
||||
*/
|
||||
public static function SYLKtoUTF8($pValue = '')
|
||||
{
|
||||
// If there is no escape character in the string there is nothing to do
|
||||
if (strpos($pValue, '') === false) {
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
if(empty(self::$_SYLKCharacters)) {
|
||||
self::_buildSYLKCharacters();
|
||||
}
|
||||
|
||||
foreach (self::$_SYLKCharacters as $k => $v) {
|
||||
$pValue = str_replace($k, $v, $pValue);
|
||||
}
|
||||
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
if (!defined('DATE_W3C')) {
|
||||
@ -34,7 +34,7 @@ if (!defined('DATE_W3C')) {
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_XMLWriter {
|
||||
/** Temporary storage method */
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,22 +20,18 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** Register new zip wrapper */
|
||||
PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_ZipStreamWrapper
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_ZipStreamWrapper {
|
||||
/**
|
||||
@ -83,24 +79,9 @@ class PHPExcel_Shared_ZipStreamWrapper {
|
||||
throw new Exception('Mode ' . $mode . ' is not supported. Only read mode is supported.');
|
||||
}
|
||||
|
||||
// Parse URL
|
||||
$url = @parse_url($path);
|
||||
|
||||
// Fix URL
|
||||
if (!is_array($url)) {
|
||||
$url['host'] = substr($path, strlen('zip://'));
|
||||
$url['path'] = '';
|
||||
}
|
||||
if (strpos($url['host'], '#') !== false) {
|
||||
if (!isset($url['fragment'])) {
|
||||
$url['fragment'] = substr($url['host'], strpos($url['host'], '#') + 1) . $url['path'];
|
||||
$url['host'] = substr($url['host'], 0, strpos($url['host'], '#'));
|
||||
unset($url['path']);
|
||||
}
|
||||
} else {
|
||||
$url['host'] = $url['host'] . $url['path'];
|
||||
unset($url['path']);
|
||||
}
|
||||
$pos = strrpos($path, '#');
|
||||
$url['host'] = substr($path, 6, $pos - 6); // 6: strlen('zip://')
|
||||
$url['fragment'] = substr($path, $pos + 1);
|
||||
|
||||
// Open archive
|
||||
$this->_archive = new ZipArchive();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Best_Fit
|
||||
{
|
||||
@ -239,7 +239,11 @@ class PHPExcel_Best_Fit
|
||||
$this->_SSResiduals = $SSres;
|
||||
$this->_DFResiduals = $this->_valueCount - 1 - $const;
|
||||
|
||||
$this->_stdevOfResiduals = sqrt($SSres / $this->_DFResiduals);
|
||||
if ($this->_DFResiduals == 0.0) {
|
||||
$this->_stdevOfResiduals = 0.0;
|
||||
} else {
|
||||
$this->_stdevOfResiduals = sqrt($SSres / $this->_DFResiduals);
|
||||
}
|
||||
if (($SStot == 0.0) || ($SSres == $SStot)) {
|
||||
$this->_goodnessOfFit = 1;
|
||||
} else {
|
||||
@ -252,9 +256,17 @@ class PHPExcel_Best_Fit
|
||||
$this->_slopeSE = $this->_stdevOfResiduals / sqrt($SSsex);
|
||||
$this->_intersectSE = $this->_stdevOfResiduals * sqrt(1 / ($this->_valueCount - ($sumX * $sumX) / $sumX2));
|
||||
if ($this->_SSResiduals != 0.0) {
|
||||
$this->_F = $this->_SSRegression / ($this->_SSResiduals / $this->_DFResiduals);
|
||||
if ($this->_DFResiduals == 0.0) {
|
||||
$this->_F = 0.0;
|
||||
} else {
|
||||
$this->_F = $this->_SSRegression / ($this->_SSResiduals / $this->_DFResiduals);
|
||||
}
|
||||
} else {
|
||||
$this->_F = $this->_SSRegression / $this->_DFResiduals;
|
||||
if ($this->_DFResiduals == 0.0) {
|
||||
$this->_F = 0.0;
|
||||
} else {
|
||||
$this->_F = $this->_SSRegression / $this->_DFResiduals;
|
||||
}
|
||||
}
|
||||
} // function _calculateGoodnessOfFit()
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,20 +20,12 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
}
|
||||
|
||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||
|
||||
|
||||
@ -42,7 +34,7 @@ require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||
{
|
||||
@ -84,8 +76,14 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||
|
||||
|
||||
private function _exponential_regression($yValues, $xValues, $const) {
|
||||
$mArray = $xValues;
|
||||
$yValues = array_map('log',$yValues);
|
||||
foreach($yValues as &$value) {
|
||||
if ($value < 0.0) {
|
||||
$value = 0 - log(abs($value));
|
||||
} elseif ($value > 0.0) {
|
||||
$value = log($value);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
|
||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
||||
} // function _exponential_regression()
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,20 +20,12 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
}
|
||||
|
||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||
|
||||
|
||||
@ -42,7 +34,7 @@ require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,20 +20,12 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
}
|
||||
|
||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||
|
||||
|
||||
@ -42,7 +34,7 @@ require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||
{
|
||||
@ -68,8 +60,14 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||
|
||||
|
||||
private function _logarithmic_regression($yValues, $xValues, $const) {
|
||||
$mArray = $xValues;
|
||||
$xValues = array_map('log',$xValues);
|
||||
foreach($xValues as &$value) {
|
||||
if ($value < 0.0) {
|
||||
$value = 0 - log(abs($value));
|
||||
} elseif ($value > 0.0) {
|
||||
$value = log($value);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
|
||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
||||
} // function _logarithmic_regression()
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,20 +20,12 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
}
|
||||
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/Matrix.php';
|
||||
|
||||
@ -43,7 +35,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/Matrix.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,20 +20,12 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
}
|
||||
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php';
|
||||
|
||||
|
||||
@ -42,7 +34,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||
{
|
||||
@ -76,10 +68,22 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||
|
||||
|
||||
private function _power_regression($yValues, $xValues, $const) {
|
||||
$mArray = $xValues;
|
||||
sort($mArray,SORT_NUMERIC);
|
||||
$xValues = array_map('log',$xValues);
|
||||
$yValues = array_map('log',$yValues);
|
||||
foreach($xValues as &$value) {
|
||||
if ($value < 0.0) {
|
||||
$value = 0 - log(abs($value));
|
||||
} elseif ($value > 0.0) {
|
||||
$value = log($value);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
foreach($yValues as &$value) {
|
||||
if ($value < 0.0) {
|
||||
$value = 0 - log(abs($value));
|
||||
} elseif ($value > 0.0) {
|
||||
$value = log($value);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
|
||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
||||
} // function _power_regression()
|
||||
|
||||
@ -1,13 +1,5 @@
|
||||
<?php
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../../');
|
||||
}
|
||||
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/linearBestFitClass.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/logarithmicBestFitClass.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/exponentialBestFitClass.php';
|
||||
|
||||
@ -2,71 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Style_Color */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
|
||||
|
||||
/** PHPExcel_Style_Font */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
|
||||
|
||||
/** PHPExcel_Style_Fill */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Fill.php';
|
||||
|
||||
/** PHPExcel_Style_Borders */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Borders.php';
|
||||
|
||||
/** PHPExcel_Style_Alignment */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Alignment.php';
|
||||
|
||||
/** PHPExcel_Style_NumberFormat */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
|
||||
|
||||
/** PHPExcel_Style_Conditional */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Conditional.php';
|
||||
|
||||
/** PHPExcel_Style_Protection */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Protection.php';
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
/**
|
||||
* PHPExcel_Style
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style implements PHPExcel_IComparable
|
||||
{
|
||||
@ -76,7 +41,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
* @var PHPExcel_Style_Font
|
||||
*/
|
||||
private $_font;
|
||||
|
||||
|
||||
/**
|
||||
* Fill
|
||||
*
|
||||
@ -90,28 +55,28 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
* @var PHPExcel_Style_Borders
|
||||
*/
|
||||
private $_borders;
|
||||
|
||||
|
||||
/**
|
||||
* Alignment
|
||||
*
|
||||
* @var PHPExcel_Style_Alignment
|
||||
*/
|
||||
private $_alignment;
|
||||
|
||||
|
||||
/**
|
||||
* Number Format
|
||||
*
|
||||
* @var PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
private $_numberFormat;
|
||||
|
||||
|
||||
/**
|
||||
* Conditional styles
|
||||
*
|
||||
* @var PHPExcel_Style_Conditional[]
|
||||
*/
|
||||
private $_conditionalStyles;
|
||||
|
||||
|
||||
/**
|
||||
* Protection
|
||||
*
|
||||
@ -181,7 +146,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
$this->_parent = $parent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is this a supervisor or a real style component?
|
||||
*
|
||||
@ -201,7 +166,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
public function getSharedComponent()
|
||||
{
|
||||
$activeSheet = $this->getActiveSheet();
|
||||
$selectedCell = $this->getXActiveCell(); // e.g. 'A1'
|
||||
$selectedCell = $this->getActiveCell(); // e.g. 'A1'
|
||||
|
||||
if ($activeSheet->cellExists($selectedCell)) {
|
||||
$cell = $activeSheet->getCell($selectedCell);
|
||||
@ -230,9 +195,9 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXSelectedCells()
|
||||
public function getSelectedCells()
|
||||
{
|
||||
return $this->_parent->getActiveSheet()->getXSelectedCells();
|
||||
return $this->_parent->getActiveSheet()->getSelectedCells();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,9 +206,9 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXActiveCell()
|
||||
public function getActiveCell()
|
||||
{
|
||||
return $this->_parent->getActiveSheet()->getXActiveCell();
|
||||
return $this->_parent->getActiveSheet()->getActiveCell();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,7 +223,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->applyFromArray(
|
||||
* array(
|
||||
@ -289,9 +254,9 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @param boolean $pAdvanced Advanced mode for setting borders.
|
||||
* @param boolean $pAdvanced Advanced mode for setting borders.
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style
|
||||
*/
|
||||
@ -299,204 +264,253 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
if (is_array($pStyles)) {
|
||||
if ($this->_isSupervisor) {
|
||||
|
||||
$pRange = $this->getXSelectedCells();
|
||||
$pRange = $this->getSelectedCells();
|
||||
|
||||
if (is_array($pStyles)) {
|
||||
// Uppercase coordinate
|
||||
$pRange = strtoupper($pRange);
|
||||
|
||||
// Is it a cell range or a single cell?
|
||||
$rangeA = '';
|
||||
$rangeB = '';
|
||||
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;
|
||||
}
|
||||
|
||||
// Simple mode
|
||||
|
||||
// First loop through cells to find out which styles are affected by this operation
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
// clone each of the affected styles, apply the style arrray, 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 cells again and update the XF index
|
||||
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]);
|
||||
}
|
||||
}
|
||||
// Uppercase coordinate
|
||||
$pRange = strtoupper($pRange);
|
||||
|
||||
// Is it a cell range or a single cell?
|
||||
$rangeA = '';
|
||||
$rangeB = '';
|
||||
if (strpos($pRange, ':') === false) {
|
||||
$rangeA = $pRange;
|
||||
$rangeB = $pRange;
|
||||
} else {
|
||||
throw new Exception("Invalid style array passed.");
|
||||
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;
|
||||
}
|
||||
|
||||
// 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 arrray, 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']);
|
||||
}
|
||||
@ -530,7 +544,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
public function getFill() {
|
||||
return $this->_fill;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Font
|
||||
*
|
||||
@ -560,7 +574,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
public function getBorders() {
|
||||
return $this->_borders;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Alignment
|
||||
*
|
||||
@ -569,7 +583,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
public function getAlignment() {
|
||||
return $this->_alignment;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Number Format
|
||||
*
|
||||
@ -578,16 +592,16 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
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->getXActiveCell());
|
||||
return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Conditional Styles. Only used on supervisor.
|
||||
*
|
||||
@ -596,13 +610,13 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
*/
|
||||
public function setConditionalStyles($pValue = null) {
|
||||
if (is_array($pValue)) {
|
||||
foreach (PHPExcel_Cell::extractAllCellReferencesInRange($this->getXSelectedCells()) as $cellReference) {
|
||||
foreach (PHPExcel_Cell::extractAllCellReferencesInRange($this->getSelectedCells()) as $cellReference) {
|
||||
$this->getActiveSheet()->setConditionalStyles($cellReference, $pValue);
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Protection
|
||||
*
|
||||
@ -611,18 +625,18 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
public function getProtection() {
|
||||
return $this->_protection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode() {
|
||||
$hashConditionals = '';
|
||||
foreach ($this->_conditionalStyles as $conditional) {
|
||||
$hashConditionals .= $conditional->getHashCode();
|
||||
}
|
||||
|
||||
|
||||
return md5(
|
||||
$this->getFill()->getHashCode()
|
||||
. $this->getFont()->getHashCode()
|
||||
@ -634,37 +648,6 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get own index in style collection
|
||||
|
||||
@ -2,51 +2,39 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Style_Alignment
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
{
|
||||
{
|
||||
/* Horizontal alignment styles */
|
||||
const HORIZONTAL_GENERAL = 'general';
|
||||
const HORIZONTAL_LEFT = 'left';
|
||||
@ -54,55 +42,55 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
const HORIZONTAL_CENTER = 'center';
|
||||
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous';
|
||||
const HORIZONTAL_JUSTIFY = 'justify';
|
||||
|
||||
|
||||
/* Vertical alignment styles */
|
||||
const VERTICAL_BOTTOM = 'bottom';
|
||||
const VERTICAL_TOP = 'top';
|
||||
const VERTICAL_CENTER = 'center';
|
||||
const VERTICAL_JUSTIFY = 'justify';
|
||||
|
||||
|
||||
/**
|
||||
* Horizontal
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_horizontal;
|
||||
|
||||
|
||||
/**
|
||||
* Vertical
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_vertical;
|
||||
|
||||
|
||||
/**
|
||||
* Text rotation
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_textRotation;
|
||||
|
||||
|
||||
/**
|
||||
* Wrap text
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_wrapText;
|
||||
|
||||
|
||||
/**
|
||||
* Shrink to fit
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_shrinkToFit;
|
||||
|
||||
|
||||
/**
|
||||
* Indent - only possible with horizontal alignment left and right
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_indent;
|
||||
|
||||
|
||||
/**
|
||||
* Parent Borders
|
||||
*
|
||||
@ -190,9 +178,9 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXSelectedCells()
|
||||
public function getSelectedCells()
|
||||
{
|
||||
return $this->getActiveSheet()->getXSelectedCells();
|
||||
return $this->getActiveSheet()->getSelectedCells();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,9 +189,9 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXActiveCell()
|
||||
public function getActiveCell()
|
||||
{
|
||||
return $this->getActiveSheet()->getXActiveCell();
|
||||
return $this->getActiveSheet()->getActiveCell();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,7 +207,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->applyFromArray(
|
||||
* array(
|
||||
@ -230,7 +218,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_Alignment
|
||||
@ -238,7 +226,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
public function applyFromArray($pStyles = null) {
|
||||
if (is_array($pStyles)) {
|
||||
if ($this->_isSupervisor) {
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
} else {
|
||||
if (array_key_exists('horizontal', $pStyles)) {
|
||||
$this->setHorizontal($pStyles['horizontal']);
|
||||
@ -264,7 +252,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Horizontal
|
||||
*
|
||||
@ -276,7 +264,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_horizontal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Horizontal
|
||||
*
|
||||
@ -287,17 +275,17 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
}
|
||||
|
||||
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('horizontal' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
}
|
||||
else {
|
||||
$this->_horizontal = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Vertical
|
||||
*
|
||||
@ -309,7 +297,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_vertical;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Vertical
|
||||
*
|
||||
@ -320,16 +308,16 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
|
||||
}
|
||||
|
||||
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('vertical' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_vertical = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get TextRotation
|
||||
*
|
||||
@ -341,7 +329,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_textRotation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set TextRotation
|
||||
*
|
||||
@ -359,17 +347,17 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
if ( ($pValue >= -90 && $pValue <= 90) || $pValue == -165 ) {
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('rotation' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_textRotation = $pValue;
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Text rotation should be a value between -90 and 90.");
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Wrap Text
|
||||
*
|
||||
@ -381,7 +369,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_wrapText;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Wrap Text
|
||||
*
|
||||
@ -394,13 +382,13 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('wrap' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_wrapText = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Shrink to fit
|
||||
*
|
||||
@ -412,7 +400,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_shrinkToFit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Shrink to fit
|
||||
*
|
||||
@ -425,7 +413,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('shrinkToFit' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_shrinkToFit = $pValue;
|
||||
}
|
||||
@ -443,7 +431,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_indent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set indent
|
||||
*
|
||||
@ -458,18 +446,18 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('indent' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_indent = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getHashCode();
|
||||
@ -484,38 +472,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
|
||||
@ -2,51 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Style_Color */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Style_Border
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
{
|
||||
@ -65,17 +50,17 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
const BORDER_SLANTDASHDOT = 'slantDashDot';
|
||||
const BORDER_THICK = 'thick';
|
||||
const BORDER_THIN = 'thin';
|
||||
|
||||
|
||||
/**
|
||||
* Border style
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_borderStyle;
|
||||
|
||||
|
||||
/**
|
||||
* Border color
|
||||
*
|
||||
*
|
||||
* @var PHPExcel_Style_Color
|
||||
*/
|
||||
private $_color;
|
||||
@ -132,7 +117,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
$this->_parentPropertyName = $parentPropertyName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is this a supervisor or a real style component?
|
||||
*
|
||||
@ -200,9 +185,9 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXSelectedCells()
|
||||
public function getSelectedCells()
|
||||
{
|
||||
return $this->getActiveSheet()->getXSelectedCells();
|
||||
return $this->getActiveSheet()->getSelectedCells();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,9 +196,9 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXActiveCell()
|
||||
public function getActiveCell()
|
||||
{
|
||||
return $this->getActiveSheet()->getXActiveCell();
|
||||
return $this->getActiveSheet()->getActiveCell();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,7 +255,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->getTop()->applyFromArray(
|
||||
* array(
|
||||
@ -281,7 +266,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_Border
|
||||
@ -289,7 +274,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
public function applyFromArray($pStyles = null) {
|
||||
if (is_array($pStyles)) {
|
||||
if ($this->_isSupervisor) {
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
} else {
|
||||
if (array_key_exists('style', $pStyles)) {
|
||||
$this->setBorderStyle($pStyles['style']);
|
||||
@ -303,7 +288,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Border style
|
||||
*
|
||||
@ -315,7 +300,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_borderStyle;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Border style
|
||||
*
|
||||
@ -323,19 +308,19 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
* @return PHPExcel_Style_Border
|
||||
*/
|
||||
public function setBorderStyle($pValue = PHPExcel_Style_Border::BORDER_NONE) {
|
||||
|
||||
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPExcel_Style_Border::BORDER_NONE;
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('style' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_borderStyle = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Border Color
|
||||
*
|
||||
@ -344,7 +329,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
public function getColor() {
|
||||
return $this->_color;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Border Color
|
||||
*
|
||||
@ -355,21 +340,21 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
public function setColor(PHPExcel_Style_Color $pValue = null) {
|
||||
// make sure parameter is a real color and not a supervisor
|
||||
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
|
||||
|
||||
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB()));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_color = $color;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getHashCode();
|
||||
@ -380,38 +365,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
|
||||
@ -2,51 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Style_Border */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Border.php';
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Style_Borders
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
{
|
||||
@ -54,84 +39,85 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
const DIAGONAL_NONE = 0;
|
||||
const DIAGONAL_UP = 1;
|
||||
const DIAGONAL_DOWN = 2;
|
||||
|
||||
const DIAGONAL_BOTH = 3;
|
||||
|
||||
/**
|
||||
* Left
|
||||
*
|
||||
* @var PHPExcel_Style_Border
|
||||
*/
|
||||
private $_left;
|
||||
|
||||
|
||||
/**
|
||||
* Right
|
||||
*
|
||||
* @var PHPExcel_Style_Border
|
||||
*/
|
||||
private $_right;
|
||||
|
||||
|
||||
/**
|
||||
* Top
|
||||
*
|
||||
* @var PHPExcel_Style_Border
|
||||
*/
|
||||
private $_top;
|
||||
|
||||
|
||||
/**
|
||||
* Bottom
|
||||
*
|
||||
* @var PHPExcel_Style_Border
|
||||
*/
|
||||
private $_bottom;
|
||||
|
||||
|
||||
/**
|
||||
* Diagonal
|
||||
*
|
||||
* @var PHPExcel_Style_Border
|
||||
*/
|
||||
private $_diagonal;
|
||||
|
||||
|
||||
/**
|
||||
* DiagonalDirection
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_diagonalDirection;
|
||||
|
||||
|
||||
/**
|
||||
* All borders psedo-border. Only applies to supervisor.
|
||||
*
|
||||
* @var PHPExcel_Style_Border
|
||||
*/
|
||||
private $_allBorders;
|
||||
|
||||
|
||||
/**
|
||||
* Outline psedo-border. Only applies to supervisor.
|
||||
*
|
||||
* @var PHPExcel_Style_Border
|
||||
*/
|
||||
private $_outline;
|
||||
|
||||
|
||||
/**
|
||||
* Inside psedo-border. Only applies to supervisor.
|
||||
*
|
||||
* @var PHPExcel_Style_Border
|
||||
*/
|
||||
private $_inside;
|
||||
|
||||
|
||||
/**
|
||||
* Vertical pseudo-border. Only applies to supervisor.
|
||||
*
|
||||
* @var PHPExcel_Style_Border
|
||||
*/
|
||||
private $_vertical;
|
||||
|
||||
|
||||
/**
|
||||
* Horizontal pseudo-border. Only applies to supervisor.
|
||||
*
|
||||
* @var PHPExcel_Style_Border
|
||||
*/
|
||||
private $_horizontal;
|
||||
|
||||
|
||||
/**
|
||||
* Parent Borders
|
||||
*
|
||||
@ -241,9 +227,9 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXSelectedCells()
|
||||
public function getSelectedCells()
|
||||
{
|
||||
return $this->getActiveSheet()->getXSelectedCells();
|
||||
return $this->getActiveSheet()->getSelectedCells();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,9 +238,9 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXActiveCell()
|
||||
public function getActiveCell()
|
||||
{
|
||||
return $this->getActiveSheet()->getXActiveCell();
|
||||
return $this->getActiveSheet()->getActiveCell();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,7 +256,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getBorders()->applyFromArray(
|
||||
* array(
|
||||
@ -301,7 +287,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_Borders
|
||||
@ -309,7 +295,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
public function applyFromArray($pStyles = null) {
|
||||
if (is_array($pStyles)) {
|
||||
if ($this->_isSupervisor) {
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
} else {
|
||||
if (array_key_exists('left', $pStyles)) {
|
||||
$this->getLeft()->applyFromArray($pStyles['left']);
|
||||
@ -335,7 +321,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Left
|
||||
*
|
||||
@ -344,7 +330,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
public function getLeft() {
|
||||
return $this->_left;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Right
|
||||
*
|
||||
@ -353,7 +339,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
public function getRight() {
|
||||
return $this->_right;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Top
|
||||
*
|
||||
@ -362,7 +348,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
public function getTop() {
|
||||
return $this->_top;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Bottom
|
||||
*
|
||||
@ -380,7 +366,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
public function getDiagonal() {
|
||||
return $this->_diagonal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get AllBorders (pseudo-border). Only applies to supervisor.
|
||||
*
|
||||
@ -393,7 +379,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_allBorders;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Outline (pseudo-border). Only applies to supervisor.
|
||||
*
|
||||
@ -406,7 +392,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_outline;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Inside (pseudo-border). Only applies to supervisor.
|
||||
*
|
||||
@ -419,7 +405,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_inside;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Vertical (pseudo-border). Only applies to supervisor.
|
||||
*
|
||||
@ -432,7 +418,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_vertical;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Horizontal (pseudo-border). Only applies to supervisor.
|
||||
*
|
||||
@ -445,7 +431,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_horizontal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get DiagonalDirection
|
||||
*
|
||||
@ -457,7 +443,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_diagonalDirection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set DiagonalDirection
|
||||
*
|
||||
@ -470,18 +456,18 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('diagonaldirection' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_diagonalDirection = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getHashcode();
|
||||
@ -496,38 +482,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
|
||||
@ -2,48 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Style_Color
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
{
|
||||
@ -58,14 +46,14 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
const COLOR_DARKGREEN = 'FF008000';
|
||||
const COLOR_YELLOW = 'FFFFFF00';
|
||||
const COLOR_DARKYELLOW = 'FF808000';
|
||||
|
||||
|
||||
/**
|
||||
* Indexed colors array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_indexedColors;
|
||||
|
||||
|
||||
/**
|
||||
* ARGB - Alpha RGB
|
||||
*
|
||||
@ -96,7 +84,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Style_Color
|
||||
*
|
||||
*
|
||||
* @param string $pARGB
|
||||
*/
|
||||
public function __construct($pARGB = PHPExcel_Style_Color::COLOR_BLACK, $isSupervisor = false)
|
||||
@ -107,7 +95,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
// Initialise values
|
||||
$this->_argb = $pARGB;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bind parent. Only used for supervisor
|
||||
*
|
||||
@ -171,9 +159,9 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXSelectedCells()
|
||||
public function getSelectedCells()
|
||||
{
|
||||
return $this->getActiveSheet()->getXSelectedCells();
|
||||
return $this->getActiveSheet()->getSelectedCells();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,9 +170,9 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXActiveCell()
|
||||
public function getActiveCell()
|
||||
{
|
||||
return $this->getActiveSheet()->getXActiveCell();
|
||||
return $this->getActiveSheet()->getActiveCell();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,11 +202,11 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->getColor()->applyFromArray( array('rgb' => '808080') );
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_Color
|
||||
@ -226,7 +214,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
public function applyFromArray($pStyles = null) {
|
||||
if (is_array($pStyles)) {
|
||||
if ($this->_isSupervisor) {
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
} else {
|
||||
if (array_key_exists('rgb', $pStyles)) {
|
||||
$this->setRGB($pStyles['rgb']);
|
||||
@ -240,7 +228,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get ARGB
|
||||
*
|
||||
@ -252,7 +240,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_argb;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set ARGB
|
||||
*
|
||||
@ -265,13 +253,13 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('argb' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_argb = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get RGB
|
||||
*
|
||||
@ -283,7 +271,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
}
|
||||
return substr($this->_argb, 2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set RGB
|
||||
*
|
||||
@ -296,23 +284,23 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('argb' => 'FF' . $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_argb = 'FF' . $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get indexed color
|
||||
*
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return PHPExcel_Style_Color
|
||||
*/
|
||||
public static function indexedColor($pIndex) {
|
||||
// Clean parameter
|
||||
$pIndex = intval($pIndex);
|
||||
|
||||
|
||||
// Indexed colors
|
||||
if (is_null(self::$_indexedColors)) {
|
||||
self::$_indexedColors = array();
|
||||
@ -381,11 +369,11 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
self::$_indexedColors[] = '00333399';
|
||||
self::$_indexedColors[] = '00333333';
|
||||
}
|
||||
|
||||
|
||||
if (array_key_exists($pIndex, self::$_indexedColors)) {
|
||||
return new PHPExcel_Style_Color(self::$_indexedColors[$pIndex]);
|
||||
}
|
||||
|
||||
|
||||
return new PHPExcel_Style_Color();
|
||||
}
|
||||
|
||||
@ -393,7 +381,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getHashCode();
|
||||
@ -403,38 +391,7 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
|
||||
@ -2,51 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Style */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style.php';
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Style_Conditional
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
{
|
||||
@ -55,7 +40,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
const CONDITION_CELLIS = 'cellIs';
|
||||
const CONDITION_CONTAINSTEXT = 'containsText';
|
||||
const CONDITION_EXPRESSION = 'expression';
|
||||
|
||||
|
||||
/* Operator types */
|
||||
const OPERATOR_NONE = '';
|
||||
const OPERATOR_BEGINSWITH = 'beginsWith';
|
||||
@ -69,42 +54,42 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
const OPERATOR_CONTAINSTEXT = 'containsText';
|
||||
const OPERATOR_NOTCONTAINS = 'notContains';
|
||||
const OPERATOR_BETWEEN = 'between';
|
||||
|
||||
|
||||
/**
|
||||
* Condition type
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_conditionType;
|
||||
|
||||
|
||||
/**
|
||||
* Operator type
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_operatorType;
|
||||
|
||||
|
||||
/**
|
||||
* Text
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_text;
|
||||
|
||||
|
||||
/**
|
||||
* Condition
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $_condition = array();
|
||||
|
||||
|
||||
/**
|
||||
* Style
|
||||
*
|
||||
*
|
||||
* @var PHPExcel_Style
|
||||
*/
|
||||
private $_style;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Style_Conditional
|
||||
*/
|
||||
@ -117,7 +102,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
$this->_condition = array();
|
||||
$this->_style = new PHPExcel_Style();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Condition type
|
||||
*
|
||||
@ -126,7 +111,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
public function getConditionType() {
|
||||
return $this->_conditionType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Condition type
|
||||
*
|
||||
@ -137,7 +122,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
$this->_conditionType = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Operator type
|
||||
*
|
||||
@ -146,7 +131,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
public function getOperatorType() {
|
||||
return $this->_operatorType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Operator type
|
||||
*
|
||||
@ -157,7 +142,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
$this->_operatorType = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
@ -166,7 +151,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
public function getText() {
|
||||
return $this->_text;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
@ -177,7 +162,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
$this->_text = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Condition
|
||||
*
|
||||
@ -188,10 +173,10 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
if (isset($this->_condition[0])) {
|
||||
return $this->_condition[0];
|
||||
}
|
||||
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Condition
|
||||
*
|
||||
@ -202,10 +187,10 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
public function setCondition($pValue = '') {
|
||||
if (!is_array($pValue))
|
||||
$pValue = array($pValue);
|
||||
|
||||
|
||||
return $this->setConditions($pValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Conditions
|
||||
*
|
||||
@ -214,7 +199,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
public function getConditions() {
|
||||
return $this->_condition;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Conditions
|
||||
*
|
||||
@ -224,11 +209,11 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
public function setConditions($pValue) {
|
||||
if (!is_array($pValue))
|
||||
$pValue = array($pValue);
|
||||
|
||||
|
||||
$this->_condition = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Condition
|
||||
*
|
||||
@ -239,7 +224,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
$this->_condition[] = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Style
|
||||
*
|
||||
@ -248,7 +233,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
public function getStyle() {
|
||||
return $this->_style;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Style
|
||||
*
|
||||
@ -265,7 +250,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode() {
|
||||
return md5(
|
||||
$this->_conditionType
|
||||
@ -275,38 +260,7 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
|
||||
@ -2,51 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Style_Color */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Style_Fill
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
{
|
||||
@ -79,28 +64,28 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
* @var string
|
||||
*/
|
||||
private $_fillType;
|
||||
|
||||
|
||||
/**
|
||||
* Rotation
|
||||
*
|
||||
* @var double
|
||||
*/
|
||||
private $_rotation;
|
||||
|
||||
|
||||
/**
|
||||
* Start color
|
||||
*
|
||||
*
|
||||
* @var PHPExcel_Style_Color
|
||||
*/
|
||||
private $_startColor;
|
||||
|
||||
|
||||
/**
|
||||
* End color
|
||||
*
|
||||
*
|
||||
* @var PHPExcel_Style_Color
|
||||
*/
|
||||
private $_endColor;
|
||||
|
||||
|
||||
/**
|
||||
* Parent Borders
|
||||
*
|
||||
@ -192,9 +177,9 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXSelectedCells()
|
||||
public function getSelectedCells()
|
||||
{
|
||||
return $this->getActiveSheet()->getXSelectedCells();
|
||||
return $this->getActiveSheet()->getSelectedCells();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,9 +188,9 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXActiveCell()
|
||||
public function getActiveCell()
|
||||
{
|
||||
return $this->getActiveSheet()->getXActiveCell();
|
||||
return $this->getActiveSheet()->getActiveCell();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,7 +206,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFill()->applyFromArray(
|
||||
* array(
|
||||
@ -236,7 +221,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_Fill
|
||||
@ -244,7 +229,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
public function applyFromArray($pStyles = null) {
|
||||
if (is_array($pStyles)) {
|
||||
if ($this->_isSupervisor) {
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
} else {
|
||||
if (array_key_exists('type', $pStyles)) {
|
||||
$this->setFillType($pStyles['type']);
|
||||
@ -267,7 +252,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Fill Type
|
||||
*
|
||||
@ -279,7 +264,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_fillType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Fill Type
|
||||
*
|
||||
@ -289,13 +274,13 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
public function setFillType($pValue = PHPExcel_Style_Fill::FILL_NONE) {
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('type' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_fillType = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Rotation
|
||||
*
|
||||
@ -307,7 +292,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_rotation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Rotation
|
||||
*
|
||||
@ -317,13 +302,13 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
public function setRotation($pValue = 0) {
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('rotation' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_rotation = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Start Color
|
||||
*
|
||||
@ -332,7 +317,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
public function getStartColor() {
|
||||
return $this->_startColor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Start Color
|
||||
*
|
||||
@ -343,16 +328,16 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
public function setStartColor(PHPExcel_Style_Color $pValue = null) {
|
||||
// make sure parameter is a real color and not a supervisor
|
||||
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
|
||||
|
||||
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStartColor()->getStyleArray(array('argb' => $color->getARGB()));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_startColor = $color;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get End Color
|
||||
*
|
||||
@ -361,7 +346,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
public function getEndColor() {
|
||||
return $this->_endColor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set End Color
|
||||
*
|
||||
@ -372,10 +357,10 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
public function setEndColor(PHPExcel_Style_Color $pValue = null) {
|
||||
// make sure parameter is a real color and not a supervisor
|
||||
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
|
||||
|
||||
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getEndColor()->getStyleArray(array('argb' => $color->getARGB()));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_endColor = $color;
|
||||
}
|
||||
@ -386,7 +371,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getHashCode();
|
||||
@ -399,38 +384,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
|
||||
@ -2,51 +2,36 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 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 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Style_Color */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Style_Font
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
{
|
||||
@ -56,63 +41,63 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
const UNDERLINE_DOUBLEACCOUNTING = 'doubleAccounting';
|
||||
const UNDERLINE_SINGLE = 'single';
|
||||
const UNDERLINE_SINGLEACCOUNTING = 'singleAccounting';
|
||||
|
||||
|
||||
/**
|
||||
* Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_name;
|
||||
|
||||
|
||||
/**
|
||||
* Bold
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_bold;
|
||||
|
||||
|
||||
/**
|
||||
* Italic
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_italic;
|
||||
|
||||
|
||||
/**
|
||||
* Superscript
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_superScript;
|
||||
|
||||
|
||||
/**
|
||||
* Subscript
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_subScript;
|
||||
|
||||
|
||||
/**
|
||||
* Underline
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_underline;
|
||||
|
||||
|
||||
/**
|
||||
* Strikethrough
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_strikethrough;
|
||||
|
||||
|
||||
/**
|
||||
* Foreground color
|
||||
*
|
||||
*
|
||||
* @var PHPExcel_Style_Color
|
||||
*/
|
||||
private $_color;
|
||||
|
||||
private $_color;
|
||||
|
||||
/**
|
||||
* Parent Borders
|
||||
*
|
||||
@ -179,7 +164,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
{
|
||||
return $this->_isSupervisor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the shared style component for the currently active cell in currently active sheet.
|
||||
* Only used for style supervisor
|
||||
@ -207,9 +192,9 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXSelectedCells()
|
||||
public function getSelectedCells()
|
||||
{
|
||||
return $this->getActiveSheet()->getXSelectedCells();
|
||||
return $this->getActiveSheet()->getSelectedCells();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,9 +203,9 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXActiveCell()
|
||||
public function getActiveCell()
|
||||
{
|
||||
return $this->getActiveSheet()->getXActiveCell();
|
||||
return $this->getActiveSheet()->getActiveCell();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,7 +221,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getFont()->applyFromArray(
|
||||
* array(
|
||||
@ -251,7 +236,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_Font
|
||||
@ -259,7 +244,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
public function applyFromArray($pStyles = null) {
|
||||
if (is_array($pStyles)) {
|
||||
if ($this->_isSupervisor) {
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
} else {
|
||||
if (array_key_exists('name', $pStyles)) {
|
||||
$this->setName($pStyles['name']);
|
||||
@ -294,7 +279,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
@ -306,7 +291,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Name
|
||||
*
|
||||
@ -319,13 +304,13 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('name' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_name = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Size
|
||||
*
|
||||
@ -337,7 +322,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_size;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Size
|
||||
*
|
||||
@ -350,13 +335,13 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('size' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_size = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Bold
|
||||
*
|
||||
@ -368,7 +353,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_bold;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Bold
|
||||
*
|
||||
@ -381,13 +366,13 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('bold' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_bold = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Italic
|
||||
*
|
||||
@ -399,7 +384,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_italic;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Italic
|
||||
*
|
||||
@ -412,13 +397,13 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('italic' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_italic = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get SuperScript
|
||||
*
|
||||
@ -430,7 +415,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_superScript;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set SuperScript
|
||||
*
|
||||
@ -443,14 +428,14 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('superScript' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_superScript = $pValue;
|
||||
$this->_subScript = !$pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get SubScript
|
||||
*
|
||||
@ -462,7 +447,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_subScript;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set SubScript
|
||||
*
|
||||
@ -475,14 +460,14 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('subScript' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_subScript = $pValue;
|
||||
$this->_superScript = !$pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Underline
|
||||
*
|
||||
@ -494,7 +479,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_underline;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Underline
|
||||
*
|
||||
@ -507,13 +492,13 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('underline' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_underline = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Striketrough
|
||||
*
|
||||
@ -523,7 +508,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
public function getStriketrough() {
|
||||
return $this->getStrikethrough();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Striketrough
|
||||
*
|
||||
@ -534,7 +519,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
public function setStriketrough($pValue = false) {
|
||||
return $this->setStrikethrough($pValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Strikethrough
|
||||
*
|
||||
@ -546,7 +531,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
return $this->_strikethrough;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Strikethrough
|
||||
*
|
||||
@ -559,7 +544,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('strike' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_strikethrough = $pValue;
|
||||
}
|
||||
@ -574,7 +559,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
public function getColor() {
|
||||
return $this->_color;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Color
|
||||
*
|
||||
@ -585,10 +570,10 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
public function setColor(PHPExcel_Style_Color $pValue = null) {
|
||||
// make sure parameter is a real color and not a supervisor
|
||||
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
|
||||
|
||||
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getColor()->getStyleArray(array('argb' => $color->getARGB()));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_color = $color;
|
||||
}
|
||||
@ -599,7 +584,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
*/
|
||||
public function getHashCode() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getHashCode();
|
||||
@ -617,38 +602,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -20,36 +20,18 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.3c, 2010-06-01
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_IComparable */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
|
||||
/** PHPExcel_Shared_Date */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Date.php';
|
||||
|
||||
/** PHPExcel_Calculation_Functions */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Functions.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Style_NumberFormat
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Style
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
{
|
||||
@ -143,17 +125,17 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
private $_parent;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
public function __construct($isSupervisor = false)
|
||||
{
|
||||
// Supervisor?
|
||||
* Create a new PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
public function __construct($isSupervisor = false)
|
||||
{
|
||||
// Supervisor?
|
||||
$this->_isSupervisor = $isSupervisor;
|
||||
|
||||
// Initialise values
|
||||
$this->_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
|
||||
$this->_builtInFormatCode = 0;
|
||||
}
|
||||
// Initialise values
|
||||
$this->_formatCode = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
|
||||
$this->_builtInFormatCode = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind parent. Only used for supervisor
|
||||
@ -203,9 +185,9 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXSelectedCells()
|
||||
public function getSelectedCells()
|
||||
{
|
||||
return $this->getActiveSheet()->getXSelectedCells();
|
||||
return $this->getActiveSheet()->getSelectedCells();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,9 +196,9 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXActiveCell()
|
||||
public function getActiveCell()
|
||||
{
|
||||
return $this->getActiveSheet()->getXActiveCell();
|
||||
return $this->getActiveSheet()->getActiveCell();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,25 +212,26 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
return array('numberformat' => $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray(
|
||||
* array(
|
||||
* 'code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
public function applyFromArray($pStyles = null) {
|
||||
/**
|
||||
* Apply styles from array
|
||||
*
|
||||
* <code>
|
||||
* $objPHPExcel->getActiveSheet()->getStyle('B2')->getNumberFormat()->applyFromArray(
|
||||
* array(
|
||||
* 'code' => PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE
|
||||
* )
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* @param array $pStyles Array containing style information
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
public function applyFromArray($pStyles = null)
|
||||
{
|
||||
if (is_array($pStyles)) {
|
||||
if ($this->_isSupervisor) {
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
|
||||
} else {
|
||||
if (array_key_exists('code', $pStyles)) {
|
||||
$this->setFormatCode($pStyles['code']);
|
||||
@ -260,79 +243,83 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Format Code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormatCode() {
|
||||
/**
|
||||
* Get Format Code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormatCode()
|
||||
{
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getFormatCode();
|
||||
}
|
||||
if ($this->_builtInFormatCode !== false)
|
||||
{
|
||||
return self::builtInFormatCode($this->_builtInFormatCode);
|
||||
}
|
||||
return $this->_formatCode;
|
||||
}
|
||||
if ($this->_builtInFormatCode !== false)
|
||||
{
|
||||
return self::builtInFormatCode($this->_builtInFormatCode);
|
||||
}
|
||||
return $this->_formatCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Format Code
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
public function setFormatCode($pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL) {
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
|
||||
}
|
||||
/**
|
||||
* Set Format Code
|
||||
*
|
||||
* @param string $pValue
|
||||
* @return PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
public function setFormatCode($pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL)
|
||||
{
|
||||
if ($pValue == '') {
|
||||
$pValue = PHPExcel_Style_NumberFormat::FORMAT_GENERAL;
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('code' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_formatCode = $pValue;
|
||||
$this->_builtInFormatCode = self::builtInFormatCodeIndex($pValue);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Built-In Format Code
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBuiltInFormatCode() {
|
||||
* Get Built-In Format Code
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBuiltInFormatCode()
|
||||
{
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getBuiltInFormatCode();
|
||||
}
|
||||
return $this->_builtInFormatCode;
|
||||
}
|
||||
return $this->_builtInFormatCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Built-In Format Code
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
public function setBuiltInFormatCode($pValue = 0) {
|
||||
/**
|
||||
* Set Built-In Format Code
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPExcel_Style_NumberFormat
|
||||
*/
|
||||
public function setBuiltInFormatCode($pValue = 0)
|
||||
{
|
||||
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('code' => self::builtInFormatCode($pValue)));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_builtInFormatCode = $pValue;
|
||||
$this->_formatCode = self::builtInFormatCode($pValue);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill built-in format codes
|
||||
*/
|
||||
private static function fillBuiltInFormatCodes()
|
||||
{
|
||||
// Built-in format codes
|
||||
if (is_null(self::$_builtInFormats)) {
|
||||
/**
|
||||
* Fill built-in format codes
|
||||
*/
|
||||
private static function fillBuiltInFormatCodes()
|
||||
{
|
||||
// Built-in format codes
|
||||
if (is_null(self::$_builtInFormats)) {
|
||||
self::$_builtInFormats = array();
|
||||
|
||||
// General
|
||||
@ -388,99 +375,72 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
|
||||
// Flip array (for faster lookups)
|
||||
self::$_flippedBuiltInFormats = array_flip(self::$_builtInFormats);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get built-in format code
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return string
|
||||
*/
|
||||
public static function builtInFormatCode($pIndex) {
|
||||
// Clean parameter
|
||||
/**
|
||||
* Get built-in format code
|
||||
*
|
||||
* @param int $pIndex
|
||||
* @return string
|
||||
*/
|
||||
public static function builtInFormatCode($pIndex)
|
||||
{
|
||||
// Clean parameter
|
||||
$pIndex = intval($pIndex);
|
||||
|
||||
// Ensure built-in format codes are available
|
||||
self::fillBuiltInFormatCodes();
|
||||
self::fillBuiltInFormatCodes();
|
||||
|
||||
// Lookup format code
|
||||
if (array_key_exists($pIndex, self::$_builtInFormats)) {
|
||||
return self::$_builtInFormats[$pIndex];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get built-in format code index
|
||||
*
|
||||
* @param string $formatCode
|
||||
* @return int|boolean
|
||||
*/
|
||||
public static function builtInFormatCodeIndex($formatCode) {
|
||||
// Ensure built-in format codes are available
|
||||
self::fillBuiltInFormatCodes();
|
||||
/**
|
||||
* Get built-in format code index
|
||||
*
|
||||
* @param string $formatCode
|
||||
* @return int|boolean
|
||||
*/
|
||||
public static function builtInFormatCodeIndex($formatCode)
|
||||
{
|
||||
// Ensure built-in format codes are available
|
||||
self::fillBuiltInFormatCodes();
|
||||
|
||||
// Lookup format code
|
||||
if (array_key_exists($formatCode, self::$_flippedBuiltInFormats)) {
|
||||
return self::$_flippedBuiltInFormats[$formatCode];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
* @return string Hash code
|
||||
*/
|
||||
public function getHashCode() {
|
||||
public function getHashCode()
|
||||
{
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getHashCode();
|
||||
}
|
||||
return md5(
|
||||
$this->_formatCode
|
||||
. $this->_builtInFormatCode
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash index
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_hashIndex;
|
||||
|
||||
/**
|
||||
* Get hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @return string Hash index
|
||||
*/
|
||||
public function getHashIndex() {
|
||||
return $this->_hashIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hash index
|
||||
*
|
||||
* Note that this index may vary during script execution! Only reliable moment is
|
||||
* while doing a write of a workbook and when changes are not allowed.
|
||||
*
|
||||
* @param string $value Hash index
|
||||
*/
|
||||
public function setHashIndex($value) {
|
||||
$this->_hashIndex = $value;
|
||||
return md5(
|
||||
$this->_formatCode
|
||||
. $this->_builtInFormatCode
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
public function __clone() {
|
||||
public function __clone()
|
||||
{
|
||||
$vars = get_object_vars($this);
|
||||
foreach ($vars as $key => $value) {
|
||||
if (is_object($value)) {
|
||||
@ -491,15 +451,60 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
}
|
||||
}
|
||||
|
||||
private static $_dateFormatReplacements = array(
|
||||
// first remove escapes related to non-format characters
|
||||
'\\' => '',
|
||||
// 12-hour suffix
|
||||
'am/pm' => 'A',
|
||||
// 4-digit year
|
||||
'yyyy' => 'Y',
|
||||
// 2-digit year
|
||||
'yy' => 'y',
|
||||
// first letter of month - no php equivalent
|
||||
'mmmmm' => 'M',
|
||||
// full month name
|
||||
'mmmm' => 'F',
|
||||
// short month name
|
||||
'mmm' => 'M',
|
||||
// mm is minutes if time or month w/leading zero
|
||||
':mm' => ':i',
|
||||
// month leading zero
|
||||
'mm' => 'm',
|
||||
// month no leading zero
|
||||
'm' => 'n',
|
||||
// full day of week name
|
||||
'dddd' => 'l',
|
||||
// short day of week name
|
||||
'ddd' => 'D',
|
||||
// days leading zero
|
||||
'dd' => 'd',
|
||||
// days no leading zero
|
||||
'd' => 'j',
|
||||
// seconds
|
||||
'ss' => 's',
|
||||
// fractional seconds - no php equivalent
|
||||
'.s' => ''
|
||||
);
|
||||
private static $_dateFormatReplacements24 = array(
|
||||
'hh' => 'H',
|
||||
'h' => 'G'
|
||||
);
|
||||
private static $_dateFormatReplacements12 = array(
|
||||
'hh' => 'h',
|
||||
'h' => 'g'
|
||||
);
|
||||
|
||||
/**
|
||||
* Convert a value in a pre-defined format to a PHP string
|
||||
*
|
||||
* @param mixed $value Value to format
|
||||
* @param string $format Format code
|
||||
* @param array $callBack Callback function for additional formatting of string
|
||||
* @return string Formatted string
|
||||
*/
|
||||
public static function toFormattedString($value = '', $format = '') {
|
||||
// For now we do not treat strings although part 4 of a format code affects strings
|
||||
public static function toFormattedString($value = '', $format = '', $callBack = null)
|
||||
{
|
||||
// For now we do not treat strings although section 4 of a format code affects strings
|
||||
if (!is_numeric($value)) return $value;
|
||||
|
||||
// For 'General' format code, we just pass the value although this is not entirely the way Excel does it,
|
||||
@ -508,104 +513,130 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
return $value;
|
||||
}
|
||||
|
||||
// Get the parts, there can be up to four parts
|
||||
$parts = explode(';', $format);
|
||||
// Get the sections, there can be up to four sections
|
||||
$sections = explode(';', $format);
|
||||
|
||||
// We should really fetch the relevant part depending on whether we have a positive number,
|
||||
// negative number, zero, or text. But for now we just use first part
|
||||
$format = $parts[0];
|
||||
// Fetch the relevant section depending on whether number is positive, negative, or zero?
|
||||
// Text not supported yet.
|
||||
// Here is how the sections apply to various values in Excel:
|
||||
// 1 section: [POSITIVE/NEGATIVE/ZERO/TEXT]
|
||||
// 2 sections: [POSITIVE/ZERO/TEXT] [NEGATIVE]
|
||||
// 3 sections: [POSITIVE/TEXT] [NEGATIVE] [ZERO]
|
||||
// 4 sections: [POSITIVE] [NEGATIVE] [ZERO] [TEXT]
|
||||
switch (count($sections)) {
|
||||
case 1:
|
||||
$format = $sections[0];
|
||||
break;
|
||||
|
||||
if (preg_match("/^[hmsdy]/i", $format)) { // custom datetime format
|
||||
case 2:
|
||||
$format = ($value >= 0) ? $sections[0] : $sections[1];
|
||||
$value = abs($value); // Use the absolute value
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$format = ($value > 0) ?
|
||||
$sections[0] : ( ($value < 0) ?
|
||||
$sections[1] : $sections[2]);
|
||||
$value = abs($value); // Use the absolute value
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$format = ($value > 0) ?
|
||||
$sections[0] : ( ($value < 0) ?
|
||||
$sections[1] : $sections[2]);
|
||||
$value = abs($value); // Use the absolute value
|
||||
break;
|
||||
|
||||
default:
|
||||
// something is wrong, just use first section
|
||||
$format = $sections[0];
|
||||
break;
|
||||
}
|
||||
|
||||
// Save format with color information for later use below
|
||||
$formatColor = $format;
|
||||
|
||||
// Strip color information
|
||||
$color_regex = '/^\\[[a-zA-Z]+\\]/';
|
||||
$format = preg_replace($color_regex, '', $format);
|
||||
|
||||
// Let's begin inspecting the format and converting the value to a formatted string
|
||||
if (preg_match('/^(\[\$[A-Z]*-[0-9A-F]*\])*[hmsdy]/i', $format)) { // datetime format
|
||||
// dvc: convert Excel formats to PHP date formats
|
||||
// first remove escapes related to non-format characters
|
||||
|
||||
// strip off first part containing e.g. [$-F800] or [$USD-409]
|
||||
// general syntax: [$<Currency string>-<language info>]
|
||||
// language info is in hexadecimal
|
||||
$format = preg_replace('/^(\[\$[A-Z]*-[0-9A-F]*\])/i', '', $format);
|
||||
|
||||
// OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case
|
||||
$format = strtolower($format);
|
||||
|
||||
$format = str_replace('\\', '', $format);
|
||||
|
||||
// 4-digit year
|
||||
$format = str_replace('yyyy', 'Y', $format);
|
||||
// 2-digit year
|
||||
$format = str_replace('yy', 'y', $format);
|
||||
// first letter of month - no php equivalent
|
||||
$format = str_replace('mmmmm', 'M', $format);
|
||||
// full month name
|
||||
$format = str_replace('mmmm', 'F', $format);
|
||||
// short month name
|
||||
$format = str_replace('mmm', 'M', $format);
|
||||
// mm is minutes if time or month w/leading zero
|
||||
$format = str_replace(':mm', ':i', $format);
|
||||
// tmp place holder
|
||||
$format = str_replace('mm', 'x', $format);
|
||||
// month no leading zero
|
||||
$format = str_replace('m', 'n', $format);
|
||||
// month leading zero
|
||||
$format = str_replace('x', 'm', $format);
|
||||
// 12-hour suffix
|
||||
$format = str_replace('am/pm', 'A', $format);
|
||||
// full day of week name
|
||||
$format = str_replace('dddd', 'l', $format);
|
||||
// short day of week name
|
||||
$format = str_replace('ddd', 'D', $format);
|
||||
// tmp place holder
|
||||
$format = str_replace('dd', 'x', $format);
|
||||
// days no leading zero
|
||||
$format = str_replace('d', 'j', $format);
|
||||
// days leading zero
|
||||
$format = str_replace('x', 'd', $format);
|
||||
// seconds
|
||||
$format = str_replace('ss', 's', $format);
|
||||
// fractional seconds - no php equivalent
|
||||
$format = str_replace('.s', '', $format);
|
||||
|
||||
if (!strpos($format,'A')) { // 24-hour format
|
||||
$format = str_replace('h', 'H', $format);
|
||||
$format = strtr($format,self::$_dateFormatReplacements);
|
||||
if (!strpos($format,'A')) { // 24-hour time format
|
||||
$format = strtr($format,self::$_dateFormatReplacements24);
|
||||
} else { // 12-hour time format
|
||||
$format = strtr($format,self::$_dateFormatReplacements12);
|
||||
}
|
||||
|
||||
return gmdate($format, PHPExcel_Shared_Date::ExcelToPHP($value));
|
||||
$dateObj = PHPExcel_Shared_Date::ExcelToPHPObject($value);
|
||||
$value = $dateObj->format($format);
|
||||
|
||||
} else if (preg_match('/%$/', $format)) { // % number format
|
||||
if ($format === self::FORMAT_PERCENTAGE) {
|
||||
return round( (100 * $value), 0) . '%';
|
||||
}
|
||||
if (preg_match('/\.[#0]+/i', $format, $m)) {
|
||||
$s = substr($m[0], 0, 1) . (strlen($m[0]) - 1);
|
||||
$format = str_replace($m[0], $s, $format);
|
||||
}
|
||||
if (preg_match('/^[#0]+/', $format, $m)) {
|
||||
$format = str_replace($m[0], strlen($m[0]), $format);
|
||||
}
|
||||
$format = '%' . str_replace('%', 'f%%', $format);
|
||||
$value = round( (100 * $value), 0) . '%';
|
||||
} else {
|
||||
if (preg_match('/\.[#0]+/i', $format, $m)) {
|
||||
$s = substr($m[0], 0, 1) . (strlen($m[0]) - 1);
|
||||
$format = str_replace($m[0], $s, $format);
|
||||
}
|
||||
if (preg_match('/^[#0]+/', $format, $m)) {
|
||||
$format = str_replace($m[0], strlen($m[0]), $format);
|
||||
}
|
||||
$format = '%' . str_replace('%', 'f%%', $format);
|
||||
|
||||
return sprintf($format, 100 * $value);
|
||||
$value = sprintf($format, 100 * $value);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (preg_match ("/^([0-9.,-]+)$/", $value)) {
|
||||
if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) {
|
||||
return 'EUR ' . sprintf('%1.2f', $value);
|
||||
if ($format === self::FORMAT_CURRENCY_EUR_SIMPLE) {
|
||||
$value = 'EUR ' . sprintf('%1.2f', $value);
|
||||
|
||||
} else {
|
||||
// In Excel formats, "_" is used to add spacing, which we can't do in HTML
|
||||
$format = preg_replace('/_./', '', $format);
|
||||
} else {
|
||||
// In Excel formats, "_" is used to add spacing, which we can't do in HTML
|
||||
$format = preg_replace('/_./', '', $format);
|
||||
|
||||
// Some non-number characters are escaped with \, which we don't need
|
||||
$format = preg_replace("/\\\\/", '', $format);
|
||||
// Some non-number characters are escaped with \, which we don't need
|
||||
$format = preg_replace("/\\\\/", '', $format);
|
||||
|
||||
// Some non-number strings are quoted, so we'll get rid of the quotes
|
||||
$format = preg_replace('/"/', '', $format);
|
||||
// Some non-number strings are quoted, so we'll get rid of the quotes
|
||||
$format = preg_replace('/"/', '', $format);
|
||||
|
||||
// TEMPORARY - Convert # to 0
|
||||
$format = preg_replace('/\\#/', '0', $format);
|
||||
// Find out if we need thousands separator
|
||||
// This is indicated by a comma enclosed by a digit placeholder:
|
||||
// #,# or 0,0
|
||||
$useThousands = preg_match('/(#,#|0,0)/', $format);
|
||||
if ($useThousands) {
|
||||
$format = preg_replace('/0,0/', '00', $format);
|
||||
$format = preg_replace('/#,#/', '##', $format);
|
||||
}
|
||||
|
||||
// Find out if we need thousands separator
|
||||
$useThousands = preg_match('/,/', $format);
|
||||
if ($useThousands) {
|
||||
$format = preg_replace('/,/', '', $format);
|
||||
}
|
||||
// Scale thousands, millions,...
|
||||
// This is indicated by a number of commas after a digit placeholder:
|
||||
// #, or 0.0,,
|
||||
$scale = 1; // same as no scale
|
||||
$matches = array();
|
||||
if (preg_match('/(#|0)(,+)/', $format, $matches)) {
|
||||
$scale = pow(1000, strlen($matches[2]));
|
||||
|
||||
if (preg_match('/0?.*\?\/\?/', $format, $m)) {
|
||||
//echo 'Format mask is fractional '.$format.' <br />';
|
||||
// strip the commas
|
||||
$format = preg_replace('/0,+/', '0', $format);
|
||||
$format = preg_replace('/#,+/', '#', $format);
|
||||
}
|
||||
|
||||
if (preg_match('/#?.*\?\/\?/', $format, $m)) {
|
||||
//echo 'Format mask is fractional '.$format.' <br />';
|
||||
if ($value != (int)$value) {
|
||||
$sign = ($value < 0) ? '-' : '';
|
||||
|
||||
$integerPart = floor(abs($value));
|
||||
@ -618,41 +649,60 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
$adjustedDecimalPart = $decimalPart/$GCD;
|
||||
$adjustedDecimalDivisor = $decimalDivisor/$GCD;
|
||||
|
||||
if (strpos($format,'0') !== false) {
|
||||
if ((strpos($format,'0') !== false) || (substr($format,0,3) == '? ?')) {
|
||||
if ($integerPart == 0) { $integerPart = ''; }
|
||||
$value = "$sign$integerPart $adjustedDecimalPart/$adjustedDecimalDivisor";
|
||||
} else {
|
||||
$adjustedDecimalPart += $integerPart * $adjustedDecimalDivisor;
|
||||
$value = "$sign$adjustedDecimalPart/$adjustedDecimalDivisor";
|
||||
}
|
||||
|
||||
} else {
|
||||
// Handle the number itself
|
||||
$number_regex = "/(\d+)(\.?)(\d*)/";
|
||||
if (preg_match($number_regex, $format, $matches)) {
|
||||
$left = $matches[1];
|
||||
$dec = $matches[2];
|
||||
$right = $matches[3];
|
||||
if ($useThousands) {
|
||||
$localeconv = localeconv();
|
||||
if (($localeconv['thousands_sep'] == '') || ($localeconv['decimal_point'] == '')) {
|
||||
$value = number_format($value, strlen($right), $localeconv['mon_decimal_point'], $localeconv['mon_thousands_sep']);
|
||||
} else {
|
||||
$value = number_format($value, strlen($right), $localeconv['decimal_point'], $localeconv['thousands_sep']);
|
||||
}
|
||||
} else {
|
||||
$sprintf_pattern = "%1." . strlen($right) . "f";
|
||||
$value = sprintf($sprintf_pattern, $value);
|
||||
}
|
||||
$value = preg_replace($number_regex, $value, $format);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
} else {
|
||||
// Handle the number itself
|
||||
|
||||
// scale number
|
||||
$value = $value / $scale;
|
||||
|
||||
// Strip #
|
||||
$format = preg_replace('/\\#/', '', $format);
|
||||
|
||||
$number_regex = "/(0+)(\.?)(0*)/";
|
||||
$matches = array();
|
||||
if (preg_match($number_regex, $format, $matches)) {
|
||||
$left = $matches[1];
|
||||
$dec = $matches[2];
|
||||
$right = $matches[3];
|
||||
|
||||
// minimun width of formatted number (including dot)
|
||||
$minWidth = strlen($left) + strlen($dec) + strlen($right);
|
||||
|
||||
if ($useThousands) {
|
||||
$value = number_format(
|
||||
$value
|
||||
, strlen($right)
|
||||
, PHPExcel_Shared_String::getDecimalSeparator()
|
||||
, PHPExcel_Shared_String::getThousandsSeparator()
|
||||
);
|
||||
|
||||
} else {
|
||||
$sprintf_pattern = "%0$minWidth." . strlen($right) . "f";
|
||||
$value = sprintf($sprintf_pattern, $value);
|
||||
}
|
||||
|
||||
$value = preg_replace($number_regex, $value, $format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
// Additional formatting provided by callback function
|
||||
if ($callBack !== null) {
|
||||
list($writerInstance, $function) = $callBack;
|
||||
$value = $writerInstance->$function($value, $formatColor);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user