axlsx 1.0.18 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/CHANGELOG.md +11 -3
  2. data/README.md +93 -18
  3. data/examples/example.csv +1000 -0
  4. data/examples/example.rb +97 -5
  5. data/examples/example.xlsx +0 -0
  6. data/examples/example_streamed.xlsx +0 -0
  7. data/examples/no-use_autowidth.xlsx +0 -0
  8. data/examples/shared_strings_example.xlsx +0 -0
  9. data/lib/axlsx.rb +30 -9
  10. data/lib/axlsx/content_type/content_type.rb +9 -9
  11. data/lib/axlsx/content_type/default.rb +9 -6
  12. data/lib/axlsx/content_type/override.rb +12 -8
  13. data/lib/axlsx/doc_props/app.rb +37 -40
  14. data/lib/axlsx/doc_props/core.rb +12 -17
  15. data/lib/axlsx/drawing/axis.rb +38 -19
  16. data/lib/axlsx/drawing/bar_3D_chart.rb +33 -32
  17. data/lib/axlsx/drawing/bar_series.rb +13 -14
  18. data/lib/axlsx/drawing/cat_axis.rb +15 -14
  19. data/lib/axlsx/drawing/cat_axis_data.rb +16 -18
  20. data/lib/axlsx/drawing/chart.rb +37 -38
  21. data/lib/axlsx/drawing/drawing.rb +15 -12
  22. data/lib/axlsx/drawing/graphic_frame.rb +21 -21
  23. data/lib/axlsx/drawing/hyperlink.rb +12 -11
  24. data/lib/axlsx/drawing/line_3D_chart.rb +30 -28
  25. data/lib/axlsx/drawing/line_series.rb +11 -11
  26. data/lib/axlsx/drawing/marker.rb +10 -8
  27. data/lib/axlsx/drawing/named_axis_data.rb +36 -0
  28. data/lib/axlsx/drawing/one_cell_anchor.rb +17 -16
  29. data/lib/axlsx/drawing/pic.rb +24 -37
  30. data/lib/axlsx/drawing/picture_locking.rb +21 -18
  31. data/lib/axlsx/drawing/pie_3D_chart.rb +10 -8
  32. data/lib/axlsx/drawing/pie_series.rb +15 -12
  33. data/lib/axlsx/drawing/scaling.rb +10 -10
  34. data/lib/axlsx/drawing/scatter_chart.rb +69 -0
  35. data/lib/axlsx/drawing/scatter_series.rb +39 -0
  36. data/lib/axlsx/drawing/ser_axis.rb +10 -10
  37. data/lib/axlsx/drawing/series.rb +15 -15
  38. data/lib/axlsx/drawing/series_title.rb +14 -14
  39. data/lib/axlsx/drawing/title.rb +26 -26
  40. data/lib/axlsx/drawing/two_cell_anchor.rb +18 -20
  41. data/lib/axlsx/drawing/val_axis.rb +8 -7
  42. data/lib/axlsx/drawing/val_axis_data.rb +17 -17
  43. data/lib/axlsx/drawing/view_3D.rb +22 -20
  44. data/lib/axlsx/package.rb +32 -15
  45. data/lib/axlsx/rels/relationship.rb +9 -6
  46. data/lib/axlsx/rels/relationships.rb +7 -1
  47. data/lib/axlsx/stylesheet/#num_fmt.rb# +69 -0
  48. data/lib/axlsx/stylesheet/border.rb +27 -23
  49. data/lib/axlsx/stylesheet/border_pr.rb +16 -15
  50. data/lib/axlsx/stylesheet/cell_alignment.rb +23 -21
  51. data/lib/axlsx/stylesheet/cell_protection.rb +10 -7
  52. data/lib/axlsx/stylesheet/cell_style.rb +8 -5
  53. data/lib/axlsx/stylesheet/color.rb +20 -14
  54. data/lib/axlsx/stylesheet/fill.rb +7 -5
  55. data/lib/axlsx/stylesheet/font.rb +14 -14
  56. data/lib/axlsx/stylesheet/gradient_fill.rb +19 -16
  57. data/lib/axlsx/stylesheet/gradient_stop.rb +9 -5
  58. data/lib/axlsx/stylesheet/num_fmt.rb +12 -6
  59. data/lib/axlsx/stylesheet/pattern_fill.rb +25 -10
  60. data/lib/axlsx/stylesheet/styles.rb +41 -32
  61. data/lib/axlsx/stylesheet/table_style.rb +9 -4
  62. data/lib/axlsx/stylesheet/table_style_element.rb +10 -7
  63. data/lib/axlsx/stylesheet/table_styles.rb +11 -8
  64. data/lib/axlsx/stylesheet/xf.rb +29 -25
  65. data/lib/axlsx/util/constants.rb +4 -0
  66. data/lib/axlsx/util/simple_typed_list.rb +18 -9
  67. data/lib/axlsx/util/validators.rb +13 -6
  68. data/lib/axlsx/version.rb +1 -1
  69. data/lib/axlsx/workbook/shared_strings_table.rb +19 -21
  70. data/lib/axlsx/workbook/workbook.rb +43 -19
  71. data/lib/axlsx/workbook/worksheet/cell.rb +93 -91
  72. data/lib/axlsx/workbook/worksheet/col.rb +114 -0
  73. data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
  74. data/lib/axlsx/workbook/worksheet/page_margins.rb +16 -13
  75. data/lib/axlsx/workbook/worksheet/row.rb +13 -13
  76. data/lib/axlsx/workbook/worksheet/table.rb +96 -0
  77. data/lib/axlsx/workbook/worksheet/table.rb~ +97 -0
  78. data/lib/axlsx/workbook/worksheet/worksheet.rb +152 -118
  79. data/lib/schema/dc.xsd +5 -5
  80. data/lib/schema/dcmitype.xsd +5 -3
  81. data/lib/schema/dcterms.xsd +15 -15
  82. data/lib/schema/opc-coreProperties.xsd +6 -2
  83. data/lib/schema/xml.xsd +7 -8
  84. data/test/#benchmark.txt# +7 -0
  85. data/test/#tc_helper.rb# +3 -0
  86. data/test/benchmark.rb +81 -0
  87. data/test/benchmark.rb~ +0 -0
  88. data/test/benchmark.txt +6 -0
  89. data/test/benchmark.txt~ +6 -0
  90. data/test/content_type/tc_content_type.rb +30 -32
  91. data/test/content_type/tc_default.rb +8 -23
  92. data/test/content_type/tc_override.rb +7 -21
  93. data/test/doc_props/tc_app.rb +2 -8
  94. data/test/doc_props/tc_core.rb +6 -7
  95. data/test/drawing/tc_axis.rb +7 -3
  96. data/test/drawing/tc_bar_3D_chart.rb +6 -7
  97. data/test/drawing/tc_bar_series.rb +4 -5
  98. data/test/drawing/tc_cat_axis.rb +2 -3
  99. data/test/drawing/tc_cat_axis_data.rb +2 -3
  100. data/test/drawing/tc_chart.rb +11 -12
  101. data/test/drawing/tc_drawing.rb +7 -8
  102. data/test/drawing/tc_graphic_frame.rb +3 -4
  103. data/test/drawing/tc_hyperlink.rb +2 -3
  104. data/test/drawing/tc_line_3d_chart.rb +5 -6
  105. data/test/drawing/tc_line_series.rb +3 -4
  106. data/test/drawing/tc_marker.rb +3 -4
  107. data/test/drawing/tc_one_cell_anchor.rb +6 -7
  108. data/test/drawing/tc_pic.rb +8 -9
  109. data/test/drawing/tc_picture_locking.rb +2 -3
  110. data/test/drawing/tc_pie_3D_chart.rb +5 -6
  111. data/test/drawing/tc_pie_series.rb +4 -5
  112. data/test/drawing/tc_scaling.rb +3 -4
  113. data/test/drawing/tc_scatter_chart.rb +43 -0
  114. data/test/drawing/tc_scatter_series.rb +20 -0
  115. data/test/drawing/tc_ser_axis.rb +2 -3
  116. data/test/drawing/tc_series.rb +4 -5
  117. data/test/drawing/tc_series_title.rb +4 -5
  118. data/test/drawing/tc_title.rb +4 -5
  119. data/test/drawing/tc_two_cell_anchor.rb +4 -5
  120. data/test/drawing/tc_val_axis.rb +2 -3
  121. data/test/drawing/tc_val_axis_data.rb +2 -3
  122. data/test/drawing/tc_view_3D.rb +6 -7
  123. data/test/example.csv +1000 -0
  124. data/test/example.xlsx +0 -0
  125. data/test/example_streamed.xlsx +0 -0
  126. data/test/profile.rb +33 -0
  127. data/test/rels/tc_relationship.rb +5 -6
  128. data/test/rels/tc_relationships.rb +4 -5
  129. data/test/stylesheet/tc_border.rb +3 -4
  130. data/test/stylesheet/tc_border_pr.rb +3 -4
  131. data/test/stylesheet/tc_cell_alignment.rb +4 -5
  132. data/test/stylesheet/tc_cell_protection.rb +2 -3
  133. data/test/stylesheet/tc_cell_style.rb +2 -3
  134. data/test/stylesheet/tc_color.rb +2 -3
  135. data/test/stylesheet/tc_fill.rb +1 -2
  136. data/test/stylesheet/tc_font.rb +5 -6
  137. data/test/stylesheet/tc_gradient_fill.rb +1 -2
  138. data/test/stylesheet/tc_gradient_stop.rb +1 -2
  139. data/test/stylesheet/tc_num_fmt.rb +1 -2
  140. data/test/stylesheet/tc_pattern_fill.rb +3 -4
  141. data/test/stylesheet/tc_styles.rb +15 -9
  142. data/test/stylesheet/tc_table_style.rb +2 -3
  143. data/test/stylesheet/tc_table_style_element.rb +2 -3
  144. data/test/stylesheet/tc_table_styles.rb +3 -4
  145. data/test/stylesheet/tc_xf.rb +16 -17
  146. data/test/tc_axlsx.rb +39 -0
  147. data/test/tc_axlsx.rb~ +0 -0
  148. data/test/tc_helper.rb +3 -0
  149. data/test/tc_helper.rb~ +3 -0
  150. data/test/tc_package.rb +13 -10
  151. data/test/util/tc_simple_typed_list.rb +8 -9
  152. data/test/util/tc_validators.rb +7 -8
  153. data/test/workbook/tc_shared_strings_table.rb +5 -6
  154. data/test/workbook/tc_workbook.rb +24 -6
  155. data/test/workbook/worksheet/table/tc_table.rb +71 -0
  156. data/test/workbook/worksheet/table/tc_table.rb~ +72 -0
  157. data/test/workbook/worksheet/tc_cell.rb +24 -10
  158. data/test/workbook/worksheet/tc_col.rb +59 -0
  159. data/test/workbook/worksheet/tc_col.rb~ +10 -0
  160. data/test/workbook/worksheet/tc_date_time_converter.rb +1 -2
  161. data/test/workbook/worksheet/tc_page_margins.rb +6 -9
  162. data/test/workbook/worksheet/tc_row.rb +26 -12
  163. data/test/workbook/worksheet/tc_worksheet.rb +134 -68
  164. metadata +150 -90
  165. data/test/drawing/tc_hyperlink.rb~ +0 -71
  166. data/test/workbook/tc_shared_strings_table.rb~ +0 -8
  167. data/test/workbook/worksheet/tc_date_time_converter.rb~ +0 -69
