Skip to content
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

Fix freeze pane for xlsx files #261

Closed
wants to merge 10 commits into from
Closed

Fix freeze pane for xlsx files #261

wants to merge 10 commits into from

Conversation

adriencohen
Copy link

@adriencohen adriencohen commented Oct 23, 2017

This is:

  • a bugfix
  • a new feature

Checklist:

What does it change?
Fix #260

Always use xsplit and ysplit to define the freeze pane

@PowerKiKi
Copy link
Member

Thank you for the contribution. Would it be possible to cover that with unit tests without adding an excel file to the repository ? Maybe by writing a file from scratch and then reading it ?

@adriencohen
Copy link
Author

adriencohen commented Oct 27, 2017

After looking a bit about making a unit test I realized that I had to change Xlsx writer too.
Finally I feel a bit like the whole thing about freeze pane is a bit confusing.

I think the main problem is that we don't make any difference between xsplit/ysplit and topLeftCell. I took a look at Apache POI and for freeze pane they have:

/**
     * Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
     * @param colSplit      Horizontal position of split.
     * @param rowSplit      Vertical position of split.
     */
    @Override
    public void createFreezePane(int colSplit, int rowSplit) {
        createFreezePane( colSplit, rowSplit, colSplit, rowSplit );
    }
 /**
     * Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
     *
     * <p>
     *     If both colSplit and rowSplit are zero then the existing freeze pane is removed
     * </p>
     *
     * @param colSplit      Horizontal position of split.
     * @param rowSplit      Vertical position of split.
     * @param leftmostColumn   Left column visible in right pane.
     * @param topRow        Top row visible in bottom pane
     */
    @Override
    public void createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow) {

Where leftmostColumn and topRow represent topLeftCell. I'm not sure why they splitted it like that as in all Excel documentation it's always topLeftCell but anyway I think this way is more clear and will fix the bug I found.

Should I continue on this PR or close this one and open a new one ?

@PowerKiKi
Copy link
Member

You can keep pushing new commits to this PR, or squash and force push. Up to you.

@PowerKiKi
Copy link
Member

I see a BC break in the method createFreezePane(). Couldn't we have kept something compatible, such as:

public function freezePane($splitCell, $topLeftCell = null)

At first glance, it seems easier to use, give it a cell coordinate, instead of two integers.

Also $topLeftCell purpose is not immediately clear from the docblock. Is it something like the current scroll position of the freeze pane ? Maybe we could slightly reword the comment ?

@adriencohen
Copy link
Author

adriencohen commented Nov 3, 2017

Ok for renaming the function but if we keep $splitCell it would mean that if we want to freeze the first 3 columns we would have to put C0 which might be more confusing but what about freezing only rows ?
From the VBA documentation of Excel it seems like they are using "my method"

Well it's not the current position of the freeze pane, this one doesn't move. If when I load a file I have this :
xlsx
GG646 is the topLeftCell
I don't really have any idea how to reword it to make it really clear. Office documentation says

Location of the top left visible cell in the bottom right pane (when in Left-To-Right mode).
https://msdn.microsoft.com/en-us/library/office/documentformat.openxml.spreadsheet.pane.aspx

@PowerKiKi PowerKiKi closed this in 11b055b Dec 17, 2017
@PowerKiKi
Copy link
Member

Thanks for your contribution. I reworked it a bit, to avoid breaking API, and merged it.

Dfred pushed a commit to Dfred/PhpSpreadsheet that referenced this pull request Nov 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants