diff --git a/Classes/PHPExcel/Cell.php b/Classes/PHPExcel/Cell.php index 4a588a2..4d2678a 100644 --- a/Classes/PHPExcel/Cell.php +++ b/Classes/PHPExcel/Cell.php @@ -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 * - * @param string $pCoordinateString - * @return string Absolute coordinate + * @param string $pCoordinateString e.g. 'A1' + * @return string Absolute coordinate e.g. '$A$1' * @throws Exception */ public static function absoluteCoordinate($pCoordinateString = 'A1') diff --git a/Classes/PHPExcel/Writer/Excel2007/Workbook.php b/Classes/PHPExcel/Writer/Excel2007/Workbook.php index d1c125f..8341458 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Workbook.php +++ b/Classes/PHPExcel/Writer/Excel2007/Workbook.php @@ -430,8 +430,8 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write $chunks = array(); foreach ($printArea as $printAreaRect) { - $printAreaRect[0] = PHPExcel_Cell::absoluteCoordinate($printAreaRect[0]); - $printAreaRect[1] = PHPExcel_Cell::absoluteCoordinate($printAreaRect[1]); + $printAreaRect[0] = PHPExcel_Cell::absoluteReference($printAreaRect[0]); + $printAreaRect[1] = PHPExcel_Cell::absoluteReference($printAreaRect[1]); $chunks[] = '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printAreaRect); } diff --git a/changelog.txt b/changelog.txt index 7153808..db70fcd 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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) The freezePaneByColumnAndRow() method row argument should default to 1 rather than 0. 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) Enhanced SheetViews element structures in the Excel2007 Writer for frozen panes.