@@ -1,22 +1,22 @@
1
1
  # encoding: UTF-8
2
2
  module Axlsx
3
- # A border part.
3
+ # A border part.
4
4
  class BorderPr
5
-
5
+
6
6
  # @return [Color] The color of this border part.
7
7
  attr_reader :color
8
8
 
9
- # @return [Symbol] The syle of this border part.
10
- # @note
9
+ # @return [Symbol] The syle of this border part.
10
+ # @note
11
11
  # The following are allowed
12
- # :none
12
+ # :none
13
13
  # :thin
14
14
  # :medium
15
15
  # :dashed
16
16
  # :dotted
17
17
  # :thick
18
18
  # :double
19
- # :hair
19
+ # :hair
20
20
  # :mediumDashed
21
21
  # :dashDot
22
22
  # :mediumDashDot
@@ -26,7 +26,7 @@ module Axlsx
26
26
  attr_reader :style
27
27
 
28
28
  # @return [Symbol] The name of this border part
29
- # @note
29
+ # @note
30
30
  # The following are allowed
31
31
  # :start
32
32
  # :end
@@ -38,7 +38,7 @@ module Axlsx
38
38
  # :vertical
39
39
  # :horizontal
40
40
  attr_reader :name
41
-
41
+
42
42
  # Creates a new Border Part Object
