From 9e463b4614348b3ddc04b1fedd5d662845ce0fb9 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 27 May 2018 11:25:55 +0800 Subject: - Add error return value for functions: `AddChart()`, `AddComment()`, `AddPicture()`, `AddShape()`, `AddTable()` and `SetConditionalFormat()` - go test has been updated --- styles.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'styles.go') diff --git a/styles.go b/styles.go index daa3447..b919475 100644 --- a/styles.go +++ b/styles.go @@ -988,7 +988,7 @@ func is12HourTime(format string) bool { func (f *File) stylesReader() *xlsxStyleSheet { if f.Styles == nil { var styleSheet xlsxStyleSheet - xml.Unmarshal([]byte(f.readXML("xl/styles.xml")), &styleSheet) + _ = xml.Unmarshal([]byte(f.readXML("xl/styles.xml")), &styleSheet) f.Styles = &styleSheet } return f.Styles @@ -2562,10 +2562,12 @@ func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) { // // bar_color - Used for data_bar. Same as min_color, see above. // -func (f *File) SetConditionalFormat(sheet, area, formatSet string) { +func (f *File) SetConditionalFormat(sheet, area, formatSet string) error { var format []*formatConditional - json.Unmarshal([]byte(formatSet), &format) - + err := json.Unmarshal([]byte(formatSet), &format) + if err != nil { + return err + } drawContFmtFunc := map[string]func(p int, ct string, fmtCond *formatConditional) *xlsxCfRule{ "cellIs": drawCondFmtCellIs, "top10": drawCondFmtTop10, @@ -2601,6 +2603,7 @@ func (f *File) SetConditionalFormat(sheet, area, formatSet string) { SQRef: area, CfRule: cfRule, }) + return err } // drawCondFmtCellIs provides function to create conditional formatting rule for -- cgit v1.2.1