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,9 +1,9 @@
1
1
  # encoding: UTF-8
2
2
  module Axlsx
3
- # The picture locking class defines the locking properties for pictures in your workbook.
3
+ # The picture locking class defines the locking properties for pictures in your workbook.
4
4
  class PictureLocking
5
-
6
-
5
+
6
+
7
7
  attr_reader :noGrp
8
8
  attr_reader :noSelect
9
9
  attr_reader :noRot
@@ -31,43 +31,46 @@ module Axlsx
31
31
  options.each do |o|
32
32
  self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
33
33
  end
34
- end
34
+ end
35
35
 
36
36
  # @see noGrp
37
- def noGrp=(v) Axlsx::validate_boolean v; @noGrp = v end
37
+ def noGrp=(v) Axlsx::validate_boolean v; @noGrp = v end
38
38
 
39
39
  # @see noSelect
40
- def noSelect=(v) Axlsx::validate_boolean v; @noSelect = v end
40
+ def noSelect=(v) Axlsx::validate_boolean v; @noSelect = v end
41
41
 
42
42
  # @see noRot
43
- def noRot=(v) Axlsx::validate_boolean v; @noRot = v end
43
+ def noRot=(v) Axlsx::validate_boolean v; @noRot = v end
44
44
 
45
45
  # @see noChangeAspect
46
- def noChangeAspect=(v) Axlsx::validate_boolean v; @noChangeAspect = v end
46
+ def noChangeAspect=(v) Axlsx::validate_boolean v; @noChangeAspect = v end
47
47
 
48
48
  # @see noMove
49
- def noMove=(v) Axlsx::validate_boolean v; @noMove = v end
49
+ def noMove=(v) Axlsx::validate_boolean v; @noMove = v end
50
50
 
51
51
  # @see noResize
52
- def noResize=(v) Axlsx::validate_boolean v; @noResize = v end
52
+ def noResize=(v) Axlsx::validate_boolean v; @noResize = v end
53
53
 
54
54
  # @see noEditPoints
55
- def noEditPoints=(v) Axlsx::validate_boolean v; @noEditPoints = v end
55
+ def noEditPoints=(v) Axlsx::validate_boolean v; @noEditPoints = v end
56
56
 
57
57
  # @see noAdjustHandles
58
- def noAdjustHandles=(v) Axlsx::validate_boolean v; @noAdjustHandles = v end
58
+ def noAdjustHandles=(v) Axlsx::validate_boolean v; @noAdjustHandles = v end
59
59
 
60
60
  # @see noChangeArrowheads
61
- def noChangeArrowheads=(v) Axlsx::validate_boolean v; @noChangeArrowheads = v end
61
+ def noChangeArrowheads=(v) Axlsx::validate_boolean v; @noChangeArrowheads = v end
62
62
 
63
63
  # @see noChangeShapeType
64
- def noChangeShapeType=(v) Axlsx::validate_boolean v; @noChangeShapeType = v end
64
+ def noChangeShapeType=(v) Axlsx::validate_boolean v; @noChangeShapeType = v end
65
65
 
66
- # Serializes the picture locking
67
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
66
+ # Serializes the object
67
+ # @param [String] str
68
68
  # @return [String]
69
- def to_xml(xml)
70
- xml[:a].picLocks(self.instance_values)
69
+ def to_xml_string(str = '')
70
+ str << '<a:picLocks '
71
+ str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
72
+ str << '/>'
71
73
  end
74
+
72
75
  end
73
76
  end
@@ -11,7 +11,7 @@ module Axlsx
11
11
  # Creates a new pie chart object
12
12
  # @param [GraphicFrame] frame The workbook that owns this chart.
13
13
  # @option options [Cell, String] title
14
- # @option options [Boolean] show_legend
14
+ # @option options [Boolean] show_legend
15
15
  # @option options [Symbol] grouping
16
16
  # @option options [String] gapDepth
17
17
  # @option options [Integer] rotX
@@ -28,15 +28,17 @@ module Axlsx
28
28
  @view3D = View3D.new({:rotX=>30, :perspective=>30}.merge(options))
