Skip to content

Active Cell Anywhere #1323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/PhpSpreadsheet/Calculation/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4159,13 +4159,6 @@ private function processTokenStack($tokens, $cellID = null, Cell $pCell = null)
if ($pCellParent) {
$pCell->attach($pCellParent);
}
if (($cellID == 'AC99') || (isset($pCell) && $pCell->getCoordinate() == 'AC99')) {
if (defined('RESOLVING')) {
define('RESOLVING2', true);
} else {
define('RESOLVING', true);
}
}

$functionName = $matches[1];
$argCount = $stack->pop();
Expand Down
2 changes: 0 additions & 2 deletions src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ private function writeSheetViews(XMLWriter $objWriter, PhpspreadsheetWorksheet $
--$ySplit;

$topLeftCell = $pSheet->getTopLeftCell();
$activeCell = $topLeftCell;
$sqref = $topLeftCell;

// pane
$pane = 'topRight';
Expand Down
69 changes: 60 additions & 9 deletions tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,8 @@ public function testFreezePane($format)
self::assertSame($topLeftCell, $actualTopLeftCell, 'should be able to set the top left cell');
}

public function providerFormatsInvalidSelectedCells()
{
return [
['Xlsx'],
];
}

/**
* @dataProvider providerFormatsInvalidSelectedCells
* @dataProvider providerFormats
*
* @param string $format
*/
Expand All @@ -70,6 +63,64 @@ public function testFreezePaneWithInvalidSelectedCells($format)

self::assertSame($cellSplit, $actualCellSplit, 'should be able to set freeze pane');
self::assertSame($topLeftCell, $actualTopLeftCell, 'should be able to set the top left cell');
self::assertSame('A24', $reloadedActive->getSelectedCells(), 'selected cell should default to be first cell after the freeze pane');
self::assertSame('F5', $reloadedActive->getSelectedCells());
}

/**
* @dataProvider providerFormats
*
* @param string $format
*/
public function testFreezePaneUserSelectedCell($format)
{
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
$worksheet->setCellValue('A1', 'Header1');
$worksheet->setCellValue('B1', 'Header2');
$worksheet->setCellValue('C1', 'Header3');
$worksheet->setCellValue('A2', 'Data1');
$worksheet->setCellValue('B2', 'Data2');
$worksheet->setCellValue('C2', 'Data3');
$worksheet->setCellValue('A3', 'Data4');
$worksheet->setCellValue('B3', 'Data5');
$worksheet->setCellValue('C3', 'Data6');
$worksheet->freezePane('A2');
$worksheet->setSelectedCells('C3');

$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
// Read written file
$reloadedActive = $reloadedSpreadsheet->getActiveSheet();

$expected = 'C3';
self::assertSame($expected, $reloadedActive->getSelectedCells());
}

/**
* @dataProvider providerFormats
*
* @param string $format
*/
public function testNoFreezePaneUserSelectedCell($format)
{
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
$worksheet->setCellValue('A1', 'Header1');
$worksheet->setCellValue('B1', 'Header2');
$worksheet->setCellValue('C1', 'Header3');
$worksheet->setCellValue('A2', 'Data1');
$worksheet->setCellValue('B2', 'Data2');
$worksheet->setCellValue('C2', 'Data3');
$worksheet->setCellValue('A3', 'Data4');
$worksheet->setCellValue('B3', 'Data5');
$worksheet->setCellValue('C3', 'Data6');
//$worksheet->freezePane('A2');
$worksheet->setSelectedCells('C3');

$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format);
// Read written file
$reloadedActive = $reloadedSpreadsheet->getActiveSheet();

$expected = 'C3';
self::assertSame($expected, $reloadedActive->getSelectedCells());
}
}