From bddea1262b9219df224d19b24928d8da78a2f8c0 Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 16 Feb 2021 00:02:14 +0800 Subject: This closes #785, support to change tab color; new formula function: FISHER, FISHERINV, GAMMA, GAMMALN, MIN, MINA, PERMUT --- sheetpr.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'sheetpr.go') diff --git a/sheetpr.go b/sheetpr.go index ee3b23c..52586d9 100644 --- a/sheetpr.go +++ b/sheetpr.go @@ -11,6 +11,8 @@ package excelize +import "strings" + // SheetPrOption is an option of a view of a worksheet. See SetSheetPrOptions(). type SheetPrOption interface { setSheetPrOption(view *xlsxSheetPr) @@ -31,6 +33,8 @@ type ( Published bool // FitToPage is a SheetPrOption FitToPage bool + // TabColor is a SheetPrOption + TabColor string // AutoPageBreaks is a SheetPrOption AutoPageBreaks bool // OutlineSummaryBelow is an outlinePr, within SheetPr option @@ -125,6 +129,28 @@ func (o *FitToPage) getSheetPrOption(pr *xlsxSheetPr) { *o = FitToPage(pr.PageSetUpPr.FitToPage) } +// setSheetPrOption implements the SheetPrOption interface and specifies a +// stable name of the sheet. +func (o TabColor) setSheetPrOption(pr *xlsxSheetPr) { + if pr.TabColor == nil { + if string(o) == "" { + return + } + pr.TabColor = new(xlsxTabColor) + } + pr.TabColor.RGB = getPaletteColor(string(o)) +} + +// getSheetPrOption implements the SheetPrOptionPtr interface and get the +// stable name of the sheet. +func (o *TabColor) getSheetPrOption(pr *xlsxSheetPr) { + if pr == nil || pr.TabColor == nil { + *o = "" + return + } + *o = TabColor(strings.TrimPrefix(pr.TabColor.RGB, "FF")) +} + // setSheetPrOption implements the SheetPrOption interface. func (o AutoPageBreaks) setSheetPrOption(pr *xlsxSheetPr) { if pr.PageSetUpPr == nil { -- cgit v1.2.1