caxlsx 4.0.0 → 4.4.1

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 (133) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +48 -12
  3. data/README.md +18 -9
  4. data/Rakefile +2 -9
  5. data/examples/generate.rb +3 -1
  6. data/lib/axlsx/content_type/abstract_content_type.rb +6 -3
  7. data/lib/axlsx/content_type/content_type.rb +4 -4
  8. data/lib/axlsx/content_type/default.rb +4 -1
  9. data/lib/axlsx/content_type/override.rb +4 -1
  10. data/lib/axlsx/doc_props/app.rb +91 -24
  11. data/lib/axlsx/drawing/area_chart.rb +3 -3
  12. data/lib/axlsx/drawing/area_series.rb +10 -4
  13. data/lib/axlsx/drawing/ax_data_source.rb +1 -1
  14. data/lib/axlsx/drawing/axes.rb +1 -1
  15. data/lib/axlsx/drawing/axis.rb +25 -7
  16. data/lib/axlsx/drawing/bar_3D_chart.rb +14 -4
  17. data/lib/axlsx/drawing/bar_chart.rb +14 -4
  18. data/lib/axlsx/drawing/bar_series.rb +14 -5
  19. data/lib/axlsx/drawing/bubble_chart.rb +2 -2
  20. data/lib/axlsx/drawing/bubble_series.rb +2 -2
  21. data/lib/axlsx/drawing/cat_axis.rb +23 -8
  22. data/lib/axlsx/drawing/chart.rb +33 -8
  23. data/lib/axlsx/drawing/d_lbls.rb +9 -8
  24. data/lib/axlsx/drawing/drawing.rb +50 -49
  25. data/lib/axlsx/drawing/hyperlink.rb +13 -4
  26. data/lib/axlsx/drawing/line_3D_chart.rb +3 -3
  27. data/lib/axlsx/drawing/line_chart.rb +3 -3
  28. data/lib/axlsx/drawing/line_series.rb +10 -4
  29. data/lib/axlsx/drawing/marker.rb +19 -4
  30. data/lib/axlsx/drawing/num_val.rb +1 -1
  31. data/lib/axlsx/drawing/one_cell_anchor.rb +8 -2
  32. data/lib/axlsx/drawing/pic.rb +17 -8
  33. data/lib/axlsx/drawing/pie_3D_chart.rb +3 -3
  34. data/lib/axlsx/drawing/pie_chart.rb +36 -0
  35. data/lib/axlsx/drawing/pie_series.rb +18 -6
  36. data/lib/axlsx/drawing/scaling.rb +18 -4
  37. data/lib/axlsx/drawing/scatter_chart.rb +2 -2
  38. data/lib/axlsx/drawing/scatter_series.rb +2 -2
  39. data/lib/axlsx/drawing/ser_axis.rb +11 -5
  40. data/lib/axlsx/drawing/series.rb +8 -2
  41. data/lib/axlsx/drawing/two_cell_anchor.rb +1 -1
  42. data/lib/axlsx/drawing/val_axis.rb +2 -2
  43. data/lib/axlsx/drawing/view_3D.rb +8 -2
  44. data/lib/axlsx/drawing/vml_shape.rb +1 -1
  45. data/lib/axlsx/package.rb +54 -21
  46. data/lib/axlsx/rels/relationship.rb +15 -5
  47. data/lib/axlsx/rels/relationships.rb +3 -3
  48. data/lib/axlsx/stylesheet/border.rb +12 -3
  49. data/lib/axlsx/stylesheet/border_pr.rb +16 -4
  50. data/lib/axlsx/stylesheet/cell_alignment.rb +39 -10
  51. data/lib/axlsx/stylesheet/cell_protection.rb +9 -2
  52. data/lib/axlsx/stylesheet/cell_style.rb +30 -7
  53. data/lib/axlsx/stylesheet/color.rb +10 -4
  54. data/lib/axlsx/stylesheet/dxf.rb +29 -6
  55. data/lib/axlsx/stylesheet/fill.rb +4 -1
  56. data/lib/axlsx/stylesheet/font.rb +59 -13
  57. data/lib/axlsx/stylesheet/gradient_fill.rb +9 -3
  58. data/lib/axlsx/stylesheet/gradient_stop.rb +9 -2
  59. data/lib/axlsx/stylesheet/num_fmt.rb +8 -2
  60. data/lib/axlsx/stylesheet/pattern_fill.rb +15 -3
  61. data/lib/axlsx/stylesheet/styles.rb +84 -43
  62. data/lib/axlsx/stylesheet/table_style.rb +15 -4
  63. data/lib/axlsx/stylesheet/table_style_element.rb +12 -3
  64. data/lib/axlsx/stylesheet/table_styles.rb +10 -3
  65. data/lib/axlsx/stylesheet/theme.rb +163 -0
  66. data/lib/axlsx/stylesheet/xf.rb +70 -16
  67. data/lib/axlsx/util/accessors.rb +9 -7
  68. data/lib/axlsx/util/buffered_zip_output_stream.rb +6 -2
  69. data/lib/axlsx/util/constants.rb +14 -2
  70. data/lib/axlsx/util/mime_type_utils.rb +72 -13
  71. data/lib/axlsx/util/serialized_attributes.rb +2 -2
  72. data/lib/axlsx/util/simple_typed_list.rb +26 -14
  73. data/lib/axlsx/util/storage.rb +4 -4
  74. data/lib/axlsx/util/uri_utils.rb +70 -0
  75. data/lib/axlsx/util/validators.rb +6 -6
  76. data/lib/axlsx/version.rb +1 -1
  77. data/lib/axlsx/workbook/defined_name.rb +2 -1
  78. data/lib/axlsx/workbook/defined_names.rb +1 -1
  79. data/lib/axlsx/workbook/shared_strings_table.rb +3 -3
  80. data/lib/axlsx/workbook/workbook.rb +87 -67
  81. data/lib/axlsx/workbook/workbook_view.rb +1 -1
  82. data/lib/axlsx/workbook/workbook_views.rb +1 -1
  83. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +4 -4
  84. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +5 -3
  85. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +4 -4
  86. data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +1 -1
  87. data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +2 -2
  88. data/lib/axlsx/workbook/worksheet/border_creator.rb +4 -4
  89. data/lib/axlsx/workbook/worksheet/cell.rb +40 -20
  90. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +1 -1
  91. data/lib/axlsx/workbook/worksheet/cfvo.rb +8 -2
  92. data/lib/axlsx/workbook/worksheet/col.rb +23 -9
  93. data/lib/axlsx/workbook/worksheet/col_breaks.rb +1 -1
  94. data/lib/axlsx/workbook/worksheet/cols.rb +1 -1
  95. data/lib/axlsx/workbook/worksheet/comment.rb +2 -2
  96. data/lib/axlsx/workbook/worksheet/comments.rb +1 -1
  97. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +9 -3
  98. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +70 -15
  99. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +3 -3
  100. data/lib/axlsx/workbook/worksheet/data_validation.rb +53 -14
  101. data/lib/axlsx/workbook/worksheet/data_validations.rb +3 -3
  102. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +2 -2
  103. data/lib/axlsx/workbook/worksheet/dimension.rb +1 -1
  104. data/lib/axlsx/workbook/worksheet/header_footer.rb +1 -1
  105. data/lib/axlsx/workbook/worksheet/icon_set.rb +17 -5
  106. data/lib/axlsx/workbook/worksheet/merged_cells.rb +1 -1
  107. data/lib/axlsx/workbook/worksheet/outline_pr.rb +1 -1
  108. data/lib/axlsx/workbook/worksheet/page_margins.rb +30 -7
  109. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -2
  110. data/lib/axlsx/workbook/worksheet/page_setup.rb +32 -9
  111. data/lib/axlsx/workbook/worksheet/pane.rb +9 -2
  112. data/lib/axlsx/workbook/worksheet/pivot_table.rb +30 -6
  113. data/lib/axlsx/workbook/worksheet/pivot_tables.rb +1 -1
  114. data/lib/axlsx/workbook/worksheet/print_options.rb +1 -0
  115. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +1 -1
  116. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +31 -11
  117. data/lib/axlsx/workbook/worksheet/row.rb +5 -2
  118. data/lib/axlsx/workbook/worksheet/row_breaks.rb +1 -1
  119. data/lib/axlsx/workbook/worksheet/selection.rb +8 -2
  120. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +1 -0
  121. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +1 -1
  122. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -1
  123. data/lib/axlsx/workbook/worksheet/sheet_view.rb +30 -9
  124. data/lib/axlsx/workbook/worksheet/table_style_info.rb +3 -2
  125. data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
  126. data/lib/axlsx/workbook/worksheet/worksheet.rb +28 -14
  127. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +4 -4
  128. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +1 -1
  129. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +3 -2
  130. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +2 -2
  131. data/lib/axlsx.rb +46 -30
  132. data/lib/caxlsx.rb +1 -1
  133. metadata +13 -52
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Axlsx
4
- # The Bar3DChart is a three dimentional barchart (who would have guessed?) that you can add to your worksheet.
4
+ # The Bar3DChart is a three dimensional barchart (who would have guessed?) that you can add to your worksheet.
5
5
  # @see Worksheet#add_chart
