Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tealeg committed Mar 23, 2020
1 parent 531baa4 commit 166ec63
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 8 additions & 5 deletions sheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion style.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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 {
Expand Down

0 comments on commit 166ec63

Please sign in to comment.