Browse Source

Now correctly applying B/U/I to the XLSX style struct.

Kaur Kuut 10 years ago
parent
commit
1ed72c208f
2 changed files with 21 additions and 0 deletions
  1. 15 0
      style.go
  2. 6 0
      style_test.go

+ 15 - 0
style.go

@@ -35,6 +35,21 @@ func (style *Style) makeXLSXStyleElements() (xFont xlsxFont, xFill xlsxFill, xBo
 	xFont.Family.Val = strconv.Itoa(style.Font.Family)
 	xFont.Charset.Val = strconv.Itoa(style.Font.Charset)
 	xFont.Color.RGB = style.Font.Color
+	if style.Font.Bold {
+		xFont.B = &struct{}{}
+	} else {
+		xFont.B = nil
+	}
+	if style.Font.Italic {
+		xFont.I = &struct{}{}
+	} else {
+		xFont.I = nil
+	}
+	if style.Font.Underline {
+		xFont.U = &struct{}{}
+	} else {
+		xFont.U = nil
+	}
 	xPatternFill := xlsxPatternFill{}
 	xPatternFill.PatternType = style.Fill.PatternType
 	xPatternFill.FgColor.RGB = style.Fill.FgColor

+ 6 - 0
style_test.go

@@ -23,6 +23,9 @@ func (s *StyleSuite) TestNewStyleDefaults(c *C) {
 func (s *StyleSuite) TestMakeXLSXStyleElements(c *C) {
 	style := NewStyle()
 	font := *NewFont(12, "Verdana")
+	font.Bold = true
+	font.Italic = true
+	font.Underline = true
 	style.Font = font
 	fill := *NewFill("solid", "00FF0000", "FF000000")
 	style.Fill = fill
@@ -37,6 +40,9 @@ func (s *StyleSuite) TestMakeXLSXStyleElements(c *C) {
 	// c.Assert(xNumFmt.FormatCode, Equals, "GENERAL")
 	c.Assert(xFont.Sz.Val, Equals, "12")
 	c.Assert(xFont.Name.Val, Equals, "Verdana")
+	c.Assert(xFont.B, NotNil)
+	c.Assert(xFont.I, NotNil)
+	c.Assert(xFont.U, NotNil)
 	c.Assert(xFill.PatternFill.PatternType, Equals, "solid")
 	c.Assert(xFill.PatternFill.FgColor.RGB, Equals, "00FF0000")
 	c.Assert(xFill.PatternFill.BgColor.RGB, Equals, "FF000000")