6
6
  # @see Chart#add_series
7
7
  # @see Package#serialize
@@ -75,7 +75,7 @@ module Axlsx
75
75
  def initialize(frame, options = {})
76
76
  @vary_colors = true
77
77
  @gap_width, @gap_depth, @shape = nil, nil, nil
78
- super(frame, options)
78
+ super
79
79
  @series_type = BarSeries
80
80
  @view_3D = View3D.new({ r_ang_ax: 1 }.merge(options))
81
81
  @d_lbls = nil
@@ -121,7 +121,7 @@ module Axlsx
121
121
  # @param [String] str
122
122
  # @return [String]
123
123
  def to_xml_string(str = +'')
124
- super(str) do
124
+ super do
125
125
  str << '<c:bar3DChart>'
126
126
  str << '<c:barDir val="' << bar_dir.to_s << '"/>'
127
127
  str << '<c:grouping val="' << grouping.to_s << '"/>'
@@ -141,7 +141,17 @@ module Axlsx
141
141
  # category axes specified via axes[:val_axes] and axes[:cat_axis]
142
142
  # @return [Axes]
143
143
  def axes
144
- @axes ||= Axes.new(cat_axis: CatAxis, val_axis: ValAxis)
144
+ @axes ||= begin
145
+ a = Axes.new(cat_axis: CatAxis, val_axis: ValAxis)
146
+
147
+ if bar_dir == :col
148
+ a[:val_axis].ax_pos = :l
149
+ else
150
+ a[:cat_axis].ax_pos = :l
151
+ end
152
+
153
+ a
154
+ end
145
155
  end
