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

Permit Max Column for Row Breaks #3345

Merged
merged 5 commits into from
Feb 11, 2023
Merged

Conversation

oleibman
Copy link
Collaborator

@oleibman oleibman commented Feb 4, 2023

Fix #3143. Page break was dropped. Difference between good and bad was the use of attribute max in brk tag in the good spreadsheet. However, max was not required in a similar spreadsheet. So the reason for the problem isn't completely explained, although the likeliest explanation seems to be an Excel bug. Nevertheless, it can't really hurt to capture the max value on read (if present) and generate it on write. This resolves the issue. User is also permitted to specify max column when setting a row break programatically. Documentation is updated.

This is:

  • a bugfix
  • a new feature
  • refactoring
  • additional unit tests

Checklist:

  • Changes are covered by unit tests
    • Changes are covered by existing unit tests
    • New unit tests have been added
  • Code style is respected
  • Commit message explains why the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
  • CHANGELOG.md contains a short summary of the change and a link to the pull request if applicable
  • Documentation is updated as necessary

Why this change is needed?

Provide an explanation of why this change is needed, with links to any Issues (if appropriate).
If this is a bugfix or a new feature, and there are no existing Issues, then please also create an issue that will make it easier to track progress with this PR.

Fix PHPOffice#3143. Page break was dropped. Difference between good and bad was the use of attribute `max` in `brk` tag in the good spreadsheet. However, `max` was *not* required in a similar spreadsheet. So the reason for the problem isn't completely explained. Nevertheless, it can't really hurt to capture the `max` value on read (if present) and generate it on write. This resolves the issue. User is also permitted to specify max column when setting a row break programatically. I am not yet in position to document when that might be a good idea.
Not a problem on my Windows system.
@oleibman
Copy link
Collaborator Author

oleibman commented Feb 6, 2023

I have tested further, using PhpSpreadsheet code to emulate the problem spreadsheet, and I am quite certain that the only difference between a spreadsheet which appears as expected and one which doesn't is the brk max attribute. This convinces me that Excel is acting strangely when faced with a row page break inside a defined print area. Bug? Feature? Who knows? At any rate, this result tells me that we should proceed with this PR. It does not convince me that it is always safe to add the max attribute, nor that the value should always be 16,383, but I can at least document when this should be done and suggest that as a reasonable value to use. I will update this PR with a documentation change and additional tests.

@oleibman
Copy link
Collaborator Author

oleibman commented Feb 6, 2023

BTW, LibreOffice handles the printing correctly whether or not max is specified on brk.

Change is necessitated by probable Excel bug.
I kind of shoe-horned it in. Better to create a new PageBreak class, which will make it easier to accomodate any future surprises about page break handling. The only difficulty with the new approach is making sure getBreaks maintains backwards compatibility. New tests will ensure that.
@oleibman oleibman merged commit 4e09fd4 into PHPOffice:master Feb 11, 2023
@oleibman oleibman deleted the issue3143 branch March 2, 2023 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Generated Excel file loses page breaks when prininting area does not start in the first column
1 participant