29
29
  end
30
30
 
31
- # Serializes the pie chart
31
+ # Serializes the object
32
+ # @param [String] str
32
33
  # @return [String]
33
- def to_xml
34
- super() do |xml|
35
- xml[:c].pie3DChart {
36
- xml[:c].varyColors :val=>1
37
- @series.each { |ser| ser.to_xml(xml) }
38
- }
34
+ def to_xml_string(str = '')
35
+ super(str) do |str_inner|
36
+ str_inner << '<c:pie3DChart>'
37
+ str_inner << '<c:varyColors val="1"/>'
38
+ @series.each { |ser| ser.to_xml_string(str_inner) }
39
+ str_inner << '</c:pie3DChart>'
39
40
  end
40
41
  end
42
+
41
43
  end
42
44
  end
@@ -1,12 +1,13 @@
1
1
  # encoding: UTF-8
2
2
  module Axlsx
3
+
3
4
  # A PieSeries defines the data and labels and explosion for pie charts series.
4
5
  # @note The recommended way to manage series is to use Chart#add_series
5
6
  # @see Worksheet#add_chart
6
7
  # @see Chart#add_series
7
8
  class PieSeries < Series
8
9
 
9
- # The data for this series.
10
+ # The data for this series.
10
11
  # @return [SimpleTypedList]
11
12
  attr_reader :data
12
13
 
@@ -29,22 +30,24 @@ module Axlsx
29
30
  super(chart, options)
30
31
  self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil?
31
32
  self.data = ValAxisData.new(options[:data]) unless options[:data].nil?
32
- end
33
-
33
+ end
34
+
34
35
  # @see explosion
35
36
  def explosion=(v) Axlsx::validate_unsigned_int(v); @explosion = v; end
36
37
 
37
- # Serializes the series
38
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
38
+ # Serializes the object
39
+ # @param [String] str
39
40
  # @return [String]
40
- def to_xml(xml)
41
- super(xml) do |xml_inner|
42
- xml_inner.explosion :val=>@explosion unless @explosion.nil?
43
- @labels.to_xml(xml_inner) unless @labels.nil?
44
- @data.to_xml(xml_inner) unless @data.nil?
45
- end
41
+ def to_xml_string(str = '')
42
+ super(str) do |str_inner|
43
+ str_inner << '<c:explosion val="' << @explosion << '"/>' unless @explosion.nil?
44
+ @labels.to_xml_string str_inner unless @labels.nil?
45
+ @data.to_xml_string str_inner unless @data.nil?
46
+ end
47
+ str
46
48
  end
47
- private
49
+
50
+ private
48
51
 
49
52
  # assigns the data for this series
50
53
  def data=(v) DataTypeValidator.validate "Series.data", [SimpleTypedList], v; @data = v; end
@@ -33,7 +33,7 @@ module Axlsx
33
33
  self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
34
34
  end
35
35
  end
36
-
36
+
37
37
  # @see logBase
38
38
  def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer, Fixnum], v, lambda { |arg| arg >= 2 && arg <= 1000}; @logBase = v; end
39
39
  # @see orientation
@@ -44,16 +44,16 @@ module Axlsx
44
44
  # @see min
45
45
  def min=(v) DataTypeValidator.validate "Scaling.min", Float, v; @min = v; end
46
46
 
47
- # Serializes the axId
48
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
47
+ # Serializes the object
48
+ # @param [String] str
49
49
  # @return [String]
50
- def to_xml(xml)
51
- xml[:c].scaling {
52
- xml[:c].logBase :val=> @logBase unless @logBase.nil?
53
- xml[:c].orientation :val=> @orientation unless @orientation.nil?
54
- xml[:c].min :val => @min unless @min.nil?
55
- xml[:c].max :val => @max unless @max.nil?
56
- }
50
+ def to_xml_string(str = '')
51
+ str << '<c:scaling>'
52
+ str << '<c:logBase val="' << @logBase.to_s << '"/>' unless @logBase.nil?
53
+ str << '<c:orientation val="' << @orientation.to_s << '"/>' unless @orientation.nil?
54
+ str << '<c:min val="' << @min.to_s << '"/>' unless @min.nil?
55
+ str << '<c:max val="' << @max.to_s << '"/>' unless @max.nil?
56
+ str << '</c:scaling>'
57
57
  end
58
58
 
59
59
  end
@@ -0,0 +1,69 @@
1
+ # encoding: UTF-8
2
+ module Axlsx
3
+
4
+ # The ScatterChart allows you to insert a scatter chart into your worksheet
5
+ # @see Worksheet#add_chart
6
+ # @see Chart#add_series
7
+ # @see README for an example
8
+ class ScatterChart < Chart
9
+
10
+ # The Style for the scatter chart
11
+ # must be one of :none | :line | :lineMarker | :marker | :smooth | :smoothMarker
12
+ # return [Symbol]
13
+ attr_reader :scatterStyle
14
+
15
+ # the x value axis
16
+ # @return [ValAxis]
17
+ attr_reader :xValAxis
18
+
19
+ # the y value axis
20
+ # @return [ValAxis]
21
+ attr_reader :yValAxis
22
+
23
+ # Creates a new scatter chart
24
+ def initialize(frame, options={})
25
+ @scatterStyle = :lineMarker
26
+ @xValAxId = rand(8 ** 8)
27
+ @yValAxId = rand(8 ** 8)
28
+ @xValAxis = ValAxis.new(@xValAxId, @yValAxId)
29
+ @yValAxis = ValAxis.new(@yValAxId, @xValAxId)
30
+ super(frame, options)
31
+ @series_type = ScatterSeries
32
+ options.each do |o|
33
+ self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
34
+ end
35
+ end
36
+
37
+ # see #scatterStyle
38
+ def scatterStyle=(v)
39
+ Axlsx.validate_scatter_style(v)
40
+ @scatterStyle = v
41
+ end
42
+
43
+ # Serializes the object
44
+ # @param [String] str
45
+ # @return [String]
46
+ def to_xml_string(str = '')
47
+ super do |str|
48
+ str << '<c:scatterChart>'
49
+ str << '<c:scatterStyle val="' << scatterStyle.to_s << '"/>'
50
+ str << '<c:varyColors val="1"/>'
51
+ @series.each { |ser| ser.to_xml_string(str) }
52
+ str << '<c:dLbls>'
53
+ str << '<c:showLegendKey val="0"/>'
54
+ str << '<c:showVal val="0"/>'
55
+ str << '<c:showCatName val="0"/>'
56
+ str << '<c:showSerName val="0"/>'
57
+ str << '<c:showPercent val="0"/>'
58
+ str << '<c:showBubbleSize val="0"/>'
59
+ str << '</c:dLbls>'
60
+ str << '<c:axId val="' << @xValAxId.to_s << '"/>'
61
+ str << '<c:axId val="' << @yValAxId.to_s << '"/>'
62
+ str << '</c:scatterChart>'
63
+ @xValAxis.to_xml_string str
64
+ @yValAxis.to_xml_string str
65
+ end
66
+ str
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: UTF-8
2
+ module Axlsx
3
+
4
+ # A ScatterSeries defines the x and y position of data in the chart
5
+ # @note The recommended way to manage series is to use Chart#add_series
6
+ # @see Worksheet#add_chart
7
+ # @see Chart#add_series
8
+ # @see examples/example.rb
9
+ class ScatterSeries < Series
10
+
11
+ # The x data for this series.
12
+ # @return [NamedAxisData]
13
+ attr_reader :xData
14
+
15
+ # The y data for this series.
16
+ # @return [NamedAxisData]
17
+ attr_reader :yData
18
+
19
+ # Creates a new ScatterSeries
20
+ def initialize(chart, options={})
21
+ @xData, @yData = nil
22
+ super(chart, options)
23
+
24
+ @xData = NamedAxisData.new("xVal", options[:xData]) unless options[:xData].nil?
25
+ @yData = NamedAxisData.new("yVal", options[:yData]) unless options[:yData].nil?
26
+ end
27
+
28
+ # Serializes the object
29
+ # @param [String] str
30
+ # @return [String]
31
+ def to_xml_string(str = '')
32
+ super(str) do |inner_str|
33
+ @xData.to_xml_string(inner_str) unless @xData.nil?
34
+ @yData.to_xml_string(inner_str) unless @yData.nil?
35
+ end
36
+ str
37
+ end
38
+ end
39
+ end
@@ -22,7 +22,7 @@ module Axlsx
22
22
  def initialize(axId, crossAx, options={})
