caxlsx 3.4.1 → 4.0.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 +16 -1
- data/README.md +9 -11
- data/Rakefile +7 -5
- data/lib/axlsx/content_type/abstract_content_type.rb +9 -4
- data/lib/axlsx/content_type/content_type.rb +7 -5
- data/lib/axlsx/content_type/default.rb +4 -2
- data/lib/axlsx/content_type/override.rb +4 -2
- data/lib/axlsx/doc_props/app.rb +26 -24
- data/lib/axlsx/doc_props/core.rb +8 -6
- data/lib/axlsx/drawing/area_chart.rb +10 -8
- data/lib/axlsx/drawing/area_series.rb +12 -10
- data/lib/axlsx/drawing/ax_data_source.rb +2 -0
- data/lib/axlsx/drawing/axes.rb +6 -4
- data/lib/axlsx/drawing/axis.rb +21 -19
- data/lib/axlsx/drawing/bar_3D_chart.rb +14 -12
- data/lib/axlsx/drawing/bar_chart.rb +13 -11
- data/lib/axlsx/drawing/bar_series.rb +8 -6
- data/lib/axlsx/drawing/bubble_chart.rb +6 -4
- data/lib/axlsx/drawing/bubble_series.rb +8 -6
- data/lib/axlsx/drawing/cat_axis.rb +12 -10
- data/lib/axlsx/drawing/chart.rb +20 -18
- data/lib/axlsx/drawing/d_lbls.rb +7 -5
- data/lib/axlsx/drawing/drawing.rb +58 -56
- data/lib/axlsx/drawing/graphic_frame.rb +6 -4
- data/lib/axlsx/drawing/hyperlink.rb +10 -8
- data/lib/axlsx/drawing/line_3D_chart.rb +7 -5
- data/lib/axlsx/drawing/line_chart.rb +10 -8
- data/lib/axlsx/drawing/line_series.rb +12 -10
- data/lib/axlsx/drawing/marker.rb +9 -7
- data/lib/axlsx/drawing/num_data.rb +9 -7
- data/lib/axlsx/drawing/num_data_source.rb +9 -7
- data/lib/axlsx/drawing/num_val.rb +7 -5
- data/lib/axlsx/drawing/one_cell_anchor.rb +7 -5
- data/lib/axlsx/drawing/pic.rb +16 -14
- data/lib/axlsx/drawing/picture_locking.rb +3 -1
- data/lib/axlsx/drawing/pie_3D_chart.rb +5 -3
- data/lib/axlsx/drawing/pie_series.rb +8 -6
- data/lib/axlsx/drawing/scaling.rb +8 -6
- data/lib/axlsx/drawing/scatter_chart.rb +7 -5
- data/lib/axlsx/drawing/scatter_series.rb +14 -12
- data/lib/axlsx/drawing/ser_axis.rb +7 -5
- data/lib/axlsx/drawing/series.rb +6 -4
- data/lib/axlsx/drawing/series_title.rb +6 -4
- data/lib/axlsx/drawing/str_data.rb +7 -5
- data/lib/axlsx/drawing/str_val.rb +6 -4
- data/lib/axlsx/drawing/title.rb +13 -14
- data/lib/axlsx/drawing/two_cell_anchor.rb +4 -2
- data/lib/axlsx/drawing/val_axis.rb +4 -2
- data/lib/axlsx/drawing/view_3D.rb +9 -7
- data/lib/axlsx/drawing/vml_drawing.rb +18 -16
- data/lib/axlsx/drawing/vml_shape.rb +24 -22
- data/lib/axlsx/package.rb +69 -66
- data/lib/axlsx/rels/relationship.rb +10 -5
- data/lib/axlsx/rels/relationships.rb +5 -3
- data/lib/axlsx/stylesheet/border.rb +6 -4
- data/lib/axlsx/stylesheet/border_pr.rb +5 -3
- data/lib/axlsx/stylesheet/cell_alignment.rb +12 -10
- data/lib/axlsx/stylesheet/cell_protection.rb +5 -3
- data/lib/axlsx/stylesheet/cell_style.rb +10 -8
- data/lib/axlsx/stylesheet/color.rb +9 -7
- data/lib/axlsx/stylesheet/dxf.rb +5 -3
- data/lib/axlsx/stylesheet/fill.rb +3 -1
- data/lib/axlsx/stylesheet/font.rb +18 -16
- data/lib/axlsx/stylesheet/gradient_fill.rb +6 -4
- data/lib/axlsx/stylesheet/gradient_stop.rb +6 -4
- data/lib/axlsx/stylesheet/num_fmt.rb +8 -10
- data/lib/axlsx/stylesheet/pattern_fill.rb +5 -3
- data/lib/axlsx/stylesheet/styles.rb +69 -71
- data/lib/axlsx/stylesheet/table_style.rb +7 -5
- data/lib/axlsx/stylesheet/table_style_element.rb +6 -4
- data/lib/axlsx/stylesheet/table_styles.rb +6 -4
- data/lib/axlsx/stylesheet/xf.rb +18 -16
- data/lib/axlsx/util/accessors.rb +4 -2
- data/lib/axlsx/util/buffered_zip_output_stream.rb +60 -0
- data/lib/axlsx/util/constants.rb +117 -104
- data/lib/axlsx/util/mime_type_utils.rb +3 -5
- data/lib/axlsx/util/options_parser.rb +3 -1
- data/lib/axlsx/util/serialized_attributes.rb +42 -17
- data/lib/axlsx/util/simple_typed_list.rb +47 -47
- data/lib/axlsx/util/storage.rb +11 -10
- data/lib/axlsx/util/validators.rb +101 -41
- data/lib/axlsx/util/zip_command.rb +10 -10
- data/lib/axlsx/version.rb +3 -1
- data/lib/axlsx/workbook/defined_name.rb +6 -4
- data/lib/axlsx/workbook/defined_names.rb +3 -1
- data/lib/axlsx/workbook/shared_strings_table.rb +8 -6
- data/lib/axlsx/workbook/workbook.rb +78 -76
- data/lib/axlsx/workbook/workbook_view.rb +3 -1
- data/lib/axlsx/workbook/workbook_views.rb +3 -1
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +65 -8
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +7 -3
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +11 -7
- data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +51 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +56 -0
- data/lib/axlsx/workbook/worksheet/border_creator.rb +5 -3
- data/lib/axlsx/workbook/worksheet/break.rb +3 -1
- data/lib/axlsx/workbook/worksheet/cell.rb +53 -54
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +31 -27
- data/lib/axlsx/workbook/worksheet/cfvo.rb +5 -3
- data/lib/axlsx/workbook/worksheet/cfvos.rb +3 -1
- data/lib/axlsx/workbook/worksheet/col.rb +5 -3
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +5 -3
- data/lib/axlsx/workbook/worksheet/color_scale.rb +12 -10
- data/lib/axlsx/workbook/worksheet/cols.rb +3 -1
- data/lib/axlsx/workbook/worksheet/comment.rb +8 -6
- data/lib/axlsx/workbook/worksheet/comments.rb +6 -4
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +9 -4
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +18 -16
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +3 -1
- data/lib/axlsx/workbook/worksheet/data_bar.rb +14 -13
- data/lib/axlsx/workbook/worksheet/data_validation.rb +30 -28
- data/lib/axlsx/workbook/worksheet/data_validations.rb +3 -1
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +7 -5
- data/lib/axlsx/workbook/worksheet/dimension.rb +4 -2
- data/lib/axlsx/workbook/worksheet/header_footer.rb +4 -2
- data/lib/axlsx/workbook/worksheet/icon_set.rb +23 -6
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +5 -5
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +6 -2
- data/lib/axlsx/workbook/worksheet/page_margins.rb +15 -10
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +6 -2
- data/lib/axlsx/workbook/worksheet/page_setup.rb +11 -9
- data/lib/axlsx/workbook/worksheet/pane.rb +11 -9
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +20 -19
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +8 -6
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +2 -0
- data/lib/axlsx/workbook/worksheet/print_options.rb +3 -1
- data/lib/axlsx/workbook/worksheet/protected_range.rb +3 -1
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +5 -3
- data/lib/axlsx/workbook/worksheet/rich_text.rb +3 -1
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +16 -14
- data/lib/axlsx/workbook/worksheet/row.rb +6 -7
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +6 -4
- data/lib/axlsx/workbook/worksheet/selection.rb +9 -7
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +6 -2
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
- data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +6 -2
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +8 -4
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +10 -8
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +15 -13
- data/lib/axlsx/workbook/worksheet/table.rb +9 -7
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +4 -2
- data/lib/axlsx/workbook/worksheet/tables.rb +3 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +38 -37
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +4 -2
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +8 -2
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +6 -4
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +4 -2
- data/lib/axlsx.rb +56 -42
- data/lib/caxlsx.rb +3 -1
- metadata +49 -43
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# a hyperlink object adds an action to an image when clicked so that when the image is clicked the link is fecthed.
|
3
5
|
# @note using the hyperlink option when calling add_image on a drawing object is the recommended way to manage hyperlinks
|
@@ -13,7 +15,7 @@ module Axlsx
|
|
13
15
|
# @option options [String] tgtFrame Target frame for opening hyperlink
|
14
16
|
# @option options [String] invalidUrl supposedly use to store the href when we know it is an invalid resource.
|
15
17
|
# @option options [String] href the target resource this hyperlink links to. This is actually stored on the relationship.
|
16
|
-
# @option options [String] action A string that can be used to perform specific actions. For
|
18
|
+
# @option options [String] action A string that can be used to perform specific actions. For Excel please see this reference: https://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
|
17
19
|
# @option options [Boolean] endSnd terminate any sound events when processing this link
|
18
20
|
# @option options [Boolean] history include this link in the list of visited links for the applications history.
|
19
21
|
# @option options [Boolean] highlightClick indicate that the link has already been visited.
|
@@ -38,7 +40,7 @@ module Axlsx
|
|
38
40
|
alias :invalidUrl :invalid_url
|
39
41
|
alias :invalidUrl= :invalid_url=
|
40
42
|
|
41
|
-
# An action to take when the link is clicked. The specification says "This can be used to specify a slide to be navigated to or a script of code to be run." but in most cases you will not need to do anything with this. MS does reserve a few interesting strings. @see
|
43
|
+
# An action to take when the link is clicked. The specification says "This can be used to specify a slide to be navigated to or a script of code to be run." but in most cases you will not need to do anything with this. MS does reserve a few interesting strings. @see https://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
|
42
44
|
# @return [String]
|
43
45
|
attr_accessor :action
|
44
46
|
|
@@ -50,7 +52,7 @@ module Axlsx
|
|
50
52
|
# @see endSnd
|
51
53
|
# @param [Boolean] v The boolean value indicating the termination of playing sounds on click
|
52
54
|
# @return [Boolean]
|
53
|
-
def end_snd=(v) Axlsx
|
55
|
+
def end_snd=(v) Axlsx.validate_boolean(v); @end_snd = v end
|
54
56
|
alias :endSnd= :end_snd=
|
55
57
|
|
56
58
|
# indicates that the link has already been clicked.
|
@@ -60,7 +62,7 @@ module Axlsx
|
|
60
62
|
|
61
63
|
# @see highlightClick
|
62
64
|
# @param [Boolean] v The value to assign
|
63
|
-
def highlight_click=(v) Axlsx
|
65
|
+
def highlight_click=(v) Axlsx.validate_boolean(v); @highlight_click = v end
|
64
66
|
alias :highlightClick= :highlight_click=
|
65
67
|
|
66
68
|
# 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.
|
@@ -69,7 +71,7 @@ module Axlsx
|
|
69
71
|
|
70
72
|
# @see history
|
71
73
|
# param [Boolean] v The value to assing
|
72
|
-
def history=(v) Axlsx
|
74
|
+
def history=(v) Axlsx.validate_boolean(v); @history = v end
|
73
75
|
|
74
76
|
# 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.
|
75
77
|
# @return [String]
|
@@ -84,14 +86,14 @@ module Axlsx
|
|
84
86
|
# The relationship object for this hyperlink.
|
85
87
|
# @return [Relationship]
|
86
88
|
def relationship
|
87
|
-
Relationship.new(self, HYPERLINK_R, href, :
|
89
|
+
Relationship.new(self, HYPERLINK_R, href, target_mode: :External)
|
88
90
|
end
|
89
91
|
|
90
92
|
# Serializes the object
|
91
93
|
# @param [String] str
|
92
94
|
# @return [String]
|
93
|
-
def to_xml_string(str = '')
|
94
|
-
serialized_tag 'a:hlinkClick', str, {
|
95
|
+
def to_xml_string(str = +'')
|
96
|
+
serialized_tag 'a:hlinkClick', str, { 'r:id': relationship.Id, 'xmlns:r': XML_NS_R }
|
95
97
|
end
|
96
98
|
end
|
97
99
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# The Line3DChart is a three dimentional line chart (who would have guessed?) that you can add to your worksheet.
|
3
5
|
# @example Creating a chart
|
@@ -24,7 +26,7 @@ module Axlsx
|
|
24
26
|
alias :gapDepth :gap_depth
|
25
27
|
|
26
28
|
# validation regex for gap amount percent
|
27
|
-
GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)
|
29
|
+
GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/.freeze
|
28
30
|
|
29
31
|
# the category axis
|
30
32
|
# @return [Axis]
|
@@ -40,7 +42,7 @@ module Axlsx
|
|
40
42
|
# @see View3D
|
41
43
|
def initialize(frame, options = {})
|
42
44
|
@gap_depth = nil
|
43
|
-
@view_3D = View3D.new({ :
|
45
|
+
@view_3D = View3D.new({ r_ang_ax: 1 }.merge(options))
|
44
46
|
super(frame, options)
|
45
47
|
axes.add_axis :ser_axis, SerAxis
|
46
48
|
end
|
@@ -48,16 +50,16 @@ module Axlsx
|
|
48
50
|
# @see gapDepth
|
49
51
|
def gap_depth=(v)
|
50
52
|
RegexValidator.validate "Line3DChart.gapWidth", GAP_AMOUNT_PERCENT, v
|
51
|
-
@gap_depth =
|
53
|
+
@gap_depth = v
|
52
54
|
end
|
53
55
|
alias :gapDepth= :gap_depth=
|
54
56
|
|
55
57
|
# Serializes the object
|
56
58
|
# @param [String] str
|
57
59
|
# @return [String]
|
58
|
-
def to_xml_string(str = '')
|
60
|
+
def to_xml_string(str = +'')
|
59
61
|
super(str) do
|
60
|
-
str <<
|
62
|
+
str << '<c:gapDepth val="' << @gap_depth.to_s << '"/>' unless @gap_depth.nil?
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# The LineChart is a two dimentional line chart (who would have guessed?) that you can add to your worksheet.
|
3
5
|
# @example Creating a chart
|
@@ -61,7 +63,7 @@ module Axlsx
|
|
61
63
|
# chart based on the actual class type and not a fixed node name.
|
62
64
|
# @return [String]
|
63
65
|
def node_name
|
64
|
-
path = self.class.
|
66
|
+
path = self.class.name
|
65
67
|
if i = path.rindex('::')
|
66
68
|
path = path[(i + 2)..-1]
|
67
69
|
end
|
@@ -72,16 +74,16 @@ module Axlsx
|
|
72
74
|
# Serializes the object
|
73
75
|
# @param [String] str
|
74
76
|
# @return [String]
|
75
|
-
def to_xml_string(str = '')
|
77
|
+
def to_xml_string(str = +'')
|
76
78
|
super(str) do
|
77
|
-
str <<
|
78
|
-
str <<
|
79
|
-
str <<
|
79
|
+
str << "<c:" << node_name << ">"
|
80
|
+
str << '<c:grouping val="' << grouping.to_s << '"/>'
|
81
|
+
str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
|
80
82
|
@series.each { |ser| ser.to_xml_string(str) }
|
81
83
|
@d_lbls.to_xml_string(str) if @d_lbls
|
82
84
|
yield if block_given?
|
83
|
-
axes.to_xml_string(str, :
|
84
|
-
str <<
|
85
|
+
axes.to_xml_string(str, ids: true)
|
86
|
+
str << "</c:" << node_name << ">"
|
85
87
|
axes.to_xml_string(str)
|
86
88
|
end
|
87
89
|
end
|
@@ -90,7 +92,7 @@ module Axlsx
|
|
90
92
|
# axis.
|
91
93
|
# @return [Axes]
|
92
94
|
def axes
|
93
|
-
@axes ||= Axes.new(:
|
95
|
+
@axes ||= Axes.new(cat_axis: CatAxis, val_axis: ValAxis)
|
94
96
|
end
|
95
97
|
end
|
96
98
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# A LineSeries defines the title, data and labels for line charts
|
3
5
|
# @note The recommended way to manage series is to use Chart#add_series
|
@@ -35,11 +37,11 @@ module Axlsx
|
|
35
37
|
# @param [Chart] chart
|
36
38
|
def initialize(chart, options = {})
|
37
39
|
@show_marker = false
|
38
|
-
@marker_symbol = options[:marker_symbol]
|
40
|
+
@marker_symbol = options[:marker_symbol] || :default
|
39
41
|
@smooth = false
|
40
42
|
@labels, @data = nil, nil
|
41
43
|
super(chart, options)
|
42
|
-
@labels = AxDataSource.new(:
|
44
|
+
@labels = AxDataSource.new(data: options[:labels]) unless options[:labels].nil?
|
43
45
|
@data = NumDataSource.new(options) unless options[:data].nil?
|
44
46
|
end
|
45
47
|
|
@@ -50,34 +52,34 @@ module Axlsx
|
|
50
52
|
|
51
53
|
# @see show_marker
|
52
54
|
def show_marker=(v)
|
53
|
-
Axlsx
|
55
|
+
Axlsx.validate_boolean(v)
|
54
56
|
@show_marker = v
|
55
57
|
end
|
56
58
|
|
57
59
|
# @see marker_symbol
|
58
60
|
def marker_symbol=(v)
|
59
|
-
Axlsx
|
61
|
+
Axlsx.validate_marker_symbol(v)
|
60
62
|
@marker_symbol = v
|
61
63
|
end
|
62
64
|
|
63
65
|
# @see smooth
|
64
66
|
def smooth=(v)
|
65
|
-
Axlsx
|
67
|
+
Axlsx.validate_boolean(v)
|
66
68
|
@smooth = v
|
67
69
|
end
|
68
70
|
|
69
71
|
# Serializes the object
|
70
72
|
# @param [String] str
|
71
73
|
# @return [String]
|
72
|
-
def to_xml_string(str = '')
|
74
|
+
def to_xml_string(str = +'')
|
73
75
|
super(str) do
|
74
76
|
if color
|
75
77
|
str << '<c:spPr><a:solidFill>'
|
76
|
-
str <<
|
78
|
+
str << '<a:srgbClr val="' << color << '"/>'
|
77
79
|
str << '</a:solidFill>'
|
78
80
|
str << '<a:ln w="28800">'
|
79
81
|
str << '<a:solidFill>'
|
80
|
-
str <<
|
82
|
+
str << '<a:srgbClr val="' << color << '"/>'
|
81
83
|
str << '</a:solidFill>'
|
82
84
|
str << '</a:ln>'
|
83
85
|
str << '<a:round/>'
|
@@ -87,12 +89,12 @@ module Axlsx
|
|
87
89
|
if !@show_marker
|
88
90
|
str << '<c:marker><c:symbol val="none"/></c:marker>'
|
89
91
|
elsif @marker_symbol != :default
|
90
|
-
str << '<c:marker><c:symbol val="'
|
92
|
+
str << '<c:marker><c:symbol val="' << @marker_symbol.to_s << '"/></c:marker>'
|
91
93
|
end
|
92
94
|
|
93
95
|
@labels.to_xml_string(str) unless @labels.nil?
|
94
96
|
@data.to_xml_string(str) unless @data.nil?
|
95
|
-
str <<
|
97
|
+
str << '<c:smooth val="' << (smooth ? '1' : '0') << '"/>'
|
96
98
|
end
|
97
99
|
end
|
98
100
|
|
data/lib/axlsx/drawing/marker.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# The Marker class defines a point in the worksheet that drawing anchors attach to.
|
3
5
|
# @note The recommended way to manage markers is Worksheet#add_chart Markers are created for a two cell anchor based on the :start and :end options.
|
@@ -32,13 +34,13 @@ module Axlsx
|
|
32
34
|
attr_reader :rowOff
|
33
35
|
|
34
36
|
# @see col
|
35
|
-
def col=(v) Axlsx
|
37
|
+
def col=(v) Axlsx.validate_unsigned_int v; @col = v end
|
36
38
|
# @see colOff
|
37
|
-
def colOff=(v) Axlsx
|
39
|
+
def colOff=(v) Axlsx.validate_int v; @colOff = v end
|
38
40
|
# @see row
|
39
|
-
def row=(v) Axlsx
|
41
|
+
def row=(v) Axlsx.validate_unsigned_int v; @row = v end
|
40
42
|
# @see rowOff
|
41
|
-
def rowOff=(v) Axlsx
|
43
|
+
def rowOff=(v) Axlsx.validate_int v; @rowOff = v end
|
42
44
|
|
43
45
|
# shortcut to set the column, row position for this marker
|
44
46
|
# @param col the column for the marker, a Cell object or a string reference like "B7"
|
@@ -54,9 +56,9 @@ module Axlsx
|
|
54
56
|
# Serializes the object
|
55
57
|
# @param [String] str
|
56
58
|
# @return [String]
|
57
|
-
def to_xml_string(str = '')
|
59
|
+
def to_xml_string(str = +'')
|
58
60
|
[:col, :colOff, :row, :rowOff].each do |k|
|
59
|
-
str <<
|
61
|
+
str << '<xdr:' << k.to_s << '>' << send(k).to_s << '</xdr:' << k.to_s << '>'
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
@@ -66,7 +68,7 @@ module Axlsx
|
|
66
68
|
# @see Chart#start_at
|
67
69
|
def parse_coord_args(x, y = 0)
|
68
70
|
if x.is_a?(String)
|
69
|
-
x, y = *Axlsx
|
71
|
+
x, y = *Axlsx.name_to_indices(x)
|
70
72
|
end
|
71
73
|
if x.is_a?(Cell)
|
72
74
|
x, y = *x.pos
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# This class specifies data for a particular data point. It is used for both numCache and numLit object
|
3
5
|
class NumData
|
@@ -23,25 +25,25 @@ module Axlsx
|
|
23
25
|
@tag_name = values.first.is_a?(Cell) ? :numCache : :numLit
|
24
26
|
values.each do |value|
|
25
27
|
value = value.is_formula? ? 0 : value.value if value.is_a?(Cell)
|
26
|
-
@pt << NumVal.new(:
|
28
|
+
@pt << NumVal.new(v: value)
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
# @see format_code
|
31
33
|
def format_code=(v = 'General')
|
32
|
-
Axlsx
|
34
|
+
Axlsx.validate_string(v)
|
33
35
|
@format_code = v
|
34
36
|
end
|
35
37
|
|
36
38
|
# serialize the object
|
37
|
-
def to_xml_string(str =
|
38
|
-
str <<
|
39
|
-
str <<
|
40
|
-
str <<
|
39
|
+
def to_xml_string(str = +'')
|
40
|
+
str << '<c:' << @tag_name.to_s << '>'
|
41
|
+
str << '<c:formatCode>' << format_code.to_s << '</c:formatCode>'
|
42
|
+
str << '<c:ptCount val="' << @pt.size.to_s << '"/>'
|
41
43
|
@pt.each_with_index do |num_val, index|
|
42
44
|
num_val.to_xml_string index, str
|
43
45
|
end
|
44
|
-
str <<
|
46
|
+
str << '</c:' << @tag_name.to_s << '>'
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# A numeric data source for use by charts.
|
3
5
|
class NumDataSource
|
@@ -15,7 +17,7 @@ module Axlsx
|
|
15
17
|
@f = nil
|
16
18
|
@data = @data_type.new(options)
|
17
19
|
if options[:data] && options[:data].first.is_a?(Cell)
|
18
|
-
@f = Axlsx
|
20
|
+
@f = Axlsx.cell_range(options[:data])
|
19
21
|
end
|
20
22
|
parse_options options
|
21
23
|
end
|
@@ -42,17 +44,17 @@ module Axlsx
|
|
42
44
|
|
43
45
|
# serialize the object
|
44
46
|
# @param [String] str
|
45
|
-
def to_xml_string(str =
|
46
|
-
str <<
|
47
|
+
def to_xml_string(str = +'')
|
48
|
+
str << '<c:' << tag_name.to_s << '>'
|
47
49
|
if @f
|
48
|
-
str <<
|
49
|
-
str <<
|
50
|
+
str << '<c:' << @ref_tag_name.to_s << '>'
|
51
|
+
str << '<c:f>' << @f.to_s << '</c:f>'
|
50
52
|
end
|
51
53
|
@data.to_xml_string str
|
52
54
|
if @f
|
53
|
-
str <<
|
55
|
+
str << '</c:' << @ref_tag_name.to_s << '>'
|
54
56
|
end
|
55
|
-
str <<
|
57
|
+
str << '</c:' << tag_name.to_s << '>'
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# This class specifies data for a particular data point.
|
3
5
|
class NumVal < StrVal
|
@@ -16,15 +18,15 @@ module Axlsx
|
|
16
18
|
|
17
19
|
# @see format_code
|
18
20
|
def format_code=(v)
|
19
|
-
Axlsx
|
21
|
+
Axlsx.validate_string(v)
|
20
22
|
@format_code = v
|
21
23
|
end
|
22
24
|
|
23
25
|
# serialize the object
|
24
|
-
def to_xml_string(idx, str =
|
25
|
-
Axlsx
|
26
|
-
|
27
|
-
str <<
|
26
|
+
def to_xml_string(idx, str = +'')
|
27
|
+
Axlsx.validate_unsigned_int(idx)
|
28
|
+
unless v.to_s.empty?
|
29
|
+
str << '<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s << '</c:v></c:pt>'
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# This class details a single cell anchor for drawings.
|
3
5
|
# @note The recommended way to manage drawings, images and charts is Worksheet#add_chart or Worksheet#add_image.
|
@@ -58,10 +60,10 @@ module Axlsx
|
|
58
60
|
|
59
61
|
#
|
60
62
|
# @see height
|
61
|
-
def height=(v) Axlsx
|
63
|
+
def height=(v) Axlsx.validate_unsigned_int(v); @height = v; end
|
62
64
|
|
63
65
|
# @see width
|
64
|
-
def width=(v) Axlsx
|
66
|
+
def width=(v) Axlsx.validate_unsigned_int(v); @width = v; end
|
65
67
|
|
66
68
|
# The index of this anchor in the drawing
|
67
69
|
# @return [Integer]
|
@@ -72,12 +74,12 @@ module Axlsx
|
|
72
74
|
# Serializes the object
|
73
75
|
# @param [String] str
|
74
76
|
# @return [String]
|
75
|
-
def to_xml_string(str = '')
|
77
|
+
def to_xml_string(str = +'')
|
76
78
|
str << '<xdr:oneCellAnchor>'
|
77
79
|
str << '<xdr:from>'
|
78
80
|
from.to_xml_string(str)
|
79
81
|
str << '</xdr:from>'
|
80
|
-
str <<
|
82
|
+
str << '<xdr:ext cx="' << ext[:cx].to_s << '" cy="' << ext[:cy].to_s << '"/>'
|
81
83
|
@object.to_xml_string(str)
|
82
84
|
str << '<xdr:clientData/>'
|
83
85
|
str << '</xdr:oneCellAnchor>'
|
@@ -91,7 +93,7 @@ module Axlsx
|
|
91
93
|
def ext
|
92
94
|
cy = @height * 914400 / 96
|
93
95
|
cx = @width * 914400 / 96
|
94
|
-
{ :
|
96
|
+
{ cy: cy, cx: cx }
|
95
97
|
end
|
96
98
|
end
|
97
99
|
end
|
data/lib/axlsx/drawing/pic.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# a Pic object represents an image in your worksheet
|
3
5
|
# Worksheet#add_image is the recommended way to manage images in your sheets
|
@@ -28,7 +30,7 @@ module Axlsx
|
|
28
30
|
end
|
29
31
|
|
30
32
|
# allowed mime types
|
31
|
-
ALLOWED_MIME_TYPES = %w(image/jpeg image/png image/gif)
|
33
|
+
ALLOWED_MIME_TYPES = %w(image/jpeg image/png image/gif).freeze
|
32
34
|
|
33
35
|
# The name to use for this picture
|
34
36
|
# @return [String]
|
@@ -76,7 +78,7 @@ module Axlsx
|
|
76
78
|
end
|
77
79
|
|
78
80
|
def image_src=(v)
|
79
|
-
Axlsx
|
81
|
+
Axlsx.validate_string(v)
|
80
82
|
if remote?
|
81
83
|
RegexValidator.validate('Pic.image_src', /\A#{URI::DEFAULT_PARSER.make_regexp}\z/, v)
|
82
84
|
RestrictionValidator.validate 'Pic.image_src', ALLOWED_MIME_TYPES, MimeTypeUtils.get_mime_type_from_uri(v)
|
@@ -89,13 +91,13 @@ module Axlsx
|
|
89
91
|
end
|
90
92
|
|
91
93
|
# @see name
|
92
|
-
def name=(v) Axlsx
|
94
|
+
def name=(v) Axlsx.validate_string(v); @name = v; end
|
93
95
|
|
94
96
|
# @see descr
|
95
|
-
def descr=(v) Axlsx
|
97
|
+
def descr=(v) Axlsx.validate_string(v); @descr = v; end
|
96
98
|
|
97
99
|
# @see remote
|
98
|
-
def remote=(v) Axlsx
|
100
|
+
def remote=(v) Axlsx.validate_boolean(v); @remote = v; end
|
99
101
|
|
100
102
|
def remote?
|
101
103
|
remote == 1 || remote.to_s == 'true'
|
@@ -122,14 +124,14 @@ module Axlsx
|
|
122
124
|
# The part name for this image used in serialization and relationship building
|
123
125
|
# @return [String]
|
124
126
|
def pn
|
125
|
-
|
127
|
+
format(IMAGE_PN, index + 1, extname)
|
126
128
|
end
|
127
129
|
|
128
130
|
# The relationship object for this pic.
|
129
131
|
# @return [Relationship]
|
130
132
|
def relationship
|
131
133
|
if remote?
|
132
|
-
Relationship.new(self, IMAGE_R,
|
134
|
+
Relationship.new(self, IMAGE_R, image_src.to_s, target_mode: :External)
|
133
135
|
else
|
134
136
|
Relationship.new(self, IMAGE_R, "../#{pn}")
|
135
137
|
end
|
@@ -187,10 +189,10 @@ module Axlsx
|
|
187
189
|
# Serializes the object
|
188
190
|
# @param [String] str
|
189
191
|
# @return [String]
|
190
|
-
def to_xml_string(str = '')
|
192
|
+
def to_xml_string(str = +'')
|
191
193
|
str << '<xdr:pic>'
|
192
194
|
str << '<xdr:nvPicPr>'
|
193
|
-
str <<
|
195
|
+
str << '<xdr:cNvPr id="2" name="' << name.to_s << '" descr="' << descr.to_s << '">'
|
194
196
|
hyperlink.to_xml_string(str) if hyperlink.is_a?(Hyperlink)
|
195
197
|
str << '</xdr:cNvPr><xdr:cNvPicPr>'
|
196
198
|
picture_locking.to_xml_string(str)
|
@@ -211,9 +213,9 @@ module Axlsx
|
|
211
213
|
# Return correct xml relationship string portion
|
212
214
|
def relationship_xml_portion
|
213
215
|
if remote?
|
214
|
-
('<a:blip xmlns:r ="' << XML_NS_R << '" r:link="' << relationship.Id << '">')
|
216
|
+
(+'<a:blip xmlns:r ="' << XML_NS_R << '" r:link="' << relationship.Id << '">')
|
215
217
|
else
|
216
|
-
('<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">')
|
218
|
+
(+'<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">')
|
217
219
|
end
|
218
220
|
end
|
219
221
|
|
@@ -221,7 +223,7 @@ module Axlsx
|
|
221
223
|
def use_one_cell_anchor
|
222
224
|
return if @anchor.is_a?(OneCellAnchor)
|
223
225
|
|
224
|
-
new_anchor = OneCellAnchor.new(@anchor.drawing, :
|
226
|
+
new_anchor = OneCellAnchor.new(@anchor.drawing, start_at: [@anchor.from.col, @anchor.from.row])
|
225
227
|
swap_anchor(new_anchor)
|
226
228
|
end
|
227
229
|
|
@@ -229,7 +231,7 @@ module Axlsx
|
|
229
231
|
def use_two_cell_anchor
|
230
232
|
return if @anchor.is_a?(TwoCellAnchor)
|
231
233
|
|
232
|
-
new_anchor = TwoCellAnchor.new(@anchor.drawing, :
|
234
|
+
new_anchor = TwoCellAnchor.new(@anchor.drawing, start_at: [@anchor.from.col, @anchor.from.row])
|
233
235
|
swap_anchor(new_anchor)
|
234
236
|
end
|
235
237
|
|
@@ -237,7 +239,7 @@ module Axlsx
|
|
237
239
|
def swap_anchor(new_anchor)
|
238
240
|
new_anchor.drawing.anchors.delete(new_anchor)
|
239
241
|
@anchor.drawing.anchors[@anchor.drawing.anchors.index(@anchor)] = new_anchor
|
240
|
-
new_anchor.instance_variable_set
|
242
|
+
new_anchor.instance_variable_set :@object, @anchor.object
|
241
243
|
@anchor = new_anchor
|
242
244
|
end
|
243
245
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# The picture locking class defines the locking properties for pictures in your workbook.
|
3
5
|
class PictureLocking
|
@@ -32,7 +34,7 @@ module Axlsx
|
|
32
34
|
# Serializes the object
|
33
35
|
# @param [String] str
|
34
36
|
# @return [String]
|
35
|
-
def to_xml_string(str = '')
|
37
|
+
def to_xml_string(str = +'')
|
36
38
|
serialized_tag('a:picLocks', str)
|
37
39
|
end
|
38
40
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# The Pie3DChart is a three dimentional piechart (who would have guessed?) that you can add to your worksheet.
|
3
5
|
# @see Worksheet#add_chart
|
@@ -22,17 +24,17 @@ module Axlsx
|
|
22
24
|
@vary_colors = true
|
23
25
|
super(frame, options)
|
24
26
|
@series_type = PieSeries
|
25
|
-
@view_3D = View3D.new({ :
|
27
|
+
@view_3D = View3D.new({ rot_x: 30, perspective: 30 }.merge(options))
|
26
28
|
@d_lbls = nil
|
27
29
|
end
|
28
30
|
|
29
31
|
# Serializes the object
|
30
32
|
# @param [String] str
|
31
33
|
# @return [String]
|
32
|
-
def to_xml_string(str = '')
|
34
|
+
def to_xml_string(str = +'')
|
33
35
|
super(str) do
|
34
36
|
str << '<c:pie3DChart>'
|
35
|
-
str <<
|
37
|
+
str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
|
36
38
|
@series.each { |ser| ser.to_xml_string(str) }
|
37
39
|
d_lbls.to_xml_string(str) if @d_lbls
|
38
40
|
str << '</c:pie3DChart>'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# A PieSeries defines the data and labels and explosion for pie charts series.
|
3
5
|
# @note The recommended way to manage series is to use Chart#add_series
|
@@ -29,7 +31,7 @@ module Axlsx
|
|
29
31
|
@explosion = nil
|
30
32
|
@colors = []
|
31
33
|
super(chart, options)
|
32
|
-
self.labels = AxDataSource.new(:
|
34
|
+
self.labels = AxDataSource.new(data: options[:labels]) unless options[:labels].nil?
|
33
35
|
self.data = NumDataSource.new(options) unless options[:data].nil?
|
34
36
|
end
|
35
37
|
|
@@ -37,19 +39,19 @@ module Axlsx
|
|
37
39
|
def colors=(v) DataTypeValidator.validate "BarSeries.colors", [Array], v; @colors = v end
|
38
40
|
|
39
41
|
# @see explosion
|
40
|
-
def explosion=(v) Axlsx
|
42
|
+
def explosion=(v) Axlsx.validate_unsigned_int(v); @explosion = v; end
|
41
43
|
|
42
44
|
# Serializes the object
|
43
45
|
# @param [String] str
|
44
46
|
# @return [String]
|
45
|
-
def to_xml_string(str = '')
|
47
|
+
def to_xml_string(str = +'')
|
46
48
|
super(str) do
|
47
|
-
str << '<c:explosion val="'
|
49
|
+
str << '<c:explosion val="' << @explosion.to_s << '"/>' unless @explosion.nil?
|
48
50
|
colors.each_with_index do |c, index|
|
49
51
|
str << '<c:dPt>'
|
50
|
-
str <<
|
52
|
+
str << '<c:idx val="' << index.to_s << '"/>'
|
51
53
|
str << '<c:spPr><a:solidFill>'
|
52
|
-
str <<
|
54
|
+
str << '<a:srgbClr val="' << c << '"/>'
|
53
55
|
str << '</a:solidFill></c:spPr></c:dPt>'
|
54
56
|
end
|
55
57
|
@labels.to_xml_string str unless @labels.nil?
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# The Scaling class defines axis scaling
|
3
5
|
class Scaling
|
@@ -33,7 +35,7 @@ module Axlsx
|
|
33
35
|
attr_reader :min
|
34
36
|
|
35
37
|
# @see logBase
|
36
|
-
def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer], v,
|
38
|
+
def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer], v, ->(arg) { arg >= 2 && arg <= 1000 }; @logBase = v; end
|
37
39
|
# @see orientation
|
38
40
|
def orientation=(v) RestrictionValidator.validate "Scaling.orientation", [:minMax, :maxMin], v; @orientation = v; end
|
39
41
|
# @see max
|
@@ -45,12 +47,12 @@ module Axlsx
|
|
45
47
|
# Serializes the object
|
46
48
|
# @param [String] str
|
47
49
|
# @return [String]
|
48
|
-
def to_xml_string(str = '')
|
50
|
+
def to_xml_string(str = +'')
|
49
51
|
str << '<c:scaling>'
|
50
|
-
str <<
|
51
|
-
str <<
|
52
|
-
str <<
|
53
|
-
str <<
|
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?
|
54
56
|
str << '</c:scaling>'
|
55
57
|
end
|
56
58
|
end
|