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

Freeze Panes takes wrong coordinates #322

Closed
juanmatias opened this Issue Jan 8, 2018 · 2 comments

Comments

2 participants
@juanmatias

juanmatias commented Jan 8, 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 I set a cell XY to freeze panes the following should happen:

  • Columns on left of X must freeze
  • Rows above of Y must freeze
  • Cell on the right of XY must be selected

What is the current behavior?

For example if I set freeze to D7 (from coordinates 4,7), the cell referenced to the freeze is G4 (from coordinates 7,4).
The "topLeftCell" is correctly set to this value (7,4).

What are the steps to reproduce?

Just try to freeze on D7 and the output will be freeze on 7,4.

<?php

use PhpOffice\PhpSpreadsheet\Helper\Sample;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Color;
use PhpOffice\PhpSpreadsheet\Style\Alignment;

(...)

// Create new Spreadsheet object
$spreadsheet = new Spreadsheet();

(...)


// with coordinates: 
$spreadsheet->getActiveSheet()->freezePaneByColumnAndRow(7,4);

// with cell name:
$spreadsheet->getActiveSheet()->freezePane('D7');

(...)

If I change this code in file vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Worksheet.php:

        $y = isset($panes[0]) ? $panes[0] : null;
        $x = isset($panes[1]) ? $panes[1] : null;

to this one:

        $x = isset($panes[0]) ? $panes[0] : null;
        $y = isset($panes[1]) ? $panes[1] : null;

... all works ok.

Which versions of PhpSpreadsheet and PHP are affected?

Installed via composer:

$ php composer.phar info phpoffice/phpspreadsheet
name     : phpoffice/phpspreadsheet
descrip. : PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
keywords : OpenXML, excel, gnumeric, ods, php, spreadsheet, xls, xlsx
versions : * 1.0.0

@PowerKiKi PowerKiKi closed this in 25bc54f Jan 8, 2018

@PowerKiKi

This comment has been minimized.

Member

PowerKiKi commented Jan 8, 2018

Thanks for reporting !

@juanmatias

This comment has been minimized.

juanmatias commented Jan 8, 2018

Thank you for programming! ;)

wppd added a commit to wppd/PhpSpreadsheet that referenced this issue Jan 16, 2018

PowerKiKi added a commit that referenced this issue Jan 28, 2018

1.1.0
- Support for PHP 7.2
- Support cell comments in HTML writer and reader - [#308](#308)
- Option to stop at a conditional styling, if it matches (only XLSX format) - [#292](#292)
- Support for line width for data series when rendering Xlsx - [#329](#329)

- Better auto-detection of CSV separators - [#305](#305)
- Support for shape style ending with `;` - [#304](#304)
- Freeze Panes takes wrong coordinates for XLSX - [#322](#322)
- `COLUMNS` and `ROWS` functions crashed in some cases - [#336](#336)
- Support XML file without styles - [#331](#331)
- Cell coordinates which are already a range cause an exception [#319](#319)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment