This closes #2108, Add helper to auto scale sheet on page by single, columns and rows options#2109
Conversation
xuri
left a comment
There was a problem hiding this comment.
Thanks for your PR. If the user uses the SetSheetAutoScalingPageByMode function together with the SetPageLayout or SetSheetProps functions, the presets in the SetSheetAutoScalingPageByMode function may be modified, potentially leading to unexpected results and confusion.
Add documentation describing how to combine the existing SetPageLayout and SetSheetProps functions to achieve the 3 scaling options mentioned in issue #2108, would be preferred approach.
Due to the principle of minimum availability, there is no plan to introduce this feature to keep the library core and easy.
There was a problem hiding this comment.
I suggest revert changes in the commit b2a4725 and comments for the SetSheetProps function like this:
// SetSheetProps provides a function to set worksheet properties. There 4 kinds
// of presets "Custom Scaling Options" in the spreadsheet applications, if you
// need to set those kind of scaling options, please using the "SetSheetProps"
// and "SetPageLayout" functions to approach these 4 scaling options:
//
// 1. No Scaling (Print sheets at their actual size):
//
// disable := false
// if err := f.SetSheetProps("Sheet1", &excelize.SheetPropsOptions{
// FitToPage: &disable,
// }); err != nil {
// fmt.Println(err)
// }
//
// 2. Fit Sheet on One Page (Shrink the printout so that it fits on one page):
//
// enable := true
// if err := f.SetSheetProps("Sheet1", &excelize.SheetPropsOptions{
// FitToPage: &enable,
// }); err != nil {
// fmt.Println(err)
// }
//
// 3. Fit All Columns on One Page (Shrink the printout so that it is one page
// wide):
//
// enable, zero := true, 0
// if err := f.SetSheetProps("Sheet1", &excelize.SheetPropsOptions{
// FitToPage: &enable,
// }); err != nil {
// fmt.Println(err)
// }
// if err := f.SetPageLayout("Sheet1", &excelize.PageLayoutOptions{
// FitToHeight: &zero,
// }); err != nil {
// fmt.Println(err)
// }
//
// 4. Fit All Rows on One Page (Shrink the printout so that it is one page
// high):
//
// enable, zero := true, 0
// if err := f.SetSheetProps("Sheet1", &excelize.SheetPropsOptions{
// FitToPage: &enable,
// }); err != nil {
// fmt.Println(err)
// }
// if err := f.SetPageLayout("Sheet1", &excelize.PageLayoutOptions{
// FitToWidth: &zero,
// }); err != nil {
// fmt.Println(err)
// }…) No Scaling; 2) Fit Sheet on One Page; 3) Fit All Columns on One Page; 4) Fit All Rows on One Page
|
@xuri Thank you for suggestion. I aplly it. |
xuri
left a comment
There was a problem hiding this comment.
LGTM, thanks for your contribution.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2109 +/- ##
=======================================
Coverage 99.20% 99.20%
=======================================
Files 32 32
Lines 30104 30104
=======================================
Hits 29866 29866
Misses 158 158
Partials 80 80
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Types of changes
Checklist