axlsx 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. data/Rakefile +13 -0
  2. data/lib/axlsx.rb +38 -0
  3. data/lib/axlsx/content_type/content_type.rb +23 -0
  4. data/lib/axlsx/content_type/default.rb +32 -0
  5. data/lib/axlsx/content_type/override.rb +30 -0
  6. data/lib/axlsx/doc_props/app.rb +148 -0
  7. data/lib/axlsx/doc_props/core.rb +34 -0
  8. data/lib/axlsx/drawing/axis.rb +78 -0
  9. data/lib/axlsx/drawing/bar_3D_chart.rb +138 -0
  10. data/lib/axlsx/drawing/bar_series.rb +91 -0
  11. data/lib/axlsx/drawing/cat_axis.rb +58 -0
  12. data/lib/axlsx/drawing/chart.rb +120 -0
  13. data/lib/axlsx/drawing/drawing.rb +121 -0
  14. data/lib/axlsx/drawing/graphic_frame.rb +55 -0
  15. data/lib/axlsx/drawing/marker.rb +57 -0
  16. data/lib/axlsx/drawing/pie_3D_chart.rb +59 -0
  17. data/lib/axlsx/drawing/pie_series.rb +88 -0
  18. data/lib/axlsx/drawing/scaling.rb +53 -0
  19. data/lib/axlsx/drawing/series.rb +70 -0
  20. data/lib/axlsx/drawing/title.rb +69 -0
  21. data/lib/axlsx/drawing/two_cell_anchor.rb +88 -0
  22. data/lib/axlsx/drawing/val_axis.rb +34 -0
  23. data/lib/axlsx/drawing/view_3D.rb +72 -0
  24. data/lib/axlsx/package.rb +181 -0
  25. data/lib/axlsx/rels/relationship.rb +43 -0
  26. data/lib/axlsx/rels/relationships.rb +25 -0
  27. data/lib/axlsx/stylesheet/border.rb +52 -0
  28. data/lib/axlsx/stylesheet/border_pr.rb +65 -0
  29. data/lib/axlsx/stylesheet/cell_alignment.rb +96 -0
  30. data/lib/axlsx/stylesheet/cell_protection.rb +33 -0
  31. data/lib/axlsx/stylesheet/cell_style.rb +60 -0
  32. data/lib/axlsx/stylesheet/color.rb +57 -0
  33. data/lib/axlsx/stylesheet/fill.rb +31 -0
  34. data/lib/axlsx/stylesheet/font.rb +128 -0
  35. data/lib/axlsx/stylesheet/gradient_fill.rb +70 -0
  36. data/lib/axlsx/stylesheet/gradient_stop.rb +31 -0
  37. data/lib/axlsx/stylesheet/num_fmt.rb +61 -0
  38. data/lib/axlsx/stylesheet/pattern_fill.rb +64 -0
  39. data/lib/axlsx/stylesheet/styles.rb +296 -0
  40. data/lib/axlsx/stylesheet/table_style.rb +44 -0
  41. data/lib/axlsx/stylesheet/table_style_element.rb +66 -0
  42. data/lib/axlsx/stylesheet/table_styles.rb +39 -0
  43. data/lib/axlsx/stylesheet/xf.rb +117 -0
  44. data/lib/axlsx/util/constants.rb +189 -0
  45. data/lib/axlsx/util/simple_typed_list.rb +150 -0
  46. data/lib/axlsx/util/validators.rb +132 -0
  47. data/lib/axlsx/workbook/workbook.rb +130 -0
  48. data/lib/axlsx/workbook/worksheet/cell.rb +184 -0
  49. data/lib/axlsx/workbook/worksheet/row.rb +92 -0
  50. data/lib/axlsx/workbook/worksheet/worksheet.rb +194 -0
  51. data/lib/schema/dc.xsd +118 -0
  52. data/lib/schema/dcmitype.xsd +50 -0
  53. data/lib/schema/dcterms.xsd +331 -0
  54. data/lib/schema/dml-chart.xsd +1499 -0
  55. data/lib/schema/dml-chartDrawing.xsd +146 -0
  56. data/lib/schema/dml-compatibility.xsd +14 -0
  57. data/lib/schema/dml-diagram.xsd +1091 -0
  58. data/lib/schema/dml-lockedCanvas.xsd +11 -0
  59. data/lib/schema/dml-main.xsd +3048 -0
  60. data/lib/schema/dml-picture.xsd +23 -0
  61. data/lib/schema/dml-spreadsheetDrawing.xsd +185 -0
  62. data/lib/schema/dml-wordprocessingDrawing.xsd +185 -0
  63. data/lib/schema/opc-contentTypes.xsd +42 -0
  64. data/lib/schema/opc-coreProperties.xsd +50 -0
  65. data/lib/schema/opc-digSig.xsd +49 -0
  66. data/lib/schema/opc-relationships.xsd +33 -0
  67. data/lib/schema/pml.xsd +1676 -0
  68. data/lib/schema/shared-additionalCharacteristics.xsd +28 -0
  69. data/lib/schema/shared-bibliography.xsd +144 -0
  70. data/lib/schema/shared-commonSimpleTypes.xsd +166 -0
  71. data/lib/schema/shared-customXmlDataProperties.xsd +25 -0
  72. data/lib/schema/shared-customXmlSchemaProperties.xsd +18 -0
  73. data/lib/schema/shared-documentPropertiesCustom.xsd +59 -0
  74. data/lib/schema/shared-documentPropertiesExtended.xsd +56 -0
  75. data/lib/schema/shared-documentPropertiesVariantTypes.xsd +195 -0
  76. data/lib/schema/shared-math.xsd +582 -0
  77. data/lib/schema/shared-relationshipReference.xsd +25 -0
  78. data/lib/schema/sml.xsd +4430 -0
  79. data/lib/schema/vml-main.xsd +569 -0
  80. data/lib/schema/vml-officeDrawing.xsd +509 -0
  81. data/lib/schema/vml-presentationDrawing.xsd +12 -0
  82. data/lib/schema/vml-spreadsheetDrawing.xsd +108 -0
  83. data/lib/schema/vml-wordprocessingDrawing.xsd +96 -0
  84. data/lib/schema/wml.xsd +3644 -0
  85. data/lib/schema/xml.xsd +117 -0
  86. data/test/content_type/tc_content_type.rb +81 -0
  87. data/test/content_type/tc_content_type.rb~ +81 -0
  88. data/test/content_type/tc_default.rb +40 -0
  89. data/test/content_type/tc_default.rb~ +40 -0
  90. data/test/content_type/tc_override.rb +40 -0
  91. data/test/content_type/tc_override.rb~ +40 -0
  92. data/test/doc_props/tc_app.rb +19 -0
  93. data/test/doc_props/tc_app.rb~ +19 -0
  94. data/test/doc_props/tc_core.rb +34 -0
  95. data/test/drawing/tc_axis.rb +39 -0
  96. data/test/drawing/tc_axis.rb~ +0 -0
  97. data/test/drawing/tc_bar_3D_chart.rb +66 -0
  98. data/test/drawing/tc_bar_3D_chart.rb~ +4 -0
  99. data/test/drawing/tc_bar_series.rb +34 -0
  100. data/test/drawing/tc_bar_series.rb~ +31 -0
  101. data/test/drawing/tc_cat_axis.rb +32 -0
  102. data/test/drawing/tc_cat_axis.rb~ +39 -0
  103. data/test/drawing/tc_chart.rb +59 -0
  104. data/test/drawing/tc_chart.rb~ +58 -0
  105. data/test/drawing/tc_drawing.rb +71 -0
  106. data/test/drawing/tc_graphic_frame.rb +26 -0
  107. data/test/drawing/tc_graphic_frame.rb~ +21 -0
  108. data/test/drawing/tc_marker.rb +45 -0
  109. data/test/drawing/tc_marker.rb~ +26 -0
  110. data/test/drawing/tc_pie_3D_chart.rb +33 -0
  111. data/test/drawing/tc_pie_3D_chart.rb~ +58 -0
  112. data/test/drawing/tc_pie_series.rb +35 -0
  113. data/test/drawing/tc_pie_series.rb~ +26 -0
  114. data/test/drawing/tc_scaling.rb +37 -0
  115. data/test/drawing/tc_scaling.rb~ +45 -0
  116. data/test/drawing/tc_series.rb +24 -0
  117. data/test/drawing/tc_series.rb~ +31 -0
  118. data/test/drawing/tc_title.rb +34 -0
  119. data/test/drawing/tc_title.rb~ +37 -0
  120. data/test/drawing/tc_two_cell_anchor.rb +37 -0
  121. data/test/drawing/tc_two_cell_anchor.rb~ +35 -0
  122. data/test/drawing/tc_val_axis.rb +20 -0
  123. data/test/drawing/tc_val_axis.rb~ +32 -0
  124. data/test/drawing/tc_view_3D.rb +46 -0
  125. data/test/drawing/tc_view_3D.rb~ +37 -0
  126. data/test/rels/tc_relationship.rb +16 -0
  127. data/test/rels/tc_relationship.rb~ +39 -0
  128. data/test/rels/tc_relationships.rb +32 -0
  129. data/test/rels/tc_relationships.rb~ +37 -0
  130. data/test/stylesheet/tc_border.rb +38 -0
  131. data/test/stylesheet/tc_border.rb~ +31 -0
  132. data/test/stylesheet/tc_border_pr.rb +33 -0
  133. data/test/stylesheet/tc_border_pr.rb~ +31 -0
  134. data/test/stylesheet/tc_cell_alignment.rb +77 -0
  135. data/test/stylesheet/tc_cell_alignment.rb~ +38 -0
  136. data/test/stylesheet/tc_cell_protection.rb +30 -0
  137. data/test/stylesheet/tc_cell_protection.rb~ +77 -0
  138. data/test/stylesheet/tc_cell_style.rb +58 -0
  139. data/test/stylesheet/tc_cell_style.rb~ +30 -0
  140. data/test/stylesheet/tc_color.rb +38 -0
  141. data/test/stylesheet/tc_color.rb~ +38 -0
  142. data/test/stylesheet/tc_fill.rb +19 -0
  143. data/test/stylesheet/tc_fill.rb~ +19 -0
  144. data/test/stylesheet/tc_font.rb +114 -0
  145. data/test/stylesheet/tc_font.rb~ +19 -0
  146. data/test/stylesheet/tc_gradient_fill.rb +65 -0
  147. data/test/stylesheet/tc_gradient_fill.rb~ +114 -0
  148. data/test/stylesheet/tc_gradient_stop.rb +32 -0
  149. data/test/stylesheet/tc_gradient_stop.rb~ +65 -0
  150. data/test/stylesheet/tc_num_fmt.rb +31 -0
  151. data/test/stylesheet/tc_num_fmt.rb~ +32 -0
  152. data/test/stylesheet/tc_pattern_fill.rb +38 -0
  153. data/test/stylesheet/tc_pattern_fill.rb~ +31 -0
  154. data/test/stylesheet/tc_styles.rb +64 -0
  155. data/test/stylesheet/tc_table_style.rb +37 -0
  156. data/test/stylesheet/tc_table_style.rb~ +38 -0
  157. data/test/stylesheet/tc_table_style_element.rb +37 -0
  158. data/test/stylesheet/tc_table_style_element.rb~ +37 -0
  159. data/test/stylesheet/tc_table_styles.rb +30 -0
  160. data/test/stylesheet/tc_table_styles.rb~ +37 -0
  161. data/test/stylesheet/tc_xf.rb +121 -0
  162. data/test/stylesheet/tc_xf.rb~ +30 -0
  163. data/test/tc_app.rb~ +19 -0
  164. data/test/tc_border_pr.rb~ +21 -0
  165. data/test/tc_package.rb +70 -0
  166. data/test/tc_package.rb~ +64 -0
  167. data/test/tc_pie_3D_chart.rb~ +66 -0
  168. data/test/tc_relationships.rb~ +37 -0
  169. data/test/tc_series.rb~ +31 -0
  170. data/test/tc_styles.rb~ +64 -0
  171. data/test/tc_validators.rb~ +77 -0
  172. data/test/tc_worksheet.rb~ +85 -0
  173. data/test/util/tc_simple_typed_list.rb +66 -0
  174. data/test/util/tc_validators.rb +76 -0
  175. data/test/workbook/tc_workbook.rb +53 -0
  176. data/test/workbook/worksheet/tc_cell.rb +78 -0
  177. data/test/workbook/worksheet/tc_row.rb +30 -0
  178. data/test/workbook/worksheet/tc_worksheet.rb +85 -0
  179. metadata +378 -0
