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

Add helper to auto scale sheet on page by single, columns and rows options #2108

Closed
1 task done
moisespsena opened this issue Mar 21, 2025 · 1 comment
Closed
1 task done
Labels
kind/documentation Improvements or additions to documentation

Comments

@moisespsena
Copy link
Contributor

Description

I have used excelize to generate data sheets for print. In many cases, when have many columns, the MS Excel or WPS SpreadSheets or LibreOffice Calc, add automatic page breaks on columns. This is a bad option for my sheets!

I see what those sheet editors have a page setup for auto scaling with three options for solve these problems: 1) Fit sheet on one page, 2) Fit all columns on one page and 3) Fit all rows on one page. See bellow image:

Image

I notice what this options is a helper to set other sheet options:

  1. Fit sheet on one page: must set SheetPropsOptions.FitToPage = true
  2. Fit all columns on one page: set SheetPropsOptions.FitToPage = true and PageLayoutOptions.FitToHeight = 0
  3. Fit all rows on one page: set SheetPropsOptions.FitToPage = true and PageLayoutOptions.FitToWidth = 0

I searched excelize api and 5th edition of the ECMA-376 Standard for Office Open XML to set those options on my sheet but i found nothing. For solve this problem, i have created sheets with those options and see the xl/worksheets/sheet1.xml file to check the XML attibutes set.

Additional context

No response

Validations

  • Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.
@moisespsena moisespsena changed the title feat: Add helper to auto fit sheet on page Add helper to auto scale sheet on page by single, columns and rows options Mar 21, 2025
moisespsena added a commit to moisespsena-go/excelize that referenced this issue Mar 21, 2025
moisespsena added a commit to moisespsena-go/excelize that referenced this issue Mar 21, 2025
…ngle, columns and rows options

- Add new SheetAutoScalingPageMode data type
- Add new consts SheetFitOnPage, SheetFitAllColumnsOnPage, SheetFitAllRowsOnPage
- Add new function SetSheetAutoScalingPageByMode
- Update unit tests
@xuri xuri added the kind/documentation Improvements or additions to documentation label Mar 22, 2025
@xuri
Copy link
Member

xuri commented Mar 22, 2025

Thanks for your issue. I've left some comments in PR #2109. These three scaling options can be found in the Excel's print settings drop-down menus:

I will update documentation for this.

moisespsena added a commit to moisespsena-go/excelize that referenced this issue Mar 23, 2025
…, 2) Fit Sheet on One Page and 3) Fit All Columns on One Page
moisespsena added a commit to moisespsena-go/excelize that referenced this issue Mar 23, 2025
…) No Scaling; 2) Fit Sheet on One Page; 3) Fit All Columns on One Page; 4) Fit All Rows on One Page
@xuri xuri closed this as completed in e9d27c7 Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants