From faa7285a4f5db13e3629360562abc8a459bad0c2 Mon Sep 17 00:00:00 2001 From: Harris Date: Thu, 13 Dec 2018 13:01:36 -0600 Subject: Add support to flip outline summaries This adds outlinePr support, with the summaryBelow attribute which defaults to true. Closes #304 Signed-off-by: Michael Harris --- sheetpr.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sheetpr.go') diff --git a/sheetpr.go b/sheetpr.go index e38b64e..57eebd4 100644 --- a/sheetpr.go +++ b/sheetpr.go @@ -31,8 +31,26 @@ type ( FitToPage bool // AutoPageBreaks is a SheetPrOption AutoPageBreaks bool + // OutlineSummaryBelow is an outlinePr, within SheetPr option + OutlineSummaryBelow bool ) +func (o OutlineSummaryBelow) setSheetPrOption(pr *xlsxSheetPr) { + if pr.OutlinePr == nil { + pr.OutlinePr = new(xlsxOutlinePr) + } + pr.OutlinePr.SummaryBelow = bool(o) +} + +func (o *OutlineSummaryBelow) getSheetPrOption(pr *xlsxSheetPr) { + // Excel default: true + if pr == nil || pr.OutlinePr == nil { + *o = true + return + } + *o = OutlineSummaryBelow(defaultTrue(&pr.OutlinePr.SummaryBelow)) +} + func (o CodeName) setSheetPrOption(pr *xlsxSheetPr) { pr.CodeName = string(o) } @@ -115,6 +133,7 @@ func (o *AutoPageBreaks) getSheetPrOption(pr *xlsxSheetPr) { // Published(bool) // FitToPage(bool) // AutoPageBreaks(bool) +// OutlineSummaryBelow(bool) func (f *File) SetSheetPrOptions(name string, opts ...SheetPrOption) error { sheet := f.workSheetReader(name) pr := sheet.SheetPr @@ -137,6 +156,7 @@ func (f *File) SetSheetPrOptions(name string, opts ...SheetPrOption) error { // Published(bool) // FitToPage(bool) // AutoPageBreaks(bool) +// OutlineSummaryBelow(bool) func (f *File) GetSheetPrOptions(name string, opts ...SheetPrOptionPtr) error { sheet := f.workSheetReader(name) pr := sheet.SheetPr -- cgit v1.2.1