diff options
author | David <JDavidVR@hotmail.com> | 2022-02-06 09:52:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-06 21:52:28 +0800 |
commit | 0f1fcb78d5518695cb80cc2266290e37df38a1ee (patch) | |
tree | 30d755a92ad7fb28b054e4e0776b372c99a0ef19 | |
parent | 862dc9dc1324e11a517b03267d07dd95051d5e6e (diff) |
Support workbook views Showruler settings (#1138)
-rw-r--r-- | sheetview.go | 15 | ||||
-rw-r--r-- | sheetview_test.go | 3 | ||||
-rw-r--r-- | xmlWorksheet.go | 1 |
3 files changed, 17 insertions, 2 deletions
diff --git a/sheetview.go b/sheetview.go index 0fb955d..5bb5aaf 100644 --- a/sheetview.go +++ b/sheetview.go @@ -60,9 +60,12 @@ type ( ShowZeros bool // View is a SheetViewOption. It specifies a flag indicating // how sheet is displayed, by default it uses empty string - // available options: pageLayout, pageBreakPreview + // available options: normal, pageLayout, pageBreakPreview View string - + // ShowRuler is a SheetViewOption. It specifies a flag indicating + // this sheet should display ruler. + ShowRuler bool + /* TODO // ShowWhiteSpace is a SheetViewOption. It specifies a flag indicating // whether page layout view shall display margins. False means do not display @@ -124,6 +127,14 @@ func (o *ShowGridLines) getSheetViewOption(view *xlsxSheetView) { *o = ShowGridLines(defaultTrue(view.ShowGridLines)) // Excel default: true } +func (o ShowRuler) setSheetViewOption(view *xlsxSheetView) { + view.ShowRuler = boolPtr(bool(o)) +} + +func (o *ShowRuler) getSheetViewOption(view *xlsxSheetView) { + *o = ShowRuler(defaultTrue(view.ShowRuler)) // Excel default: true +} + func (o ShowZeros) setSheetViewOption(view *xlsxSheetView) { view.ShowZeros = boolPtr(bool(o)) } diff --git a/sheetview_test.go b/sheetview_test.go index 6eb206e..cfe628d 100644 --- a/sheetview_test.go +++ b/sheetview_test.go @@ -15,6 +15,7 @@ var _ = []SheetViewOption{ ShowRowColHeaders(true), TopLeftCell("B2"), View("pageLayout"), + ShowRuler(false), // SheetViewOptionPtr are also SheetViewOption new(DefaultGridColor), new(RightToLeft), @@ -32,6 +33,7 @@ var _ = []SheetViewOptionPtr{ (*ShowRowColHeaders)(nil), (*TopLeftCell)(nil), (*View)(nil), + (*ShowRuler)(nil), } func ExampleFile_SetSheetViewOptions() { @@ -47,6 +49,7 @@ func ExampleFile_SetSheetViewOptions() { ZoomScale(80), TopLeftCell("C3"), View("pageLayout"), + ShowRuler(false), ); err != nil { fmt.Println(err) } diff --git a/xmlWorksheet.go b/xmlWorksheet.go index 76c6188..83dd1ba 100644 --- a/xmlWorksheet.go +++ b/xmlWorksheet.go @@ -191,6 +191,7 @@ type xlsxSheetView struct { ShowZeros *bool `xml:"showZeros,attr,omitempty"` RightToLeft bool `xml:"rightToLeft,attr,omitempty"` TabSelected bool `xml:"tabSelected,attr,omitempty"` + ShowRuler *bool `xml:"showRuler,attr,omitempty"` ShowWhiteSpace *bool `xml:"showWhiteSpace,attr"` ShowOutlineSymbols bool `xml:"showOutlineSymbols,attr,omitempty"` DefaultGridColor *bool `xml:"defaultGridColor,attr"` |