Bugfix: The freezePaneByColumnAndRow() method row argument should default to 1 rather than 0. Default row argument for all __ByColumnAndRow() methods should be 1

General: Enhanced SheetViews element structures in the Excel2007 Writer for frozen panes.

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@68124 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2011-02-07 11:19:07 +00:00
parent 3757a0e6ff
commit 919df79991
3 changed files with 96 additions and 74 deletions

View File

@ -875,7 +875,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param bool $returnCell Return the worksheet (false, default) or the cell (true) * @param bool $returnCell Return the worksheet (false, default) or the cell (true)
* @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified * @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified
*/ */
public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 0, $pValue = null, $returnCell = false) public function setCellValueByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $returnCell = false)
{ {
$cell = $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); $cell = $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
$cell->setValue($pValue); $cell->setValue($pValue);
@ -910,7 +910,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $pDataType Explicit data type * @param string $pDataType Explicit data type
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 0, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING) public function setCellValueExplicitByColumnAndRow($pColumn = 0, $pRow = 1, $pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING)
{ {
return $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValueExplicit($pValue, $pDataType); return $this->getCell(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow)->setValueExplicit($pValue, $pDataType);
} }
@ -992,7 +992,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $pRow Numeric row coordinate of the cell * @param string $pRow Numeric row coordinate of the cell
* @return PHPExcel_Cell Cell that was found * @return PHPExcel_Cell Cell that was found
*/ */
public function getCellByColumnAndRow($pColumn = 0, $pRow = 0) public function getCellByColumnAndRow($pColumn = 0, $pRow = 1)
{ {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn); $columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
$coordinate = $columnLetter . $pRow; $coordinate = $columnLetter . $pRow;
@ -1066,7 +1066,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $pRow Numeric row coordinate of the cell * @param string $pRow Numeric row coordinate of the cell
* @return boolean * @return boolean
*/ */
public function cellExistsByColumnAndRow($pColumn = 0, $pRow = 0) public function cellExistsByColumnAndRow($pColumn = 0, $pRow = 1)
{ {
return $this->cellExists(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); return $this->cellExists(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
} }
@ -1077,7 +1077,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param int $pRow Numeric index of the row * @param int $pRow Numeric index of the row
* @return PHPExcel_Worksheet_RowDimension * @return PHPExcel_Worksheet_RowDimension
*/ */
public function getRowDimension($pRow = 0) public function getRowDimension($pRow = 1)
{ {
// Found // Found
$found = null; $found = null;
@ -1253,7 +1253,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param int $pRow Numeric row coordinate of the cell * @param int $pRow Numeric row coordinate of the cell
* @return PHPExcel_Style * @return PHPExcel_Style
*/ */
public function getStyleByColumnAndRow($pColumn = 0, $pRow = 0) public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1)
{ {
return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
} }
@ -1384,13 +1384,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
/** /**
* Set break on a cell by using numeric cell coordinates * Set break on a cell by using numeric cell coordinates
* *
* @param int $pColumn Numeric column coordinate of the cell * @param integer $pColumn Numeric column coordinate of the cell
* @param int $pRow Numeric row coordinate of the cell * @param integer $pRow Numeric row coordinate of the cell
* @param int $pBreak Break type (type of PHPExcel_Worksheet::BREAK_*) * @param integer $pBreak Break type (type of PHPExcel_Worksheet::BREAK_*)
* @throws Exception * @throws Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setBreakByColumnAndRow($pColumn = 0, $pRow = 0, $pBreak = PHPExcel_Worksheet::BREAK_NONE) public function setBreakByColumnAndRow($pColumn = 0, $pRow = 1, $pBreak = PHPExcel_Worksheet::BREAK_NONE)
{ {
return $this->setBreak(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow, $pBreak); return $this->setBreak(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow, $pBreak);
} }
@ -1454,7 +1454,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws Exception * @throws Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function mergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 0, $pColumn2 = 0, $pRow2 = 0) public function mergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1)
{ {
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->mergeCells($cellRange); return $this->mergeCells($cellRange);
@ -1495,7 +1495,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws Exception * @throws Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function unmergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 0, $pColumn2 = 0, $pRow2 = 0) public function unmergeCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1)
{ {
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->unmergeCells($cellRange); return $this->unmergeCells($cellRange);
@ -1558,7 +1558,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws Exception * @throws Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function protectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 0, $pColumn2 = 0, $pRow2 = 0, $pPassword = '', $pAlreadyHashed = false) public function protectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false)
{ {
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->protectCells($cellRange, $pPassword, $pAlreadyHashed); return $this->protectCells($cellRange, $pPassword, $pAlreadyHashed);
@ -1596,7 +1596,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws Exception * @throws Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function unprotectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 0, $pColumn2 = 0, $pRow2 = 0, $pPassword = '', $pAlreadyHashed = false) public function unprotectCellsByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1, $pPassword = '', $pAlreadyHashed = false)
{ {
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->unprotectCells($cellRange, $pPassword, $pAlreadyHashed); return $this->unprotectCells($cellRange, $pPassword, $pAlreadyHashed);
@ -1653,7 +1653,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws Exception * @throws Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setAutoFilterByColumnAndRow($pColumn1 = 0, $pRow1 = 0, $pColumn2 = 0, $pRow2 = 0) public function setAutoFilterByColumnAndRow($pColumn1 = 0, $pRow1 = 1, $pColumn2 = 0, $pRow2 = 1)
{ {
return $this->setAutoFilter( return $this->setAutoFilter(
PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1 PHPExcel_Cell::stringFromColumnIndex($pColumn1) . $pRow1
@ -1711,7 +1711,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws Exception * @throws Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function freezePaneByColumnAndRow($pColumn = 0, $pRow = 0) public function freezePaneByColumnAndRow($pColumn = 0, $pRow = 1)
{ {
return $this->freezePane(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); return $this->freezePane(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
} }
@ -1979,7 +1979,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param int $pRow Numeric row coordinate of the cell * @param int $pRow Numeric row coordinate of the cell
* @return PHPExcel_Comment * @return PHPExcel_Comment
*/ */
public function getCommentByColumnAndRow($pColumn = 0, $pRow = 0) public function getCommentByColumnAndRow($pColumn = 0, $pRow = 1)
{ {
return $this->getComment(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); return $this->getComment(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
} }
@ -2068,7 +2068,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws Exception * @throws Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setSelectedCellByColumnAndRow($pColumn = 0, $pRow = 0) public function setSelectedCellByColumnAndRow($pColumn = 0, $pRow = 1)
{ {
return $this->setSelectedCells(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); return $this->setSelectedCells(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
} }

View File

@ -236,31 +236,50 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$objWriter->writeAttribute('rightToLeft', 'true'); $objWriter->writeAttribute('rightToLeft', 'true');
} }
// Pane $activeCell = $pSheet->getActiveCell();
if ($pSheet->getFreezePane() != '') {
// Calculate freeze coordinates
$xSplit = 0;
$ySplit = 0;
$topLeftCell = $pSheet->getFreezePane();
list($xSplit, $ySplit) = PHPExcel_Cell::coordinateFromString($pSheet->getFreezePane()); // Pane
$pane = '';
$topLeftCell = $pSheet->getFreezePane();
if (($topLeftCell != '') && ($topLeftCell != 'A1')) {
$activeCell = $topLeftCell;
// Calculate freeze coordinates
$xSplit = $ySplit = 0;
list($xSplit, $ySplit) = PHPExcel_Cell::coordinateFromString($topLeftCell);
$xSplit = PHPExcel_Cell::columnIndexFromString($xSplit); $xSplit = PHPExcel_Cell::columnIndexFromString($xSplit);
// pane // pane
$pane = 'topRight';
$objWriter->startElement('pane'); $objWriter->startElement('pane');
if ($xSplit > 1)
$objWriter->writeAttribute('xSplit', $xSplit - 1); $objWriter->writeAttribute('xSplit', $xSplit - 1);
if ($ySplit > 1) {
$objWriter->writeAttribute('ySplit', $ySplit - 1); $objWriter->writeAttribute('ySplit', $ySplit - 1);
$pane = ($xSplit > 1) ? 'bottomRight' : 'bottomLeft';
}
$objWriter->writeAttribute('topLeftCell', $topLeftCell); $objWriter->writeAttribute('topLeftCell', $topLeftCell);
$objWriter->writeAttribute('activePane', 'bottomRight'); $objWriter->writeAttribute('activePane', $pane);
$objWriter->writeAttribute('state', 'frozen'); $objWriter->writeAttribute('state', 'frozen');
$objWriter->endElement(); $objWriter->endElement();
if (($xSplit > 1) && ($ySplit > 1)) {
// Write additional selections if more than two panes (ie both an X and a Y split)
$objWriter->startElement('selection'); $objWriter->writeAttribute('pane', 'topRight'); $objWriter->endElement();
$objWriter->startElement('selection'); $objWriter->writeAttribute('pane', 'bottomLeft'); $objWriter->endElement();
}
} }
// Selection // Selection
if ($pane != '') {
// Only need to write selection element if we have a split pane
// We cheat a little by over-riding the active cell selection, setting it to the split cell
$objWriter->startElement('selection'); $objWriter->startElement('selection');
$objWriter->writeAttribute('activeCell', $pSheet->getActiveCell()); $objWriter->writeAttribute('pane', $pane);
$objWriter->writeAttribute('sqref', $pSheet->getSelectedCells()); $objWriter->writeAttribute('activeCell', $activeCell);
$objWriter->writeAttribute('sqref', $activeCell);
$objWriter->endElement(); $objWriter->endElement();
}
$objWriter->endElement(); $objWriter->endElement();

View File

@ -54,7 +54,10 @@ Fixed in SVN:
- Bugfix: (MBaker) Work item 14980 - Images not getting copyied with the ->clone function - Bugfix: (MBaker) Work item 14980 - Images not getting copyied with the ->clone function
- Bugfix: (MBaker) Work item 11576 - AdvancedValueBinder.php: String sometimes becomes a date when it shouldn't - Bugfix: (MBaker) Work item 11576 - AdvancedValueBinder.php: String sometimes becomes a date when it shouldn't
- 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.
Default row argument for all __ByColumnAndRow() methods should be 1
- 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.