Support workbook views settings (#1136)

This commit is contained in:
David 2022-02-04 01:45:42 -04:00 committed by GitHub
parent 156bf6d16e
commit 862dc9dc13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

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

View File

@ -14,6 +14,7 @@ var _ = []SheetViewOption{
ShowGridLines(true),
ShowRowColHeaders(true),
TopLeftCell("B2"),
View("pageLayout"),
// SheetViewOptionPtr are also SheetViewOption
new(DefaultGridColor),
new(RightToLeft),
@ -30,6 +31,7 @@ var _ = []SheetViewOptionPtr{
(*ShowGridLines)(nil),
(*ShowRowColHeaders)(nil),
(*TopLeftCell)(nil),
(*View)(nil),
}
func ExampleFile_SetSheetViewOptions() {
@ -44,6 +46,7 @@ func ExampleFile_SetSheetViewOptions() {
ShowRowColHeaders(true),
ZoomScale(80),
TopLeftCell("C3"),
View("pageLayout"),
); err != nil {
fmt.Println(err)
}