146
156
  end
147
157
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Axlsx
4
- # The BarChart is a two dimentional barchart that you can add to your worksheet.
4
+ # The BarChart is a two dimensional barchart that you can add to your worksheet.
5
5
  # @see Worksheet#add_chart
6
6
  # @see Chart#add_series
7
7
  # @see Package#serialize
@@ -68,7 +68,7 @@ module Axlsx
68
68
  def initialize(frame, options = {})
69
69
  @vary_colors = true
70
70
  @gap_width, @overlap, @shape = nil, nil, nil
71
- super(frame, options)
71
+ super
72
72
  @series_type = BarSeries
73
73
  @d_lbls = nil
74
74
  end
@@ -111,7 +111,7 @@ module Axlsx
111
111
  # @param [String] str
112
112
  # @return [String]
113
113
  def to_xml_string(str = +'')
114
- super(str) do
114
+ super do
115
115
  str << '<c:barChart>'
116
116
  str << '<c:barDir val="' << bar_dir.to_s << '"/>'
117
117
  str << '<c:grouping val="' << grouping.to_s << '"/>'
@@ -131,7 +131,17 @@ module Axlsx
131
131
  # category axes specified via axes[:val_axes] and axes[:cat_axis]
132
132
  # @return [Axes]
133
133
  def axes
134
- @axes ||= Axes.new(cat_axis: CatAxis, val_axis: ValAxis)
134
+ @axes ||= begin
135
+ a = Axes.new(cat_axis: CatAxis, val_axis: ValAxis)
136
+
137
+ if bar_dir == :col
138
+ a[:val_axis].ax_pos = :l
139
+ else
140
+ a[:cat_axis].ax_pos = :l
141
+ end
142
+
143
+ a
144
+ end
135
145
  end
136
146
  end
137
147
  end
@@ -37,13 +37,16 @@ module Axlsx
37
37
  def initialize(chart, options = {})
38
38
  @shape = :box
39
39
  @colors = []
40
- super(chart, options)
40
+ super
41
41
  self.labels = AxDataSource.new({ data: options[:labels] }) unless options[:labels].nil?
42
42
  self.data = NumDataSource.new(options) unless options[:data].nil?
43
43
  end
44
44
 
45
45
  # @see colors
46
- def colors=(v) DataTypeValidator.validate "BarSeries.colors", [Array], v; @colors = v end
46
+ def colors=(v)
47
+ DataTypeValidator.validate "BarSeries.colors", [Array], v
48
+ @colors = v
49
+ end
47
50
 
48
51
  def series_color=(v)
49
52
  @series_color = v
@@ -59,7 +62,7 @@ module Axlsx
59
62
  # @param [String] str
60
63
  # @return [String]
61
64
  def to_xml_string(str = +'')
62
- super(str) do
65
+ super do
63
66
  colors.each_with_index do |c, index|
64
67
  str << '<c:dPt>'
65
68
  str << '<c:idx val="' << index.to_s << '"/>'
@@ -85,9 +88,15 @@ module Axlsx
85
88
  private
86
89
 
87
90
  # assigns the data for this series
88
- def data=(v) DataTypeValidator.validate "Series.data", [NumDataSource], v; @data = v; end
91
+ def data=(v)
92
+ DataTypeValidator.validate "Series.data", [NumDataSource], v
93
+ @data = v
94
+ end
89
95
 
90
96
  # assigns the labels for this series
91
- def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end
97
+ def labels=(v)
98
+ DataTypeValidator.validate "Series.labels", [AxDataSource], v
99
+ @labels = v
100
+ end
92
101
  end
