style.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. NumFmts []xlsxNumFmt `xml:numFmts>numFmt"`
  19. }
  20. // xlsxNumFmt directly maps the numFmt element in the namespace
  21. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  22. // currently I have not checked it for completeness - it does as much
  23. // as I need.
  24. type xlsxNumFmt struct {
  25. NumFmtId int `xml:"numFmtId"`
  26. FormatCode string `xml:"formatCode"`
  27. }
  28. // xlsxFont directly maps the font element in the namespace
  29. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  30. // currently I have not checked it for completeness - it does as much
  31. // as I need.
  32. type xlsxFont struct {
  33. Sz xlsxVal `xml:"sz"`
  34. Name xlsxVal `xml:"name"`
  35. Family xlsxVal `xml:"family"`
  36. Charset xlsxVal `xml:"charset"`
  37. }
  38. // xlsxVal directly maps the val element in the namespace
  39. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  40. // currently I have not checked it for completeness - it does as much
  41. // as I need.
  42. type xlsxVal struct {
  43. Val string `xml:"val,attr"`
  44. }
  45. // xlsxFill directly maps the fill element in the namespace
  46. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  47. // currently I have not checked it for completeness - it does as much
  48. // as I need.
  49. type xlsxFill struct {
  50. PatternFill xlsxPatternFill `xml:"patternFill"`
  51. }
  52. // xlsxPatternFill directly maps the patternFill element in the namespace
  53. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  54. // currently I have not checked it for completeness - it does as much
  55. // as I need.
  56. type xlsxPatternFill struct {
  57. PatternType string `xml:"patternType,attr"`
  58. FgColor xlsxColor `xml:"fgColor"`
  59. BgColor xlsxColor `xml:"bgColor"`
  60. }
  61. // xlsxColor is a common mapping used for both the fgColor and bgColor
  62. // elements in the namespace
  63. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  64. // currently I have not checked it for completeness - it does as much
  65. // as I need.
  66. type xlsxColor struct {
  67. RGB string `xml:"rgb,attr"`
  68. }
  69. // xlsxBorder directly maps the border element in the namespace
  70. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  71. // currently I have not checked it for completeness - it does as much
  72. // as I need.
  73. type xlsxBorder struct {
  74. Left xlsxLine `xml:"left"`
  75. Right xlsxLine `xml:"right"`
  76. Top xlsxLine `xml:"top"`
  77. Bottom xlsxLine `xml:"bottom"`
  78. }
  79. // xlsxLine directly maps the line style element in the namespace
  80. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  81. // currently I have not checked it for completeness - it does as much
  82. // as I need.
  83. type xlsxLine struct {
  84. Style string `xml:"style,attr"`
  85. }
  86. // xlsxXf directly maps the xf element in the namespace
  87. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  88. // currently I have not checked it for completeness - it does as much
  89. // as I need.
  90. type xlsxXf struct {
  91. ApplyAlignment bool `xml:"applyAlignment,attr"`
  92. ApplyBorder bool `xml:"applyBorder,attr"`
  93. ApplyFont bool `xml:"applyFont,attr"`
  94. ApplyFill bool `xml:"applyFill,attr"`
  95. ApplyProtection bool `xml:"applyProtection,attr"`
  96. BorderId int `xml:"borderId,attr"`
  97. FillId int `xml:"fillId,attr"`
  98. FontId int `xml:"fontId,attr"`
  99. NumFmtId int `xml:"numFmtId,attr"`
  100. alignment xlsxAlignment `xml:"alignement"`
  101. }
  102. type xlsxAlignment struct {
  103. Horizontal string `xml:"horizontal,attr"`
  104. Indent int `xml:"indent,attr"`
  105. ShrinkToFit bool `xml:"shrinkToFit,attr"`
  106. TextRotation int `xml:"textRotation,attr"`
  107. Vertical string `xml:"vertical,attr"`
  108. WrapText bool `xml:"wrapText,attr"`
  109. }