upgrade to PHPExcel 1.7.2
This commit is contained in:
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/WorksheetIterator.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -212,6 +212,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 +231,14 @@ class PHPExcel
|
||||
0,
|
||||
array($pSheet)
|
||||
);
|
||||
|
||||
// Adjust active sheet index if necessary
|
||||
if ($this->_activeSheetIndex >= $iSheetIndex) {
|
||||
++$this->_activeSheetIndex;
|
||||
}
|
||||
|
||||
}
|
||||
return $pSheet;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,10 +399,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.");
|
||||
}
|
||||
@@ -414,7 +424,7 @@ class PHPExcel
|
||||
$cell->setXfIndex( $cell->getXfIndex() + $countCellXfs );
|
||||
}
|
||||
|
||||
return $this->addSheet($pSheet);
|
||||
return $this->addSheet($pSheet, $iSheetIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -700,7 +710,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 +722,27 @@ class PHPExcel
|
||||
}
|
||||
|
||||
foreach ($this->getWorksheetIterator() as $sheet) {
|
||||
|
||||
// from cells
|
||||
foreach ($sheet->getCellCollection(false) as $cell) {
|
||||
++$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 +754,35 @@ 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) {
|
||||
echo $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) {
|
||||
|
||||
// for all cells
|
||||
foreach ($sheet->getCellCollection(false) as $cell) {
|
||||
$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
|
||||
|
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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
@@ -41,7 +41,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Exception.php';
|
||||
*
|
||||
* @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 {
|
||||
/**
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/FormulaToken.php';
|
||||
*
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -136,11 +136,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 +166,7 @@ class PHPExcel_Cell
|
||||
*/
|
||||
public function getColumn()
|
||||
{
|
||||
return strtoupper($this->_column);
|
||||
return $this->_column;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,22 +221,42 @@ 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;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -492,22 +507,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.');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -745,6 +755,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;
|
||||
}
|
||||
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -124,21 +124,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
|
||||
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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Cell/DefaultValueBinder.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -82,4 +82,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -87,22 +87,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} === '=') {
|
||||
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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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_Hyperlink
|
||||
{
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
*
|
||||
* @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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -290,37 +290,6 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PasswordHasher.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -101,26 +101,10 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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,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
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -49,10 +49,10 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReader.php';
|
||||
*
|
||||
* @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
|
||||
*
|
||||
@@ -62,24 +62,27 @@ class PHPExcel_IOFactory
|
||||
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
|
||||
*/
|
||||
private static $_autoResolveClasses = array(
|
||||
'Excel2007',
|
||||
'Excel5',
|
||||
'Excel2003XML',
|
||||
'OOCalc',
|
||||
'SYLK',
|
||||
'Serialized',
|
||||
'CSV'
|
||||
'CSV',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Private constructor for PHPExcel_IOFactory
|
||||
*/
|
||||
private function __construct() { }
|
||||
|
||||
|
||||
/**
|
||||
* Get search locations
|
||||
*
|
||||
@@ -88,10 +91,10 @@ class PHPExcel_IOFactory
|
||||
public static function getSearchLocations() {
|
||||
return self::$_searchLocations;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set search locations
|
||||
*
|
||||
*
|
||||
* @param array $value
|
||||
* @throws Exception
|
||||
*/
|
||||
@@ -102,10 +105,10 @@ class PHPExcel_IOFactory
|
||||
throw new Exception('Invalid parameter passed.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add search location
|
||||
*
|
||||
*
|
||||
* @param string $type Example: IWriter
|
||||
* @param string $location Example: PHPExcel/Writer/{0}.php
|
||||
* @param string $classname Example: PHPExcel_Writer_{0}
|
||||
@@ -113,7 +116,7 @@ class PHPExcel_IOFactory
|
||||
public static function addSearchLocation($type = '', $location = '', $classname = '') {
|
||||
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Writer_IWriter
|
||||
*
|
||||
@@ -124,28 +127,28 @@ class PHPExcel_IOFactory
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create PHPExcel_Reader_IReader
|
||||
*
|
||||
@@ -155,34 +158,34 @@ class PHPExcel_IOFactory
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
|
||||
*
|
||||
* @param string $pFileName
|
||||
* @return PHPExcel
|
||||
*/
|
||||
*/
|
||||
public static function load($pFilename) {
|
||||
$reader = self::createReaderForFile($pFilename);
|
||||
return $reader->load($pFilename);
|
||||
@@ -193,9 +196,55 @@ class PHPExcel_IOFactory
|
||||
*
|
||||
* @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 ($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 +253,5 @@ class PHPExcel_IOFactory
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Could not automatically determine PHPExcel_Reader_IReader for 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
|
||||
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/ReferenceHelper.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -55,10 +55,17 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
/**
|
||||
* Input encoding
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_inputEncoding;
|
||||
|
||||
/**
|
||||
* Delimiter
|
||||
*
|
||||
@@ -98,6 +105,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
|
||||
* Create a new PHPExcel_Reader_CSV
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->_inputEncoding = 'UTF-8';
|
||||
$this->_delimiter = ',';
|
||||
$this->_enclosure = '"';
|
||||
$this->_lineEnding = PHP_EOL;
|
||||
@@ -117,9 +125,8 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,6 +162,26 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
|
||||
$this->_readFilter = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set input encoding
|
||||
*
|
||||
* @param string $pValue Input encoding
|
||||
*/
|
||||
public function setInputEncoding($pValue = 'UTF-8')
|
||||
{
|
||||
$this->_inputEncoding = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get input encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
return $this->_inputEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
@@ -181,7 +208,18 @@ 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) {
|
||||
@@ -193,6 +231,11 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
|
||||
// Unescape enclosures
|
||||
$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(
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/IReadFilter.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
|
698
libraries/PHPExcel/PHPExcel/Reader/Excel2003XML.php
Normal file
698
libraries/PHPExcel/PHPExcel/Reader/Excel2003XML.php
Normal file
@@ -0,0 +1,698 @@
|
||||
<?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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** 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_Calculation */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation.php';
|
||||
|
||||
/** PHPExcel_Reader_DefaultReadFilter */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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
|
||||
* @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 = $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()->setCellValue($columnID.$rowID,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,9 +20,9 @@
|
||||
*
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
@@ -62,7 +62,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Escher/DgContainer/SpgrContainer/S
|
||||
*
|
||||
* @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
|
||||
{
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
500
libraries/PHPExcel/PHPExcel/Reader/OOCalc.php
Normal file
500
libraries/PHPExcel/PHPExcel/Reader/OOCalc.php
Normal file
@@ -0,0 +1,500 @@
|
||||
<?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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** 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_Calculation */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation.php';
|
||||
|
||||
/** PHPExcel_Reader_DefaultReadFilter */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
|
||||
|
||||
|
||||
/**
|
||||
* 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 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
|
||||
* @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
|
||||
* @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 = $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;
|
||||
$dataValue = PHPExcel_Shared_Date::PHPToExcel(strtotime($cellDataOfficeAttributes['date-value']));
|
||||
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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
506
libraries/PHPExcel/PHPExcel/Reader/SYLK.php
Normal file
506
libraries/PHPExcel/PHPExcel/Reader/SYLK.php
Normal file
@@ -0,0 +1,506 @@
|
||||
<?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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** 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_Calculation */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation.php';
|
||||
|
||||
/** PHPExcel_Reader_DefaultReadFilter */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Reader/DefaultReadFilter.php';
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set input encoding
|
||||
*
|
||||
* @param string $pValue Input encoding
|
||||
*/
|
||||
public function setInputEncoding($pValue = 'ANSI')
|
||||
{
|
||||
$this->_inputEncoding = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get input encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInputEncoding()
|
||||
{
|
||||
return $this->_inputEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PHPExcel from file into PHPExcel instance
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @param PHPExcel $objPHPExcel
|
||||
* @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 = '';
|
||||
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
||||
$rowData = explode("\t",str_replace('<27>',';',str_replace(';',"\t",str_replace(';;','<27>',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()->setCellValue($columnLetter.$row, (($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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/File.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
|
@@ -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,10 +19,10 @@
|
||||
* 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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ 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,20 +86,20 @@ 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) {
|
||||
/**
|
||||
* 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();
|
||||
@@ -108,15 +108,15 @@ class PHPExcel_ReferenceHelper
|
||||
}*/
|
||||
$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) {
|
||||
@@ -155,7 +155,7 @@ class PHPExcel_ReferenceHelper
|
||||
// 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
|
||||
@@ -181,8 +181,8 @@ class PHPExcel_ReferenceHelper
|
||||
|
||||
|
||||
// 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 +303,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 +364,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,24 +439,28 @@ 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) {
|
||||
/**
|
||||
* 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 $cell) {
|
||||
if (!is_null($cell) && $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||
$formula = $cell->getValue();
|
||||
@@ -451,56 +471,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 +540,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,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_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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -157,7 +157,7 @@ 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();
|
||||
}
|
||||
@@ -257,37 +257,6 @@ class PHPExcel_RichText implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
@@ -18,9 +18,9 @@
|
||||
*
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
|
@@ -18,9 +18,9 @@
|
||||
*
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
|
@@ -18,9 +18,9 @@
|
||||
*
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Font.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
|
@@ -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,9 +21,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
|
||||
*
|
||||
* @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 +106,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 +135,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()
|
||||
|
||||
|
@@ -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,18 +20,30 @@
|
||||
*
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Shared_String */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Drawing
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -60,33 +72,67 @@ class PHPExcel_Shared_Drawing
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
@@ -39,12 +39,15 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
/** PHPExcel_Shared_Drawing */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Drawing.php';
|
||||
|
||||
/** PHPExcel_Shared_Font */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Font.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 +62,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 +73,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 +109,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 +130,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
|
||||
@@ -301,8 +313,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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,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,21 +20,37 @@
|
||||
*
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Shared_String */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Font
|
||||
*
|
||||
* @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;
|
||||
@@ -56,6 +72,175 @@ class PHPExcel_Shared_Font
|
||||
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
|
||||
*
|
||||
@@ -65,29 +250,120 @@ class PHPExcel_Shared_Font
|
||||
* @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);
|
||||
}
|
||||
|
||||
// If it is rich text, use rich text...
|
||||
public static function calculateColumnWidth(PHPExcel_Style_Font $font, $columnText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) {
|
||||
|
||||
// If it is rich text, use plain text
|
||||
if ($columnText instanceof PHPExcel_RichText) {
|
||||
$columnText = $columnText->getPlainText();
|
||||
}
|
||||
|
||||
// Only measure the part before the first newline character
|
||||
if (strpos($columnText, "\r") !== false) {
|
||||
$columnText = substr($columnText, 0, strpos($columnText, "\r"));
|
||||
}
|
||||
|
||||
// Only measure the part before the first newline character (is always "\n")
|
||||
if (strpos($columnText, "\n") !== false) {
|
||||
$columnText = substr($columnText, 0, strpos($columnText, "\n"));
|
||||
}
|
||||
|
||||
// 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($columnText, $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($columnText, $font, $rotation);
|
||||
|
||||
// Excel adds some padding, just use approx width of 'n' glyph
|
||||
$columnWidth += self::getTextWidthPixelsApprox('n', $font, 0);
|
||||
}
|
||||
|
||||
// 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];
|
||||
|
||||
// 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
|
||||
// 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 approximate rotated column width
|
||||
if ($rotation !== 0) {
|
||||
@@ -101,18 +377,19 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,6 +412,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 +549,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 +557,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,6 +21,8 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/LUDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/QRDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/EigenvalueDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/SingularValueDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Functions.php';
|
||||
|
||||
/*
|
||||
* Matrix class
|
||||
@@ -760,7 +762,21 @@ class Matrix {
|
||||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$this->A[$i][$j] += $M->get($i, $j);
|
||||
$validValues = True;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
|
||||
}
|
||||
if ((is_string($value)) && (!is_numeric($value))) {
|
||||
$value = trim($value,'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
|
||||
}
|
||||
if ($validValues) {
|
||||
$this->A[$i][$j] += $value;
|
||||
} else {
|
||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
@@ -832,7 +848,21 @@ class Matrix {
|
||||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$this->A[$i][$j] -= $M->get($i, $j);
|
||||
$validValues = True;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
|
||||
}
|
||||
if ((is_string($value)) && (!is_numeric($value))) {
|
||||
$value = trim($value,'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
|
||||
}
|
||||
if ($validValues) {
|
||||
$this->A[$i][$j] -= $value;
|
||||
} else {
|
||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
@@ -906,7 +936,21 @@ class Matrix {
|
||||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$this->A[$i][$j] *= $M->get($i, $j);
|
||||
$validValues = True;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
|
||||
}
|
||||
if ((is_string($value)) && (!is_numeric($value))) {
|
||||
$value = trim($value,'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
|
||||
}
|
||||
if ($validValues) {
|
||||
$this->A[$i][$j] *= $value;
|
||||
} else {
|
||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
@@ -943,7 +987,26 @@ class Matrix {
|
||||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$M->set($i, $j, $this->A[$i][$j] / $M->get($i, $j));
|
||||
$validValues = True;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
|
||||
}
|
||||
if ((is_string($value)) && (!is_numeric($value))) {
|
||||
$value = trim($value,'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
|
||||
}
|
||||
if ($validValues) {
|
||||
if ($value == 0) {
|
||||
// Trap for Divide by Zero error
|
||||
$M->set($i, $j, '#DIV/0!');
|
||||
} else {
|
||||
$M->set($i, $j, $this->A[$i][$j] / $value);
|
||||
}
|
||||
} else {
|
||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $M;
|
||||
@@ -1181,7 +1244,21 @@ class Matrix {
|
||||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$this->A[$i][$j] = pow($this->A[$i][$j],$M->get($i, $j));
|
||||
$validValues = True;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
|
||||
}
|
||||
if ((is_string($value)) && (!is_numeric($value))) {
|
||||
$value = trim($value,'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
|
||||
}
|
||||
if ($validValues) {
|
||||
$this->A[$i][$j] = pow($this->A[$i][$j],$value);
|
||||
} else {
|
||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
@@ -22,7 +22,7 @@
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
|
@@ -248,7 +248,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) {
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1));
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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,20 @@ class PHPExcel_Shared_String
|
||||
*/
|
||||
private static $_controlCharacters = array();
|
||||
|
||||
/**
|
||||
* Decimal separator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_decimalSeparator;
|
||||
|
||||
/**
|
||||
* Thousands separator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_thousandsSeparator;
|
||||
|
||||
/**
|
||||
* Is mbstring extension avalable?
|
||||
*
|
||||
@@ -60,7 +80,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);
|
||||
@@ -97,12 +117,19 @@ 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;
|
||||
// Check that iconv exists
|
||||
// Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
|
||||
// we cannot use iconv when that happens
|
||||
// Also, 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 (function_exists('iconv')
|
||||
&& @iconv('UTF-8', 'UTF-16LE', 'x')
|
||||
&& @iconv_substr('A', 0, 1, 'UTF-8') ) {
|
||||
|
||||
self::$_isIconvEnabled = true;
|
||||
} else {
|
||||
self::$_isIconvEnabled = false;
|
||||
}
|
||||
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
@@ -172,7 +199,7 @@ class PHPExcel_Shared_String
|
||||
// else, no conversion
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a string contains UTF8 data
|
||||
*
|
||||
@@ -213,7 +240,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 +266,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
|
||||
@@ -272,7 +299,7 @@ class PHPExcel_Shared_String
|
||||
// else, no conversion
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get character count. First try mbstring, then iconv, finally strlen
|
||||
*
|
||||
@@ -322,4 +349,82 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
*
|
||||
* @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 {
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ class PHPExcel_Shared_ZipStreamWrapper {
|
||||
}
|
||||
|
||||
// Parse URL
|
||||
$url = @parse_url($path);
|
||||
$url = @parse_url(str_replace('zip://', 'file://', $path));
|
||||
|
||||
// Fix URL
|
||||
if (!is_array($url)) {
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -42,7 +42,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 +84,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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -42,7 +42,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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -42,7 +42,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 +68,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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -43,7 +43,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,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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -42,7 +42,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 +76,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()
|
||||
|
@@ -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_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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -201,7 +201,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 +230,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 +241,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,204 +299,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']);
|
||||
}
|
||||
@@ -585,7 +634,7 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
* @return PHPExcel_Style_Conditional[]
|
||||
*/
|
||||
public function getConditionalStyles() {
|
||||
return $this->getActiveSheet()->getConditionalStyles($this->getXActiveCell());
|
||||
return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -596,7 +645,7 @@ 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);
|
||||
}
|
||||
}
|
||||
@@ -635,37 +684,6 @@ class PHPExcel_Style implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,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_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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -190,9 +190,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 +201,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,7 +238,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']);
|
||||
@@ -290,7 +290,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
|
||||
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;
|
||||
@@ -323,7 +323,7 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ 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;
|
||||
}
|
||||
@@ -394,7 +394,7 @@ 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;
|
||||
}
|
||||
@@ -425,7 +425,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;
|
||||
}
|
||||
@@ -458,7 +458,7 @@ 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;
|
||||
}
|
||||
@@ -485,37 +485,6 @@ class PHPExcel_Style_Alignment implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -200,9 +200,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 +211,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,7 +289,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']);
|
||||
@@ -329,7 +329,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -358,7 +358,7 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -381,37 +381,6 @@ class PHPExcel_Style_Border implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
*
|
||||
* @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,6 +54,7 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
const DIAGONAL_NONE = 0;
|
||||
const DIAGONAL_UP = 1;
|
||||
const DIAGONAL_DOWN = 2;
|
||||
const DIAGONAL_BOTH = 3;
|
||||
|
||||
/**
|
||||
* Left
|
||||
@@ -241,9 +242,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 +253,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,7 +310,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']);
|
||||
@@ -470,7 +471,7 @@ 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;
|
||||
}
|
||||
@@ -497,37 +498,6 @@ class PHPExcel_Style_Borders implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -171,9 +171,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 +182,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,7 +226,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']);
|
||||
@@ -265,7 +265,7 @@ 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;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ 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;
|
||||
}
|
||||
@@ -404,37 +404,6 @@ class PHPExcel_Style_Color implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -276,37 +276,6 @@ class PHPExcel_Style_Conditional implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -192,9 +192,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 +203,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,7 +244,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']);
|
||||
@@ -289,7 +289,7 @@ 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;
|
||||
}
|
||||
@@ -317,7 +317,7 @@ 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;
|
||||
}
|
||||
@@ -346,7 +346,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -375,7 +375,7 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -400,37 +400,6 @@ class PHPExcel_Style_Fill implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -207,9 +207,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 +218,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,7 +259,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']);
|
||||
@@ -319,7 +319,7 @@ 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;
|
||||
}
|
||||
@@ -350,7 +350,7 @@ 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;
|
||||
}
|
||||
@@ -381,7 +381,7 @@ 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;
|
||||
}
|
||||
@@ -412,7 +412,7 @@ 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;
|
||||
}
|
||||
@@ -443,7 +443,7 @@ 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;
|
||||
@@ -475,7 +475,7 @@ 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;
|
||||
@@ -507,7 +507,7 @@ 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;
|
||||
}
|
||||
@@ -559,7 +559,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;
|
||||
}
|
||||
@@ -588,7 +588,7 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -618,37 +618,6 @@ class PHPExcel_Style_Font implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Functions.php';
|
||||
*
|
||||
* @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
|
||||
{
|
||||
@@ -203,9 +203,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 +214,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,7 +248,7 @@ class PHPExcel_Style_NumberFormat 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('code', $pStyles)) {
|
||||
$this->setFormatCode($pStyles['code']);
|
||||
@@ -288,7 +288,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
}
|
||||
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);
|
||||
@@ -318,7 +318,7 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
|
||||
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);
|
||||
@@ -446,37 +446,6 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@@ -491,15 +460,59 @@ 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,82 +521,94 @@ 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));
|
||||
$value = gmdate($format, PHPExcel_Shared_Date::ExcelToPHP($value));
|
||||
|
||||
} 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);
|
||||
$value = 'EUR ' . sprintf('%1.2f', $value);
|
||||
|
||||
} else {
|
||||
// In Excel formats, "_" is used to add spacing, which we can't do in HTML
|
||||
@@ -618,7 +643,8 @@ 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;
|
||||
@@ -633,12 +659,13 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
$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']);
|
||||
}
|
||||
$value = number_format(
|
||||
$value
|
||||
, strlen($right)
|
||||
, PHPExcel_Shared_String::getDecimalSeparator()
|
||||
, PHPExcel_Shared_String::getThousandsSeparator()
|
||||
);
|
||||
|
||||
} else {
|
||||
$sprintf_pattern = "%1." . strlen($right) . "f";
|
||||
$value = sprintf($sprintf_pattern, $value);
|
||||
@@ -646,13 +673,16 @@ class PHPExcel_Style_NumberFormat implements PHPExcel_IComparable
|
||||
$value = preg_replace($number_regex, $value, $format);
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
// Additional formatting provided by callback function
|
||||
if ($callBack !== null) {
|
||||
list($writerInstance, $function) = $callBack;
|
||||
$value = $writerInstance->$function($value, $formatColor);
|
||||
}
|
||||
|
||||
return $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,7 +20,7 @@
|
||||
*
|
||||
* @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.4.5, 2007-08-23
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/IComparable.php';
|
||||
*
|
||||
* @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_Protection implements PHPExcel_IComparable
|
||||
{
|
||||
@@ -149,9 +149,9 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXSelectedCells()
|
||||
public function getSelectedCells()
|
||||
{
|
||||
return $this->getActiveSheet()->getXSelectedCells();
|
||||
return $this->getActiveSheet()->getSelectedCells();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,9 +160,9 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable
|
||||
*
|
||||
* @return string E.g. 'A1'
|
||||
*/
|
||||
public function getXActiveCell()
|
||||
public function getActiveCell()
|
||||
{
|
||||
return $this->getActiveSheet()->getXActiveCell();
|
||||
return $this->getActiveSheet()->getActiveCell();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +190,7 @@ class PHPExcel_Style_Protection 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('locked', $pStyles)) {
|
||||
$this->setLocked($pStyles['locked']);
|
||||
@@ -226,7 +226,7 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable
|
||||
public function setLocked($pValue = self::PROTECTION_INHERIT) {
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('locked' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_locked = $pValue;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable
|
||||
public function setHidden($pValue = self::PROTECTION_INHERIT) {
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('hidden' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getXSelectedCells())->applyFromArray($styleArray);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_hidden = $pValue;
|
||||
}
|
||||
@@ -277,37 +277,6 @@ class PHPExcel_Style_Protection implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -88,6 +88,9 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style.php';
|
||||
/** PHPExcel_Style_Fill */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Fill.php';
|
||||
|
||||
/** PHPExcel_Style_Color */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
|
||||
|
||||
/** PHPExcel_Style_NumberFormat */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
|
||||
|
||||
@@ -112,7 +115,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/ReferenceHelper.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
{
|
||||
@@ -120,6 +123,11 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
const BREAK_NONE = 0;
|
||||
const BREAK_ROW = 1;
|
||||
const BREAK_COLUMN = 2;
|
||||
|
||||
/* Sheet state */
|
||||
const SHEETSTATE_VISIBLE = 'visible';
|
||||
const SHEETSTATE_HIDDEN = 'hidden';
|
||||
const SHEETSTATE_VERYHIDDEN = 'veryHidden';
|
||||
|
||||
/**
|
||||
* Parent spreadsheet
|
||||
@@ -176,6 +184,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
* @var string
|
||||
*/
|
||||
private $_title;
|
||||
|
||||
/**
|
||||
* Sheet state
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_sheetState;
|
||||
|
||||
/**
|
||||
* Page setup
|
||||
@@ -304,43 +319,36 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
private $_comments = array();
|
||||
|
||||
/**
|
||||
* Selected cell
|
||||
* Active cell. (Only one!)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_selectedCell = 'A1';
|
||||
private $_activeCell = 'A1';
|
||||
|
||||
/**
|
||||
* Temporary property used by style supervisor. Will be removed
|
||||
* Selected cells
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_xActiveCell = 'A1';
|
||||
|
||||
/**
|
||||
* Temporary property used by style supervisor. Will be removed
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_xSelectedCells = 'A1:A1';
|
||||
private $_selectedCells = 'A1';
|
||||
|
||||
/**
|
||||
* Cached highest column
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_cachedHighestColumn = null;
|
||||
private $_cachedHighestColumn = 'A';
|
||||
|
||||
/**
|
||||
* Cached highest row
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_cachedHighestRow = null;
|
||||
private $_cachedHighestRow = 1;
|
||||
|
||||
/**
|
||||
* Right-to-left?
|
||||
*
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_rightToLeft = false;
|
||||
@@ -359,6 +367,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
*/
|
||||
private $_dataValidationCollection = array();
|
||||
|
||||
/**
|
||||
* Tab color
|
||||
*
|
||||
* @var PHPExcel_Style_Color
|
||||
*/
|
||||
private $_tabColor;
|
||||
|
||||
/**
|
||||
* Create a new worksheet
|
||||
*
|
||||
@@ -370,6 +385,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
// Set parent and title
|
||||
$this->_parent = $pParent;
|
||||
$this->setTitle($pTitle);
|
||||
$this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE);
|
||||
|
||||
// Set page setup
|
||||
$this->_pageSetup = new PHPExcel_Worksheet_PageSetup();
|
||||
@@ -404,6 +420,28 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
$this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check sheet title for valid Excel syntax
|
||||
*
|
||||
* @param string $pValue The string to check
|
||||
* @return string The valid string
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function _checkSheetTitle($pValue)
|
||||
{
|
||||
// Some of the printable ASCII characters are invalid: * : / \ ? [ ]
|
||||
if (preg_match('/(\\*|\\:|\\/|\\\\|\\?|\\[|\\])/', $pValue)) {
|
||||
throw new Exception('Invalid character found in sheet title');
|
||||
}
|
||||
|
||||
// Maximum 31 characters allowed for sheet title
|
||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 31) {
|
||||
throw new Exception('Maximum 31 characters allowed in sheet title.');
|
||||
}
|
||||
|
||||
return $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collection of cells
|
||||
*
|
||||
@@ -555,45 +593,56 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
return 'A1' . ':' . $this->getHighestColumn() . $this->getHighestRow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate widths for auto-size columns
|
||||
*
|
||||
* @param boolean $calculateMergeCells Calculate merge cell width
|
||||
* @return PHPExcel_Worksheet;
|
||||
*/
|
||||
public function calculateColumnWidths($calculateMergeCells = false)
|
||||
{
|
||||
/**
|
||||
* Calculate widths for auto-size columns
|
||||
*
|
||||
* @param boolean $calculateMergeCells Calculate merge cell width
|
||||
* @return PHPExcel_Worksheet;
|
||||
*/
|
||||
public function calculateColumnWidths($calculateMergeCells = false)
|
||||
{
|
||||
// initialize $autoSizes array
|
||||
$autoSizes = array();
|
||||
foreach ($this->getColumnDimensions() as $colDimension) {
|
||||
foreach ($this->getColumnDimensions() as $colDimension) {
|
||||
if ($colDimension->getAutoSize()) {
|
||||
$autoSizes[$colDimension->getColumnIndex()] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getCellCollection() as $cell) {
|
||||
if (isset($autoSizes[$cell->getColumn()])) {
|
||||
$cellValue = $cell->getCalculatedValue();
|
||||
|
||||
foreach ($this->getMergeCells() as $cells) {
|
||||
if ($cell->isInRange($cells) && !$calculateMergeCells) {
|
||||
$cellValue = ''; // do not calculate merge cells
|
||||
}
|
||||
}
|
||||
|
||||
$autoSizes[$cell->getColumn()] = max(
|
||||
(float)$autoSizes[$cell->getColumn()],
|
||||
(float)PHPExcel_Shared_Font::calculateColumnWidth(
|
||||
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSize(),
|
||||
false,
|
||||
$cellValue,
|
||||
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
foreach ($autoSizes as $columnIndex => $width) {
|
||||
if ($width == -1) $width = $this->getDefaultColumnDimension()->getWidth();
|
||||
$this->getColumnDimension($columnIndex)->setWidth($width);
|
||||
|
||||
// There is only something to do if there are some auto-size columns
|
||||
if (count($autoSizes) > 0) {
|
||||
// loop though all cells in sheet expand $autoSizes
|
||||
foreach ($this->getCellCollection(false) as $cell) {
|
||||
if (isset($autoSizes[$cell->getColumn()])) {
|
||||
// Calculated value
|
||||
$cellValue = $cell->getCalculatedValue();
|
||||
|
||||
// To formatted string
|
||||
$cellValue = PHPExcel_Style_NumberFormat::toFormattedString($cellValue, $this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode());
|
||||
|
||||
foreach ($this->getMergeCells() as $cells) {
|
||||
if ($cell->isInRange($cells) && !$calculateMergeCells) {
|
||||
$cellValue = ''; // do not calculate merge cells
|
||||
}
|
||||
}
|
||||
|
||||
$autoSizes[$cell->getColumn()] = max(
|
||||
(float)$autoSizes[$cell->getColumn()],
|
||||
(float)PHPExcel_Shared_Font::calculateColumnWidth(
|
||||
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
|
||||
$cellValue,
|
||||
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
|
||||
$this->getDefaultStyle()->getFont()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// adjust column widths
|
||||
foreach ($autoSizes as $columnIndex => $width) {
|
||||
if ($width == -1) $width = $this->getDefaultColumnDimension()->getWidth();
|
||||
$this->getColumnDimension($columnIndex)->setWidth($width);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -642,7 +691,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
* Set title
|
||||
*
|
||||
* @param string $pValue String containing the dimension of this worksheet
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function setTitle($pValue = 'Worksheet')
|
||||
@@ -652,10 +700,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
return;
|
||||
}
|
||||
|
||||
// Maximum 31 characters allowed for sheet title
|
||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 31) {
|
||||
throw new Exception('Maximum 31 characters allowed in sheet title.');
|
||||
}
|
||||
// Syntax check
|
||||
self::_checkSheetTitle($pValue);
|
||||
|
||||
// Old title
|
||||
$oldTitle = $this->getTitle();
|
||||
@@ -684,7 +730,27 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get sheet state
|
||||
*
|
||||
* @return string Sheet state (visible, hidden, veryHidden)
|
||||
*/
|
||||
public function getSheetState() {
|
||||
return $this->_sheetState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sheet state
|
||||
*
|
||||
* @param string $value Sheet state (visible, hidden, veryHidden)
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) {
|
||||
$this->_sheetState = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get page setup
|
||||
*
|
||||
@@ -802,36 +868,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
*/
|
||||
public function getHighestColumn()
|
||||
{
|
||||
// Cached?
|
||||
if (!is_null($this->_cachedHighestColumn)) {
|
||||
return $this->_cachedHighestColumn;
|
||||
}
|
||||
|
||||
// Highest column
|
||||
$highestColumn = -1;
|
||||
|
||||
// Loop trough cells
|
||||
foreach ($this->_cellCollection as $cell) {
|
||||
if ($highestColumn < PHPExcel_Cell::columnIndexFromString($cell->getColumn())) {
|
||||
$highestColumn = PHPExcel_Cell::columnIndexFromString($cell->getColumn());
|
||||
}
|
||||
}
|
||||
|
||||
// Loop trough column dimensions
|
||||
foreach ($this->_columnDimensions as $dimension) {
|
||||
if ($highestColumn < PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex())) {
|
||||
$highestColumn = PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex());
|
||||
}
|
||||
}
|
||||
|
||||
// Return & cache
|
||||
if ($highestColumn < 0) {
|
||||
$this->_cachedHighestColumn = 'A';
|
||||
} else {
|
||||
$this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn);
|
||||
}
|
||||
|
||||
return $this->_cachedHighestColumn;
|
||||
return $this->_cachedHighestColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -841,33 +878,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
*/
|
||||
public function getHighestRow()
|
||||
{
|
||||
// Cached?
|
||||
if (!is_null($this->_cachedHighestRow)) {
|
||||
return $this->_cachedHighestRow;
|
||||
}
|
||||
|
||||
// Highest row
|
||||
$highestRow = 1;
|
||||
|
||||
// Loop trough cells
|
||||
foreach ($this->_cellCollection as $cell) {
|
||||
if ($cell->getRow() > $highestRow) {
|
||||
$highestRow = $cell->getRow();
|
||||
}
|
||||
}
|
||||
|
||||
// Loop trough row dimensions
|
||||
foreach ($this->_rowDimensions as $dimension) {
|
||||
if ($highestRow < $dimension->getRowIndex()) {
|
||||
$highestRow = $dimension->getRowIndex();
|
||||
}
|
||||
}
|
||||
|
||||
// Cache
|
||||
$this->_cachedHighestRow = $highestRow;
|
||||
|
||||
// Return
|
||||
return $highestRow;
|
||||
return $this->_cachedHighestRow;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -949,7 +960,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
|
||||
// Named range?
|
||||
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
|
||||
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches))) {
|
||||
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
|
||||
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
|
||||
if (!is_null($namedRange)) {
|
||||
$pCoordinate = $namedRange->getRange();
|
||||
@@ -959,6 +970,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
} else {
|
||||
throw new Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle());
|
||||
}
|
||||
} else {
|
||||
//Allow named ranges within the same sheet.
|
||||
return $this->getCell($pCoordinate);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -971,14 +985,36 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
} elseif (strpos($pCoordinate,'$') !== false) {
|
||||
throw new Exception('Cell coordinate must not be absolute.');
|
||||
} else {
|
||||
// Create new cell object
|
||||
|
||||
// Coordinates
|
||||
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
|
||||
|
||||
$this->_cellCollection[$pCoordinate] = new PHPExcel_Cell($aCoordinates[0], $aCoordinates[1], null, PHPExcel_Cell_DataType::TYPE_NULL, $this);
|
||||
$this->_cellCollectionIsSorted = false;
|
||||
|
||||
$this->_cachedHighestColumn = null;
|
||||
$this->_cachedHighestRow = null;
|
||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
|
||||
$this->_cachedHighestColumn = $aCoordinates[0];
|
||||
|
||||
if ($this->_cachedHighestRow < $aCoordinates[1])
|
||||
$this->_cachedHighestRow = $aCoordinates[1];
|
||||
|
||||
// Cell needs appropriate xfIndex
|
||||
$rowDimensions = $this->getRowDimensions();
|
||||
$columnDimensions = $this->getColumnDimensions();
|
||||
|
||||
if ( isset($rowDimensions[$aCoordinates[1]]) && $rowDimensions[$aCoordinates[1]]->getXfIndex() !== null ) {
|
||||
// then there is a row dimension with explicit style, assign it to the cell
|
||||
$this->_cellCollection[$pCoordinate]->setXfIndex($rowDimensions[$aCoordinates[1]]->getXfIndex());
|
||||
|
||||
} else if ( isset($columnDimensions[$aCoordinates[0]]) ) {
|
||||
// then there is a column dimension, assign it to the cell
|
||||
$this->_cellCollection[$pCoordinate]->setXfIndex($columnDimensions[$aCoordinates[0]]->getXfIndex());
|
||||
|
||||
} else {
|
||||
// set to default index
|
||||
$this->_cellCollection[$pCoordinate]->setXfIndex(0);
|
||||
}
|
||||
|
||||
return $this->_cellCollection[$pCoordinate];
|
||||
}
|
||||
@@ -1001,8 +1037,11 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
$this->_cellCollection[$coordinate] = new PHPExcel_Cell($columnLetter, $pRow, null, PHPExcel_Cell_DataType::TYPE_NULL, $this);
|
||||
$this->_cellCollectionIsSorted = false;
|
||||
|
||||
$this->_cachedHighestColumn = null;
|
||||
$this->_cachedHighestRow = null;
|
||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn)
|
||||
$this->_cachedHighestColumn = $pColumn;
|
||||
|
||||
if ($this->_cachedHighestRow < $pRow)
|
||||
$this->_cachedHighestRow = $pRow;
|
||||
}
|
||||
|
||||
return $this->_cellCollection[$coordinate];
|
||||
@@ -1025,7 +1064,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
|
||||
// Named range?
|
||||
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
|
||||
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches))) {
|
||||
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
|
||||
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
|
||||
if (!is_null($namedRange)) {
|
||||
$pCoordinate = $namedRange->getRange();
|
||||
@@ -1081,7 +1120,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
// Get row dimension
|
||||
if (!isset($this->_rowDimensions[$pRow])) {
|
||||
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
|
||||
$this->_cachedHighestRow = null;
|
||||
|
||||
if ($this->_cachedHighestRow < $pRow)
|
||||
$this->_cachedHighestRow = $pRow;
|
||||
}
|
||||
return $this->_rowDimensions[$pRow];
|
||||
}
|
||||
@@ -1100,7 +1141,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
// Fetch dimensions
|
||||
if (!isset($this->_columnDimensions[$pColumn])) {
|
||||
$this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn);
|
||||
$this->_cachedHighestColumn = null;
|
||||
|
||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn))
|
||||
$this->_cachedHighestColumn = $pColumn;
|
||||
}
|
||||
return $this->_columnDimensions[$pColumn];
|
||||
}
|
||||
@@ -1147,9 +1190,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function setDefaultStyle(PHPExcel_Style $value)
|
||||
public function setDefaultStyle(PHPExcel_Style $pValue)
|
||||
{
|
||||
$this->_parent->setDefaultStyle($value);
|
||||
$this->_parent->getDefaultStyle()->applyFromArray(array(
|
||||
'font' => array(
|
||||
'name' => $pValue->getFont()->getName(),
|
||||
'size' => $pValue->getFont()->getSize(),
|
||||
),
|
||||
));
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1166,7 +1214,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
$this->_parent->setActiveSheetIndex($this->_parent->getIndex($this));
|
||||
|
||||
// set cell coordinate as active
|
||||
$this->setXSelectedCells($pCellCoordinate);
|
||||
$this->setSelectedCells($pCellCoordinate);
|
||||
|
||||
return $this->_parent->getCellXfSupervisor();
|
||||
}
|
||||
@@ -1317,7 +1365,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
$rangeEnd = $tmp;
|
||||
}
|
||||
|
||||
// Loop trough cells and apply styles
|
||||
// Loop through cells and apply styles
|
||||
for ($col = $rangeStart[0]; $col <= $rangeEnd[0]; ++$col) {
|
||||
for ($row = $rangeStart[1]; $row <= $rangeEnd[1]; ++$row) {
|
||||
$this->getCell(PHPExcel_Cell::stringFromColumnIndex($col) . $row)->setXfIndex($xfIndex);
|
||||
@@ -1472,7 +1520,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
}
|
||||
|
||||
/**
|
||||
* Get merge cells
|
||||
* Get merge cells array.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
@@ -1481,6 +1529,19 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
return $this->_mergeCells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set merge cells array for the entire sheet. Use instead mergeCells() to merge
|
||||
* a single cell range.
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
public function setMergeCells($pValue = array())
|
||||
{
|
||||
$this->_mergeCells = $pValue;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set protection on a cell range
|
||||
*
|
||||
@@ -1912,72 +1973,76 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
/**
|
||||
* Get selected cell
|
||||
*
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function getSelectedCell()
|
||||
{
|
||||
return $this->_selectedCell;
|
||||
return $this->getSelectedCells();
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary method used by style supervisor. Will be removed
|
||||
* Get active cell
|
||||
*
|
||||
* @return string
|
||||
* @return string Example: 'A1'
|
||||
*/
|
||||
public function getXActiveCell()
|
||||
public function getActiveCell()
|
||||
{
|
||||
return $this->_xActiveCell;
|
||||
return $this->_activeCell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary method used by style supervisor. Will be removed
|
||||
* Get selected cells
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getXSelectedCells()
|
||||
public function getSelectedCells()
|
||||
{
|
||||
return $this->_xSelectedCells;
|
||||
return $this->_selectedCells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selected cell
|
||||
*
|
||||
* @param string $pCell Cell (i.e. A1)
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function setSelectedCell($pCell = '')
|
||||
public function setSelectedCell($pCoordinate = 'A1')
|
||||
{
|
||||
// Uppercase coordinate
|
||||
$pCell = strtoupper($pCell);
|
||||
|
||||
if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) {
|
||||
$this->_selectedCell = $pCell;
|
||||
} else {
|
||||
throw new Exception('Selected cell can not be set on a range of cells.');
|
||||
}
|
||||
return $this;
|
||||
return $this->setSelectedCells($pCoordinate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary method used by style supervisor. Will be removed
|
||||
* Select a range of cells.
|
||||
*
|
||||
* @param string $pCell Cell (i.e. A1)
|
||||
* @param string $pCoordinate Cell range, examples: 'A1', 'B2:G5', 'A:C', '3:6'
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function setXSelectedCells($pCoordinate = 'A1:A1')
|
||||
public function setSelectedCells($pCoordinate = 'A1')
|
||||
{
|
||||
// Uppercase coordinate
|
||||
// Uppercase coordinate
|
||||
$pCoordinate = strtoupper($pCoordinate);
|
||||
|
||||
// Convert 'A' to 'A:A'
|
||||
$pCoordinate = preg_replace('/^([A-Z]+)$/', '${1}:${1}', $pCoordinate);
|
||||
|
||||
// Convert '1' to '1:1'
|
||||
$pCoordinate = preg_replace('/^([0-9]+)$/', '${1}:${1}', $pCoordinate);
|
||||
|
||||
// Convert 'A:C' to 'A1:C1048576'
|
||||
$pCoordinate = preg_replace('/^([A-Z]+):([A-Z]+)$/', '${1}1:${2}1048576', $pCoordinate);
|
||||
|
||||
// Convert '1:3' to 'A1:XFD3'
|
||||
$pCoordinate = preg_replace('/^([0-9]+):([0-9]+)$/', 'A${1}:XFD${2}', $pCoordinate);
|
||||
|
||||
if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) {
|
||||
list($first, ) = PHPExcel_Cell::splitRange($pCoordinate);
|
||||
$this->_xActiveCell = $first[0];
|
||||
$this->_activeCell = $first[0];
|
||||
} else {
|
||||
$this->_xActiveCell = $pCoordinate;
|
||||
$this->_activeCell = $pCoordinate;
|
||||
}
|
||||
$this->_xSelectedCells = $pCoordinate;
|
||||
$this->_selectedCells = $pCoordinate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1991,24 +2056,24 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
*/
|
||||
public function setSelectedCellByColumnAndRow($pColumn = 0, $pRow = 0)
|
||||
{
|
||||
return $this->setSelectedCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
|
||||
return $this->setSelectedCells(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get right-to-left
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getRightToLeft() {
|
||||
return $this->_rightToLeft;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set right-to-left
|
||||
*
|
||||
*
|
||||
* @param boolean $value Right-to-left true/false
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
*/
|
||||
public function setRightToLeft($value = false) {
|
||||
$this->_rightToLeft = $value;
|
||||
return $this;
|
||||
@@ -2028,7 +2093,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
list ($startColumn, $startRow) = PHPExcel_Cell::coordinateFromString($pCell);
|
||||
$startColumn = PHPExcel_Cell::columnIndexFromString($startColumn) - 1;
|
||||
|
||||
// Loop trough $source
|
||||
// Loop through $source
|
||||
$currentRow = $startRow - 1;
|
||||
$rowData = null;
|
||||
foreach ($source as $rowData) {
|
||||
@@ -2071,7 +2136,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
$dimension[1] = PHPExcel_Cell::coordinateFromString($dimension[1]);
|
||||
$dimension[1][0] = PHPExcel_Cell::columnIndexFromString($dimension[1][0]) - 1;
|
||||
|
||||
// Loop trough cells
|
||||
// Loop through cells
|
||||
for ($row = $dimension[0][1]; $row <= $dimension[1][1]; ++$row) {
|
||||
for ($column = $dimension[0][0]; $column <= $dimension[1][0]; ++$column) {
|
||||
// Cell exists?
|
||||
@@ -2125,6 +2190,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
$iterator->next();
|
||||
}
|
||||
|
||||
// Lookup highest column and highest row if cells are cleaned
|
||||
$highestColumn = -1;
|
||||
$highestRow = 1;
|
||||
|
||||
// Find cells that can be cleaned
|
||||
foreach ($this->_cellCollection as $coordinate => $cell) {
|
||||
// Can be cleaned?
|
||||
@@ -2145,10 +2214,42 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
|
||||
// Clean?
|
||||
if ($canBeCleaned) {
|
||||
// Remove the cell
|
||||
unset($this->_cellCollection[$coordinate]);
|
||||
}
|
||||
} else {
|
||||
// Determine highest column and row
|
||||
if ($highestColumn < PHPExcel_Cell::columnIndexFromString($cell->getColumn())) {
|
||||
$highestColumn = PHPExcel_Cell::columnIndexFromString($cell->getColumn());
|
||||
}
|
||||
if ($cell->getRow() > $highestRow) {
|
||||
$highestRow = $cell->getRow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through column dimensions
|
||||
foreach ($this->_columnDimensions as $dimension) {
|
||||
if ($highestColumn < PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex())) {
|
||||
$highestColumn = PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex());
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through row dimensions
|
||||
foreach ($this->_rowDimensions as $dimension) {
|
||||
if ($highestRow < $dimension->getRowIndex()) {
|
||||
$highestRow = $dimension->getRowIndex();
|
||||
}
|
||||
}
|
||||
|
||||
// Cache values
|
||||
if ($highestColumn < 0) {
|
||||
$this->_cachedHighestColumn = 'A';
|
||||
} else {
|
||||
$this->_cachedHighestColumn = PHPExcel_Cell::stringFromColumnIndex(--$highestColumn);
|
||||
}
|
||||
$this->_cachedHighestRow = $highestRow;
|
||||
|
||||
// Return
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -2167,37 +2268,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract worksheet title from range.
|
||||
*
|
||||
@@ -2350,6 +2420,42 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
return $this->_dataValidationCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tab color
|
||||
*
|
||||
* @return PHPExcel_Style_Color
|
||||
*/
|
||||
public function getTabColor()
|
||||
{
|
||||
if (is_null($this->_tabColor))
|
||||
$this->_tabColor = new PHPExcel_Style_Color();
|
||||
|
||||
return $this->_tabColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset tab color
|
||||
*
|
||||
* @return PHPExcel_Worksheet
|
||||
*/
|
||||
public function resetTabColor()
|
||||
{
|
||||
$this->_tabColor = null;
|
||||
unset($this->_tabColor);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab color set?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTabColorSet()
|
||||
{
|
||||
return !is_null($this->_tabColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy worksheet (!= clone!)
|
||||
*
|
||||
|
@@ -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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
|
||||
{
|
||||
@@ -486,37 +486,6 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_CellIterator extends IteratorIterator
|
||||
{
|
||||
@@ -115,20 +115,7 @@ class PHPExcel_Worksheet_CellIterator extends IteratorIterator
|
||||
* @return PHPExcel_Cell
|
||||
*/
|
||||
public function current() {
|
||||
$cellExists = $this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex);
|
||||
if ( ($this->_onlyExistingCells && $cellExists) || (!$this->_onlyExistingCells) ) {
|
||||
return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex);
|
||||
} else if ($this->_onlyExistingCells && !$cellExists) {
|
||||
// Loop untill we find one
|
||||
while ($this->valid()) {
|
||||
$this->next();
|
||||
if ($this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) {
|
||||
return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +140,23 @@ class PHPExcel_Worksheet_CellIterator extends IteratorIterator
|
||||
* @return boolean
|
||||
*/
|
||||
public function valid() {
|
||||
return $this->_position < PHPExcel_Cell::columnIndexFromString( $this->_subject->getHighestColumn() );
|
||||
// columnIndexFromString() returns an index based at one,
|
||||
// treat it as a count when comparing it to the base zero
|
||||
// position.
|
||||
$columnCount = PHPExcel_Cell::columnIndexFromString($this->_subject->getHighestColumn());
|
||||
|
||||
if ($this->_onlyExistingCells) {
|
||||
// If we aren't looking at an existing cell, either
|
||||
// because the first column doesn't exist or next() has
|
||||
// been called onto a nonexistent cell, then loop until we
|
||||
// find one, or pass the last column.
|
||||
while ($this->_position < $columnCount &&
|
||||
!$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) {
|
||||
++$this->_position;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_position < $columnCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_ColumnDimension
|
||||
{
|
||||
@@ -78,9 +78,16 @@ class PHPExcel_Worksheet_ColumnDimension
|
||||
* @var bool
|
||||
*/
|
||||
private $_collapsed;
|
||||
|
||||
|
||||
/**
|
||||
* Index to cellXf
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_xfIndex;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Worksheet_RowDimension
|
||||
* Create a new PHPExcel_Worksheet_ColumnDimension
|
||||
*
|
||||
* @param string $pIndex Character column index
|
||||
*/
|
||||
@@ -93,6 +100,9 @@ class PHPExcel_Worksheet_ColumnDimension
|
||||
$this->_visible = true;
|
||||
$this->_outlineLevel = 0;
|
||||
$this->_collapsed = false;
|
||||
|
||||
// set default index to cellXf
|
||||
$this->_xfIndex = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,6 +232,28 @@ class PHPExcel_Worksheet_ColumnDimension
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index to cellXf
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getXfIndex()
|
||||
{
|
||||
return $this->_xfIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set index to cellXf
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPExcel_Worksheet_ColumnDimension
|
||||
*/
|
||||
public function setXfIndex($pValue = 0)
|
||||
{
|
||||
$this->_xfIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||
*/
|
||||
@@ -235,4 +267,5 @@ class PHPExcel_Worksheet_ColumnDimension
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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_Worksheet_Drawing
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet_Drawing
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
|
||||
{
|
||||
@@ -153,37 +153,6 @@ class PHPExcel_Worksheet_Drawing extends PHPExcel_Worksheet_BaseDrawing implemen
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_Worksheet_Drawing
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/Color.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet_Drawing
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
|
||||
{
|
||||
@@ -289,37 +289,6 @@ class PHPExcel_Worksheet_Drawing_Shadow implements PHPExcel_IComparable
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/HeaderFooterDrawing.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_HeaderFooter
|
||||
{
|
||||
@@ -457,7 +457,7 @@ class PHPExcel_Worksheet_HeaderFooter
|
||||
/**
|
||||
* Get header/footer images
|
||||
*
|
||||
* @return HPExcel_Worksheet_HeaderFooterDrawing[]
|
||||
* @return PHPExcel_Worksheet_HeaderFooterDrawing[]
|
||||
*/
|
||||
public function getImages() {
|
||||
// Sort array
|
||||
|
@@ -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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing implements PHPExcel_IComparable
|
||||
{
|
||||
@@ -354,37 +354,6 @@ class PHPExcel_Worksheet_HeaderFooterDrawing extends PHPExcel_Worksheet_Drawing
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Drawing/Shadow.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable
|
||||
{
|
||||
@@ -205,37 +205,6 @@ class PHPExcel_Worksheet_MemoryDrawing extends PHPExcel_Worksheet_BaseDrawing im
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_PageMargins
|
||||
{
|
||||
|
@@ -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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_PageSetup
|
||||
{
|
||||
@@ -203,6 +203,14 @@ class PHPExcel_Worksheet_PageSetup
|
||||
*/
|
||||
private $_scale;
|
||||
|
||||
/**
|
||||
* Fit To Page
|
||||
* Whether scale or fitToWith / fitToHeight applies
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_fitToPage;
|
||||
|
||||
/**
|
||||
* Fit To Height
|
||||
* Number of vertical pages to fit on
|
||||
@@ -253,6 +261,13 @@ class PHPExcel_Worksheet_PageSetup
|
||||
* @var string
|
||||
*/
|
||||
private $_printArea = null;
|
||||
|
||||
/**
|
||||
* First page number
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_firstPageNumber = null;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Worksheet_PageSetup
|
||||
@@ -262,14 +277,16 @@ class PHPExcel_Worksheet_PageSetup
|
||||
// Initialise values
|
||||
$this->_paperSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER;
|
||||
$this->_orientation = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT;
|
||||
$this->_scale = null;
|
||||
$this->_fitToHeight = null;
|
||||
$this->_fitToWidth = null;
|
||||
$this->_scale = 100;
|
||||
$this->_fitToPage = false;
|
||||
$this->_fitToHeight = 1;
|
||||
$this->_fitToWidth = 1;
|
||||
$this->_columnsToRepeatAtLeft = array('', '');
|
||||
$this->_rowsToRepeatAtTop = array(0, 0);
|
||||
$this->_horizontalCentered = false;
|
||||
$this->_verticalCentered = false;
|
||||
$this->_printArea = null;
|
||||
$this->_firstPageNumber = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -328,20 +345,44 @@ class PHPExcel_Worksheet_PageSetup
|
||||
* This setting is overridden when fitToWidth and/or fitToHeight are in use
|
||||
*
|
||||
* @param int? $pValue
|
||||
* @param boolean $pUpdate Update fitToPage so scaling applies rather than fitToHeight / fitToWidth
|
||||
* @throws Exception
|
||||
* @return PHPExcel_Worksheet_PageSetup
|
||||
*/
|
||||
public function setScale($pValue = 100) {
|
||||
public function setScale($pValue = 100, $pUpdate = true) {
|
||||
// Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
|
||||
// but it is apparently still able to handle any scale >= 0, where 0 results in 100
|
||||
if (($pValue >= 0) || is_null($pValue)) {
|
||||
$this->_scale = $pValue;
|
||||
if ($pUpdate) {
|
||||
$this->_fitToPage = false;
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Scale must not be negative");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fit To Page
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getFitToPage() {
|
||||
return $this->_fitToPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fit To Page
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_Worksheet_PageSetup
|
||||
*/
|
||||
public function setFitToPage($pValue = true) {
|
||||
$this->_fitToPage = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fit To Height
|
||||
*
|
||||
@@ -355,11 +396,13 @@ class PHPExcel_Worksheet_PageSetup
|
||||
* Set Fit To Height
|
||||
*
|
||||
* @param int? $pValue
|
||||
* @param boolean $pUpdate Update fitToPage so it applies rather than scaling
|
||||
* @return PHPExcel_Worksheet_PageSetup
|
||||
*/
|
||||
public function setFitToHeight($pValue = 1) {
|
||||
if ($pValue != '') {
|
||||
$this->_fitToHeight = $pValue;
|
||||
public function setFitToHeight($pValue = 1, $pUpdate = true) {
|
||||
$this->_fitToHeight = $pValue;
|
||||
if ($pUpdate) {
|
||||
$this->_fitToPage = true;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@@ -377,11 +420,13 @@ class PHPExcel_Worksheet_PageSetup
|
||||
* Set Fit To Width
|
||||
*
|
||||
* @param int? $pValue
|
||||
* @param boolean $pUpdate Update fitToPage so it applies rather than scaling
|
||||
* @return PHPExcel_Worksheet_PageSetup
|
||||
*/
|
||||
public function setFitToWidth($pValue = 1) {
|
||||
if ($pValue != '') {
|
||||
$this->_fitToWidth = $pValue;
|
||||
public function setFitToWidth($pValue = 1, $pUpdate = true) {
|
||||
$this->_fitToWidth = $pValue;
|
||||
if ($pUpdate) {
|
||||
$this->_fitToPage = true;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@@ -543,7 +588,7 @@ class PHPExcel_Worksheet_PageSetup
|
||||
}
|
||||
|
||||
/**
|
||||
* Set print area
|
||||
* Set print area. E.g. 'A1:D10' or 'A1:D10,G5:M20'
|
||||
*
|
||||
* @param string $value
|
||||
* @throws Exception
|
||||
@@ -573,6 +618,35 @@ class PHPExcel_Worksheet_PageSetup
|
||||
{
|
||||
return $this->setPrintArea(PHPExcel_Cell::stringFromColumnIndex($column1) . $row1 . ':' . PHPExcel_Cell::stringFromColumnIndex($column2) . $row2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get first page number
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getFirstPageNumber() {
|
||||
return $this->_firstPageNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set first page number
|
||||
*
|
||||
* @param int $value
|
||||
* @return PHPExcel_Worksheet_HeaderFooter
|
||||
*/
|
||||
public function setFirstPageNumber($value = null) {
|
||||
$this->_firstPageNumber = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset first page number
|
||||
*
|
||||
* @return PHPExcel_Worksheet_HeaderFooter
|
||||
*/
|
||||
public function resetFirstPageNumber() {
|
||||
return $this->setFirstPageNumber(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/PasswordHasher.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_Protection
|
||||
{
|
||||
|
@@ -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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/CellIterator.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_Row
|
||||
{
|
||||
|
@@ -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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_RowDimension
|
||||
{
|
||||
@@ -71,7 +71,14 @@ class PHPExcel_Worksheet_RowDimension
|
||||
* @var bool
|
||||
*/
|
||||
private $_collapsed;
|
||||
|
||||
|
||||
/**
|
||||
* Index to cellXf. Null value means row has no explicit cellXf format.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
private $_xfIndex;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Worksheet_RowDimension
|
||||
*
|
||||
@@ -85,6 +92,9 @@ class PHPExcel_Worksheet_RowDimension
|
||||
$this->_visible = true;
|
||||
$this->_outlineLevel = 0;
|
||||
$this->_collapsed = false;
|
||||
|
||||
// set row dimension as unformatted by default
|
||||
$this->_xfIndex = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +203,29 @@ class PHPExcel_Worksheet_RowDimension
|
||||
$this->_collapsed = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get index to cellXf
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getXfIndex()
|
||||
{
|
||||
return $this->_xfIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set index to cellXf
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPExcel_Worksheet_RowDimension
|
||||
*/
|
||||
public function setXfIndex($pValue = 0)
|
||||
{
|
||||
$this->_xfIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet/Row.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_RowIterator extends IteratorIterator
|
||||
{
|
||||
|
@@ -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_Worksheet
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Worksheet
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Worksheet_SheetView
|
||||
{
|
||||
|
@@ -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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Worksheet.php';
|
||||
*
|
||||
* @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_WorksheetIterator extends IteratorIterator
|
||||
{
|
||||
|
@@ -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_Writer
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_CSV implements PHPExcel_Writer_IWriter {
|
||||
/**
|
||||
|
@@ -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_Writer_Excel2007
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Writer/Excel2007/Comments.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007 implements PHPExcel_Writer_IWriter
|
||||
{
|
||||
|
@@ -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_Writer_Excel2007
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
@@ -107,14 +107,14 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
|
||||
$objWriter->startElement('comments');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
|
||||
|
||||
// Loop trough authors
|
||||
// Loop through authors
|
||||
$objWriter->startElement('authors');
|
||||
foreach ($authors as $author => $index) {
|
||||
$objWriter->writeElement('author', $author);
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// Loop trough comments
|
||||
// Loop through comments
|
||||
$objWriter->startElement('commentList');
|
||||
foreach ($comments as $key => $value) {
|
||||
$this->_writeComment($objWriter, $key, $value, $authors);
|
||||
@@ -212,7 +212,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Loop trough comments
|
||||
// Loop through comments
|
||||
foreach ($comments as $key => $value) {
|
||||
$this->_writeVMLComment($objWriter, $key, $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,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
|
@@ -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_Writer_Excel2007
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
|
@@ -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_Writer_Excel2007
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
@@ -99,7 +99,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
|
||||
$objWriter->writeAttribute('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');
|
||||
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
|
||||
|
||||
// Loop trough images and write drawings
|
||||
// Loop through images and write drawings
|
||||
$i = 1;
|
||||
$iterator = $pWorksheet->getDrawingCollection()->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
@@ -469,7 +469,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Loop trough images
|
||||
// Loop through images
|
||||
foreach ($images as $key => $value) {
|
||||
$this->_writeVMLHeaderFooterImage($objWriter, $key, $value);
|
||||
}
|
||||
@@ -535,10 +535,10 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
|
||||
// Get an array of all drawings
|
||||
$aDrawings = array();
|
||||
|
||||
// Loop trough PHPExcel
|
||||
// Loop through PHPExcel
|
||||
$sheetCount = $pPHPExcel->getSheetCount();
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
// Loop trough images and add to array
|
||||
// Loop through images and add to array
|
||||
$iterator = $pPHPExcel->getSheet($i)->getDrawingCollection()->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
$aDrawings[] = $iterator->current();
|
||||
|
@@ -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_Writer_Excel2007
|
||||
* @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.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/XMLWriter.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
@@ -219,13 +219,13 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
|
||||
|
||||
// Write hyperlink relationships?
|
||||
$i = 1;
|
||||
foreach ($pWorksheet->getCellCollection() as $cell) {
|
||||
if ($cell->hasHyperlink() && !$cell->getHyperlink()->isInternal()) {
|
||||
foreach ($pWorksheet->getHyperlinkCollection() as $hyperlink) {
|
||||
if (!$hyperlink->isInternal()) {
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
'_hyperlink_' . $i,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
|
||||
$cell->getHyperlink()->getUrl(),
|
||||
$hyperlink->getUrl(),
|
||||
'External'
|
||||
);
|
||||
|
||||
@@ -292,7 +292,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Loop trough images and write relationships
|
||||
// Loop through images and write relationships
|
||||
$i = 1;
|
||||
$iterator = $pWorksheet->getDrawingCollection()->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
@@ -341,7 +341,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Loop trough images and write relationships
|
||||
// Loop through images and write relationships
|
||||
foreach ($pWorksheet->getHeaderFooter()->getImages() as $key => $value) {
|
||||
// Write relationship for image drawing
|
||||
$this->_writeRelationship(
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user