Browse Source

always return new style with default font, fill and border

crahles 11 years ago
parent
commit
d42802a77d
2 changed files with 21 additions and 1 deletions
  1. 14 1
      style.go
  2. 7 0
      style_test.go

+ 14 - 1
style.go

@@ -15,7 +15,11 @@ type Style struct {
 
 // Return a new Style structure initialised with the default values.
 func NewStyle() *Style {
-	return &Style{Font: *DefaulFont()}
+	return &Style{
+		Font:   *DefaulFont(),
+		Border: *DefaulBoder(),
+		Fill:   *DefaulFill(),
+	}
 }
 
 // Generate the underlying XLSX style elements that correspond to the Style.
@@ -90,3 +94,12 @@ func NewFont(size int, name string) *Font {
 func DefaulFont() *Font {
 	return NewFont(12, "Verdana")
 }
+
+func DefaulFill() *Fill {
+	return NewFill("none", "FFFFFFFF", "00000000")
+
+}
+
+func DefaulBoder() *Border {
+	return NewBorder("none", "none", "none", "none")
+}

+ 7 - 0
style_test.go

@@ -13,6 +13,13 @@ func (s *StyleSuite) TestNewStyle(c *C) {
 	c.Assert(style, NotNil)
 }
 
+func (s *StyleSuite) TestNewStyleDefaults(c *C) {
+	style := NewStyle()
+	c.Assert(style.Font, Equals, *DefaulFont())
+	c.Assert(style.Fill, Equals, *DefaulFill())
+	c.Assert(style.Border, Equals, *DefaulBoder())
+}
+
 func (s *StyleSuite) TestMakeXLSXStyleElements(c *C) {
 	style := NewStyle()
 	font := *NewFont(12, "Verdana")