From b260485f29038ca8df9993edb1c021672b3df7e4 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 17 Jan 2021 01:06:08 +0800 Subject: support to set print black and white and specified the first printed page number --- sheet.go | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'sheet.go') diff --git a/sheet.go b/sheet.go index 9f71de4..4e56943 100644 --- a/sheet.go +++ b/sheet.go @@ -1135,14 +1135,19 @@ type PageLayoutOptionPtr interface { } type ( + // BlackAndWhite specified print black and white. + BlackAndWhite bool + // FirstPageNumber specified first printed page number. If no value is + // specified, then 'automatic' is assumed. + FirstPageNumber uint // PageLayoutOrientation defines the orientation of page layout for a // worksheet. PageLayoutOrientation string - // PageLayoutPaperSize defines the paper size of the worksheet + // PageLayoutPaperSize defines the paper size of the worksheet. PageLayoutPaperSize int - // FitToHeight specified number of vertical pages to fit on + // FitToHeight specified number of vertical pages to fit on. FitToHeight int - // FitToWidth specified number of horizontal pages to fit on + // 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 @@ -1157,6 +1162,41 @@ const ( OrientationLandscape = "landscape" ) +// setPageLayout provides a method to set the print black and white for the +// worksheet. +func (p BlackAndWhite) setPageLayout(ps *xlsxPageSetUp) { + ps.BlackAndWhite = bool(p) +} + +// getPageLayout provides a method to get the print black and white for the +// worksheet. +func (p *BlackAndWhite) getPageLayout(ps *xlsxPageSetUp) { + if ps == nil { + *p = false + return + } + *p = BlackAndWhite(ps.BlackAndWhite) +} + +// setPageLayout provides a method to set the first printed page number for +// the worksheet. +func (p FirstPageNumber) setPageLayout(ps *xlsxPageSetUp) { + if 0 < uint(p) { + ps.FirstPageNumber = uint(p) + ps.UseFirstPageNumber = true + } +} + +// getPageLayout provides a method to get the first printed page number for +// the worksheet. +func (p *FirstPageNumber) getPageLayout(ps *xlsxPageSetUp) { + if ps == nil || ps.FirstPageNumber == 0 || !ps.UseFirstPageNumber { + *p = 1 + return + } + *p = FirstPageNumber(ps.FirstPageNumber) +} + // setPageLayout provides a method to set the orientation for the worksheet. func (o PageLayoutOrientation) setPageLayout(ps *xlsxPageSetUp) { ps.Orientation = string(o) @@ -1238,8 +1278,14 @@ func (p *PageLayoutScale) getPageLayout(ps *xlsxPageSetUp) { // SetPageLayout provides a function to sets worksheet page layout. // // Available options: -// PageLayoutOrientation(string) -// PageLayoutPaperSize(int) +// +// BlackAndWhite(bool) +// FirstPageNumber(uint) +// PageLayoutOrientation(string) +// PageLayoutPaperSize(int) +// FitToHeight(int) +// FitToWidth(int) +// PageLayoutScale(uint) // // The following shows the paper size sorted by excelize index number: // -- cgit v1.2.1