diff options
author | Ri Xu <xuri.me@gmail.com> | 2017-08-18 20:55:27 +0800 |
---|---|---|
committer | Ri Xu <xuri.me@gmail.com> | 2017-08-18 20:55:27 +0800 |
commit | 77af25295ece8863326c99652d615f82385286b2 (patch) | |
tree | 2ad2f3f88abaa556dd71947d4c2785ca726207da /styles.go | |
parent | 58e2caff33906df86cd51446acb74be833aee140 (diff) |
- Conditional format with formula support, relate issue #75;
- go test and readme update
Diffstat (limited to 'styles.go')
-rw-r--r-- | styles.go | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -793,7 +793,7 @@ var validType = map[string]string{ "2_color_scale": "2_color_scale", "3_color_scale": "3_color_scale", "data_bar": "dataBar", - "formula": "expression", // Doesn't support currently + "formula": "expression", } // criteriaType defined the list of valid criteria types. @@ -2540,6 +2540,7 @@ func (f *File) SetConditionalFormat(sheet, area, formatSet string) { "2_color_scale": drawCondFmtColorScale, "3_color_scale": drawCondFmtColorScale, "dataBar": drawCondFmtDataBar, + "expression": drawConfFmtExp, } xlsx := f.workSheetReader(sheet) @@ -2554,7 +2555,7 @@ func (f *File) SetConditionalFormat(sheet, area, formatSet string) { } // Check for valid criteria types. ct, ok = criteriaType[v.Criteria] - if !ok { + if !ok && vt != "expression" { continue } @@ -2672,6 +2673,17 @@ func drawCondFmtDataBar(p int, ct string, format *formatConditional) *xlsxCfRule } } +// drawConfFmtExp provides function to create conditional formatting rule for +// expression by given priority, criteria type and format settings. +func drawConfFmtExp(p int, ct string, format *formatConditional) *xlsxCfRule { + return &xlsxCfRule{ + Priority: p + 1, + Type: validType[format.Type], + Formula: []string{format.Criteria}, + DxfID: &format.Format, + } +} + // getPaletteColor provides function to convert the RBG color by given string. func getPaletteColor(color string) string { return "FF" + strings.Replace(strings.ToUpper(color), "#", "", -1) |