From 88e48e079a91191e05f32a232f8dec4454b25238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Sun, 5 Nov 2017 02:16:41 +0100 Subject: Add SetSheetViewOptions and GetSheetViewOptions (#145) Two new methods: - SetSheetViewOptions(sheetName string, viewIndex int, opts ...SheetViewOption) error - GetSheetViewOptions(sheetName string, viewIndex int, opts ...SheetViewOptionPtr) error The option values are given by the user through types that have privates methods that implement the private SheetViewOption and SheetViewOptionPtr interfaces: - DefaultGridColor(bool) - RightToLeft(bool) - ShowFormulas(bool) - ShowGridLines(bool) - ShowRowColHeaders(bool) Examples: err := xl.SetSheetViewOptions("Sheet1", -1, excelize.ShowGridLines(true)) var showGridLines excelize.ShowGridLines err := xl.GetSheetViewOptions("Sheet1", -1, &showGridLines) Fixes #145. --- lib.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib.go') diff --git a/lib.go b/lib.go index b28b50f..2f3df35 100644 --- a/lib.go +++ b/lib.go @@ -121,3 +121,14 @@ func deepCopy(dst, src interface{}) error { } return gob.NewDecoder(bytes.NewBuffer(buf.Bytes())).Decode(dst) } + +// boolPtr returns a pointer to a bool with the given value. +func boolPtr(b bool) *bool { return &b } + +// defaultTrue returns true if b is nil, or the pointed value. +func defaultTrue(b *bool) bool { + if b == nil { + return true + } + return *b +} -- cgit v1.2.1