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,6 +58,10 @@ type (
// When using a formula to reference another cell which is empty, the referenced value becomes 0 // 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.) // when the flag is true. (Default setting is true.)
ShowZeros bool 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 /* TODO
// ShowWhiteSpace is a SheetViewOption. It specifies a flag indicating // ShowWhiteSpace is a SheetViewOption. It specifies a flag indicating
@ -80,6 +84,14 @@ func (o *TopLeftCell) getSheetViewOption(view *xlsxSheetView) {
*o = TopLeftCell(string(view.TopLeftCell)) *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) { func (o DefaultGridColor) setSheetViewOption(view *xlsxSheetView) {
view.DefaultGridColor = boolPtr(bool(o)) view.DefaultGridColor = boolPtr(bool(o))
} }

View File

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