caxlsx 4.0.0 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -12
- data/README.md +1 -1
- data/examples/generate.rb +3 -1
- data/lib/axlsx/content_type/abstract_content_type.rb +6 -3
- data/lib/axlsx/content_type/content_type.rb +4 -4
- data/lib/axlsx/content_type/default.rb +4 -1
- data/lib/axlsx/content_type/override.rb +4 -1
- data/lib/axlsx/doc_props/app.rb +91 -24
- data/lib/axlsx/drawing/area_chart.rb +3 -3
- data/lib/axlsx/drawing/area_series.rb +10 -4
- data/lib/axlsx/drawing/ax_data_source.rb +1 -1
- data/lib/axlsx/drawing/axes.rb +1 -1
- data/lib/axlsx/drawing/axis.rb +25 -7
- data/lib/axlsx/drawing/bar_3D_chart.rb +3 -3
- data/lib/axlsx/drawing/bar_chart.rb +3 -3
- data/lib/axlsx/drawing/bar_series.rb +14 -5
- data/lib/axlsx/drawing/bubble_chart.rb +2 -2
- data/lib/axlsx/drawing/bubble_series.rb +2 -2
- data/lib/axlsx/drawing/cat_axis.rb +23 -8
- data/lib/axlsx/drawing/chart.rb +32 -8
- data/lib/axlsx/drawing/d_lbls.rb +8 -8
- data/lib/axlsx/drawing/drawing.rb +50 -49
- data/lib/axlsx/drawing/hyperlink.rb +13 -4
- data/lib/axlsx/drawing/line_3D_chart.rb +3 -3
- data/lib/axlsx/drawing/line_chart.rb +3 -3
- data/lib/axlsx/drawing/line_series.rb +10 -4
- data/lib/axlsx/drawing/marker.rb +19 -4
- data/lib/axlsx/drawing/num_val.rb +1 -1
- data/lib/axlsx/drawing/one_cell_anchor.rb +8 -2
- data/lib/axlsx/drawing/pic.rb +17 -8
- data/lib/axlsx/drawing/pie_3D_chart.rb +3 -3
- data/lib/axlsx/drawing/pie_chart.rb +36 -0
- data/lib/axlsx/drawing/pie_series.rb +18 -6
- data/lib/axlsx/drawing/scaling.rb +18 -4
- data/lib/axlsx/drawing/scatter_chart.rb +2 -2
- data/lib/axlsx/drawing/scatter_series.rb +2 -2
- data/lib/axlsx/drawing/ser_axis.rb +11 -5
- data/lib/axlsx/drawing/series.rb +8 -2
- data/lib/axlsx/drawing/two_cell_anchor.rb +1 -1
- data/lib/axlsx/drawing/val_axis.rb +2 -2
- data/lib/axlsx/drawing/view_3D.rb +8 -2
- data/lib/axlsx/package.rb +11 -11
- data/lib/axlsx/rels/relationship.rb +15 -5
- data/lib/axlsx/rels/relationships.rb +3 -3
- data/lib/axlsx/stylesheet/border.rb +12 -3
- data/lib/axlsx/stylesheet/border_pr.rb +15 -4
- data/lib/axlsx/stylesheet/cell_alignment.rb +39 -10
- data/lib/axlsx/stylesheet/cell_protection.rb +9 -2
- data/lib/axlsx/stylesheet/cell_style.rb +30 -7
- data/lib/axlsx/stylesheet/color.rb +10 -4
- data/lib/axlsx/stylesheet/dxf.rb +29 -6
- data/lib/axlsx/stylesheet/fill.rb +4 -1
- data/lib/axlsx/stylesheet/font.rb +59 -13
- data/lib/axlsx/stylesheet/gradient_fill.rb +9 -3
- data/lib/axlsx/stylesheet/gradient_stop.rb +9 -2
- data/lib/axlsx/stylesheet/num_fmt.rb +8 -2
- data/lib/axlsx/stylesheet/pattern_fill.rb +14 -3
- data/lib/axlsx/stylesheet/styles.rb +83 -43
- data/lib/axlsx/stylesheet/table_style.rb +15 -4
- data/lib/axlsx/stylesheet/table_style_element.rb +12 -3
- data/lib/axlsx/stylesheet/table_styles.rb +10 -3
- data/lib/axlsx/stylesheet/xf.rb +69 -16
- data/lib/axlsx/util/accessors.rb +9 -7
- data/lib/axlsx/util/constants.rb +2 -2
- data/lib/axlsx/util/serialized_attributes.rb +2 -2
- data/lib/axlsx/util/simple_typed_list.rb +25 -12
- data/lib/axlsx/util/storage.rb +4 -4
- data/lib/axlsx/util/validators.rb +1 -1
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +1 -1
- data/lib/axlsx/workbook/defined_names.rb +1 -1
- data/lib/axlsx/workbook/shared_strings_table.rb +3 -3
- data/lib/axlsx/workbook/workbook.rb +80 -67
- data/lib/axlsx/workbook/workbook_views.rb +1 -1
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +4 -4
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +5 -3
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +3 -3
- data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +1 -1
- data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +2 -2
- data/lib/axlsx/workbook/worksheet/border_creator.rb +4 -4
- data/lib/axlsx/workbook/worksheet/cell.rb +37 -17
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +1 -1
- data/lib/axlsx/workbook/worksheet/cfvo.rb +8 -2
- data/lib/axlsx/workbook/worksheet/col.rb +22 -9
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +1 -1
- data/lib/axlsx/workbook/worksheet/cols.rb +1 -1
- data/lib/axlsx/workbook/worksheet/comment.rb +2 -2
- data/lib/axlsx/workbook/worksheet/comments.rb +1 -1
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +9 -3
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +70 -15
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +3 -3
- data/lib/axlsx/workbook/worksheet/data_validation.rb +53 -14
- data/lib/axlsx/workbook/worksheet/data_validations.rb +3 -3
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +2 -2
- data/lib/axlsx/workbook/worksheet/dimension.rb +1 -1
- data/lib/axlsx/workbook/worksheet/icon_set.rb +17 -5
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +1 -1
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/page_margins.rb +30 -7
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -2
- data/lib/axlsx/workbook/worksheet/page_setup.rb +32 -9
- data/lib/axlsx/workbook/worksheet/pane.rb +8 -2
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +29 -5
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +1 -1
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +31 -11
- data/lib/axlsx/workbook/worksheet/row.rb +5 -2
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +1 -1
- data/lib/axlsx/workbook/worksheet/selection.rb +8 -2
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -1
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +30 -9
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +2 -2
- data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +28 -14
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +3 -3
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +2 -2
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +2 -2
- data/lib/axlsx.rb +44 -30
- data/lib/caxlsx.rb +1 -1
- metadata +10 -48
@@ -37,13 +37,16 @@ module Axlsx
|
|
37
37
|
def initialize(chart, options = {})
|
38
38
|
@shape = :box
|
39
39
|
@colors = []
|
40
|
-
super
|
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)
|
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
|
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)
|
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)
|
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
|
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
|
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
|
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
|
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
|
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
|
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)
|
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)
|
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)
|
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)
|
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)
|
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
|
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 << '"/>'
|
data/lib/axlsx/drawing/chart.rb
CHANGED
@@ -62,7 +62,10 @@ module Axlsx
|
|
62
62
|
|
63
63
|
# Configures the vary_colors options for this chart
|
64
64
|
# @param [Boolean] v The value to set
|
65
|
-
def vary_colors=(v)
|
65
|
+
def vary_colors=(v)
|
66
|
+
Axlsx.validate_boolean(v)
|
67
|
+
@vary_colors = v
|
68
|
+
end
|
66
69
|
|
67
70
|
# The title object for the chart.
|
68
71
|
# @return [Title]
|
@@ -149,21 +152,33 @@ module Axlsx
|
|
149
152
|
# Show the legend in the chart
|
150
153
|
# @param [Boolean] v
|
151
154
|
# @return [Boolean]
|
152
|
-
def show_legend=(v)
|
155
|
+
def show_legend=(v)
|
156
|
+
Axlsx.validate_boolean(v)
|
157
|
+
@show_legend = v
|
158
|
+
end
|
153
159
|
|
154
160
|
# How to display blank values
|
155
161
|
# @see display_blanks_as
|
156
162
|
# @param [Symbol] v
|
157
163
|
# @return [Symbol]
|
158
|
-
def display_blanks_as=(v)
|
164
|
+
def display_blanks_as=(v)
|
165
|
+
Axlsx.validate_display_blanks_as(v)
|
166
|
+
@display_blanks_as = v
|
167
|
+
end
|
159
168
|
|
160
169
|
# The style for the chart.
|
161
170
|
# see ECMA Part 1 §21.2.2.196
|
162
171
|
# @param [Integer] v must be between 1 and 48
|
163
|
-
def style=(v)
|
172
|
+
def style=(v)
|
173
|
+
DataTypeValidator.validate "Chart.style", Integer, v, ->(arg) { arg >= 1 && arg <= 48 }
|
174
|
+
@style = v
|
175
|
+
end
|
164
176
|
|
165
177
|
# @see legend_position
|
166
|
-
def legend_position=(v)
|
178
|
+
def legend_position=(v)
|
179
|
+
RestrictionValidator.validate "Chart.legend_position", [:b, :l, :r, :t, :tr], v
|
180
|
+
@legend_position = v
|
181
|
+
end
|
167
182
|
|
168
183
|
# backwards compatibility to allow chart.to and chart.from access to anchor markers
|
169
184
|
# @note This will be disconinued in version 2.0.0. Please use the end_at method
|
@@ -194,12 +209,18 @@ module Axlsx
|
|
194
209
|
# Whether only data from visible cells should be plotted.
|
195
210
|
# @param [Boolean] v
|
196
211
|
# @return [Boolean]
|
197
|
-
def plot_visible_only=(v)
|
212
|
+
def plot_visible_only=(v)
|
213
|
+
Axlsx.validate_boolean(v)
|
214
|
+
@plot_visible_only = v
|
215
|
+
end
|
198
216
|
|
199
217
|
# Whether the chart area shall have rounded corners.
|
200
218
|
# @param [Boolean] v
|
201
219
|
# @return [Boolean]
|
202
|
-
def rounded_corners=(v)
|
220
|
+
def rounded_corners=(v)
|
221
|
+
Axlsx.validate_boolean(v)
|
222
|
+
@rounded_corners = v
|
223
|
+
end
|
203
224
|
|
204
225
|
# Serializes the object
|
205
226
|
# @param [String] str
|
@@ -290,7 +311,10 @@ module Axlsx
|
|
290
311
|
end
|
291
312
|
|
292
313
|
# sets the view_3D object for the chart
|
293
|
-
def view_3D=(v)
|
314
|
+
def view_3D=(v)
|
315
|
+
DataTypeValidator.validate "#{self.class}.view_3D", View3D, v
|
316
|
+
@view_3D = v
|
317
|
+
end
|
294
318
|
alias :view3D= :view_3D=
|
295
319
|
end
|
296
320
|
end
|
data/lib/axlsx/drawing/d_lbls.rb
CHANGED
@@ -19,7 +19,7 @@ module Axlsx
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# These attributes are all boolean so I'm doing a bit of a hand
|
22
|
-
# waving magic show to set up the
|
22
|
+
# waving magic show to set up the attribute accessors
|
23
23
|
# @note
|
24
24
|
# not all charts support all methods!
|
25
25
|
# Bar3DChart and Line3DChart and ScatterChart do not support d_lbl_pos or show_leader_lines
|
@@ -38,11 +38,11 @@ module Axlsx
|
|
38
38
|
[:show_legend_key, :show_val, :show_cat_name,
|
39
39
|
:show_ser_name, :show_percent, :show_bubble_size,
|
40
40
|
:show_leader_lines].each do |attr|
|
41
|
-
send("#{attr}=", false)
|
41
|
+
send(:"#{attr}=", false)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
# The chart type that is using this data
|
45
|
+
# The chart type that is using this data labels instance.
|
46
46
|
# This affects the xml output as not all chart types support the
|
47
47
|
# same data label attributes.
|
48
48
|
attr_reader :chart_type
|
@@ -51,19 +51,19 @@ module Axlsx
|
|
51
51
|
# @see d_lbl_pos= for a list of allowed values
|
52
52
|
# @return [Symbol]
|
53
53
|
def d_lbl_pos
|
54
|
-
return unless [Pie3DChart, LineChart].include? @chart_type
|
54
|
+
return unless [PieChart, Pie3DChart, LineChart].include? @chart_type
|
55
55
|
|
56
56
|
@d_lbl_pos ||= :bestFit
|
57
57
|
end
|
58
58
|
|
59
59
|
# @see DLbls#d_lbl_pos
|
60
|
-
# Assigns the label
|
60
|
+
# Assigns the label position for this data labels on this chart.
|
61
61
|
# Allowed positions are :bestFit, :b, :ctr, :inBase, :inEnd, :l,
|
62
62
|
# :outEnd, :r and :t
|
63
63
|
# The default is :bestFit
|
64
|
-
# @param [Symbol] label_position the
|
64
|
+
# @param [Symbol] label_position the position you want to use.
|
65
65
|
def d_lbl_pos=(label_position)
|
66
|
-
return unless [Pie3DChart, LineChart].include? @chart_type
|
66
|
+
return unless [PieChart, Pie3DChart, LineChart].include? @chart_type
|
67
67
|
|
68
68
|
Axlsx::RestrictionValidator.validate 'DLbls#d_lbl_pos', [:bestFit, :b, :ctr, :inBase, :inEnd, :l, :outEnd, :r, :t], label_position
|
69
69
|
@d_lbl_pos = label_position
|
@@ -85,7 +85,7 @@ module Axlsx
|
|
85
85
|
|
86
86
|
# 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
87
|
def validate_attributes_for_chart_type
|
88
|
-
return if [Pie3DChart, LineChart].include? @chart_type
|
88
|
+
return if [PieChart, Pie3DChart, LineChart].include? @chart_type
|
89
89
|
|
90
90
|
@d_lbl_pos = nil
|
91
91
|
@show_leader_lines = nil
|
@@ -1,55 +1,56 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Axlsx
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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)
|
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)
|
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
|
74
|
-
def history=(v)
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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)
|
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)
|
110
|
+
def labels=(v)
|
111
|
+
DataTypeValidator.validate "Series.labels", [AxDataSource], v
|
112
|
+
@labels = v
|
113
|
+
end
|
108
114
|
end
|
109
115
|
end
|
data/lib/axlsx/drawing/marker.rb
CHANGED
@@ -34,13 +34,28 @@ module Axlsx
|
|
34
34
|
attr_reader :rowOff
|
35
35
|
|
36
36
|
# @see col
|
37
|
-
def col=(v)
|
37
|
+
def col=(v)
|
38
|
+
Axlsx.validate_unsigned_int v
|
39
|
+
@col = v
|
40
|
+
end
|
41
|
+
|
38
42
|
# @see colOff
|
39
|
-
def colOff=(v)
|
43
|
+
def colOff=(v)
|
44
|
+
Axlsx.validate_int v
|
45
|
+
@colOff = v
|
46
|
+
end
|
47
|
+
|
40
48
|
# @see row
|
41
|
-
def row=(v)
|
49
|
+
def row=(v)
|
50
|
+
Axlsx.validate_unsigned_int v
|
51
|
+
@row = v
|
52
|
+
end
|
53
|
+
|
42
54
|
# @see rowOff
|
43
|
-
def rowOff=(v)
|
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"
|
@@ -60,10 +60,16 @@ module Axlsx
|
|
60
60
|
|
61
61
|
#
|
62
62
|
# @see height
|
63
|
-
def height=(v)
|
63
|
+
def height=(v)
|
64
|
+
Axlsx.validate_unsigned_int(v)
|
65
|
+
@height = v
|
66
|
+
end
|
64
67
|
|
65
68
|
# @see width
|
66
|
-
def width=(v)
|
69
|
+
def width=(v)
|
70
|
+
Axlsx.validate_unsigned_int(v)
|
71
|
+
@width = v
|
72
|
+
end
|
67
73
|
|
68
74
|
# The index of this anchor in the drawing
|
69
75
|
# @return [Integer]
|
data/lib/axlsx/drawing/pic.rb
CHANGED
@@ -69,7 +69,7 @@ module Axlsx
|
|
69
69
|
options[:href] = v
|
70
70
|
if hyperlink.is_a?(Hyperlink)
|
71
71
|
options.each do |o|
|
72
|
-
hyperlink.send("#{o[0]}=", o[1]) if hyperlink.respond_to? "#{o[0]}="
|
72
|
+
hyperlink.send(:"#{o[0]}=", o[1]) if hyperlink.respond_to? :"#{o[0]}="
|
73
73
|
end
|
74
74
|
else
|
75
75
|
@hyperlink = Hyperlink.new(self, options)
|
@@ -80,7 +80,7 @@ module Axlsx
|
|
80
80
|
def image_src=(v)
|
81
81
|
Axlsx.validate_string(v)
|
82
82
|
if remote?
|
83
|
-
RegexValidator.validate('Pic.image_src', /\A#{
|
83
|
+
RegexValidator.validate('Pic.image_src', /\A#{Axlsx.uri_parser.make_regexp}\z/, v)
|
84
84
|
RestrictionValidator.validate 'Pic.image_src', ALLOWED_MIME_TYPES, MimeTypeUtils.get_mime_type_from_uri(v)
|
85
85
|
else
|
86
86
|
RestrictionValidator.validate 'Pic.image_src', ALLOWED_MIME_TYPES, MimeTypeUtils.get_mime_type(v)
|
@@ -91,13 +91,22 @@ module Axlsx
|
|
91
91
|
end
|
92
92
|
|
93
93
|
# @see name
|
94
|
-
def name=(v)
|
94
|
+
def name=(v)
|
95
|
+
Axlsx.validate_string(v)
|
96
|
+
@name = v
|
97
|
+
end
|
95
98
|
|
96
99
|
# @see descr
|
97
|
-
def descr=(v)
|
100
|
+
def descr=(v)
|
101
|
+
Axlsx.validate_string(v)
|
102
|
+
@descr = v
|
103
|
+
end
|
98
104
|
|
99
105
|
# @see remote
|
100
|
-
def remote=(v)
|
106
|
+
def remote=(v)
|
107
|
+
Axlsx.validate_boolean(v)
|
108
|
+
@remote = v
|
109
|
+
end
|
101
110
|
|
102
111
|
def remote?
|
103
112
|
remote == 1 || remote.to_s == 'true'
|
@@ -109,7 +118,7 @@ module Axlsx
|
|
109
118
|
File.basename(image_src) unless remote? || image_src.nil?
|
110
119
|
end
|
111
120
|
|
112
|
-
# returns the extension of image_src without the
|
121
|
+
# returns the extension of image_src without the preceding '.'
|
113
122
|
# @return [String]
|
114
123
|
def extname
|
115
124
|
File.extname(image_src).delete('.') unless image_src.nil?
|
@@ -213,9 +222,9 @@ module Axlsx
|
|
213
222
|
# Return correct xml relationship string portion
|
214
223
|
def relationship_xml_portion
|
215
224
|
if remote?
|
216
|
-
(+'<a:blip xmlns:r
|
225
|
+
(+'<a:blip xmlns:r="' << XML_NS_R << '" r:link="' << relationship.Id << '">')
|
217
226
|
else
|
218
|
-
(+'<a:blip xmlns:r
|
227
|
+
(+'<a:blip xmlns:r="' << XML_NS_R << '" r:embed="' << relationship.Id << '">')
|
219
228
|
end
|
220
229
|
end
|
221
230
|
|