Parcourir la source

Now correctly marshaling B/I/U in xmlStyle.

Kaur Kuut il y a 10 ans
Parent
commit
b0bf95f328
2 fichiers modifiés avec 13 ajouts et 1 suppressions
  1. 9 0
      xmlStyle.go
  2. 4 1
      xmlStyle_test.go

+ 9 - 0
xmlStyle.go

@@ -471,6 +471,15 @@ func (font *xlsxFont) Marshal() (result string, err error) {
 	if font.Color.RGB != "" {
 		result += fmt.Sprintf(`<color rgb="%s"/>`, font.Color.RGB)
 	}
+	if font.B != nil {
+		result += "<b/>"
+	}
+	if font.I != nil {
+		result += "<i/>"
+	}
+	if font.U != nil {
+		result += "<u/>"
+	}
 	result += `</font>`
 	return
 }

+ 4 - 1
xmlStyle_test.go

@@ -26,10 +26,13 @@ func (x *XMLStyleSuite) TestMarshalXlsxStyleSheetWithAFont(c *C) {
 	font := xlsxFont{}
 	font.Sz.Val = "10"
 	font.Name.Val = "Andale Mono"
+	font.B = &struct{}{}
+	font.I = &struct{}{}
+	font.U = &struct{}{}
 	styles.Fonts.Font[0] = font
 
 	expected := `<?xml version="1.0" encoding="UTF-8"?>
-<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><fonts count="1"><font><sz val="10"/><name val="Andale Mono"/></font></fonts></styleSheet>`
+<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><fonts count="1"><font><sz val="10"/><name val="Andale Mono"/><b/><i/><u/></font></fonts></styleSheet>`
 	result, err := styles.Marshal()
 	c.Assert(err, IsNil)
 	c.Assert(string(result), Equals, expected)