43
43
  # @option options [Color] color
44
44
  # @option options [Symbol] name
@@ -53,17 +53,18 @@ module Axlsx
53
53
  # @see name
54
54
  def name=(v) RestrictionValidator.validate "BorderPr.name", [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal], v; @name = v end
55
55
  # @see color
56
- def color=(v) DataTypeValidator.validate(:color, Color, v); @color = v end
56
+ def color=(v) DataTypeValidator.validate(:color, Color, v); @color = v end
57
57
  # @see style
58
58
  def style=(v) RestrictionValidator.validate "BorderPr.style", [:none, :thin, :medium, :dashed, :dotted, :thick, :double, :hair, :mediumDashed, :dashDot, :mediumDashDot, :dashDotDot, :mediumDashDotDot, :slantDashDot], v; @style = v end
59
59
 
60
- # Serializes the border part
61
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
60
+ # Serializes the object
61
+ # @param [String] str
62
62
  # @return [String]
63
- def to_xml(xml)
64
- xml.send(@name, :style => @style) {
65
- @color.to_xml(xml) if @color.is_a? Color
66
- }
63
+ def to_xml_string(str = '')
64
+ str << '<' << @name.to_s << ' style="' << @style.to_s << '">'
65
+ @color.to_xml_string(str) if @color.is_a?(Color)
66
+ str << '</' << @name.to_s << '>'
67
67
  end