23
23
  @tickLblSkip, @tickMarkSkip = nil, nil
24
24
  super(axId, crossAx, options)
25
- end
25
+ end
26
26
 
27
27
  # @see tickLblSkip
28
28
  def tickLblSkip=(v) Axlsx::validate_unsigned_int(v); @tickLblSkip = v; end
@@ -30,17 +30,17 @@ module Axlsx
30
30
  # @see tickMarkSkip
31
31
  def tickMarkSkip=(v) Axlsx::validate_unsigned_int(v); @tickMarkSkip = v; end
32
32
 
33
- # Serializes the series axis
34
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
33
+ # Serializes the object
34
+ # @param [String] str
35
35
  # @return [String]
36
- def to_xml(xml)
37
- xml[:c].serAx {
38
- super(xml)
39
- xml[:c].tickLblSkip :val=>@tickLblSkip unless @tickLblSkip.nil?
40
- xml[:c].tickMarkSkip :val=>@tickMarkSkip unless @tickMarkSkip.nil?
41
- }
36
+ def to_xml_string(str = '')
37
+ str << '<c:serAx>'
38
+ super(str)
39
+ str << '<c:tickLblSkip val="' << @tickLblSkip.to_s << '"/>' unless @tickLblSkip.nil?
40
+ str << '<c:tickMarkSkip val="' << @tickMarkSkip.to_s << '"/>' unless @tickMarkSkip.nil?
41
+ str << '</c:serAx>'
42
42
  end
43
43
  end
44
-
44
+
45
45
 
46
46
  end
@@ -25,7 +25,7 @@ module Axlsx
25
25
  options.each do |o|
26
26
  self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
27
27
  end
28
- end
28
+ end
29
29
 
30
30
  # The index of this series in the chart's series.
31
31
  # @return [Integer]
@@ -44,27 +44,27 @@ module Axlsx
44
44
  def order=(v) Axlsx::validate_unsigned_int(v); @order = v; end
45
45
 
46
46
  # @see title
47
- def title=(v)
47
+ def title=(v)
48
48
  v = SeriesTitle.new(v) if v.is_a?(String) || v.is_a?(Cell)
49
49
  DataTypeValidator.validate "#{self.class}.title", SeriesTitle, v
50
50
  @title = v
51
51
  end
52
-
53
- private
54
-
52
+
53
+ private
54
+
55
55
  # assigns the chart for this series
56
- def chart=(v) DataTypeValidator.validate "Series.chart", Chart, v; @chart = v; end
56
+ def chart=(v) DataTypeValidator.validate "Series.chart", Chart, v; @chart = v; end
57
57
 
58
- # Serializes the series
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.ser {
63
- xml.idx :val=>index
64
- xml.order :val=>order || index
65
- title.to_xml(xml) unless title.nil?
66
- yield xml if block_given?
67
- }
61
+ def to_xml_string(str = '')
62
+ str << '<c:ser>'
63
+ str << '<c:idx val="' << index.to_s << '"/>'
64
+ str << '<c:order val="' << (order || index).to_s << '"/>'
65
+ title.to_xml_string(str) unless title.nil?
66
+ yield str if block_given?
67
+ str << '</c:ser>'
68
68
  end
69
69
 
70
70
  end
@@ -3,21 +3,21 @@ module Axlsx
3
3
  # A series title is a Title with a slightly different serialization than chart titles.
4
4
  class SeriesTitle < Title
5
5
 
