summaryrefslogtreecommitdiff
path: root/lib.go
diff options
context:
space:
mode:
authorOlivier Mengué <dolmen@cpan.org>2017-11-05 02:16:41 +0100
committerOlivier Mengué <dolmen@cpan.org>2017-11-16 12:00:36 +0100
commit88e48e079a91191e05f32a232f8dec4454b25238 (patch)
treec7d42ad32a89db79be454a4017c64026207dc9b0 /lib.go
parenta4ffb4fbfc9048998345e979577dab2a81bf57ff (diff)
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.
Diffstat (limited to 'lib.go')
-rw-r--r--lib.go11
1 files changed, 11 insertions, 0 deletions
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
+}