Skip to content

Commit

Permalink
Merge pull request #531 from tealeg/write-collumn-style-when-no-numfm…
Browse files Browse the repository at this point in the history
…t-is-set

Write the style for a column, even when no numfmt is set
  • Loading branch information
tealeg authored Mar 23, 2020
2 parents bd13e4e + 55fa6fa commit c669193
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ func (s *Sheet) makeCols(worksheet *xlsxWorksheet, styles *xlsxStyleSheet) (maxL
if hasNumFmt {
xNumFmt := styles.newNumFmt(col.numFmt)
XfId = handleStyleForXLSX(style, xNumFmt.NumFmtId, styles)
} else {
XfId = handleStyleForXLSX(style, 0, styles)
}
col.outXfID = XfId

Expand Down
22 changes: 22 additions & 0 deletions sheet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,28 @@ func TestSheet(t *testing.T) {
c.Assert(worksheet.Cols, qt.IsNil)
})

csRunO(c, "TestMakeXlsxSheetWithColStyle", func(qc *qt.C, option FileOption) {
file := NewFile(option)
sheet, _ := file.AddSheet("Sheet1")
row := sheet.AddRow()
cell1 := row.AddCell()
cell1.Value = "A cell!"

colStyle := NewStyle()
colStyle.Fill.FgColor = "EEEEEE00"
colStyle.Fill.PatternType = "solid"
colStyle.ApplyFill = true
col := NewColForRange(10, 11)
col.SetStyle(colStyle)
sheet.Cols.Add(col)
refTable := NewSharedStringRefTable()
styles := newXlsxStyleSheet(nil)
worksheet := sheet.makeXLSXSheet(refTable, styles, nil)
c.Assert(worksheet.Cols, qt.Not(qt.IsNil))
c.Assert(worksheet.Cols.Col[0].Style, qt.Equals, 0)
c.Assert(styles.getStyle(0), qt.DeepEquals, colStyle)
})

csRunO(c, "TestMarshalSheet", func(c *qt.C, option FileOption) {
file := NewFile(option)
sheet, _ := file.AddSheet("Sheet1")
Expand Down

0 comments on commit c669193

Please sign in to comment.