@@ -0,0 +1,96 @@
1
+ module Axlsx
2
+ # CellAlignment stores information about the cell alignment of a style Xf Object.
3
+ # @note Using Styles#add_style is the recommended way to manage cell alignment.
4
+ # @see Styles#add_style
5
+ class CellAlignment
6
+ # The horizontal alignment of the cell.
7
+ # @note
8
+ # The horizontal cell alignement style must be one of
9
+ # :general
10
+ # :left
11
+ # :center
12
+ # :right
13
+ # :fill
14
+ # :justify
15
+ # :centerContinuous
16
+ # :distributed
17
+ # @return [Symbol]
18
+ attr_accessor :horizontal
19
+
20
+ # The vertical alignment of the cell.
21
+ # @note
22
+ # The vertical cell allingment style must be one of the following:
23
+ # :top
24
+ # :center
25
+ # :bottom
26
+ # :justify
27
+ # :distributed
28
+ # @return [Symbol]
29
+ attr_accessor :vertical
30
+
31
+ # The textRotation of the cell.
32
+ # @return [Integer]
33
+ attr_accessor :textRotation
34
+
35
+ # Indicate if the text of the cell should wrap
36
+ # @return [Boolean]
37
+ attr_accessor :wrapText
38
+
39
+ # The amount of indent
40
+ # @return [Integer]
41
+ attr_accessor :indent
42
+
43
+ # The amount of relativeIndent
44
+ # @return [Integer]
45
+ attr_accessor :relativeIndent
46
+
47
+ # Indicate if the last line should be justified.
48
+ # @return [Boolean]
49
+ attr_accessor :justifyLastLine
50
+
51
+ # Indicate if the text should be shrunk to the fit in the cell.
52
+ # @return [Boolean]
53
+ attr_accessor :shrinkToFit
54
+
55
+ # The reading order of the text
56
+ # 0 Context Dependent
57
+ # 1 Left-to-Right
58
+ # 2 Right-to-Left
59
+ # @return [Integer]
60
+ attr_accessor :readingOrder
61
+
62
+ # Create a new cell_alignment object
63
+ # @option options [Symbol] horizontal
64
+ # @option options [Symbol] vertical
65
+ # @option options [Integer] textRotation
66
+ # @option options [Boolean] wrapText
67
+ # @option options [Integer] indent
68
+ # @option options [Integer] relativeIndent
69
+ # @option options [Boolean] justifyLastLine
70
+ # @option options [Boolean] shrinkToFit
71
+ # @option options [Integer] readingOrder
72
+ def initialize(options={})
73
+ options.each do |o|
74
+ self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
75
+ end
76
+ end
77
+
78
+ def horizontal=(v) Axlsx::validate_horizontal_alignment v; @horizontal = v end
79
+ def vertical=(v) Axlsx::validate_vertical_alignment v; @vertical = v end
80
+ def textRotation=(v) Axlsx::validate_unsigned_int v; @textRotation = v end
81
+ def wrapText=(v) Axlsx::validate_boolean v; @wrapText = v end
82
+ def indent=(v) Axlsx::validate_unsigned_int v; @indent = v end
83
+ def relativeIndent=(v) Axlsx::validate_int v; @relativeIndent = v end
84
+ def justifyLastLine=(v) Axlsx::validate_boolean v; @justifyLastLine = v end
85
+ def shrinkToFit=(v) Axlsx::validate_boolean v; @shrinkToFit = v end
86
+ def readingOrder=(v) Axlsx::validate_unsigned_int v; @readingOrder = v end
87
+
88
+ # Serializes the cell alignment
89
+ # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
90
+ # @return [String]
91
+ def to_xml(xml)
92
+ xml.alignment(self.instance_values)
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,33 @@
1
+ module Axlsx
2
+ # CellProtection stores information about locking or hiding cells in spreadsheet.
3
+ # @note Using Styles#add_style is the recommended way to manage cell protection.
4
+ # @see Styles#add_style
5
+ class CellProtection
6
+
7
+ # specifies locking for cells that have the style containing this protection
8
+ # @return [Boolean]
9
+ attr_accessor :hidden
10
+
11
+ # specifies if the cells that have the style containing this protection
12
+ # @return [Boolean]
13
+ attr_accessor :locked
14
+
15
+ # Creates a new CellProtection
16
+ # @option options [Boolean] hidden value for hidden protection
17
+ # @option options [Boolean] locked value for locked protection
18
+ def initialize(options={})
19
+ options.each do |o|
20
+ self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
21
+ end
22
+ end
23
+ def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
24
+ def locked=(v) Axlsx::validate_boolean v; @locked = v end
25
+
26
+ # Serializes the cell protection
27
+ # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
28
+ # @return [String]
29
+ def to_xml(xml)
30
+ xml.protection(self.instance_values)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,60 @@
1
+ module Axlsx
2
+ # CellStyle defines named styles that reference defined formatting records and can be used in your worksheet.
3
+ # @note Using Styles#add_style is the recommended way to manage cell styling.
4
+ # @see Styles#add_style
5
+ class CellStyle
6
+ # The name of this cell style
7
+ # @return [String]
8
+ attr_accessor :name
9
+
10
+ # The formatting record id this named style utilizes
11
+ # @return [Integer]
12
+ # @see Axlsx::Xf
13
+ attr_accessor :xfId
14
+
15
+ # The buildinId to use when this named style is applied
16
+ # @return [Integer]
17
+ # @see Axlsx::NumFmt
18
+ attr_accessor :builtinId
19
+
20
+ # Determines if this formatting is for an outline style, and what level of the outline it is to be applied to.
21
+ # @return [Integer]
22
+ attr_accessor :iLevel
23
+
24
+ # Determines if this named style should show in the list of styles when using excel
25
+ # @return [Boolean]
26
+ attr_accessor :hidden
27
+
28
+ # Indicates that the build in style reference has been customized.
29
+ # @return [Boolean]
30
+ attr_accessor :customBuiltin
31
+
32
+ # Creats a new CellStyle object
33
+ # @option options [String] name
34
+ # @option options [Integer] xfId
35
+ # @option options [Integer] buildinId
36
+ # @option options [Integer] iLevel
37
+ # @option options [Boolean] hidden
38
+ # @option options [Boolean] customBuiltIn
39
+ def initialize(options={})
40
+ options.each do |o|
41
+ self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
42
+ end
43
+ end
44
+
45
+ def name=(v) Axlsx::validate_string v; @name = v end
46
+ def xfId=(v) Axlsx::validate_unsigned_int v; @xfId = v end
47
+ def builtinId=(v) Axlsx::validate_unsigned_int v; @builtinId = v end
48
+ def iLevel=(v) Axlsx::validate_unsigned_int v; @iLevel = v end
49
+ def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
50
+ def customBuiltin=(v) Axlsx::validate_boolean v; @customBuiltin = v end
51
+
52
+ # Serializes the cell style
53
+ # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
54
+ # @return [String]
55
+ def to_xml(xml)
56
+ xml.cellStyle(self.instance_values)
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,57 @@
1
+ module Axlsx
2
+ # The color class represents a color used for borders, fills an fonts
3
+ class Color
4
+ # Determines if the color is system color dependant
5
+ # @return [Boolean]
6
+ attr_accessor :auto
7
+
8
+ # Backwards compatability color index
9
+ # return [Integer]
10
+ #attr_accessor :indexed
11
+
12
+ # The color as defined in rgb terms.
13
+ # @note
14
+ # rgb colors need to conform to ST_UnsignedIntHex. That basically means put 'FF' before you color
15
+ # @example rgb colors
16
+ # "FF000000" is black
17
+ # "FFFFFFFF" is white
18
+ # @return [String]
19
+ attr_accessor :rgb
20
+
21
+ # no support for theme just yet
22
+ # @return [Integer]
23
+ #attr_accessor :theme
24
+
25
+ # The tint value.
26
+ # @note valid values are between -1.0 and 1.0
27
+ # @return [Float]
28
+ attr_accessor :tint
29
+
30
+ # Creates a new Color object
31
+ # @option options [Boolean] auto
32
+ # @option options [String] rgb
33
+ # @option options [Float] tint
34
+ def initialize(options={})
35
+ @rgb = "FF000000"
36
+ options.each do |o|
37
+ self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
38
+ end
39
+ end
40
+
41
+ def auto=(v) Axlsx::validate_boolean v; @auto = v end
42
+ def rgb=(v) Axlsx::validate_string v; @rgb = v end
43
+ def tint=(v) Axlsx::validate_float v; @tint = v end
44
+
45
+ # This version does not support themes
46
+ # def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end
47
+
48
+ # Indexed colors are for backward compatability which I am choosing not to support
49
+ # def indexed=(v) Axlsx::validate_unsigned_integer v; @indexed = v end
50
+
51
+
52
+ # Serializes the color
53
+ # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
54
+ # @return [String]
55
+ def to_xml(xml) xml.color(self.instance_values) end
56
+ end
57
+ end
@@ -0,0 +1,31 @@
1
+ module Axlsx
2
+ # The Fill is a formatting object that manages the background color, and pattern for cells.
3
+ # @note The recommended way to manage styles in your workbook is to use Styles#add_style.
4
+ # @see Styles#add_style
5
+ # @see PatternFill
6
+ # @see GradientFill
7
+ class Fill
8
+
9
+ # The type of fill
10
+ # @return [PatternFill, GradientFill]
11
+ attr_accessor :fill_type
12
+
13
+ # Creates a new Fill object
14
+ # @param [PatternFill, GradientFill] fill_type
15
+ # @raise [ArgumentError] if the fill_type parameter is not a PatternFill or a GradientFill instance
16
+ def initialize(fill_type)
17
+ self.fill_type = fill_type
18
+ end
19
+
20
+ # Serializes the fill
21
+ # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
22
+ # @return [String]
23
+ def to_xml(xml)
24
+ xml.fill { @fill_type.to_xml(xml) }
25
+ end
26
+
27
+ def fill_type=(v) DataTypeValidator.validate "Fill.fill_type", [PatternFill, GradientFill], v; @fill_type = v; end
28
+
29
+
30
+ end
31
+ end
@@ -0,0 +1,128 @@
1
+ module Axlsx
2
+ # The Font class details a font instance for use in styling cells.
3
+ # @note The recommended way to manage fonts, and other styles is Styles#add_style
4
+ # @see Styles#add_style
5
+ class Font
6
+ # The name of the font
7
+ # @return [String]
8
+ attr_accessor :name
9
+
10
+ # The charset of the font
11
+ # @return [Integer]
12
+ # @note
13
+ # The following values are defined in the OOXML specification and are OS dependant values
14
+ # 0 ANSI_CHARSET
15
+ # 1 DEFAULT_CHARSET
16
+ # 2 SYMBOL_CHARSET
17
+ # 77 MAC_CHARSET
18
+ # 128 SHIFTJIS_CHARSET
19
+ # 129 HANGUL_CHARSET
20
+ # 130 JOHAB_CHARSET
21
+ # 134 GB2312_CHARSET
22
+ # 136 CHINESEBIG5_CHARSET
23
+ # 161 GREEK_CHARSET
24
+ # 162 TURKISH_CHARSET
25
+ # 163 VIETNAMESE_CHARSET
26
+ # 177 HEBREW_CHARSET
27
+ # 178 ARABIC_CHARSET
28
+ # 186 BALTIC_CHARSET
29
+ # 204 RUSSIAN_CHARSET
30
+ # 222 THAI_CHARSET
31
+ # 238 EASTEUROPE_CHARSET
32
+ # 255 OEM_CHARSET
33
+ attr_accessor :charset
34
+
35
+ # The font's family
36
+ # @note
37
+ # The following are defined OOXML specification
38
+ # 0 Not applicable.
39
+ # 1 Roman
40
+ # 2 Swiss
41
+ # 3 Modern
42
+ # 4 Script
43
+ # 5 Decorative
44
+ # 6..14 Reserved for future use
45
+ # @return [Integer]
46
+ attr_accessor :family
47
+
48
+ # Indicates if the font should be rendered in *bold*
49
+ # @return [Boolean]
50
+ attr_accessor :b
51
+
52
+ # Indicates if the font should be rendered italicized
53
+ # @return [Boolean]
54
+ attr_accessor :i
55
+
56
+ # Indicates if the font should be rendered with a strikthrough
57
+ # @return [Boolean]
58
+ attr_accessor :strike
59
+
60
+ # Indicates if the font should be rendered with an outline
61
+ # @return [Boolean]
62
+ attr_accessor :outline
63
+
64
+ # Indicates if the font should be rendered with a shadow
65
+ # @return [Boolean]
66
+ attr_accessor :shadow
67
+
68
+ # Indicates if the font should be condensed
69
+ # @return [Boolean]
70
+ attr_accessor :condense
71
+
72
+ # The font's extend property
73
+ # @return [Boolean]
74
+ attr_accessor :extend
75
+
76
+ # The color of the font
77
+ # @return [Color]
78
+ attr_accessor :color
79
+
80
+ # The size of the font.
81
+ # @return [Integer]
82
+ attr_accessor :sz
83
+
84
+ # Creates a new Font
85
+ # @option options [String] name
86
+ # @option options [Integer] charset
87
+ # @option options [Integer] family
88
+ # @option options [Integer] family
89
+ # @option options [Boolean] b
90
+ # @option options [Boolean] i
91
+ # @option options [Boolean] strike
92
+ # @option options [Boolean] outline
93
+ # @option options [Boolean] shadow
94
+ # @option options [Boolean] condense
95
+ # @option options [Boolean] extend
96
+ # @option options [Color] color
97
+ # @option options [Integer] sz
98
+ def initialize(options={})
99
+ options.each do |o|
100
+ self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
101
+ end
102
+ end
103
+
104
+ def name=(v) Axlsx::validate_string v; @name = v end
105
+ def charset=(v) Axlsx::validate_unsigned_int v; @charset = v end
106
+ def family=(v) Axlsx::validate_unsigned_int v; @family = v end
107
+ def b=(v) Axlsx::validate_boolean v; @b = v end
108
+ def i=(v) Axlsx::validate_boolean v; @i = v end
109
+ def strike=(v) Axlsx::validate_boolean v; @strike = v end
110
+ def outline=(v) Axlsx::validate_boolean v; @outline = v end
111
+ def shadow=(v) Axlsx::validate_boolean v; @shadow = v end
112
+ def condense=(v) Axlsx::validate_boolean v; @condense = v end
113
+ def extend=(v) Axlsx::validate_boolean v; @extend = v end
114
+ def color=(v) DataTypeValidator.validate "Font.color", Color, v; @color=v end
115
+ def sz=(v) Axlsx::validate_unsigned_int v; @sz=v end
116
+
117
+ # Serializes the fill
118
+ # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
119
+ # @return [String]
120
+ def to_xml(xml)
121
+ xml.font {
122
+ self.instance_values.each do |k, v|
123
+ v.is_a?(Color) ? v.to_xml(xml) : xml.send(k, {:val => v})
124
+ end
125
+ }
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,70 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Axlsx
3
+ # A GradientFill defines the color and positioning for gradiant cell fill.
4
+ # @see Open Office XML Part 1 §18.8.24
5
+ class GradientFill
6
+
7
+ # The type of gradient.
8
+ # @note
9
+ # valid options are
10
+ # :linear
11
+ # :path
12
+ # @return [Symbol]
13
+ attr_accessor :type
14
+
15
+ # Angle of the linear gradient
16
+ # @return [Float]
17
+ attr_accessor :degree
18
+
19
+ # Percentage format left
20
+ # @return [Float]
21
+ attr_accessor :left
22
+
23
+ # Percentage format right
24
+ # @return [Float]
25
+ attr_accessor :right
26
+
27
+ # Percentage format top
28
+ # @return [Float]
29
+ attr_accessor :top
30
+
31
+ # Percentage format bottom
32
+ # @return [Float]
33
+ attr_accessor :bottom
34
+
35
+ # Collection of stop objects
36
+ # @return [SimpleTypedList]
37
+ attr_reader :stop
38
+
39
+ # Creates a new GradientFill object
40
+ # @option options [Symbol] type
41
+ # @option options [Float] degree
42
+ # @option options [Float] left
43
+ # @option options [Float] right
44
+ # @option options [Float] top
45
+ # @option options [Float] bottom
46
+ def initialize(options={})
47
+ options[:type] ||= :linear
48
+ options.each do |o|
49
+ self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
50
+ end
51
+ @stop = SimpleTypedList.new GradientStop
52
+ end
53
+
54
+ def type=(v) Axlsx::validate_gradient_type v; @type = v end
55
+ def degree=(v) Axlsx::validate_float v; @degree = v end
56
+ def left=(v) DataTypeValidator.validate "GradientFill.left", Float, v, lambda { |v| v >= 0.0 && v <= 1.0}; @left = v end
57
+ def right=(v) DataTypeValidator.validate "GradientFill.right", Float, v, lambda { |v| v >= 0.0 && v <= 1.0}; @right = v end
58
+ def top=(v) DataTypeValidator.validate "GradientFill.top", Float, v, lambda { |v| v >= 0.0 && v <= 1.0}; @top = v end
59
+ def bottom=(v) DataTypeValidator.validate "GradientFill.bottom", Float, v, lambda { |v| v >= 0.0 && v <= 1.0}; @bottom= v end
60
+
61
+ # Serializes the gradientFill
62
+ # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
63
+ # @return [String]
64
+ def to_xml(xml)
65
+ xml.gradientFill(self.instance_values.reject { |k,v| k.to_sym == :stop }) {
66
+ @stop.each { |s| s.to_xml(xml) }
67
+ }
68
+ end
69
+ end
70
+ end