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

Added view configuration to SheetView #1136

Merged
merged 3 commits into from
Feb 4, 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
14 changes: 13 additions & 1 deletion sheetview.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ type (
// When using a formula to reference another cell which is empty, the referenced value becomes 0
// when the flag is true. (Default setting is true.)
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
View string

/* TODO
// ShowWhiteSpace is a SheetViewOption. It specifies a flag indicating
// whether page layout view shall display margins. False means do not display
Expand All @@ -80,6 +84,14 @@ func (o *TopLeftCell) getSheetViewOption(view *xlsxSheetView) {
*o = TopLeftCell(string(view.TopLeftCell))
}

func (o View) setSheetViewOption(view *xlsxSheetView) {
view.View = string(o)
}

func (o *View) getSheetViewOption(view *xlsxSheetView) {
*o = View(string(view.View))
}

func (o DefaultGridColor) setSheetViewOption(view *xlsxSheetView) {
view.DefaultGridColor = 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 @@ -14,6 +14,7 @@ var _ = []SheetViewOption{
ShowGridLines(true),
ShowRowColHeaders(true),
TopLeftCell("B2"),
View("pageLayout"),
// SheetViewOptionPtr are also SheetViewOption
new(DefaultGridColor),
new(RightToLeft),
Expand All @@ -30,6 +31,7 @@ var _ = []SheetViewOptionPtr{
(*ShowGridLines)(nil),
(*ShowRowColHeaders)(nil),
(*TopLeftCell)(nil),
(*View)(nil),
}

func ExampleFile_SetSheetViewOptions() {
Expand All @@ -44,6 +46,7 @@ func ExampleFile_SetSheetViewOptions() {
ShowRowColHeaders(true),
ZoomScale(80),
TopLeftCell("C3"),
View("pageLayout"),
); err != nil {
fmt.Println(err)
}
Expand Down