style.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // xslx is a package designed to help with reading data from
  2. // spreadsheets stored in the XLSX format used in recent versions of
  3. // Microsoft's Excel spreadsheet.
  4. //
  5. // For a concise example of how to use this library why not check out
  6. // the source for xlsx2csv here: https://github.com/tealeg/xlsx2csv
  7. package xlsx
  8. // xlsxStyle directly maps the style element in the namespace
  9. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  10. // currently I have not checked it for completeness - it does as much
  11. // as I need.
  12. type xlsxStyles struct {
  13. Fonts []xlsxFont `xml:"fonts>font"`
  14. Fills []xlsxFill `xml:"fills>fill"`
  15. Borders []xlsxBorder `xml:"borders>border"`
  16. CellStyleXfs []xlsxXf `xml:"cellStyleXfs>xf"`
  17. CellXfs []xlsxXf `xml:"cellXfs>xf"`
  18. }
  19. // xlsxFont directly maps the font element in the namespace
  20. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  21. // currently I have not checked it for completeness - it does as much
  22. // as I need.
  23. type xlsxFont struct {
  24. Sz xlsxVal `xml:"sz"`
  25. Name xlsxVal `xml:"name"`
  26. Family xlsxVal `xml:"family"`
  27. Charset xlsxVal `xml:"charset"`
  28. }
  29. // xlsxVal directly maps the val element in the namespace
  30. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  31. // currently I have not checked it for completeness - it does as much
  32. // as I need.
  33. type xlsxVal struct {
  34. Val string `xml:"val,attr"`
  35. }
  36. // xlsxFill directly maps the fill element in the namespace
  37. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  38. // currently I have not checked it for completeness - it does as much
  39. // as I need.
  40. type xlsxFill struct {
  41. PatternFill xlsxPatternFill `xml:"patternFill"`
  42. }
  43. // xlsxPatternFill directly maps the patternFill element in the namespace
  44. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  45. // currently I have not checked it for completeness - it does as much
  46. // as I need.
  47. type xlsxPatternFill struct {
  48. PatternType string `xml:"patternType,attr"`
  49. FgColor xlsxColor `xml:"fgColor"`
  50. BgColor xlsxColor `xml:"bgColor"`
  51. }
  52. // xlsxColor is a common mapping used for both the fgColor and bgColor
  53. // elements in the namespace
  54. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  55. // currently I have not checked it for completeness - it does as much
  56. // as I need.
  57. type xlsxColor struct {
  58. RGB string `xml:"rgb,attr"`
  59. }
  60. // xlsxBorder directly maps the border element in the namespace
  61. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  62. // currently I have not checked it for completeness - it does as much
  63. // as I need.
  64. type xlsxBorder struct {
  65. Left xlsxLine `xml:"left"`
  66. Right xlsxLine `xml:"right"`
  67. Top xlsxLine `xml:"top"`
  68. Bottom xlsxLine `xml:"bottom"`
  69. }
  70. // xlsxLine directly maps the line style element in the namespace
  71. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  72. // currently I have not checked it for completeness - it does as much
  73. // as I need.
  74. type xlsxLine struct {
  75. Style string `xml:"style,attr"`
  76. }
  77. // xlsxXf directly maps the xf element in the namespace
  78. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  79. // currently I have not checked it for completeness - it does as much
  80. // as I need.
  81. type xlsxXf struct {
  82. ApplyAlignment bool `xml:"applyAlignment,attr"`
  83. ApplyBorder bool `xml:"applyBorder,attr"`
  84. ApplyFont bool `xml:"applyFont,attr"`
  85. ApplyFill bool `xml:"applyFill,attr"`
  86. ApplyProtection bool `xml:"applyProtection,attr"`
  87. BorderId int `xml:"borderId,attr"`
  88. FillId int `xml:"fillId,attr"`
  89. FontId int `xml:"fontId,attr"`
  90. NumFmtId int `xml:"numFmtId,attr"`
  91. alignment xlsxAlignment `xml:"alignement"`
  92. }
  93. type xlsxAlignment struct {
  94. Horizontal string `xml:"horizontal,attr"`
  95. Indent int `xml:"indent,attr"`
  96. ShrinkToFit bool `xml:"shrinkToFit,attr"`
  97. TextRotation int `xml:"textRotation,attr"`
  98. Vertical string `xml:"vertical,attr"`
  99. WrapText bool `xml:"wrapText,attr"`
  100. }