93
102
  end
@@ -26,7 +26,7 @@ module Axlsx
26
26
  def initialize(frame, options = {})
27
27
  @vary_colors = 0
28
28
 
29
- super(frame, options)
29
+ super
30
30
  @series_type = BubbleSeries
31
31
  @d_lbls = nil
32
32
  parse_options options
@@ -36,7 +36,7 @@ module Axlsx
36
36
  # @param [String] str
37
37
  # @return [String]
38
38
  def to_xml_string(str = +'')
39
- super(str) do
39
+ super do
40
40
  str << '<c:bubbleChart>'
41
41
  str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
42
42
  @series.each { |ser| ser.to_xml_string(str) }
@@ -27,7 +27,7 @@ module Axlsx
27
27
  # Creates a new BubbleSeries
28
28
  def initialize(chart, options = {})
29
29
  @xData, @yData, @bubbleSize = nil
30
- super(chart, options)
30
+ super
31
31
  @xData = AxDataSource.new(tag_name: :xVal, data: options[:xData]) unless options[:xData].nil?
32
32
  @yData = NumDataSource.new({ tag_name: :yVal, data: options[:yData] }) unless options[:yData].nil?
33
33
  @bubbleSize = NumDataSource.new({ tag_name: :bubbleSize, data: options[:bubbleSize] }) unless options[:bubbleSize].nil?
@@ -42,7 +42,7 @@ module Axlsx
42
42
  # @param [String] str
43
43
  # @return [String]
44
44
  def to_xml_string(str = +'')
45
- super(str) do
45
+ super do
46
46
  # needs to override the super color here to push in ln/and something else!
47
47
  if color
48
48
  str << '<c:spPr><a:solidFill>'
@@ -12,7 +12,7 @@ module Axlsx
12
12
  self.auto = 1
13
13
  self.lbl_algn = :ctr
14
14
  self.lbl_offset = "100"
15
- super(options)
15
+ super
16
16
  end
17
17
 
18
18
  # From the docs: This element specifies that this axis is a date or text axis based on the data that is used for the axis labels, not a specific choice.
@@ -31,7 +31,7 @@ module Axlsx
31
31
  attr_reader :lbl_offset
32
32
  alias :lblOffset :lbl_offset
33
33
 
34
- # The number of tick lables to skip between labels
34
+ # The number of tick labels to skip between labels
35
35
  # @return [Integer]
36
36
  attr_reader :tick_lbl_skip
37
37
  alias :tickLblSkip :tick_lbl_skip
@@ -45,24 +45,39 @@ module Axlsx
45
45
  LBL_OFFSET_REGEX = /0*(([0-9])|([1-9][0-9])|([1-9][0-9][0-9])|1000)/.freeze
46
46
 
47
47
  # @see tick_lbl_skip
48
- def tick_lbl_skip=(v) Axlsx.validate_unsigned_int(v); @tick_lbl_skip = v; end
48
+ def tick_lbl_skip=(v)
49
+ Axlsx.validate_unsigned_int(v)
50
+ @tick_lbl_skip = v
51
+ end
49
52
  alias :tickLblSkip= :tick_lbl_skip=
50
53
 
51
54
  # @see tick_mark_skip
52
- def tick_mark_skip=(v) Axlsx.validate_unsigned_int(v); @tick_mark_skip = v; end
55
+ def tick_mark_skip=(v)
56
+ Axlsx.validate_unsigned_int(v)
57
+ @tick_mark_skip = v
58
+ end
53
59
  alias :tickMarkSkip= :tick_mark_skip=
54
60
 
55
61
  # From the docs: This element specifies that this axis is a date or text axis based on the data that is used for the axis labels, not a specific choice.
56
- def auto=(v) Axlsx.validate_boolean(v); @auto = v; end
62
+ def auto=(v)
63
+ Axlsx.validate_boolean(v)
64
+ @auto = v
65
+ end
57
66
 
58
67
  # specifies how the perpendicular axis is crossed
59
68
  # must be one of [:ctr, :l, :r]
60
- def lbl_algn=(v) RestrictionValidator.validate "#{self.class}.lbl_algn", [:ctr, :l, :r], v; @lbl_algn = v; end
69
+ def lbl_algn=(v)
70
+ RestrictionValidator.validate "#{self.class}.lbl_algn", [:ctr, :l, :r], v
71
+ @lbl_algn = v
72
+ end
61
73
  alias :lblAlgn= :lbl_algn=
62
74
 
63
75
  # The offset of the labels
64
76
  # must be between a string between 0 and 1000
65
- def lbl_offset=(v) RegexValidator.validate "#{self.class}.lbl_offset", LBL_OFFSET_REGEX, v; @lbl_offset = v; end
77
+ def lbl_offset=(v)
78
+ RegexValidator.validate "#{self.class}.lbl_offset", LBL_OFFSET_REGEX, v
79
+ @lbl_offset = v
80
+ end
66
81
  alias :lblOffset= :lbl_offset=
