Bugfix: Work item 15121 - Column reference rather than cell reference in Print Area definition

Fixed Excel2007 Writer to handle print areas that are defined as row or column ranges rather than just as cell ranges... added a static absoluteReference() method to PHPExcel_Cell that will return an absolute row, column or cell reference, and modified the _writeDefinedNameForPrintArea() method of the Excel2007 Workbook Writer to call that rather than absoluteCoordinate()

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@68176 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2011-02-08 12:55:45 +00:00
parent 919df79991
commit 8a83e847cd
3 changed files with 28 additions and 4 deletions

View File

@ -509,11 +509,33 @@ class PHPExcel_Cell
} }
} }
/**
* Make string row, column or cell coordinate absolute
*
* @param string $pCoordinateString e.g. 'A' or '1' or 'A1'
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
* @throws Exception
*/
public static function absoluteReference($pCoordinateString = 'A1')
{
if (strpos($pCoordinateString,':') === false && strpos($pCoordinateString,',') === false) {
// Create absolute coordinate
if (ctype_digit($pCoordinateString)) {
return '$'.$pCoordinateString;
} elseif (ctype_alpha($pCoordinateString)) {
return '$'.strtoupper($pCoordinateString);
}
return self::absoluteCoordinate($pCoordinateString);
} else {
throw new Exception("Coordinate string should not be a cell range.");
}
}
/** /**
* Make string coordinate absolute * Make string coordinate absolute
* *
* @param string $pCoordinateString * @param string $pCoordinateString e.g. 'A1'
* @return string Absolute coordinate * @return string Absolute coordinate e.g. '$A$1'
* @throws Exception * @throws Exception
*/ */
public static function absoluteCoordinate($pCoordinateString = 'A1') public static function absoluteCoordinate($pCoordinateString = 'A1')

View File

@ -430,8 +430,8 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
$chunks = array(); $chunks = array();
foreach ($printArea as $printAreaRect) { foreach ($printArea as $printAreaRect) {
$printAreaRect[0] = PHPExcel_Cell::absoluteCoordinate($printAreaRect[0]); $printAreaRect[0] = PHPExcel_Cell::absoluteReference($printAreaRect[0]);
$printAreaRect[1] = PHPExcel_Cell::absoluteCoordinate($printAreaRect[1]); $printAreaRect[1] = PHPExcel_Cell::absoluteReference($printAreaRect[1]);
$chunks[] = '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printAreaRect); $chunks[] = '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printAreaRect);
} }

View File

@ -56,6 +56,8 @@ Fixed in SVN:
- Bugfix: (MBaker) Fix Excel5 Writer so that it only writes column dimensions for columns that are actually used rather than the full range (A to IV) - Bugfix: (MBaker) Fix Excel5 Writer so that it only writes column dimensions for columns that are actually used rather than the full range (A to IV)
- Bugfix: (MBaker) The freezePaneByColumnAndRow() method row argument should default to 1 rather than 0. - Bugfix: (MBaker) The freezePaneByColumnAndRow() method row argument should default to 1 rather than 0.
Default row argument for all __ByColumnAndRow() methods should be 1 Default row argument for all __ByColumnAndRow() methods should be 1
- Bugfix: (MBaker) Work item 15121 - Column reference rather than cell reference in Print Area definition
Fix Excel2007 Writer to handle print areas that are defined as row or column ranges rather than just as cell ranges
- General: (MBaker) Improved performance (speed), for building the Shared Strings table in the Excel2007 Writer. - General: (MBaker) Improved performance (speed), for building the Shared Strings table in the Excel2007 Writer.
- General: (MBaker) Enhanced SheetViews element structures in the Excel2007 Writer for frozen panes. - General: (MBaker) Enhanced SheetViews element structures in the Excel2007 Writer for frozen panes.