6
- # Serializes the series title
7
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
6
+ # Serializes the object
7
+ # @param [String] str
8
8
  # @return [String]
9
- def to_xml(xml)
10
- xml[:c].tx {
11
- xml[:c].strRef {
12
- xml[:c].f Axlsx::cell_range([@cell])
13
- xml[:c].strCache {
14
- xml[:c].ptCount :val=>1
15
- xml[:c].pt(:idx=>0) {
16
- xml[:c].v @text
17
- }
18
- }
19
- }
20
- }
9
+ def to_xml_string(str = '')
10
+ str << '<c:tx>'
11
+ str << '<c:strRef>'
12
+ str << '<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>'
13
+ str << '<c:strCache>'
14
+ str << '<c:ptCount val="1"/>'
15
+ str << '<c:pt idx="0">'
16
+ str << '<c:v>' << @text << '</c:v>'
17
+ str << '</c:pt>'
18
+ str << '</c:strCache>'
19
+ str << '</c:strRef>'
20
+ str << '</c:tx>'
21
21
  end
22
22
  end
23
23
  end
@@ -2,7 +2,7 @@
2
2
  module Axlsx
3
3
  # A Title stores information about the title of a chart
4
4
  class Title
5
-
5
+
6
6
  # The text to be shown. Setting this property directly with a string will remove the cell reference.
7
7
  # @return [String]
8
8
  attr_reader :text
@@ -17,9 +17,9 @@ module Axlsx
17
17
  self.cell = title if title.is_a?(Cell)
18
18
  self.text = title.to_s unless title.is_a?(Cell)
19
19
  end
20
-
20
+
21
21
  # @see text
22
- def text=(v)
22
+ def text=(v)
23
23
  DataTypeValidator.validate 'Title.text', String, v
24
24
  @text = v
25
25
  @cell = nil
@@ -30,7 +30,7 @@ module Axlsx
30
30
  def cell=(v)
31
31
  DataTypeValidator.validate 'Title.text', Cell, v
32
32
  @cell = v
33
- @text = v.value.to_s
33
+ @text = v.value.to_s
34
34
  v
35
35
  end
36
36
 
@@ -38,29 +38,29 @@ module Axlsx
38
38
  #def layout=(v) DataTypeValidator.validate 'Title.layout', Layout, v; @layout = v; end
39
39
  #def overlay=(v) Axlsx::validate_boolean v; @overlay=v; end
40
40
  #def spPr=(v) DataTypeValidator.validate 'Title.spPr', SpPr, v; @spPr = v; end
41
-
42
- # Serializes the chart title
43
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
41
+
42
+ # Serializes the object
43
+ # @param [String] str
44
44
  # @return [String]
45
- def to_xml(xml)
46
- xml[:c].title {
47
- unless @text.empty?
48
- xml[:c].tx {
49
- xml[:c].strRef {
50
- xml[:c].f Axlsx::cell_range([@cell])
51
- xml[:c].strCache {
52
- xml[:c].ptCount :val=>1
53
- xml[:c].pt(:idx=>0) {
54
- xml[:c].v @text
55
- }
56
- }
57
- }
58
- }
59
- end
60
- xml[:c].layout
61
- xml[:c].overlay :val=>0
62
- }
45
+ def to_xml_string(str = '')
46
+ str << '<c:title>'
47
+ unless @text.empty?
48
+ str << '<c:tx>'
49
+ str << '<c:strRef>'
50
+ str << '<c:f>' << Axlsx::cell_range([@cell]) << '</c:f>'
51
+ str << '<c:strCache>'
52
+ str << '<c:ptCount val="1"/>'
53
+ str << '<c:pt idx="0">'
54
+ str << '<c:v>' << @text << '</c:v>'
55
+ str << '</c:pt>'
56
+ str << '</c:strCache>'
57
+ str << '</c:strRef>'
58
+ str << '</c:tx>'
59
+ end
60
+ str << '<c:layout/>'
61
+ str << '<c:overlay val="0"/>'
62
+ str << '</c:title>'
63
63
  end
64
-
64
+
65
65
  end
66
66
  end