67
82
 
68
83
  # Serializes the object
@@ -70,7 +85,7 @@ module Axlsx
70
85
  # @return [String]
71
86
  def to_xml_string(str = +'')
72
87
  str << '<c:catAx>'
73
- super(str)
88
+ super
74
89
  str << '<c:auto val="' << @auto.to_s << '"/>'
75
90
  str << '<c:lblAlgn val="' << @lbl_algn.to_s << '"/>'
76
91
  str << '<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>'
@@ -6,6 +6,7 @@ module Axlsx
6
6
  # @see README for examples
7
7
  class Chart
8
8
  include Axlsx::OptionsParser
9
+
9
10
  # Creates a new chart object
10
11
  # @param [GraphicalFrame] frame The frame that holds this chart.
11
12
  # @option options [Cell, String] title
@@ -62,7 +63,10 @@ module Axlsx
62
63
 
63
64
  # Configures the vary_colors options for this chart
64
65
  # @param [Boolean] v The value to set
65
- def vary_colors=(v) Axlsx.validate_boolean(v); @vary_colors = v; end
66
+ def vary_colors=(v)
67
+ Axlsx.validate_boolean(v)
68
+ @vary_colors = v
69
+ end
66
70
 
67
71
  # The title object for the chart.
68
72
  # @return [Title]
@@ -149,21 +153,33 @@ module Axlsx
149
153
  # Show the legend in the chart
150
154
  # @param [Boolean] v
151
155
  # @return [Boolean]
152
- def show_legend=(v) Axlsx.validate_boolean(v); @show_legend = v; end
156
+ def show_legend=(v)
157
+ Axlsx.validate_boolean(v)
158
+ @show_legend = v
159
+ end
153
160
 
154
161
  # How to display blank values
155
162
  # @see display_blanks_as
156
163
  # @param [Symbol] v
157
164
  # @return [Symbol]
158
- def display_blanks_as=(v) Axlsx.validate_display_blanks_as(v); @display_blanks_as = v; end
165
+ def display_blanks_as=(v)
166
+ Axlsx.validate_display_blanks_as(v)
167
+ @display_blanks_as = v
168
+ end
159
169
 
160
170
  # The style for the chart.
161
171
  # see ECMA Part 1 §21.2.2.196
162
172
  # @param [Integer] v must be between 1 and 48
163
- def style=(v) DataTypeValidator.validate "Chart.style", Integer, v, ->(arg) { arg >= 1 && arg <= 48 }; @style = v; end
173
+ def style=(v)
174
+ DataTypeValidator.validate "Chart.style", Integer, v, ->(arg) { arg >= 1 && arg <= 48 }
175
+ @style = v
176
+ end
164
177
 
165
178
  # @see legend_position
166
- def legend_position=(v) RestrictionValidator.validate "Chart.legend_position", [:b, :l, :r, :t, :tr], v; @legend_position = v; end
179
+ def legend_position=(v)
180
+ RestrictionValidator.validate "Chart.legend_position", [:b, :l, :r, :t, :tr], v
181
+ @legend_position = v
182
+ end
167
183
 
168
184
  # backwards compatibility to allow chart.to and chart.from access to anchor markers
169
185
  # @note This will be disconinued in version 2.0.0. Please use the end_at method
@@ -194,12 +210,18 @@ module Axlsx
194
210
  # Whether only data from visible cells should be plotted.
195
211
  # @param [Boolean] v
196
212
  # @return [Boolean]
197
- def plot_visible_only=(v) Axlsx.validate_boolean(v); @plot_visible_only = v; end
213
+ def plot_visible_only=(v)
214
+ Axlsx.validate_boolean(v)
215
+ @plot_visible_only = v
216
+ end
198
217
 
199
218
  # Whether the chart area shall have rounded corners.
200
219
  # @param [Boolean] v
201
220
  # @return [Boolean]
202
- def rounded_corners=(v) Axlsx.validate_boolean(v); @rounded_corners = v; end
221
+ def rounded_corners=(v)
222
+ Axlsx.validate_boolean(v)
223
+ @rounded_corners = v
224
+ end
203
225
 
204
226
  # Serializes the object
205
227
  # @param [String] str
@@ -290,7 +312,10 @@ module Axlsx
290
312
  end
291
313
 
292
314
  # sets the view_3D object for the chart
293
- def view_3D=(v) DataTypeValidator.validate "#{self.class}.view_3D", View3D, v; @view_3D = v; end
315
+ def view_3D=(v)
316
+ DataTypeValidator.validate "#{self.class}.view_3D", View3D, v
317
+ @view_3D = v
318
+ end
294
319
  alias :view3D= :view_3D=
295
320
  end
296
321
  end