68
+
68
69
  end
69
70
  end
@@ -1,11 +1,11 @@
1
1
  # encoding: UTF-8
2
2
  module Axlsx
3
3
  # CellAlignment stores information about the cell alignment of a style Xf Object.
4
- # @note Using Styles#add_style is the recommended way to manage cell alignment.
4
+ # @note Using Styles#add_style is the recommended way to manage cell alignment.
5
5
  # @see Styles#add_style
6
6
  class CellAlignment
7
7
  # The horizontal alignment of the cell.
8
- # @note
8
+ # @note
9
9
  # The horizontal cell alignement style must be one of
10
10
  # :general
11
11
  # :left
@@ -36,7 +36,7 @@ module Axlsx
36
36
  # Indicate if the text of the cell should wrap
37
37
  # @return [Boolean]
38
38
  attr_reader :wrapText
39
-
39
+
40
40
  # The amount of indent
41
41
  # @return [Integer]
42
42
  attr_reader :indent
@@ -54,12 +54,12 @@ module Axlsx
54
54
  attr_reader :shrinkToFit
55
55
 
56
56
  # The reading order of the text
57
- # 0 Context Dependent
57
+ # 0 Context Dependent
58
58
  # 1 Left-to-Right
59
59
  # 2 Right-to-Left
60
60
  # @return [Integer]
61
61
  attr_reader :readingOrder
62
-
62
+
63
63
  # Create a new cell_alignment object
64
64
  # @option options [Symbol] horizontal
65
65
  # @option options [Symbol] vertical
@@ -74,33 +74,35 @@ module Axlsx
74
74
  options.each do |o|
75
75
  self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
76
76
  end
77
- end
78
-
77
+ end
78
+
79
79
  # @see horizontal
80
- def horizontal=(v) Axlsx::validate_horizontal_alignment v; @horizontal = v end
80
+ def horizontal=(v) Axlsx::validate_horizontal_alignment v; @horizontal = v end
81
81
  # @see vertical
82
- def vertical=(v) Axlsx::validate_vertical_alignment v; @vertical = v end
82
+ def vertical=(v) Axlsx::validate_vertical_alignment v; @vertical = v end
83
83
  # @see textRotation
84
- def textRotation=(v) Axlsx::validate_unsigned_int v; @textRotation = v end
84
+ def textRotation=(v) Axlsx::validate_unsigned_int v; @textRotation = v end
85
85
  # @see wrapText
86
- def wrapText=(v) Axlsx::validate_boolean v; @wrapText = v end
86
+ def wrapText=(v) Axlsx::validate_boolean v; @wrapText = v end
87
87
  # @see indent
88
- def indent=(v) Axlsx::validate_unsigned_int v; @indent = v end
88
+ def indent=(v) Axlsx::validate_unsigned_int v; @indent = v end
89
89
  # @see relativeIndent
90
- def relativeIndent=(v) Axlsx::validate_int v; @relativeIndent = v end
90
+ def relativeIndent=(v) Axlsx::validate_int v; @relativeIndent = v end
91
91
  # @see justifyLastLine
