Skip to content

Conversation

@oleibman
Copy link
Collaborator

Fix #3941. Html and Pdf Writers will show PrintArea if specified rather than the entire sheet. Html Writer, which needs to handle both screen and print views, will use PrintArea through CSS; PDF, which needs to handle only print view, will use it by not including rows and columns which are not in the PrintArea. The support is limited because:

  • PrintArea can consist of several different ranges. The writers will use the PrintArea only if it consists of a single range.
  • Html use will be effective only if useInlineCSS is set to false, which is its default value.
  • Other aspects of page setup, e.g. horizontal centered, remain unsupported, with or without PrintArea.

Html Writer will also set a data-printarea attribute on the table declaration for a worksheet when appropriate. Html Reader will recognize and process that attribute. This usage does not require that the PrintArea consist of a single range.

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

Fix PHPOffice#3941. Html and Pdf Writers will show PrintArea if specified rather than the entire sheet. Html Writer, which needs to handle both screen and print views, will use PrintArea through CSS; PDF, which needs to handle only print view, will use it by not including rows and columns which are not in the PrintArea. The support is limited because:
- PrintArea can consist of several different ranges. The writers will use the PrintArea only if it consists of a single range.
- Html use will be effective only if `useInlineCSS` is set to `false`, which is its default value.
- Other aspects of page setup, e.g. horizontal centered, remain unsupported, with or without PrintArea.

Html Writer will also set a `data-printarea` attribute on the `table` declaration for a worksheet when appropriate. Html Reader will recognize and process that attribute. This usage does not require that the PrintArea consist of a single range.
@oleibman oleibman enabled auto-merge November 14, 2025 06:15
@oleibman oleibman added this pull request to the merge queue Nov 14, 2025
Merged via the queue into PHPOffice:master with commit ee2d4e8 Nov 14, 2025
13 checks passed
@oleibman oleibman deleted the printarea branch November 14, 2025 06:27
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.

converting a .xlsx file to .pdf not retain the specified print area

1 participant