@@ -9,6 +9,7 @@ module Axlsx
9
9
  class DLbls
10
10
  include Axlsx::Accessors
11
11
  include Axlsx::OptionsParser
12
+
12
13
  # creates a new DLbls object
13
14
  def initialize(chart_type, options = {})
14
15
  raise ArgumentError, 'chart_type must inherit from Chart' unless [Chart, LineChart].include?(chart_type.superclass)
@@ -19,7 +20,7 @@ module Axlsx
19
20
  end
20
21
 
21
22
  # These attributes are all boolean so I'm doing a bit of a hand
22
- # waving magic show to set up the attriubte accessors
23
+ # waving magic show to set up the attribute accessors
23
24
  # @note
24
25
  # not all charts support all methods!
25
26
  # Bar3DChart and Line3DChart and ScatterChart do not support d_lbl_pos or show_leader_lines
@@ -38,11 +39,11 @@ module Axlsx
38
39
  [:show_legend_key, :show_val, :show_cat_name,
39
40
  :show_ser_name, :show_percent, :show_bubble_size,
40
41
  :show_leader_lines].each do |attr|
41
- send("#{attr}=", false)
42
+ send(:"#{attr}=", false)
42
43
  end
43
44
  end
44
45
 
45
- # The chart type that is using this data lables instance.
46
+ # The chart type that is using this data labels instance.
46
47
  # This affects the xml output as not all chart types support the
47
48
  # same data label attributes.
48
49
  attr_reader :chart_type
@@ -51,19 +52,19 @@ module Axlsx
51
52
  # @see d_lbl_pos= for a list of allowed values
52
53
  # @return [Symbol]
53
54
  def d_lbl_pos
54
- return unless [Pie3DChart, LineChart].include? @chart_type
55
+ return unless [PieChart, Pie3DChart, LineChart].include? @chart_type
55
56
 
56
57
  @d_lbl_pos ||= :bestFit
57
58
  end
58
59
 
59
60
  # @see DLbls#d_lbl_pos
60
- # Assigns the label postion for this data labels on this chart.
61
+ # Assigns the label position for this data labels on this chart.
61
62
  # Allowed positions are :bestFit, :b, :ctr, :inBase, :inEnd, :l,
62
63
  # :outEnd, :r and :t
63
64
  # The default is :bestFit
64
- # @param [Symbol] label_position the postion you want to use.
65
+ # @param [Symbol] label_position the position you want to use.
65
66
  def d_lbl_pos=(label_position)
66
- return unless [Pie3DChart, LineChart].include? @chart_type
67
+ return unless [PieChart, Pie3DChart, LineChart].include? @chart_type
67
68
 
68
69
  Axlsx::RestrictionValidator.validate 'DLbls#d_lbl_pos', [:bestFit, :b, :ctr, :inBase, :inEnd, :l, :outEnd, :r, :t], label_position
69
70
  @d_lbl_pos = label_position
@@ -85,7 +86,7 @@ module Axlsx
85
86
 
86
87
  # nills out d_lbl_pos and show_leader_lines as these attributes, while valid in the spec actually crash Excel for any chart type other than pie charts.
87
88
  def validate_attributes_for_chart_type
88
- return if [Pie3DChart, LineChart].include? @chart_type
89
+ return if [PieChart, Pie3DChart, LineChart].include? @chart_type
89
90
 
90
91
  @d_lbl_pos = nil
91
92
  @show_leader_lines = nil