92
- def justifyLastLine=(v) Axlsx::validate_boolean v; @justifyLastLine = v end
92
+ def justifyLastLine=(v) Axlsx::validate_boolean v; @justifyLastLine = v end
93
93
  # @see shrinkToFit
94
- def shrinkToFit=(v) Axlsx::validate_boolean v; @shrinkToFit = v end
94
+ def shrinkToFit=(v) Axlsx::validate_boolean v; @shrinkToFit = v end
95
95
  # @see readingOrder
96
- def readingOrder=(v) Axlsx::validate_unsigned_int v; @readingOrder = v end
96
+ def readingOrder=(v) Axlsx::validate_unsigned_int v; @readingOrder = v end
97
97
 
98
- # Serializes the cell alignment
99
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
98
+ # Serializes the object
99
+ # @param [String] str
100
100
  # @return [String]
101
- def to_xml(xml)
102
- xml.alignment(self.instance_values)
101
+ def to_xml_string(str = '')
102
+ str << '<alignment '
103
+ str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
104
+ str << '/>'
103
105
  end
104
-
106
+
105
107
  end
106
108
  end
@@ -4,7 +4,7 @@ module Axlsx
4
4
  # @note Using Styles#add_style is the recommended way to manage cell protection.
5
5
  # @see Styles#add_style
6
6
  class CellProtection
7
-
7
+
8
8
  # specifies locking for cells that have the style containing this protection
9
9
  # @return [Boolean]
10
10
  attr_reader :hidden
@@ -23,15 +23,18 @@ module Axlsx
23
23
  end
24
24
 
25
25
  # @see hidden
26
- def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
26
+ def hidden=(v) Axlsx::validate_boolean v; @hidden = v end
27
27
  # @see locked
28
- def locked=(v) Axlsx::validate_boolean v; @locked = v end
28
+ def locked=(v) Axlsx::validate_boolean v; @locked = v end
29
29
 
30
- # Serializes the cell protection
31
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
30
+ # Serializes the object
31
+ # @param [String] str
32
32
  # @return [String]
33
- def to_xml(xml)
34
- xml.protection(self.instance_values)
33
+ def to_xml_string(str = '')
34
+ str << '<protection '
35
+ str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
36
+ str << '/>'
35
37
  end
38
+
36
39
  end
37
40
  end
@@ -7,7 +7,7 @@ module Axlsx
7
7
  # The name of this cell style
8
8
  # @return [String]
9
9
  attr_reader :name
10
-
10
+
11
11
  # The formatting record id this named style utilizes
12
12
  # @return [Integer]
13
13
  # @see Axlsx::Xf
@@ -55,12 +55,15 @@ module Axlsx
55
55
  # @see customBuiltin
56
56
  def customBuiltin=(v) Axlsx::validate_boolean v; @customBuiltin = v end
57
57
 
58
- # Serializes the cell style
59
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
58
+ # Serializes the object
59
+ # @param [String] str
60
60
  # @return [String]
61
- def to_xml(xml)
62
- xml.cellStyle(self.instance_values)
61
+ def to_xml_string(str = '')
62
+ str << '<cellStyle '
63
+ str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
64
+ str << '/>'
63
65
  end
66
+
64
67
  end
65
68
 
66
69
  end
@@ -5,9 +5,9 @@ module Axlsx
5
5
  # Determines if the color is system color dependant
6
6
  # @return [Boolean]
7
7
  attr_reader :auto
8
-
9
- # The color as defined in rgb terms.
10
- # @note
8
+
9
+ # The color as defined in rgb terms.
10
+ # @note
11
11
  # rgb colors need to conform to ST_UnsignedIntHex. That basically means put 'FF' before you color
12
12
  # When assigning the rgb value the behavior is much like CSS selectors and can use shorthand versions as follows:
13
13
  # If you provide a two character value it will be repeated for each r, g, b assignment
@@ -25,16 +25,16 @@ module Axlsx
25
25
  # no support for theme just yet
26
26
  # @return [Integer]
27
27
  #attr_reader :theme
28
-
28
+
29
29
  # The tint value.
30
30
  # @note valid values are between -1.0 and 1.0
31
31
  # @return [Float]
32
32
  attr_reader :tint
33
-
33
+
34
34
  # Creates a new Color object
35
35
  # @option options [Boolean] auto
36
36
  # @option options [String] rgb
