Experimental - Added getHighestDataColumn(), getHighestDataRow(), getHighestRowAndColumn() and calculateWorksheetDataDimension() methods for the worksheet that return the highest row and column that have cell records
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@83932 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
0924d0a4ca
commit
b235c531a7
|
@ -155,6 +155,56 @@ class PHPExcel_CachedObjectStorage_CacheBase {
|
||||||
} // function sortCellList()
|
} // function sortCellList()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get highest worksheet column and highest row that have cell records
|
||||||
|
*
|
||||||
|
* @return array Highest column name and highest row number
|
||||||
|
*/
|
||||||
|
public function getHighestRowAndColumn()
|
||||||
|
{
|
||||||
|
// Lookup highest column and highest row
|
||||||
|
$col = array('A' => '1A');
|
||||||
|
$row = array(1);
|
||||||
|
foreach ($this->getCellList() as $coord) {
|
||||||
|
list($c,$r) = sscanf($coord,'%[A-Z]%d');
|
||||||
|
$row[$r] = $r;
|
||||||
|
$col[$c] = strlen($c).$c;
|
||||||
|
}
|
||||||
|
if (count($row) > 0) {
|
||||||
|
// Determine highest column and row
|
||||||
|
$highestRow = max($row);
|
||||||
|
$highestColumn = substr(max($col),1);
|
||||||
|
}
|
||||||
|
return array( 'row' => $highestRow,
|
||||||
|
'column' => $highestColumn
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get highest worksheet column
|
||||||
|
*
|
||||||
|
* @return string Highest column name
|
||||||
|
*/
|
||||||
|
public function getHighestColumn()
|
||||||
|
{
|
||||||
|
$colRow = $this->getHighestRowAndColumn();
|
||||||
|
return $colRow['column'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get highest worksheet row
|
||||||
|
*
|
||||||
|
* @return int Highest row number
|
||||||
|
*/
|
||||||
|
public function getHighestRow()
|
||||||
|
{
|
||||||
|
$colRow = $this->getHighestRowAndColumn();
|
||||||
|
return $colRow['row'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function _getUniqueID() {
|
protected function _getUniqueID() {
|
||||||
if (function_exists('posix_getpid')) {
|
if (function_exists('posix_getpid')) {
|
||||||
$baseUnique = posix_getpid();
|
$baseUnique = posix_getpid();
|
||||||
|
|
|
@ -539,6 +539,17 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||||
return 'A1' . ':' . $this->getHighestColumn() . $this->getHighestRow();
|
return 'A1' . ':' . $this->getHighestColumn() . $this->getHighestRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate worksheet data dimension
|
||||||
|
*
|
||||||
|
* @return string String containing the dimension of this worksheet that actually contain data
|
||||||
|
*/
|
||||||
|
public function calculateWorksheetDataDimension()
|
||||||
|
{
|
||||||
|
// Return
|
||||||
|
return 'A1' . ':' . $this->getHighestDataColumn() . $this->getHighestDataRow();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate widths for auto-size columns
|
* Calculate widths for auto-size columns
|
||||||
*
|
*
|
||||||
|
@ -843,6 +854,16 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||||
return $this->_cachedHighestColumn;
|
return $this->_cachedHighestColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get highest worksheet column that contains data
|
||||||
|
*
|
||||||
|
* @return string Highest column name that contains data
|
||||||
|
*/
|
||||||
|
public function getHighestDataColumn()
|
||||||
|
{
|
||||||
|
return $this->_cellCollection->getHighestColumn();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get highest worksheet row
|
* Get highest worksheet row
|
||||||
*
|
*
|
||||||
|
@ -853,6 +874,26 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||||
return $this->_cachedHighestRow;
|
return $this->_cachedHighestRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get highest worksheet row that contains data
|
||||||
|
*
|
||||||
|
* @return string Highest row number that contains data
|
||||||
|
*/
|
||||||
|
public function getHighestDataRow()
|
||||||
|
{
|
||||||
|
return $this->_cellCollection->getHighestRow();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get highest worksheet column and highest row that have cell records
|
||||||
|
*
|
||||||
|
* @return array Highest column name and highest row number
|
||||||
|
*/
|
||||||
|
public function getHighestRowAndColumn()
|
||||||
|
{
|
||||||
|
return $this->_cellCollection->getHighestRowAndColumn();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a cell value
|
* Set a cell value
|
||||||
*
|
*
|
||||||
|
@ -2297,21 +2338,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Lookup highest column and highest row if cells are cleaned
|
// Lookup highest column and highest row if cells are cleaned
|
||||||
$highestColumn = -1;
|
$colRow = $this->_cellCollection->getHighestRowAndColumn();
|
||||||
$highestRow = 1;
|
$highestRow = $colRow['row'];
|
||||||
|
$highestColumn = PHPExcel_Cell::columnIndexFromString($colRow['column']);
|
||||||
// Find cells that can be cleaned
|
|
||||||
$col = $row = array();
|
|
||||||
foreach ($this->_cellCollection->getCellList() as $coord) {
|
|
||||||
list($c,$r) = sscanf($coord,'%[A-Z]%d');
|
|
||||||
$row[$r] = $r;
|
|
||||||
$col[$c] = strlen($c).$c;
|
|
||||||
}
|
|
||||||
if (count($row) > 0) {
|
|
||||||
// Determine highest column and row
|
|
||||||
$highestRow = max($row);
|
|
||||||
$highestColumn = PHPExcel_Cell::columnIndexFromString(substr(max($col),1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop through column dimensions
|
// Loop through column dimensions
|
||||||
foreach ($this->_columnDimensions as $dimension) {
|
foreach ($this->_columnDimensions as $dimension) {
|
||||||
|
|
|
@ -29,6 +29,8 @@ Fixed in SVN:
|
||||||
- General: (MBaker) Reduce cell caching overhead using dirty flag to ensure that cells are only rewritten to the cache if they have actually been changed
|
- General: (MBaker) Reduce cell caching overhead using dirty flag to ensure that cells are only rewritten to the cache if they have actually been changed
|
||||||
- General: (MBaker) Improved memory usage in CSV Writer
|
- General: (MBaker) Improved memory usage in CSV Writer
|
||||||
- General: (MBaker) Improved speed and memory usage in Excel5 Writer
|
- General: (MBaker) Improved speed and memory usage in Excel5 Writer
|
||||||
|
- General: (MBaker) Experimental -
|
||||||
|
Added getHighestDataColumn(), getHighestDataRow(), getHighestRowAndColumn() and calculateWorksheetDataDimension() methods for the worksheet that return the highest row and column that have cell records
|
||||||
- Bugfix: (MBaker) Work item 15459 - Invalid cell coordinate in Autofilter for Excel2007 Writer
|
- Bugfix: (MBaker) Work item 15459 - Invalid cell coordinate in Autofilter for Excel2007 Writer
|
||||||
- Bugfix: (MBaker) Work item 15518 - PCLZip library issue
|
- Bugfix: (MBaker) Work item 15518 - PCLZip library issue
|
||||||
- Bugfix: (MBaker) Work item 15537 - Excel2007 Reader canRead function bug
|
- Bugfix: (MBaker) Work item 15537 - Excel2007 Reader canRead function bug
|
||||||
|
|
Loading…
Reference in New Issue