style_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package xlsx
  2. import (
  3. . "gopkg.in/check.v1"
  4. )
  5. type StyleSuite struct{}
  6. var _ = Suite(&StyleSuite{})
  7. func (s *StyleSuite) TestNewStyle(c *C) {
  8. style := NewStyle()
  9. c.Assert(style, NotNil)
  10. }
  11. func (s *StyleSuite) TestMakeXLSXStyleElements(c *C) {
  12. style := NewStyle()
  13. font := *NewFont(12, "Verdana")
  14. style.Font = font
  15. fill := *NewFill("solid", "00FF0000", "FF000000")
  16. style.Fill = fill
  17. border := *NewBorder("thin", "thin", "thin", "thin")
  18. style.Border = border
  19. style.ApplyBorder = true
  20. style.ApplyFill = true
  21. style.ApplyFont = true
  22. xNumFmt, xFont, xFill, xBorder, xCellStyleXf, xCellXf := style.makeXLSXStyleElements()
  23. c.Assert(xNumFmt.NumFmtId, Equals, 164)
  24. c.Assert(xNumFmt.FormatCode, Equals, "GENERAL")
  25. c.Assert(xFont.Sz.Val, Equals, "12")
  26. c.Assert(xFont.Name.Val, Equals, "Verdana")
  27. c.Assert(xFill.PatternFill.PatternType, Equals, "solid")
  28. c.Assert(xFill.PatternFill.FgColor.RGB, Equals, "00FF0000")
  29. c.Assert(xFill.PatternFill.BgColor.RGB, Equals, "FF000000")
  30. c.Assert(xBorder.Left.Style, Equals, "thin")
  31. c.Assert(xBorder.Right.Style, Equals, "thin")
  32. c.Assert(xBorder.Top.Style, Equals, "thin")
  33. c.Assert(xBorder.Bottom.Style, Equals, "thin")
  34. c.Assert(xCellStyleXf.ApplyBorder, Equals, true)
  35. c.Assert(xCellStyleXf.ApplyFill, Equals, true)
  36. c.Assert(xCellStyleXf.ApplyFont, Equals, true)
  37. c.Assert(xCellXf.ApplyBorder, Equals, true)
  38. c.Assert(xCellXf.ApplyFill, Equals, true)
  39. c.Assert(xCellXf.ApplyFont, Equals, true)
  40. }
  41. type FontSuite struct{}
  42. var _ = Suite(&FontSuite{})
  43. func (s *FontSuite) TestNewFont(c *C) {
  44. font := NewFont(12, "Verdana")
  45. c.Assert(font, NotNil)
  46. c.Assert(font.Name, Equals, "Verdana")
  47. c.Assert(font.Size, Equals, 12)
  48. }