summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2019-07-06 15:11:51 +0800
committerGitHub <noreply@github.com>2019-07-06 15:11:51 +0800
commite14d2febc880f5dc0a8352f9f57af5ac3a9d37f5 (patch)
treeacd62029004408de355111b2b22bff2b5eba4dad
parent4897276c68474c5a3e16ac4e07fae55738c66eca (diff)
Resolve #432, supplement the function of SetPageLayout
SetPageLayout support to set fit to width and height
-rw-r--r--sheet.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/sheet.go b/sheet.go
index d579c6a..1c19e86 100644
--- a/sheet.go
+++ b/sheet.go
@@ -1025,6 +1025,10 @@ type (
PageLayoutOrientation string
// PageLayoutPaperSize defines the paper size of the worksheet
PageLayoutPaperSize int
+ // FitToHeight specified number of vertical pages to fit on
+ FitToHeight int
+ // FitToWidth specified number of horizontal pages to fit on
+ FitToWidth int
)
const (
@@ -1064,6 +1068,38 @@ func (p *PageLayoutPaperSize) getPageLayout(ps *xlsxPageSetUp) {
*p = PageLayoutPaperSize(ps.PaperSize)
}
+// setPageLayout provides a method to set the fit to height for the worksheet.
+func (p FitToHeight) setPageLayout(ps *xlsxPageSetUp) {
+ if int(p) > 0 {
+ ps.FitToHeight = int(p)
+ }
+}
+
+// getPageLayout provides a method to get the fit to height for the worksheet.
+func (p *FitToHeight) getPageLayout(ps *xlsxPageSetUp) {
+ if ps == nil || ps.FitToHeight == 0 {
+ *p = 1
+ return
+ }
+ *p = FitToHeight(ps.FitToHeight)
+}
+
+// setPageLayout provides a method to set the fit to width for the worksheet.
+func (p FitToWidth) setPageLayout(ps *xlsxPageSetUp) {
+ if int(p) > 0 {
+ ps.FitToWidth = int(p)
+ }
+}
+
+// getPageLayout provides a method to get the fit to width for the worksheet.
+func (p *FitToWidth) getPageLayout(ps *xlsxPageSetUp) {
+ if ps == nil || ps.FitToWidth == 0 {
+ *p = 1
+ return
+ }
+ *p = FitToWidth(ps.FitToWidth)
+}
+
// SetPageLayout provides a function to sets worksheet page layout.
//
// Available options:
@@ -1213,6 +1249,8 @@ func (f *File) SetPageLayout(sheet string, opts ...PageLayoutOption) error {
// Available options:
// PageLayoutOrientation(string)
// PageLayoutPaperSize(int)
+// FitToHeight(int)
+// FitToWidth(int)
func (f *File) GetPageLayout(sheet string, opts ...PageLayoutOptionPtr) error {
s, err := f.workSheetReader(sheet)
if err != nil {