@@ -1,55 +1,56 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Axlsx
4
- require 'axlsx/drawing/d_lbls'
5
- require 'axlsx/drawing/title'
6
- require 'axlsx/drawing/series_title'
7
- require 'axlsx/drawing/series'
8
- require 'axlsx/drawing/pie_series'
9
- require 'axlsx/drawing/bar_series'
10
- require 'axlsx/drawing/line_series'
11
- require 'axlsx/drawing/scatter_series'
12
- require 'axlsx/drawing/bubble_series'
13
- require 'axlsx/drawing/area_series'
14
-
15
- require 'axlsx/drawing/scaling'
16
- require 'axlsx/drawing/axis'
17
-
18
- require 'axlsx/drawing/str_val'
19
- require 'axlsx/drawing/num_val'
20
- require 'axlsx/drawing/str_data'
21
- require 'axlsx/drawing/num_data'
22
- require 'axlsx/drawing/num_data_source'
23
- require 'axlsx/drawing/ax_data_source'
24
-
25
- require 'axlsx/drawing/ser_axis'
26
- require 'axlsx/drawing/cat_axis'
27
- require 'axlsx/drawing/val_axis'
28
- require 'axlsx/drawing/axes'
29
-
30
- require 'axlsx/drawing/marker'
31
-
32
- require 'axlsx/drawing/one_cell_anchor'
33
- require 'axlsx/drawing/two_cell_anchor'
34
- require 'axlsx/drawing/graphic_frame'
35
-
36
- require 'axlsx/drawing/view_3D'
37
- require 'axlsx/drawing/chart'
38
- require 'axlsx/drawing/pie_3D_chart'
39
- require 'axlsx/drawing/bar_3D_chart'
40
- require 'axlsx/drawing/bar_chart'
41
- require 'axlsx/drawing/line_chart'
42
- require 'axlsx/drawing/line_3D_chart'
43
- require 'axlsx/drawing/scatter_chart'
44
- require 'axlsx/drawing/bubble_chart'
45
- require 'axlsx/drawing/area_chart'
46
-
47
- require 'axlsx/drawing/picture_locking'
48
- require 'axlsx/drawing/pic'
49
- require 'axlsx/drawing/hyperlink'
50
-
51
- require 'axlsx/drawing/vml_drawing'
52
- require 'axlsx/drawing/vml_shape'
4
+ require_relative 'd_lbls'
5
+ require_relative 'title'
6
+ require_relative 'series_title'
7
+ require_relative 'series'
8
+ require_relative 'pie_series'
9
+ require_relative 'bar_series'
10
+ require_relative 'line_series'
11
+ require_relative 'scatter_series'
12
+ require_relative 'bubble_series'
13
+ require_relative 'area_series'
14
+
15
+ require_relative 'scaling'
16
+ require_relative 'axis'
17
+
18
+ require_relative 'str_val'
19
+ require_relative 'num_val'
20
+ require_relative 'str_data'
21
+ require_relative 'num_data'
22
+ require_relative 'num_data_source'
23
+ require_relative 'ax_data_source'
24
+
25
+ require_relative 'ser_axis'
26
+ require_relative 'cat_axis'
27
+ require_relative 'val_axis'
28
+ require_relative 'axes'
29
+
30
+ require_relative 'marker'
31
+
32
+ require_relative 'one_cell_anchor'
33
+ require_relative 'two_cell_anchor'
34
+ require_relative 'graphic_frame'
35
+
36
+ require_relative 'view_3D'
37
+ require_relative 'chart'
38
+ require_relative 'pie_3D_chart'
39
+ require_relative 'pie_chart'
40
+ require_relative 'bar_3D_chart'
41
+ require_relative 'bar_chart'
42
+ require_relative 'line_chart'
43
+ require_relative 'line_3D_chart'
44
+ require_relative 'scatter_chart'
45
+ require_relative 'bubble_chart'
46
+ require_relative 'area_chart'
47
+
48
+ require_relative 'picture_locking'
49
+ require_relative 'pic'
50
+ require_relative 'hyperlink'
51
+
52
+ require_relative 'vml_drawing'
53
+ require_relative 'vml_shape'
53
54
 
54
55
  # A Drawing is a canvas for charts and images. Each worksheet has a single drawing that manages anchors.
55
56
  # The anchors reference the charts or images via graphical frames. This is not a trivial relationship so please do follow the advice in the note.
@@ -52,7 +52,10 @@ module Axlsx
52
52
  # @see endSnd
53
53
  # @param [Boolean] v The boolean value indicating the termination of playing sounds on click
54
54
  # @return [Boolean]
55
- def end_snd=(v) Axlsx.validate_boolean(v); @end_snd = v end
55
+ def end_snd=(v)
56
+ Axlsx.validate_boolean(v)
57
+ @end_snd = v
58
+ end
56
59
  alias :endSnd= :end_snd=
57
60
 
58
61
  # indicates that the link has already been clicked.
@@ -62,7 +65,10 @@ module Axlsx
62
65
 
63
66
  # @see highlightClick
64
67
  # @param [Boolean] v The value to assign
65
- def highlight_click=(v) Axlsx.validate_boolean(v); @highlight_click = v end
68
+ def highlight_click=(v)
69
+ Axlsx.validate_boolean(v)
70
+ @highlight_click = v
71
+ end
66
72
  alias :highlightClick= :highlight_click=
67
73
 
68
74
  # From the specs: Specifies whether to add this URI to the history when navigating to it. This allows for the viewing of this presentation without the storing of history information on the viewing machine. If this attribute is omitted, then a value of 1 or true is assumed.
@@ -70,8 +76,11 @@ module Axlsx
70
76
  attr_reader :history
71
77
 
72
78
  # @see history
73
- # param [Boolean] v The value to assing
74
- def history=(v) Axlsx.validate_boolean(v); @history = v end
79
+ # param [Boolean] v The value to assign
80
+ def history=(v)
81
+ Axlsx.validate_boolean(v)
82
+ @history = v
83
+ end
75
84
 
76
85
  # From the specs: Specifies the target frame that is to be used when opening this hyperlink. When the hyperlink is activated this attribute is used to determine if a new window is launched for viewing or if an existing one can be used. If this attribute is omitted, than a new window is opened.
