Skip to content

freezePane leaving incorrect cell selected #389

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
ant-g opened this issue Feb 23, 2018 · 0 comments
Closed

freezePane leaving incorrect cell selected #389

ant-g opened this issue Feb 23, 2018 · 0 comments

Comments

@ant-g
Copy link

ant-g commented Feb 23, 2018

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

When calling freezePane the cell is frozen above and to left of selected cell and selected cell is 'selected'

What is the current behavior?

When calling freezePane the cell is frozen above and to left of selected cell and the cell 1 row below the selected cell is 'selected'

What are the steps to reproduce?

require __DIR__ . '/vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\IOFactory;

$spreadsheet = new Spreadsheet();
// Add some data
$spreadsheet->setActiveSheetIndex(0)
    ->setCellValue('A1', 'Hello')
    ->setCellValue('A2', 'world!')
    ->setCellValue('A3', 'Hello')
    ->setCellValue('A4', 'world!');	
	
$spreadsheet->getActiveSheet()->freezePane('A2');

// Redirect output to a client’s web browser (Xlsx)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="01simple.xlsx"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header('Pragma: public'); // HTTP/1.0
	
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('php://output');
exit;

can be corrected by explicitly providing 'topLeftCell' argument

$spreadsheet->getActiveSheet()->freezePane('A2','A2');

but seems to me that the code at line 1991 in worksheet.php should change from

 $topLeftCell = $coordinate[0] . ($coordinate[1]+1);

to

  $topLeftCell = $coordinate[0] . $coordinate[1];

?

Which versions of PhpSpreadsheet and PHP are affected?

PhpSpreadsheet Based on current non-dev composer deployment. V1.1
PHP v7.0

@UziTech UziTech mentioned this issue Feb 26, 2018
5 tasks
Dfred pushed a commit to Dfred/PhpSpreadsheet that referenced this issue Nov 20, 2018
Fixes a bug when calling `$sheet->freezePane('B2')` without a second argument.
The selected cell will now be `B2` instead of the incorrect `B3`.

Fixes PHPOffice#389
Closes PHPOffice#393
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant