From 166ec63c9edb7279a238fd523851fc5cb35d0631 Mon Sep 17 00:00:00 2001 From: "Geoffrey J. Teale" Date: Mon, 23 Mar 2020 19:10:25 +0100 Subject: [PATCH] Fix broken tests --- sheet.go | 13 ++++++++----- style.go | 7 ++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sheet.go b/sheet.go index dbcef623..bbdc350c 100644 --- a/sheet.go +++ b/sheet.go @@ -442,15 +442,18 @@ func (s *Sheet) makeCols(worksheet *xlsxWorksheet, styles *xlsxStyleSheet) (maxL style := col.GetStyle() hasNumFmt := len(col.numFmt) > 0 - if style == nil && hasNumFmt { - style = NewStyle() - } + if hasNumFmt { + if style == nil { + style = NewStyle() + } + - if hasNumFmt { xNumFmt := styles.newNumFmt(col.numFmt) XfId = handleStyleForXLSX(style, xNumFmt.NumFmtId, styles) } else { - XfId = handleStyleForXLSX(style, 0, styles) + if style != nil { + XfId = handleStyleForXLSX(style, 0, styles) + } } col.outXfID = XfId diff --git a/style.go b/style.go index 4a77af9c..ab9c4516 100644 --- a/style.go +++ b/style.go @@ -51,6 +51,10 @@ func NewStyle() *Style { // Generate the underlying XLSX style elements that correspond to the Style. func (style *Style) makeXLSXStyleElements() (xFont xlsxFont, xFill xlsxFill, xBorder xlsxBorder, xCellXf xlsxXf) { + if style == nil { + panic("Called makeXLSXStyleElements on a nil *Style!") + } + xFont = xlsxFont{} xFill = xlsxFill{} xBorder = xlsxBorder{} @@ -59,7 +63,8 @@ func (style *Style) makeXLSXStyleElements() (xFont xlsxFont, xFill xlsxFill, xBo xFont.Name.Val = style.Font.Name xFont.Family.Val = strconv.Itoa(style.Font.Family) xFont.Charset.Val = strconv.Itoa(style.Font.Charset) - xFont.Color.RGB = style.Font.Color + xFont.Color.RGB = style.Font.Color + if style.Font.Bold { xFont.B = &xlsxVal{} } else {