forked from tealeg/xlsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyle_test.go
80 lines (67 loc) · 2.35 KB
/
style_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package xlsx
import (
"testing"
qt "github.com/frankban/quicktest"
. "gopkg.in/check.v1"
)
type StyleSuite struct{}
var _ = Suite(&StyleSuite{})
func (s *StyleSuite) TestNewStyle(c *C) {
style := NewStyle()
c.Assert(style, NotNil)
}
func (s *StyleSuite) TestNewStyleDefaultts(c *C) {
style := NewStyle()
c.Assert(style.Font, Equals, *DefaultFont())
c.Assert(style.Fill, Equals, *DefaultFill())
c.Assert(style.Border, Equals, *DefaultBorder())
}
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
border := *NewBorder("thin", "thin", "thin", "thin")
style.Border = border
style.ApplyBorder = true
style.ApplyFill = true
style.ApplyFont = true
xFont, xFill, xBorder, xCellXf := style.makeXLSXStyleElements()
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")
c.Assert(xBorder.Left.Style, Equals, "thin")
c.Assert(xBorder.Right.Style, Equals, "thin")
c.Assert(xBorder.Top.Style, Equals, "thin")
c.Assert(xBorder.Bottom.Style, Equals, "thin")
c.Assert(xCellXf.ApplyBorder, Equals, true)
c.Assert(xCellXf.ApplyFill, Equals, true)
c.Assert(xCellXf.ApplyFont, Equals, true)
}
func TestReadCellColorBackground(t *testing.T) {
c := qt.New(t)
xFile, err := OpenFile("./testdocs/color_stylesheet.xlsx")
c.Assert(err, qt.Equals, nil)
c.Assert(xFile.styles.Fills.Fill, qt.HasLen, 4)
c.Assert(xFile.styles.Colors.IndexedColors, qt.HasLen, 64)
c.Assert(xFile.Sheets[0].Cell(0, 1).GetStyle().Fill, qt.Equals, *NewFill("none", "", ""))
c.Assert(xFile.Sheets[0].Cell(1, 1).GetStyle().Fill, qt.Equals, *NewFill("solid", "00CC99FF", "00333333"))
c.Assert(xFile.Sheets[0].Cell(2, 1).GetStyle().Fill, qt.Equals, *NewFill("solid", "FF990099", "00333333"))
}
type FontSuite struct{}
var _ = Suite(&FontSuite{})
func (s *FontSuite) TestNewFont(c *C) {
font := NewFont(12, "Verdana")
c.Assert(font, NotNil)
c.Assert(font.Name, Equals, "Verdana")
c.Assert(font.Size, Equals, 12)
}