Ver código fonte

- Add ApplyBorder, ApplyFill and ApplyFont to user oriented Style struct.
- Coppy these booleans back when making XLSX elements.

Geoffrey J. Teale 11 anos atrás
pai
commit
dfb9fd0c76
2 arquivos alterados com 23 adições e 4 exclusões
  1. 12 3
      style.go
  2. 11 1
      style_test.go

+ 12 - 3
style.go

@@ -5,9 +5,12 @@ import "strconv"
 // Style is a high level structure intended to provide user access to
 // the contents of Style within an XLSX file.
 type Style struct {
-	Border Border
-	Fill   Fill
-	Font   Font
+	Border      Border
+	Fill        Fill
+	Font        Font
+	ApplyBorder bool
+	ApplyFill   bool
+	ApplyFont   bool
 }
 
 func NewStyle() *Style {
@@ -33,6 +36,12 @@ func (style *Style) makeXLSXStyleElements() (xFont xlsxFont, xFill xlsxFill, xBo
 	xBorder.Right = xlsxLine{Style: style.Border.Right}
 	xBorder.Top = xlsxLine{Style: style.Border.Top}
 	xBorder.Bottom = xlsxLine{Style: style.Border.Bottom}
+	xCellXf.ApplyBorder = style.ApplyBorder
+	xCellXf.ApplyFill = style.ApplyFill
+	xCellXf.ApplyFont = style.ApplyFont
+	xCellStyleXf.ApplyBorder = style.ApplyBorder
+	xCellStyleXf.ApplyFill = style.ApplyFill
+	xCellStyleXf.ApplyFont = style.ApplyFont
 	return
 }
 

+ 11 - 1
style_test.go

@@ -21,7 +21,10 @@ func (s *StyleSuite) TestMakeXLSXStyleElements(c *C) {
 	style.Fill = fill
 	border := *NewBorder("thin", "thin", "thin", "thin")
 	style.Border = border
-	xFont, xFill, xBorder, _, _ := style.makeXLSXStyleElements()
+	style.ApplyBorder = true
+	style.ApplyFill = true
+	style.ApplyFont = true
+	xFont, xFill, xBorder, xCellStyleXf, xCellXf := style.makeXLSXStyleElements()
 	c.Assert(xFont.Sz.Val, Equals, "12")
 	c.Assert(xFont.Name.Val, Equals, "Verdana")
 	c.Assert(xFill.PatternFill.PatternType, Equals, "solid")
@@ -31,6 +34,13 @@ func (s *StyleSuite) TestMakeXLSXStyleElements(c *C) {
 	c.Assert(xBorder.Right.Style, Equals, "thin")
 	c.Assert(xBorder.Top.Style, Equals, "thin")
 	c.Assert(xBorder.Bottom.Style, Equals, "thin")
+	c.Assert(xCellStyleXf.ApplyBorder, Equals, true)
+	c.Assert(xCellStyleXf.ApplyFill, Equals, true)
+	c.Assert(xCellStyleXf.ApplyFont, Equals, true)
+	c.Assert(xCellXf.ApplyBorder, Equals, true)
+	c.Assert(xCellXf.ApplyFill, Equals, true)
+	c.Assert(xCellXf.ApplyFont, Equals, true)
+
 }
 
 type FontSuite struct{}