77
86
  # @return [String]
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Axlsx
4
- # The Line3DChart is a three dimentional line chart (who would have guessed?) that you can add to your worksheet.
4
+ # The Line3DChart is a three dimensional line chart (who would have guessed?) that you can add to your worksheet.
5
5
  # @example Creating a chart
6
6
  # # This example creates a line in a single sheet.
7
7
  # require "rubygems" # if that is your preferred way to manage gems!
@@ -43,7 +43,7 @@ module Axlsx
43
43
  def initialize(frame, options = {})
44
44
  @gap_depth = nil
45
45
  @view_3D = View3D.new({ r_ang_ax: 1 }.merge(options))
46
- super(frame, options)
46
+ super
47
47
  axes.add_axis :ser_axis, SerAxis
48
48
  end
49
49
 
@@ -58,7 +58,7 @@ module Axlsx
58
58
  # @param [String] str
59
59
  # @return [String]
60
60
  def to_xml_string(str = +'')
61
- super(str) do
61
+ super do
62
62
  str << '<c:gapDepth val="' << @gap_depth.to_s << '"/>' unless @gap_depth.nil?
63
63
  end
64
64
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Axlsx
4
- # The LineChart is a two dimentional line chart (who would have guessed?) that you can add to your worksheet.
4
+ # The LineChart is a two dimensional line chart (who would have guessed?) that you can add to your worksheet.
5
5
  # @example Creating a chart
6
6
  # # This example creates a line in a single sheet.
7
7
  # require "rubygems" # if that is your preferred way to manage gems!
@@ -47,7 +47,7 @@ module Axlsx
47
47
  def initialize(frame, options = {})
48
48
  @vary_colors = false
49
49
  @grouping = :standard
50
- super(frame, options)
50
+ super
51
51
  @series_type = LineSeries
52
52
  @d_lbls = nil
53
53
  end
@@ -75,7 +75,7 @@ module Axlsx
75
75
  # @param [String] str
76
76
  # @return [String]
77
77
  def to_xml_string(str = +'')
78
- super(str) do
78
+ super do
79
79
  str << "<c:" << node_name << ">"
80
80
  str << '<c:grouping val="' << grouping.to_s << '"/>'
81
81
  str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
@@ -40,7 +40,7 @@ module Axlsx
40
40
  @marker_symbol = options[:marker_symbol] || :default
41
41
  @smooth = false
42
42
  @labels, @data = nil, nil
43
- super(chart, options)
43
+ super
44
44
  @labels = AxDataSource.new(data: options[:labels]) unless options[:labels].nil?
45
45
  @data = NumDataSource.new(options) unless options[:data].nil?
46
46
  end
@@ -72,7 +72,7 @@ module Axlsx
72
72
  # @param [String] str
73
73
  # @return [String]
74
74
  def to_xml_string(str = +'')
75
- super(str) do
75
+ super do
76
76
  if color
77
77
  str << '<c:spPr><a:solidFill>'
78
78
  str << '<a:srgbClr val="' << color << '"/>'
@@ -101,9 +101,15 @@ module Axlsx
101
101
  private
102
102
 
103
103
  # assigns the data for this series
104
- def data=(v) DataTypeValidator.validate "Series.data", [NumDataSource], v; @data = v; end
104
+ def data=(v)
105
+ DataTypeValidator.validate "Series.data", [NumDataSource], v
106
+ @data = v
107
+ end
105
108
 
106
109
  # assigns the labels for this series
107
- def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end
110
+ def labels=(v)
111
+ DataTypeValidator.validate "Series.labels", [AxDataSource], v
112
+ @labels = v
113
+ end
108
114
  end
109
115
  end
@@ -34,13 +34,28 @@ module Axlsx
34
34
  attr_reader :rowOff
35
35
 
36
36
  # @see col
37
- def col=(v) Axlsx.validate_unsigned_int v; @col = v end
37
+ def col=(v)
38
+ Axlsx.validate_unsigned_int v
39
+ @col = v
40
+ end
41
+
38
42
  # @see colOff
39
- def colOff=(v) Axlsx.validate_int v; @colOff = v end
43
+ def colOff=(v)
44
+ Axlsx.validate_int v
45
+ @colOff = v
46
+ end
47
+
40
48
  # @see row
41
- def row=(v) Axlsx.validate_unsigned_int v; @row = v end
49
+ def row=(v)
50
+ Axlsx.validate_unsigned_int v
51
+ @row = v
52
+ end
53
+
42
54
  # @see rowOff
43
- def rowOff=(v) Axlsx.validate_int v; @rowOff = v end
55
+ def rowOff=(v)
56
+ Axlsx.validate_int v
57
+ @rowOff = v
58
+ end
44
59
 
45
60
  # shortcut to set the column, row position for this marker
46
61
  # @param col the column for the marker, a Cell object or a string reference like "B7"