Support workbook views Showruler settings (#1138)

This commit is contained in:
David 2022-02-06 09:52:28 -04:00 committed by GitHub
parent 862dc9dc13
commit 0f1fcb78d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -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))
}

View File

@ -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)
}

View File

@ -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"`