Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Showruler to Sheetview #1138

Merged
merged 2 commits into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions sheetview.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
}
Expand Down
3 changes: 3 additions & 0 deletions sheetview_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var _ = []SheetViewOption{
ShowRowColHeaders(true),
TopLeftCell("B2"),
View("pageLayout"),
ShowRuler(false),
// SheetViewOptionPtr are also SheetViewOption
new(DefaultGridColor),
new(RightToLeft),
Expand All @@ -32,6 +33,7 @@ var _ = []SheetViewOptionPtr{
(*ShowRowColHeaders)(nil),
(*TopLeftCell)(nil),
(*View)(nil),
(*ShowRuler)(nil),
}

func ExampleFile_SetSheetViewOptions() {
Expand All @@ -47,6 +49,7 @@ func ExampleFile_SetSheetViewOptions() {
ZoomScale(80),
TopLeftCell("C3"),
View("pageLayout"),
ShowRuler(false),
); err != nil {
fmt.Println(err)
}
Expand Down
1 change: 1 addition & 0 deletions xmlWorksheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down