From 054bb9f0612ab7bd5836c3817d105a9b0c9e6059 Mon Sep 17 00:00:00 2001 From: xuri Date: Sat, 16 Jan 2021 21:51:23 +0800 Subject: Support to adjust print scaling of the worksheet --- sheet.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sheet.go') diff --git a/sheet.go b/sheet.go index 82c6a69..9f71de4 100644 --- a/sheet.go +++ b/sheet.go @@ -1144,6 +1144,10 @@ type ( FitToHeight int // FitToWidth specified number of horizontal pages to fit on FitToWidth int + // PageLayoutScale defines the print scaling. This attribute is restricted + // to values ranging from 10 (10%) to 400 (400%). This setting is + // overridden when fitToWidth and/or fitToHeight are in use. + PageLayoutScale uint ) const ( @@ -1215,6 +1219,22 @@ func (p *FitToWidth) getPageLayout(ps *xlsxPageSetUp) { *p = FitToWidth(ps.FitToWidth) } +// setPageLayout provides a method to set the scale for the worksheet. +func (p PageLayoutScale) setPageLayout(ps *xlsxPageSetUp) { + if 10 <= uint(p) && uint(p) <= 400 { + ps.Scale = uint(p) + } +} + +// getPageLayout provides a method to get the scale for the worksheet. +func (p *PageLayoutScale) getPageLayout(ps *xlsxPageSetUp) { + if ps == nil || ps.Scale < 10 || ps.Scale > 400 { + *p = 100 + return + } + *p = PageLayoutScale(ps.Scale) +} + // SetPageLayout provides a function to sets worksheet page layout. // // Available options: -- cgit v1.2.1