37
- # @option options [Float] tint
37
+ # @option options [Float] tint
38
38
  def initialize(options={})
39
39
  @rgb = "FF000000"
40
40
  options.each do |o|
@@ -42,7 +42,7 @@ module Axlsx
42
42
  end
43
43
  end
44
44
  # @see auto
45
- def auto=(v) Axlsx::validate_boolean v; @auto = v end
45
+ def auto=(v) Axlsx::validate_boolean v; @auto = v end
46
46
  # @see color
47
47
  def rgb=(v)
48
48
  Axlsx::validate_string(v)
@@ -56,15 +56,21 @@ module Axlsx
56
56
  def tint=(v) Axlsx::validate_float v; @tint = v end
57
57
 
58
58
  # This version does not support themes
59
- # def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end
60
-
61
- # Indexed colors are for backward compatability which I am choosing not to support
62
- # def indexed=(v) Axlsx::validate_unsigned_integer v; @indexed = v end
59
+ # def theme=(v) Axlsx::validate_unsigned_integer v; @theme = v end
63
60
 
61
+ # Indexed colors are for backward compatability which I am choosing not to support
62
+ # def indexed=(v) Axlsx::validate_unsigned_integer v; @indexed = v end
64
63
 
65
- # Serializes the color
66
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
64
+ # Serializes the object
65
+ # @param [String] str
67
66
  # @return [String]
68
- def to_xml(xml) xml.color(self.instance_values) end
67
+ def to_xml_string(str = '')
68
+ str << "<color "
69
+ self.instance_values.each do |key, value|
70
+ str << key.to_s << '="' << value.to_s << '" '
71
+ end
72
+ str << "/>"
73
+ end
74
+
69
75
  end
70
76
  end
@@ -12,17 +12,19 @@ module Axlsx
12
12
  attr_reader :fill_type
13
13
 
14
14
  # Creates a new Fill object
15
- # @param [PatternFill, GradientFill] fill_type
15
+ # @param [PatternFill, GradientFill] fill_type
16
16
  # @raise [ArgumentError] if the fill_type parameter is not a PatternFill or a GradientFill instance
17
17
  def initialize(fill_type)
18
18
  self.fill_type = fill_type
19
19
  end
20
20
 
21
- # Serializes the fill
22
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
21
+ # Serializes the object
22
+ # @param [String] str
23
23
  # @return [String]
24
- def to_xml(xml)
25
- xml.fill { @fill_type.to_xml(xml) }
24
+ def to_xml_string(str = '')
25
+ str << '<fill>'
26
+ @fill_type.to_xml_string(str)
27
+ str << '</fill>'
26
28
  end
27
29
 
28
30
  # @see fill_type
@@ -7,7 +7,7 @@ module Axlsx
7
7
  # The name of the font
8
8
  # @return [String]
9
9
  attr_reader :name
10
-
10
+
11
11
  # The charset of the font
12
12
  # @return [Integer]
13
13
  # @note
@@ -32,9 +32,9 @@ module Axlsx
32
32
  # 238 EASTEUROPE_CHARSET
33
33
  # 255 OEM_CHARSET
34
34
  attr_reader :charset
35
-
35
+
36
36
  # The font's family
37
- # @note
37
+ # @note
38
38
  # The following are defined OOXML specification
39
39
  # 0 Not applicable.
40
40
  # 1 Roman
@@ -107,13 +107,13 @@ module Axlsx
107
107
  end
108
108
  end
109
109
  # @see name
110
- def name=(v) Axlsx::validate_string v; @name = v end
110
+ def name=(v) Axlsx::validate_string v; @name = v end
111
111
  # @see charset
112
112
  def charset=(v) Axlsx::validate_unsigned_int v; @charset = v end
113
113
  # @see family
114
114
  def family=(v) Axlsx::validate_unsigned_int v; @family = v end
115
115
  # @see b
116
- def b=(v) Axlsx::validate_boolean v; @b = v end
116
+ def b=(v) Axlsx::validate_boolean v; @b = v end
117
117
  # @see i
118
118
  def i=(v) Axlsx::validate_boolean v; @i = v end
119
119
  # @see u
@@ -123,7 +123,7 @@ module Axlsx
123
123
  # @see outline
124
124
  def outline=(v) Axlsx::validate_boolean v; @outline = v end
125
125
  # @see shadow
