upgrade to PHPExcel 1.7.2

This commit is contained in:
Dieter Adriaenssens
2010-05-02 21:01:53 +02:00
parent 798def6e45
commit b90a1b496b
118 changed files with 9154 additions and 4035 deletions

View 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_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!)
*