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
|
# The ScatterChart allows you to insert a scatter chart into your worksheet
|
3
5
|
# @see Worksheet#add_chart
|
@@ -47,14 +49,14 @@ module Axlsx
|
|
47
49
|
# Serializes the object
|
48
50
|
# @param [String] str
|
49
51
|
# @return [String]
|
50
|
-
def to_xml_string(str = '')
|
52
|
+
def to_xml_string(str = +'')
|
51
53
|
super(str) do
|
52
54
|
str << '<c:scatterChart>'
|
53
|
-
str <<
|
54
|
-
str <<
|
55
|
+
str << '<c:scatterStyle val="' << scatter_style.to_s << '"/>'
|
56
|
+
str << '<c:varyColors val="' << vary_colors.to_s << '"/>'
|
55
57
|
@series.each { |ser| ser.to_xml_string(str) }
|
56
58
|
d_lbls.to_xml_string(str) if @d_lbls
|
57
|
-
axes.to_xml_string(str, :
|
59
|
+
axes.to_xml_string(str, ids: true)
|
58
60
|
str << '</c:scatterChart>'
|
59
61
|
axes.to_xml_string(str)
|
60
62
|
end
|
@@ -65,7 +67,7 @@ module Axlsx
|
|
65
67
|
# a y_val_axis
|
66
68
|
# @return [Axes]
|
67
69
|
def axes
|
68
|
-
@axes ||= Axes.new(:
|
70
|
+
@axes ||= Axes.new(x_val_axis: ValAxis, y_val_axis: ValAxis)
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# A ScatterSeries defines the x and y position of data in the chart
|
3
5
|
# @note The recommended way to manage series is to use Chart#add_series
|
@@ -41,7 +43,7 @@ module Axlsx
|
|
41
43
|
@smooth = [:smooth, :smoothMarker].include?(chart.scatter_style)
|
42
44
|
else
|
43
45
|
# Set smoothing according to the option provided
|
44
|
-
Axlsx
|
46
|
+
Axlsx.validate_boolean(options[:smooth])
|
45
47
|
@smooth = options[:smooth]
|
46
48
|
end
|
47
49
|
@ln_width = options[:ln_width] unless options[:ln_width].nil?
|
@@ -49,8 +51,8 @@ module Axlsx
|
|
49
51
|
@marker_symbol = :default
|
50
52
|
|
51
53
|
super(chart, options)
|
52
|
-
@xData = AxDataSource.new(:
|
53
|
-
@yData = NumDataSource.new({ :
|
54
|
+
@xData = AxDataSource.new(tag_name: :xVal, data: options[:xData]) unless options[:xData].nil?
|
55
|
+
@yData = NumDataSource.new({ tag_name: :yVal, data: options[:yData] }) unless options[:yData].nil?
|
54
56
|
end
|
55
57
|
|
56
58
|
# @see color
|
@@ -60,7 +62,7 @@ module Axlsx
|
|
60
62
|
|
61
63
|
# @see smooth
|
62
64
|
def smooth=(v)
|
63
|
-
Axlsx
|
65
|
+
Axlsx.validate_boolean(v)
|
64
66
|
@smooth = v
|
65
67
|
end
|
66
68
|
|
@@ -71,29 +73,29 @@ module Axlsx
|
|
71
73
|
|
72
74
|
# @see marker_symbol
|
73
75
|
def marker_symbol=(v)
|
74
|
-
Axlsx
|
76
|
+
Axlsx.validate_marker_symbol(v)
|
75
77
|
@marker_symbol = v
|
76
78
|
end
|
77
79
|
|
78
80
|
# Serializes the object
|
79
81
|
# @param [String] str
|
80
82
|
# @return [String]
|
81
|
-
def to_xml_string(str = '')
|
83
|
+
def to_xml_string(str = +'')
|
82
84
|
super(str) do
|
83
85
|
# needs to override the super color here to push in ln/and something else!
|
84
86
|
if color
|
85
87
|
str << '<c:spPr><a:solidFill>'
|
86
|
-
str <<
|
88
|
+
str << '<a:srgbClr val="' << color << '"/>'
|
87
89
|
str << '</a:solidFill>'
|
88
90
|
str << '<a:ln><a:solidFill>'
|
89
|
-
str <<
|
91
|
+
str << '<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>'
|
90
92
|
str << '</c:spPr>'
|
91
93
|
str << '<c:marker>'
|
92
94
|
str << '<c:spPr><a:solidFill>'
|
93
|
-
str <<
|
95
|
+
str << '<a:srgbClr val="' << color << '"/>'
|
94
96
|
str << '</a:solidFill>'
|
95
97
|
str << '<a:ln><a:solidFill>'
|
96
|
-
str <<
|
98
|
+
str << '<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>'
|
97
99
|
str << '</c:spPr>'
|
98
100
|
str << marker_symbol_xml
|
99
101
|
str << '</c:marker>'
|
@@ -108,7 +110,7 @@ module Axlsx
|
|
108
110
|
end
|
109
111
|
@xData.to_xml_string(str) unless @xData.nil?
|
110
112
|
@yData.to_xml_string(str) unless @yData.nil?
|
111
|
-
str <<
|
113
|
+
str << '<c:smooth val="' << (smooth ? '1' : '0') << '"/>'
|
112
114
|
end
|
113
115
|
str
|
114
116
|
end
|
@@ -119,7 +121,7 @@ module Axlsx
|
|
119
121
|
if !@show_marker
|
120
122
|
'<c:symbol val="none"/>'
|
121
123
|
elsif @marker_symbol != :default
|
122
|
-
'<c:symbol val="'
|
124
|
+
+'<c:symbol val="' << @marker_symbol.to_s << '"/>'
|
123
125
|
end.to_s
|
124
126
|
end
|
125
127
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# A SerAxis object defines a series axis
|
3
5
|
class SerAxis < Axis
|
@@ -20,21 +22,21 @@ module Axlsx
|
|
20
22
|
end
|
21
23
|
|
22
24
|
# @see tickLblSkip
|
23
|
-
def tick_lbl_skip=(v) Axlsx
|
25
|
+
def tick_lbl_skip=(v) Axlsx.validate_unsigned_int(v); @tick_lbl_skip = v; end
|
24
26
|
alias :tickLblSkip= :tick_lbl_skip=
|
25
27
|
|
26
28
|
# @see tickMarkSkip
|
27
|
-
def tick_mark_skip=(v) Axlsx
|
29
|
+
def tick_mark_skip=(v) Axlsx.validate_unsigned_int(v); @tick_mark_skip = v; end
|
28
30
|
alias :tickMarkSkip= :tick_mark_skip=
|
29
31
|
|
30
32
|
# Serializes the object
|
31
33
|
# @param [String] str
|
32
34
|
# @return [String]
|
33
|
-
def to_xml_string(str = '')
|
35
|
+
def to_xml_string(str = +'')
|
34
36
|
str << '<c:serAx>'
|
35
37
|
super(str)
|
36
|
-
str <<
|
37
|
-
str <<
|
38
|
+
str << '<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>' unless @tick_lbl_skip.nil?
|
39
|
+
str << '<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>' unless @tick_mark_skip.nil?
|
38
40
|
str << '</c:serAx>'
|
39
41
|
end
|
40
42
|
end
|
data/lib/axlsx/drawing/series.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# A Series defines the common series attributes and is the super class for all concrete series types.
|
3
5
|
# @note The recommended way to manage series is to use Chart#add_series
|
@@ -38,7 +40,7 @@ module Axlsx
|
|
38
40
|
end
|
39
41
|
|
40
42
|
# @see order
|
41
|
-
def order=(v) Axlsx
|
43
|
+
def order=(v) Axlsx.validate_unsigned_int(v); @order = v; end
|
42
44
|
|
43
45
|
# @see title
|
44
46
|
def title=(v)
|
@@ -55,10 +57,10 @@ module Axlsx
|
|
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
|
str << '<c:ser>'
|
60
|
-
str <<
|
61
|
-
str <<
|
62
|
+
str << '<c:idx val="' << index.to_s << '"/>'
|
63
|
+
str << '<c:order val="' << (order || index).to_s << '"/>'
|
62
64
|
title.to_xml_string(str) unless title.nil?
|
63
65
|
yield if block_given?
|
64
66
|
str << '</c:ser>'
|
@@ -1,19 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# A series title is a Title with a slightly different serialization than chart titles.
|
3
5
|
class SeriesTitle < Title
|
4
6
|
# Serializes the object
|
5
7
|
# @param [String] str
|
6
8
|
# @return [String]
|
7
|
-
def to_xml_string(str = '')
|
8
|
-
clean_value = Axlsx
|
9
|
+
def to_xml_string(str = +'')
|
10
|
+
clean_value = Axlsx.trust_input ? @text.to_s : ::CGI.escapeHTML(Axlsx.sanitize(@text.to_s))
|
9
11
|
|
10
12
|
str << '<c:tx>'
|
11
13
|
str << '<c:strRef>'
|
12
|
-
str <<
|
14
|
+
str << '<c:f>' << Axlsx.cell_range([@cell]) << '</c:f>'
|
13
15
|
str << '<c:strCache>'
|
14
16
|
str << '<c:ptCount val="1"/>'
|
15
17
|
str << '<c:pt idx="0">'
|
16
|
-
str <<
|
18
|
+
str << '<c:v>' << clean_value << '</c:v>'
|
17
19
|
str << '</c:pt>'
|
18
20
|
str << '</c:strCache>'
|
19
21
|
str << '</c:strRef>'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# This specifies the last string data used for a chart. (e.g. strLit and strCache)
|
3
5
|
# This class is extended for NumData to include the formatCode attribute required for numLit and numCache
|
@@ -20,18 +22,18 @@ module Axlsx
|
|
20
22
|
@tag_name = values.first.is_a?(Cell) ? :strCache : :strLit
|
21
23
|
values.each do |value|
|
22
24
|
v = value.is_a?(Cell) ? value.value : value
|
23
|
-
@pt << @type.new(:
|
25
|
+
@pt << @type.new(v: v)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
29
|
# serialize the object
|
28
|
-
def to_xml_string(str =
|
29
|
-
str <<
|
30
|
-
str <<
|
30
|
+
def to_xml_string(str = +'')
|
31
|
+
str << '<c:' << @tag_name.to_s << '>'
|
32
|
+
str << '<c:ptCount val="' << @pt.size.to_s << '"/>'
|
31
33
|
@pt.each_with_index do |value, index|
|
32
34
|
value.to_xml_string index, str
|
33
35
|
end
|
34
|
-
str <<
|
36
|
+
str << '</c:' << @tag_name.to_s << '>'
|
35
37
|
end
|
36
38
|
end
|
37
39
|
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 StrVal
|
@@ -21,10 +23,10 @@ module Axlsx
|
|
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 << '"><c:v>' << ::CGI.escapeHTML(v.to_s) << '</c:v></c:pt>'
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
data/lib/axlsx/drawing/title.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# A Title stores information about the title of a chart
|
3
5
|
class Title
|
@@ -18,11 +20,11 @@ module Axlsx
|
|
18
20
|
def initialize(title = "", title_size = "")
|
19
21
|
self.cell = title if title.is_a?(Cell)
|
20
22
|
self.text = title.to_s unless title.is_a?(Cell)
|
21
|
-
if title_size.to_s.empty?
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
self.text_size = if title_size.to_s.empty?
|
24
|
+
"1600"
|
25
|
+
else
|
26
|
+
title_size.to_s
|
27
|
+
end
|
26
28
|
end
|
27
29
|
|
28
30
|
# @see text
|
@@ -30,7 +32,6 @@ module Axlsx
|
|
30
32
|
DataTypeValidator.validate 'Title.text', String, v
|
31
33
|
@text = v
|
32
34
|
@cell = nil
|
33
|
-
v
|
34
35
|
end
|
35
36
|
|
36
37
|
# @see text_size
|
@@ -38,7 +39,6 @@ module Axlsx
|
|
38
39
|
DataTypeValidator.validate 'Title.text_size', String, v
|
39
40
|
@text_size = v
|
40
41
|
@cell = nil
|
41
|
-
v
|
42
42
|
end
|
43
43
|
|
44
44
|
# @see cell
|
@@ -46,7 +46,6 @@ module Axlsx
|
|
46
46
|
DataTypeValidator.validate 'Title.text', Cell, v
|
47
47
|
@cell = v
|
48
48
|
@text = v.value.to_s
|
49
|
-
v
|
50
49
|
end
|
51
50
|
|
52
51
|
# Check if the title is empty.
|
@@ -67,18 +66,18 @@ module Axlsx
|
|
67
66
|
# Serializes the object
|
68
67
|
# @param [String] str
|
69
68
|
# @return [String]
|
70
|
-
def to_xml_string(str = '')
|
69
|
+
def to_xml_string(str = +'')
|
71
70
|
str << '<c:title>'
|
72
71
|
unless empty?
|
73
|
-
clean_value = Axlsx
|
72
|
+
clean_value = Axlsx.trust_input ? @text.to_s : ::CGI.escapeHTML(Axlsx.sanitize(@text.to_s))
|
74
73
|
str << '<c:tx>'
|
75
74
|
if @cell.is_a?(Cell)
|
76
75
|
str << '<c:strRef>'
|
77
|
-
str <<
|
76
|
+
str << '<c:f>' << Axlsx.cell_range([@cell]) << '</c:f>'
|
78
77
|
str << '<c:strCache>'
|
79
78
|
str << '<c:ptCount val="1"/>'
|
80
79
|
str << '<c:pt idx="0">'
|
81
|
-
str <<
|
80
|
+
str << '<c:v>' << clean_value << '</c:v>'
|
82
81
|
str << '</c:pt>'
|
83
82
|
str << '</c:strCache>'
|
84
83
|
str << '</c:strRef>'
|
@@ -88,8 +87,8 @@ module Axlsx
|
|
88
87
|
str << '<a:lstStyle/>'
|
89
88
|
str << '<a:p>'
|
90
89
|
str << '<a:r>'
|
91
|
-
str <<
|
92
|
-
str <<
|
90
|
+
str << '<a:rPr sz="' << @text_size.to_s << '"/>'
|
91
|
+
str << '<a:t>' << clean_value << '</a:t>'
|
93
92
|
str << '</a:r>'
|
94
93
|
str << '</a:p>'
|
95
94
|
str << '</c:rich>'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# This class details the anchor points for drawings.
|
3
5
|
# @note The recommended way to manage drawings and charts is Worksheet#add_chart. Anchors are specified by the :start_at and :end_at options to that method.
|
@@ -33,7 +35,7 @@ module Axlsx
|
|
33
35
|
def initialize(drawing, options = {})
|
34
36
|
@drawing = drawing
|
35
37
|
drawing.anchors << self
|
36
|
-
@from, @to = Marker.new, Marker.new(:
|
38
|
+
@from, @to = Marker.new, Marker.new(col: 5, row: 10)
|
37
39
|
parse_options options
|
38
40
|
|
39
41
|
# bit of a hack to work around the fact that the coords for start at and end at
|
@@ -79,7 +81,7 @@ module Axlsx
|
|
79
81
|
# Serializes the object
|
80
82
|
# @param [String] str
|
81
83
|
# @return [String]
|
82
|
-
def to_xml_string(str = '')
|
84
|
+
def to_xml_string(str = +'')
|
83
85
|
str << '<xdr:twoCellAnchor>'
|
84
86
|
str << '<xdr:from>'
|
85
87
|
from.to_xml_string str
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# the ValAxis class defines a chart value axis.
|
3
5
|
class ValAxis < Axis
|
@@ -24,10 +26,10 @@ module Axlsx
|
|
24
26
|
# Serializes the object
|
25
27
|
# @param [String] str
|
26
28
|
# @return [String]
|
27
|
-
def to_xml_string(str = '')
|
29
|
+
def to_xml_string(str = +'')
|
28
30
|
str << '<c:valAx>'
|
29
31
|
super(str)
|
30
|
-
str <<
|
32
|
+
str << '<c:crossBetween val="' << @cross_between.to_s << '"/>'
|
31
33
|
str << '</c:valAx>'
|
32
34
|
end
|
33
35
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# 3D attributes for a chart.
|
3
5
|
class View3D
|
@@ -16,10 +18,10 @@ module Axlsx
|
|
16
18
|
end
|
17
19
|
|
18
20
|
# Validation for hPercent
|
19
|
-
H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)
|
21
|
+
H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)/.freeze
|
20
22
|
|
21
23
|
# validation for depthPercent
|
22
|
-
DEPTH_PERCENT_REGEX = /0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)
|
24
|
+
DEPTH_PERCENT_REGEX = /0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)/.freeze
|
23
25
|
|
24
26
|
# x rotation for the chart
|
25
27
|
# must be between -90 and 90
|
@@ -80,7 +82,7 @@ module Axlsx
|
|
80
82
|
alias :depthPercent= :depth_percent=
|
81
83
|
|
82
84
|
# @see r_ang_ax
|
83
|
-
def r_ang_ax=(v) Axlsx
|
85
|
+
def r_ang_ax=(v) Axlsx.validate_boolean(v); @r_ang_ax = v; end
|
84
86
|
alias :rAngAx= :r_ang_ax=
|
85
87
|
|
86
88
|
# @see perspective
|
@@ -94,7 +96,7 @@ module Axlsx
|
|
94
96
|
# Serializes the object
|
95
97
|
# @param [String] str
|
96
98
|
# @return [String]
|
97
|
-
def to_xml_string(str = '')
|
99
|
+
def to_xml_string(str = +'')
|
98
100
|
str << '<c:view3D>'
|
99
101
|
%w(rot_x h_percent rot_y depth_percent r_ang_ax perspective).each do |key|
|
100
102
|
str << element_for_attribute(key, 'c')
|
@@ -104,12 +106,12 @@ module Axlsx
|
|
104
106
|
|
105
107
|
private
|
106
108
|
|
107
|
-
#
|
109
|
+
# NOTE: move this to Axlsx module if we find the same pattern elsewhere.
|
108
110
|
def element_for_attribute(name, namespace = '')
|
109
111
|
val = Axlsx.instance_values_for(self)[name]
|
110
|
-
return "" if val
|
112
|
+
return "" if val.nil?
|
111
113
|
|
112
|
-
"<%s:%s val='%s'/>"
|
114
|
+
format("<%s:%s val='%s'/>", namespace, Axlsx.camel(name, false), val)
|
113
115
|
end
|
114
116
|
end
|
115
117
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
|
-
# a vml drawing used for comments in
|
4
|
+
# a vml drawing used for comments in Excel.
|
3
5
|
class VmlDrawing
|
4
6
|
# creates a new Vml Drawing object.
|
5
7
|
# @param [Comments] comments the comments object this drawing is associated with
|
@@ -12,26 +14,26 @@ module Axlsx
|
|
12
14
|
# The part name for this vml drawing
|
13
15
|
# @return [String]
|
14
16
|
def pn
|
15
|
-
|
17
|
+
format(VML_DRAWING_PN, @comments.worksheet.index + 1)
|
16
18
|
end
|
17
19
|
|
18
20
|
# serialize the vml_drawing to xml.
|
19
21
|
# @param [String] str
|
20
22
|
# @return [String]
|
21
|
-
def to_xml_string(str = '')
|
22
|
-
str <<
|
23
|
-
<xml xmlns:v="urn:schemas-microsoft-com:vml"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
23
|
+
def to_xml_string(str = +'')
|
24
|
+
str << <<~XML
|
25
|
+
<xml xmlns:v="urn:schemas-microsoft-com:vml"
|
26
|
+
xmlns:o="urn:schemas-microsoft-com:office:office"
|
27
|
+
xmlns:x="urn:schemas-microsoft-com:office:excel">
|
28
|
+
<o:shapelayout v:ext="edit">
|
29
|
+
<o:idmap v:ext="edit" data="#{@comments.worksheet.index + 1}"/>
|
30
|
+
</o:shapelayout>
|
31
|
+
<v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202"
|
32
|
+
path="m0,0l0,21600,21600,21600,21600,0xe">
|
33
|
+
<v:stroke joinstyle="miter"/>
|
34
|
+
<v:path gradientshapeok="t" o:connecttype="rect"/>
|
35
|
+
</v:shapetype>
|
36
|
+
XML
|
35
37
|
@comments.each { |comment| comment.vml_shape.to_xml_string str }
|
36
38
|
str << "</xml>"
|
37
39
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Axlsx
|
2
4
|
# A VmlShape is used to position and render a comment.
|
3
5
|
class VmlShape
|
@@ -22,7 +24,7 @@ module Axlsx
|
|
22
24
|
@right_offset = 50
|
23
25
|
@bottom_offset = 5
|
24
26
|
@visible = true
|
25
|
-
@id = (
|
27
|
+
@id = Array.new(8) { rand(65..89).chr }.join
|
26
28
|
parse_options options
|
27
29
|
yield self if block_given?
|
28
30
|
end
|
@@ -35,29 +37,29 @@ module Axlsx
|
|
35
37
|
# serialize the shape to a string
|
36
38
|
# @param [String] str
|
37
39
|
# @return [String]
|
38
|
-
def to_xml_string(str = '')
|
39
|
-
str <<
|
40
|
+
def to_xml_string(str = +'')
|
41
|
+
str << <<~XML
|
40
42
|
|
41
|
-
<v:shape id="#{@id}" type="#_x0000_t202" fillcolor="#ffffa1 [80]" o:insetmode="auto"
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
<v:shape id="#{@id}" type="#_x0000_t202" fillcolor="#ffffa1 [80]" o:insetmode="auto"
|
44
|
+
style="visibility:#{@visible ? 'visible' : 'hidden'}">
|
45
|
+
<v:fill color2="#ffffa1 [80]"/>
|
46
|
+
<v:shadow on="t" obscured="t"/>
|
47
|
+
<v:path o:connecttype="none"/>
|
48
|
+
<v:textbox style='mso-fit-text-with-word-wrap:t'>
|
49
|
+
<div style='text-align:left'></div>
|
50
|
+
</v:textbox>
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
52
|
+
<x:ClientData ObjectType="Note">
|
53
|
+
<x:MoveWithCells/>
|
54
|
+
<x:SizeWithCells/>
|
55
|
+
<x:Anchor>#{left_column}, #{left_offset}, #{top_row}, #{top_offset}, #{right_column}, #{right_offset}, #{bottom_row}, #{bottom_offset}</x:Anchor>
|
56
|
+
<x:AutoFill>False</x:AutoFill>
|
57
|
+
<x:Row>#{row}</x:Row>
|
58
|
+
<x:Column>#{column}</x:Column>
|
59
|
+
#{@visible ? '<x:Visible/>' : ''}
|
60
|
+
</x:ClientData>
|
61
|
+
</v:shape>
|
62
|
+
XML
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|