126
- def shadow=(v) Axlsx::validate_boolean v; @shadow = v end
126
+ def shadow=(v) Axlsx::validate_boolean v; @shadow = v end
127
127
  # @see condense
128
128
  def condense=(v) Axlsx::validate_boolean v; @condense = v end
129
129
  # @see extend
@@ -133,15 +133,15 @@ module Axlsx
133
133
  # @see sz
134
134
  def sz=(v) Axlsx::validate_unsigned_int v; @sz=v end
135
135
 
136
- # Serializes the fill
137
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
136
+ # Serializes the object
137
+ # @param [String] str
138
138
  # @return [String]
139
- def to_xml(xml)
140
- xml.font {
141
- self.instance_values.each do |k, v|
142
- v.is_a?(Color) ? v.to_xml(xml) : xml.send(k, {:val => v})
143
- end
144
- }
139
+ def to_xml_string(str = '')
140
+ str << '<font>'
141
+ instance_values.each do |k, v|
142
+ v.is_a?(Color) ? v.to_xml_string(str) : (str << '<' << k.to_s << ' val="' << v.to_s << '"/>')
143
+ end
144
+ str << '</font>'
145
145
  end
146
146
  end
147
147
  end
@@ -1,11 +1,11 @@
1
1
  # encoding: UTF-8
2
2
  module Axlsx
3
3
  # A GradientFill defines the color and positioning for gradiant cell fill.
4
- # @see Open Office XML Part 1 §18.8.24
4
+ # @see Open Office XML Part 1 §18.8.24
5
5
  class GradientFill
6
6
 
7
7
  # The type of gradient.
8
- # @note
8
+ # @note
9
9
  # valid options are
10
10
  # :linear
11
11
  # :path
@@ -26,7 +26,7 @@ module Axlsx
26
26
 
27
27
  # Percentage format top
28
28
  # @return [Float]
29
- attr_reader :top
29
+ attr_reader :top
30
30
 
31
31
  # Percentage format bottom
32
32
  # @return [Float]
@@ -35,7 +35,7 @@ module Axlsx
35
35
  # Collection of stop objects
36
36
  # @return [SimpleTypedList]
37
37
  attr_reader :stop
38
-
38
+
39
39
  # Creates a new GradientFill object
40
40
  # @option options [Symbol] type
41
41
  # @option options [Float] degree
@@ -52,25 +52,28 @@ module Axlsx
52
52
  end
53
53
 
54
54
  # @see type
55
- def type=(v) Axlsx::validate_gradient_type v; @type = v end
55
+ def type=(v) Axlsx::validate_gradient_type v; @type = v end
56
56
  # @see degree
57
- def degree=(v) Axlsx::validate_float v; @degree = v end
57
+ def degree=(v) Axlsx::validate_float v; @degree = v end
58
58
  # @see left
59
- def left=(v) DataTypeValidator.validate "GradientFill.left", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @left = v end
59
+ def left=(v) DataTypeValidator.validate "GradientFill.left", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @left = v end
60
60
  # @see right
61
- def right=(v) DataTypeValidator.validate "GradientFill.right", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @right = v end
61
+ def right=(v) DataTypeValidator.validate "GradientFill.right", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @right = v end
62
62
  # @see top
63
- def top=(v) DataTypeValidator.validate "GradientFill.top", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @top = v end
63
+ def top=(v) DataTypeValidator.validate "GradientFill.top", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @top = v end
64
64
  # @see bottom
65
- def bottom=(v) DataTypeValidator.validate "GradientFill.bottom", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @bottom= v end
65
+ def bottom=(v) DataTypeValidator.validate "GradientFill.bottom", Float, v, lambda { |arg| arg >= 0.0 && arg <= 1.0}; @bottom= v end
66
66
 
67
- # Serializes the gradientFill
68
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
67
+ # Serializes the object
68
+ # @param [String] str
69
69
  # @return [String]
70
- def to_xml(xml)
71
- xml.gradientFill(self.instance_values.reject { |k,v| k.to_sym == :stop }) {
72
- @stop.each { |s| s.to_xml(xml) }
73
- }
70
+ def to_xml_string(str = '')
71
+ str << '<gradientFill'
72
+ h = self.instance_values.reject { |k,v| k.to_sym == :stop }
73
+ str << h.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
74
+ str << '>'
75
+ @stop.each { |s| s.to_xml_string(str) }
76
+ str << '</gradientFill>'
74
77
  end
75
78
  end
76
79
  end