Pārlūkot izejas kodu

Add color element to styleSheet/fonts/font.

Geoffrey J. Teale 11 gadi atpakaļ
vecāks
revīzija
2cc795381d
3 mainītis faili ar 9 papildinājumiem un 4 dzēšanām
  1. 2 0
      file_test.go
  2. 2 0
      style.go
  3. 5 4
      xmlStyle.go

+ 2 - 0
file_test.go

@@ -399,12 +399,14 @@ func (l *FileSuite) TestMarshalFile(c *C) {
         <name val="Verdana"></name>
         <family val="0"></family>
         <charset val="0"></charset>
+        <color></color>
       </font>
       <font>
         <sz val="12"></sz>
         <name val="Verdana"></name>
         <family val="0"></family>
         <charset val="0"></charset>
+        <color></color>
       </font>
     </fonts>
     <fills count="2">

+ 2 - 0
style.go

@@ -29,6 +29,7 @@ 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
 	xPatternFill := xlsxPatternFill{}
 	xPatternFill.PatternType = style.Fill.PatternType
 	xPatternFill.FgColor.RGB = style.Fill.FgColor
@@ -77,6 +78,7 @@ type Font struct {
 	Name    string
 	Family  int
 	Charset int
+	Color   string
 }
 
 func NewFont(size int, name string) *Font {

+ 5 - 4
xmlStyle.go

@@ -51,10 +51,11 @@ type xlsxFonts struct {
 // currently I have not checked it for completeness - it does as much
 // as I need.
 type xlsxFont struct {
-	Sz      xlsxVal `xml:"sz,omitempty"`
-	Name    xlsxVal `xml:"name,omitempty"`
-	Family  xlsxVal `xml:"family,omitempty"`
-	Charset xlsxVal `xml:"charset,omitempty"`
+	Sz      xlsxVal   `xml:"sz,omitempty"`
+	Name    xlsxVal   `xml:"name,omitempty"`
+	Family  xlsxVal   `xml:"family,omitempty"`
+	Charset xlsxVal   `xml:"charset,omitempty"`
+	Color   xlsxColor `xml:"color,omitempty"`
 }
 
 // xlsxVal directly maps the val element in the namespace