caxlsx 2.0.2 → 3.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 +5 -0
- data/README.md +41 -33
- data/Rakefile +9 -11
- data/examples/auto_filter.rb +10 -1
- data/examples/conditional_formatting/example_conditional_formatting.rb +18 -3
- data/examples/data_validation.rb +57 -40
- data/examples/example.rb +115 -7
- data/examples/merge_cells.rb +17 -0
- data/examples/no_grid_with_borders.rb +18 -0
- data/examples/pivot_test.rb +63 -0
- data/examples/split.rb +16 -0
- data/lib/axlsx.rb +34 -15
- data/lib/axlsx/content_type/abstract_content_type.rb +1 -1
- data/lib/axlsx/content_type/content_type.rb +1 -1
- data/lib/axlsx/doc_props/app.rb +1 -1
- data/lib/axlsx/doc_props/core.rb +5 -5
- data/lib/axlsx/drawing/area_chart.rb +99 -0
- data/lib/axlsx/drawing/area_series.rb +110 -0
- data/lib/axlsx/drawing/axes.rb +1 -1
- data/lib/axlsx/drawing/axis.rb +12 -9
- data/lib/axlsx/drawing/bar_3D_chart.rb +13 -13
- data/lib/axlsx/drawing/bar_chart.rb +143 -0
- data/lib/axlsx/drawing/bar_series.rb +9 -9
- data/lib/axlsx/drawing/bubble_chart.rb +59 -0
- data/lib/axlsx/drawing/bubble_series.rb +63 -0
- data/lib/axlsx/drawing/cat_axis.rb +5 -5
- data/lib/axlsx/drawing/chart.rb +52 -8
- data/lib/axlsx/drawing/d_lbls.rb +3 -3
- data/lib/axlsx/drawing/drawing.rb +6 -1
- data/lib/axlsx/drawing/graphic_frame.rb +3 -3
- data/lib/axlsx/drawing/hyperlink.rb +1 -3
- data/lib/axlsx/drawing/line_3D_chart.rb +2 -2
- data/lib/axlsx/drawing/line_chart.rb +10 -10
- data/lib/axlsx/drawing/line_series.rb +32 -3
- data/lib/axlsx/drawing/marker.rb +1 -1
- data/lib/axlsx/drawing/num_data.rb +4 -4
- data/lib/axlsx/drawing/num_data_source.rb +6 -6
- data/lib/axlsx/drawing/num_val.rb +3 -1
- data/lib/axlsx/drawing/one_cell_anchor.rb +3 -2
- data/lib/axlsx/drawing/pic.rb +25 -19
- data/lib/axlsx/drawing/picture_locking.rb +1 -3
- data/lib/axlsx/drawing/pie_3D_chart.rb +5 -6
- data/lib/axlsx/drawing/pie_series.rb +6 -6
- data/lib/axlsx/drawing/scaling.rb +6 -6
- data/lib/axlsx/drawing/scatter_chart.rb +10 -10
- data/lib/axlsx/drawing/scatter_series.rb +40 -7
- data/lib/axlsx/drawing/ser_axis.rb +2 -2
- data/lib/axlsx/drawing/series.rb +3 -3
- data/lib/axlsx/drawing/series_title.rb +2 -2
- data/lib/axlsx/drawing/str_data.rb +3 -3
- data/lib/axlsx/drawing/str_val.rb +3 -1
- data/lib/axlsx/drawing/title.rb +22 -4
- data/lib/axlsx/drawing/two_cell_anchor.rb +6 -1
- data/lib/axlsx/drawing/val_axis.rb +1 -1
- data/lib/axlsx/drawing/view_3D.rb +2 -2
- data/lib/axlsx/drawing/vml_drawing.rb +1 -1
- data/lib/axlsx/package.rb +33 -31
- data/lib/axlsx/rels/relationship.rb +1 -1
- data/lib/axlsx/rels/relationships.rb +7 -4
- data/lib/axlsx/stylesheet/border_pr.rb +2 -2
- data/lib/axlsx/stylesheet/cell_alignment.rb +1 -3
- data/lib/axlsx/stylesheet/cell_protection.rb +1 -3
- data/lib/axlsx/stylesheet/cell_style.rb +1 -3
- data/lib/axlsx/stylesheet/color.rb +1 -3
- data/lib/axlsx/stylesheet/font.rb +1 -1
- data/lib/axlsx/stylesheet/gradient_stop.rb +1 -1
- data/lib/axlsx/stylesheet/num_fmt.rb +10 -3
- data/lib/axlsx/stylesheet/pattern_fill.rb +1 -1
- data/lib/axlsx/stylesheet/styles.rb +7 -7
- data/lib/axlsx/stylesheet/table_style_element.rb +1 -3
- data/lib/axlsx/util/accessors.rb +6 -6
- data/lib/axlsx/util/constants.rb +107 -99
- data/lib/axlsx/util/mime_type_utils.rb +11 -0
- data/lib/axlsx/util/options_parser.rb +2 -1
- data/lib/axlsx/util/parser.rb +4 -4
- data/lib/axlsx/util/serialized_attributes.rb +16 -6
- data/lib/axlsx/util/simple_typed_list.rb +28 -52
- data/lib/axlsx/util/storage.rb +4 -4
- data/lib/axlsx/util/validators.rb +29 -17
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/defined_name.rb +11 -12
- data/lib/axlsx/workbook/defined_names.rb +2 -2
- data/lib/axlsx/workbook/shared_strings_table.rb +5 -5
- data/lib/axlsx/workbook/workbook.rb +36 -11
- data/lib/axlsx/workbook/workbook_view.rb +80 -0
- data/lib/axlsx/workbook/workbook_views.rb +22 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +2 -2
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +1 -3
- data/lib/axlsx/workbook/worksheet/break.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cell.rb +136 -74
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +63 -43
- data/lib/axlsx/workbook/worksheet/cfvo.rb +1 -3
- data/lib/axlsx/workbook/worksheet/cfvos.rb +4 -1
- data/lib/axlsx/workbook/worksheet/col.rb +7 -10
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/cols.rb +5 -2
- data/lib/axlsx/workbook/worksheet/comment.rb +5 -6
- data/lib/axlsx/workbook/worksheet/comments.rb +9 -12
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +1 -1
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
- data/lib/axlsx/workbook/worksheet/data_bar.rb +4 -6
- data/lib/axlsx/workbook/worksheet/data_validation.rb +6 -4
- data/lib/axlsx/workbook/worksheet/dimension.rb +2 -2
- data/lib/axlsx/workbook/worksheet/header_footer.rb +6 -8
- data/lib/axlsx/workbook/worksheet/icon_set.rb +3 -5
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +4 -2
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +33 -0
- data/lib/axlsx/workbook/worksheet/page_margins.rb +1 -3
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -1
- data/lib/axlsx/workbook/worksheet/page_setup.rb +21 -23
- data/lib/axlsx/workbook/worksheet/pane.rb +1 -3
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +44 -28
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +4 -4
- data/lib/axlsx/workbook/worksheet/print_options.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_range.rb +1 -3
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +5 -2
- data/lib/axlsx/workbook/worksheet/rich_text.rb +55 -0
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +250 -0
- data/lib/axlsx/workbook/worksheet/row.rb +40 -51
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +2 -2
- data/lib/axlsx/workbook/worksheet/selection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +21 -3
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -3
- data/lib/axlsx/workbook/worksheet/table.rb +6 -6
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +1 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +4 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +64 -78
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +10 -10
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +3 -3
- data/test/drawing/tc_area_chart.rb +39 -0
- data/test/drawing/tc_area_series.rb +71 -0
- data/test/drawing/tc_axis.rb +27 -0
- data/test/drawing/tc_bar_chart.rb +71 -0
- data/test/drawing/tc_bubble_chart.rb +44 -0
- data/test/drawing/tc_bubble_series.rb +21 -0
- data/test/drawing/tc_chart.rb +23 -10
- data/test/drawing/tc_data_source.rb +6 -0
- data/test/drawing/tc_drawing.rb +2 -2
- data/test/drawing/tc_line_chart.rb +5 -5
- data/test/drawing/tc_line_series.rb +47 -6
- data/test/drawing/tc_pic.rb +11 -15
- data/test/drawing/tc_scatter_series.rb +36 -1
- data/test/drawing/tc_str_val.rb +9 -0
- data/test/drawing/tc_title.rb +5 -0
- data/test/stylesheet/tc_styles.rb +2 -2
- data/test/tc_axlsx.rb +31 -0
- data/test/tc_helper.rb +2 -0
- data/test/tc_package.rb +19 -1
- data/test/util/tc_mime_type_utils.rb +13 -0
- data/test/util/tc_simple_typed_list.rb +2 -3
- data/test/util/tc_validators.rb +34 -10
- data/test/workbook/tc_defined_name.rb +12 -4
- data/test/workbook/tc_shared_strings_table.rb +16 -1
- data/test/workbook/tc_workbook.rb +38 -3
- data/test/workbook/tc_workbook_view.rb +50 -0
- data/test/workbook/worksheet/auto_filter/tc_filters.rb +1 -1
- data/test/workbook/worksheet/tc_break.rb +1 -1
- data/test/workbook/worksheet/tc_cell.rb +76 -8
- data/test/workbook/worksheet/tc_col.rb +2 -2
- data/test/workbook/worksheet/tc_conditional_formatting.rb +2 -2
- data/test/workbook/worksheet/tc_data_bar.rb +1 -1
- data/test/workbook/worksheet/tc_data_validation.rb +11 -11
- data/test/workbook/worksheet/tc_header_footer.rb +2 -2
- data/test/workbook/worksheet/tc_icon_set.rb +1 -1
- data/test/workbook/worksheet/tc_outline_pr.rb +19 -0
- data/test/workbook/worksheet/tc_page_setup.rb +3 -3
- data/test/workbook/worksheet/tc_pivot_table.rb +21 -6
- data/test/workbook/worksheet/tc_print_options.rb +1 -1
- data/test/workbook/worksheet/tc_rich_text.rb +44 -0
- data/test/workbook/worksheet/tc_rich_text_run.rb +172 -0
- data/test/workbook/worksheet/tc_row.rb +7 -2
- data/test/workbook/worksheet/tc_sheet_calc_pr.rb +1 -1
- data/test/workbook/worksheet/tc_sheet_format_pr.rb +4 -4
- data/test/workbook/worksheet/tc_sheet_pr.rb +26 -4
- data/test/workbook/worksheet/tc_sheet_protection.rb +5 -5
- data/test/workbook/worksheet/tc_sheet_view.rb +4 -4
- data/test/workbook/worksheet/tc_table.rb +2 -3
- data/test/workbook/worksheet/tc_worksheet.rb +99 -45
- metadata +89 -16
data/lib/axlsx/drawing/d_lbls.rb
CHANGED
@@ -49,7 +49,7 @@ module Axlsx
|
|
49
49
|
# @see d_lbl_pos= for a list of allowed values
|
50
50
|
# @return [Symbol]
|
51
51
|
def d_lbl_pos
|
52
|
-
return unless @chart_type
|
52
|
+
return unless [Pie3DChart, LineChart].include? @chart_type
|
53
53
|
@d_lbl_pos ||= :bestFit
|
54
54
|
end
|
55
55
|
|
@@ -60,7 +60,7 @@ module Axlsx
|
|
60
60
|
# The default is :bestFit
|
61
61
|
# @param [Symbol] label_position the postion you want to use.
|
62
62
|
def d_lbl_pos=(label_position)
|
63
|
-
return unless @chart_type
|
63
|
+
return unless [Pie3DChart, LineChart].include? @chart_type
|
64
64
|
Axlsx::RestrictionValidator.validate 'DLbls#d_lbl_pos', [:bestFit, :b, :ctr, :inBase, :inEnd, :l, :outEnd, :r, :t], label_position
|
65
65
|
@d_lbl_pos = label_position
|
66
66
|
end
|
@@ -80,7 +80,7 @@ module Axlsx
|
|
80
80
|
|
81
81
|
# nills out d_lbl_pos and show_leader_lines as these attributes, while valid in the spec actually chrash excel for any chart type other than pie charts.
|
82
82
|
def validate_attributes_for_chart_type
|
83
|
-
return if @chart_type
|
83
|
+
return if [Pie3DChart, LineChart].include? @chart_type
|
84
84
|
@d_lbl_pos = nil
|
85
85
|
@show_leader_lines = nil
|
86
86
|
end
|
@@ -8,6 +8,8 @@ module Axlsx
|
|
8
8
|
require 'axlsx/drawing/bar_series.rb'
|
9
9
|
require 'axlsx/drawing/line_series.rb'
|
10
10
|
require 'axlsx/drawing/scatter_series.rb'
|
11
|
+
require 'axlsx/drawing/bubble_series.rb'
|
12
|
+
require 'axlsx/drawing/area_series.rb'
|
11
13
|
|
12
14
|
require 'axlsx/drawing/scaling.rb'
|
13
15
|
require 'axlsx/drawing/axis.rb'
|
@@ -34,9 +36,12 @@ module Axlsx
|
|
34
36
|
require 'axlsx/drawing/chart.rb'
|
35
37
|
require 'axlsx/drawing/pie_3D_chart.rb'
|
36
38
|
require 'axlsx/drawing/bar_3D_chart.rb'
|
39
|
+
require 'axlsx/drawing/bar_chart.rb'
|
37
40
|
require 'axlsx/drawing/line_chart.rb'
|
38
41
|
require 'axlsx/drawing/line_3D_chart.rb'
|
39
42
|
require 'axlsx/drawing/scatter_chart.rb'
|
43
|
+
require 'axlsx/drawing/bubble_chart.rb'
|
44
|
+
require 'axlsx/drawing/area_chart.rb'
|
40
45
|
|
41
46
|
require 'axlsx/drawing/picture_locking.rb'
|
42
47
|
require 'axlsx/drawing/pic.rb'
|
@@ -153,7 +158,7 @@ module Axlsx
|
|
153
158
|
# @return [String]
|
154
159
|
def to_xml_string(str = '')
|
155
160
|
str << '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
|
156
|
-
str << '<xdr:wsDr xmlns:xdr="' << XML_NS_XDR << '" xmlns:a="' << XML_NS_A << '">'
|
161
|
+
str << ('<xdr:wsDr xmlns:xdr="' << XML_NS_XDR << '" xmlns:a="' << XML_NS_A << '">')
|
157
162
|
anchors.each { |anchor| anchor.to_xml_string(str) }
|
158
163
|
str << '</xdr:wsDr>'
|
159
164
|
end
|
@@ -35,7 +35,7 @@ module Axlsx
|
|
35
35
|
# macro attribute should be optional!
|
36
36
|
str << '<xdr:graphicFrame>'
|
37
37
|
str << '<xdr:nvGraphicFramePr>'
|
38
|
-
str << '<xdr:cNvPr id="' << @anchor.drawing.index.to_s << '" name="' << 'item_' << @anchor.drawing.index.to_s << '"/>'
|
38
|
+
str << ('<xdr:cNvPr id="' << @anchor.drawing.index.to_s << '" name="' << 'item_' << @anchor.drawing.index.to_s << '"/>')
|
39
39
|
str << '<xdr:cNvGraphicFramePr/>'
|
40
40
|
str << '</xdr:nvGraphicFramePr>'
|
41
41
|
str << '<xdr:xfrm>'
|
@@ -43,8 +43,8 @@ module Axlsx
|
|
43
43
|
str << '<a:ext cx="0" cy="0"/>'
|
44
44
|
str << '</xdr:xfrm>'
|
45
45
|
str << '<a:graphic>'
|
46
|
-
str << '<a:graphicData uri="' << XML_NS_C << '">'
|
47
|
-
str << '<c:chart xmlns:c="' << XML_NS_C << '" xmlns:r="' << XML_NS_R << '" r:id="' << rId << '"/>'
|
46
|
+
str << ('<a:graphicData uri="' << XML_NS_C << '">')
|
47
|
+
str << ('<c:chart xmlns:c="' << XML_NS_C << '" xmlns:r="' << XML_NS_R << '" r:id="' << rId << '"/>')
|
48
48
|
str << '</a:graphicData>'
|
49
49
|
str << '</a:graphic>'
|
50
50
|
str << '</xdr:graphicFrame>'
|
@@ -93,9 +93,7 @@ module Axlsx
|
|
93
93
|
# @param [String] str
|
94
94
|
# @return [String]
|
95
95
|
def to_xml_string(str = '')
|
96
|
-
|
97
|
-
serialized_attributes str, {:'r:id' => relationship.Id, :'xmlns:r' => XML_NS_R }
|
98
|
-
str << '/>'
|
96
|
+
serialized_tag 'a:hlinkClick', str, {:'r:id' => relationship.Id, :'xmlns:r' => XML_NS_R }
|
99
97
|
end
|
100
98
|
|
101
99
|
end
|
@@ -60,8 +60,8 @@ module Axlsx
|
|
60
60
|
# @param [String] str
|
61
61
|
# @return [String]
|
62
62
|
def to_xml_string(str = '')
|
63
|
-
super(str) do
|
64
|
-
|
63
|
+
super(str) do
|
64
|
+
str << ('<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil?
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -76,16 +76,16 @@ module Axlsx
|
|
76
76
|
# @param [String] str
|
77
77
|
# @return [String]
|
78
78
|
def to_xml_string(str = '')
|
79
|
-
super(str) do
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
@series.each { |ser| ser.to_xml_string(
|
84
|
-
@d_lbls.to_xml_string(
|
85
|
-
yield
|
86
|
-
axes.to_xml_string(
|
87
|
-
|
88
|
-
axes.to_xml_string(
|
79
|
+
super(str) do
|
80
|
+
str << ("<c:" << node_name << ">")
|
81
|
+
str << ('<c:grouping val="' << grouping.to_s << '"/>')
|
82
|
+
str << ('<c:varyColors val="' << vary_colors.to_s << '"/>')
|
83
|
+
@series.each { |ser| ser.to_xml_string(str) }
|
84
|
+
@d_lbls.to_xml_string(str) if @d_lbls
|
85
|
+
yield if block_given?
|
86
|
+
axes.to_xml_string(str, :ids => true)
|
87
|
+
str << ("</c:" << node_name << ">")
|
88
|
+
axes.to_xml_string(str)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -23,12 +23,22 @@ module Axlsx
|
|
23
23
|
# @return [Boolean]
|
24
24
|
attr_reader :show_marker
|
25
25
|
|
26
|
+
# custom marker symbol
|
27
|
+
# @return [String]
|
28
|
+
attr_reader :marker_symbol
|
29
|
+
|
30
|
+
# line smoothing on values
|
31
|
+
# @return [Boolean]
|
32
|
+
attr_reader :smooth
|
33
|
+
|
26
34
|
# Creates a new series
|
27
35
|
# @option options [Array, SimpleTypedList] data
|
28
36
|
# @option options [Array, SimpleTypedList] labels
|
29
37
|
# @param [Chart] chart
|
30
38
|
def initialize(chart, options={})
|
31
39
|
@show_marker = false
|
40
|
+
@marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default
|
41
|
+
@smooth = false
|
32
42
|
@labels, @data = nil, nil
|
33
43
|
super(chart, options)
|
34
44
|
@labels = AxDataSource.new(:data => options[:labels]) unless options[:labels].nil?
|
@@ -46,6 +56,18 @@ module Axlsx
|
|
46
56
|
@show_marker = v
|
47
57
|
end
|
48
58
|
|
59
|
+
# @see marker_symbol
|
60
|
+
def marker_symbol=(v)
|
61
|
+
Axlsx::validate_marker_symbol(v)
|
62
|
+
@marker_symbol = v
|
63
|
+
end
|
64
|
+
|
65
|
+
# @see smooth
|
66
|
+
def smooth=(v)
|
67
|
+
Axlsx::validate_boolean(v)
|
68
|
+
@smooth = v
|
69
|
+
end
|
70
|
+
|
49
71
|
# Serializes the object
|
50
72
|
# @param [String] str
|
51
73
|
# @return [String]
|
@@ -53,19 +75,26 @@ module Axlsx
|
|
53
75
|
super(str) do
|
54
76
|
if color
|
55
77
|
str << '<c:spPr><a:solidFill>'
|
56
|
-
str << '<a:srgbClr val="' << color << '"/>'
|
78
|
+
str << ('<a:srgbClr val="' << color << '"/>')
|
57
79
|
str << '</a:solidFill>'
|
58
80
|
str << '<a:ln w="28800">'
|
59
81
|
str << '<a:solidFill>'
|
60
|
-
str << '<a:srgbClr val="' << color << '"/>'
|
82
|
+
str << ('<a:srgbClr val="' << color << '"/>')
|
61
83
|
str << '</a:solidFill>'
|
62
84
|
str << '</a:ln>'
|
63
85
|
str << '<a:round/>'
|
64
86
|
str << '</c:spPr>'
|
65
87
|
end
|
66
|
-
|
88
|
+
|
89
|
+
if !@show_marker
|
90
|
+
str << '<c:marker><c:symbol val="none"/></c:marker>'
|
91
|
+
elsif @marker_symbol != :default
|
92
|
+
str << '<c:marker><c:symbol val="' + @marker_symbol.to_s + '"/></c:marker>'
|
93
|
+
end
|
94
|
+
|
67
95
|
@labels.to_xml_string(str) unless @labels.nil?
|
68
96
|
@data.to_xml_string(str) unless @data.nil?
|
97
|
+
str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>')
|
69
98
|
end
|
70
99
|
end
|
71
100
|
|
data/lib/axlsx/drawing/marker.rb
CHANGED
@@ -58,7 +58,7 @@ module Axlsx
|
|
58
58
|
# @return [String]
|
59
59
|
def to_xml_string(str = '')
|
60
60
|
[:col, :colOff, :row, :rowOff].each do |k|
|
61
|
-
str << '<xdr:' << k.to_s << '>' << self.send(k).to_s << '</xdr:' << k.to_s << '>'
|
61
|
+
str << ('<xdr:' << k.to_s << '>' << self.send(k).to_s << '</xdr:' << k.to_s << '>')
|
62
62
|
end
|
63
63
|
end
|
64
64
|
private
|
@@ -38,13 +38,13 @@ module Axlsx
|
|
38
38
|
|
39
39
|
# serialize the object
|
40
40
|
def to_xml_string(str = "")
|
41
|
-
str << '<c:' << @tag_name.to_s << '>'
|
42
|
-
str << '<c:formatCode>' << format_code.to_s << '</c:formatCode>'
|
43
|
-
str << '<c:ptCount val="' << @pt.size.to_s << '"/>'
|
41
|
+
str << ('<c:' << @tag_name.to_s << '>')
|
42
|
+
str << ('<c:formatCode>' << format_code.to_s << '</c:formatCode>')
|
43
|
+
str << ('<c:ptCount val="' << @pt.size.to_s << '"/>')
|
44
44
|
@pt.each_with_index do |num_val, index|
|
45
45
|
num_val.to_xml_string index, str
|
46
46
|
end
|
47
|
-
str << '</c:' << @tag_name.to_s << '>'
|
47
|
+
str << ('</c:' << @tag_name.to_s << '>')
|
48
48
|
end
|
49
49
|
|
50
50
|
end
|
@@ -33,7 +33,7 @@ module Axlsx
|
|
33
33
|
# allowed element tag names
|
34
34
|
# @return [Array]
|
35
35
|
def self.allowed_tag_names
|
36
|
-
[:yVal, :val]
|
36
|
+
[:yVal, :val, :bubbleSize]
|
37
37
|
end
|
38
38
|
|
39
39
|
# sets the tag name for this data source
|
@@ -46,16 +46,16 @@ module Axlsx
|
|
46
46
|
# serialize the object
|
47
47
|
# @param [String] str
|
48
48
|
def to_xml_string(str="")
|
49
|
-
str << '<c:' << tag_name.to_s << '>'
|
49
|
+
str << ('<c:' << tag_name.to_s << '>')
|
50
50
|
if @f
|
51
|
-
str << '<c:' << @ref_tag_name.to_s << '>'
|
52
|
-
str << '<c:f>' << @f.to_s << '</c:f>'
|
51
|
+
str << ('<c:' << @ref_tag_name.to_s << '>')
|
52
|
+
str << ('<c:f>' << @f.to_s << '</c:f>')
|
53
53
|
end
|
54
54
|
@data.to_xml_string str
|
55
55
|
if @f
|
56
|
-
str << '</c:' << @ref_tag_name.to_s << '>'
|
56
|
+
str << ('</c:' << @ref_tag_name.to_s << '>')
|
57
57
|
end
|
58
|
-
str << '</c:' << tag_name.to_s << '>'
|
58
|
+
str << ('</c:' << tag_name.to_s << '>')
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -26,7 +26,9 @@ module Axlsx
|
|
26
26
|
# serialize the object
|
27
27
|
def to_xml_string(idx, str = "")
|
28
28
|
Axlsx::validate_unsigned_int(idx)
|
29
|
-
|
29
|
+
if !v.to_s.empty?
|
30
|
+
str << ('<c:pt idx="' << idx.to_s << '" formatCode="' << format_code << '"><c:v>' << v.to_s << '</c:v></c:pt>')
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -7,7 +7,7 @@ module Axlsx
|
|
7
7
|
class OneCellAnchor
|
8
8
|
|
9
9
|
include Axlsx::OptionsParser
|
10
|
-
|
10
|
+
|
11
11
|
# Creates a new OneCellAnchor object and an Pic associated with it.
|
12
12
|
# @param [Drawing] drawing
|
13
13
|
# @option options [Array] start_at the col, row to start at
|
@@ -23,6 +23,7 @@ module Axlsx
|
|
23
23
|
drawing.anchors << self
|
24
24
|
@from = Marker.new
|
25
25
|
parse_options options
|
26
|
+
start_at(*options[:start_at]) if options[:start_at]
|
26
27
|
@object = Pic.new(self, options)
|
27
28
|
end
|
28
29
|
|
@@ -77,7 +78,7 @@ module Axlsx
|
|
77
78
|
str << '<xdr:from>'
|
78
79
|
from.to_xml_string(str)
|
79
80
|
str << '</xdr:from>'
|
80
|
-
str << '<xdr:ext cx="' << ext[:cx].to_s << '" cy="' << ext[:cy].to_s << '"/>'
|
81
|
+
str << ('<xdr:ext cx="' << ext[:cx].to_s << '" cy="' << ext[:cy].to_s << '"/>')
|
81
82
|
@object.to_xml_string(str)
|
82
83
|
str << '<xdr:clientData/>'
|
83
84
|
str << '</xdr:oneCellAnchor>'
|
data/lib/axlsx/drawing/pic.rb
CHANGED
@@ -9,12 +9,13 @@ module Axlsx
|
|
9
9
|
|
10
10
|
# Creates a new Pic(ture) object
|
11
11
|
# @param [Anchor] anchor the anchor that holds this image
|
12
|
-
# @option options [String] name
|
13
|
-
# @option options [String] descr
|
14
|
-
# @option options [String] image_src
|
15
|
-
# @option options [Array] start_at
|
16
|
-
# @option options [
|
17
|
-
# @option options [
|
12
|
+
# @option options [String] :name
|
13
|
+
# @option options [String] :descr
|
14
|
+
# @option options [String] :image_src
|
15
|
+
# @option options [Array] :start_at
|
16
|
+
# @option options [Integer] :width
|
17
|
+
# @option options [Integer] :height
|
18
|
+
# @option options [Float] :opacity - set the picture opacity, accepts a value between 0.0 and 1.0
|
18
19
|
def initialize(anchor, options={})
|
19
20
|
@anchor = anchor
|
20
21
|
@hyperlink = nil
|
@@ -23,10 +24,11 @@ module Axlsx
|
|
23
24
|
start_at(*options[:start_at]) if options[:start_at]
|
24
25
|
yield self if block_given?
|
25
26
|
@picture_locking = PictureLocking.new(options)
|
27
|
+
@opacity = (options[:opacity] * 100000).round if options[:opacity]
|
26
28
|
end
|
27
29
|
|
28
|
-
# allowed
|
29
|
-
|
30
|
+
# allowed mime types
|
31
|
+
ALLOWED_MIME_TYPES = %w(image/jpeg image/png image/gif)
|
30
32
|
|
31
33
|
# The name to use for this picture
|
32
34
|
# @return [String]
|
@@ -50,24 +52,28 @@ module Axlsx
|
|
50
52
|
|
51
53
|
attr_reader :hyperlink
|
52
54
|
|
55
|
+
# Picture opacity
|
56
|
+
# @return [Integer]
|
57
|
+
attr_reader :opacity
|
58
|
+
|
53
59
|
# sets or updates a hyperlink for this image.
|
54
60
|
# @param [String] v The href value for the hyper link
|
55
61
|
# @option options @see Hyperlink#initialize All options available to the Hyperlink class apply - however href will be overridden with the v parameter value.
|
56
62
|
def hyperlink=(v, options={})
|
57
63
|
options[:href] = v
|
58
|
-
if
|
64
|
+
if hyperlink.is_a?(Hyperlink)
|
59
65
|
options.each do |o|
|
60
|
-
|
66
|
+
hyperlink.send("#{o[0]}=", o[1]) if hyperlink.respond_to? "#{o[0]}="
|
61
67
|
end
|
62
68
|
else
|
63
69
|
@hyperlink = Hyperlink.new(self, options)
|
64
70
|
end
|
65
|
-
|
71
|
+
hyperlink
|
66
72
|
end
|
67
73
|
|
68
74
|
def image_src=(v)
|
69
75
|
Axlsx::validate_string(v)
|
70
|
-
RestrictionValidator.validate 'Pic.image_src',
|
76
|
+
RestrictionValidator.validate 'Pic.image_src', ALLOWED_MIME_TYPES, MimeTypeUtils.get_mime_type(v)
|
71
77
|
raise ArgumentError, "File does not exist" unless File.exist?(v)
|
72
78
|
@image_src = v
|
73
79
|
end
|
@@ -78,7 +84,6 @@ module Axlsx
|
|
78
84
|
# @see descr
|
79
85
|
def descr=(v) Axlsx::validate_string(v); @descr = v; end
|
80
86
|
|
81
|
-
|
82
87
|
# The file name of image_src without any path information
|
83
88
|
# @return [String]
|
84
89
|
def file_name
|
@@ -110,7 +115,6 @@ module Axlsx
|
|
110
115
|
end
|
111
116
|
|
112
117
|
# providing access to the anchor's width attribute
|
113
|
-
# @param [Integer] v
|
114
118
|
# @see OneCellAnchor.width
|
115
119
|
def width
|
116
120
|
return unless @anchor.is_a?(OneCellAnchor)
|
@@ -124,7 +128,6 @@ module Axlsx
|
|
124
128
|
end
|
125
129
|
|
126
130
|
# providing access to update the anchor's height attribute
|
127
|
-
# @param [Integer] v
|
128
131
|
# @see OneCellAnchor.width
|
129
132
|
# @note this is a noop if you are using a TwoCellAnchor
|
130
133
|
def height
|
@@ -165,17 +168,20 @@ module Axlsx
|
|
165
168
|
def to_xml_string(str = '')
|
166
169
|
str << '<xdr:pic>'
|
167
170
|
str << '<xdr:nvPicPr>'
|
168
|
-
str << '<xdr:cNvPr id="2" name="' << name.to_s << '" descr="' << descr.to_s << '">'
|
169
|
-
|
171
|
+
str << ('<xdr:cNvPr id="2" name="' << name.to_s << '" descr="' << descr.to_s << '">')
|
172
|
+
hyperlink.to_xml_string(str) if hyperlink.is_a?(Hyperlink)
|
170
173
|
str << '</xdr:cNvPr><xdr:cNvPicPr>'
|
171
174
|
picture_locking.to_xml_string(str)
|
172
175
|
str << '</xdr:cNvPicPr></xdr:nvPicPr>'
|
173
176
|
str << '<xdr:blipFill>'
|
174
|
-
str << '<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id <<
|
177
|
+
str << ('<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">')
|
178
|
+
if opacity
|
179
|
+
str << "<a:alphaModFix amt=\"#{opacity}\"/>"
|
180
|
+
end
|
181
|
+
str << '</a:blip>'
|
175
182
|
str << '<a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr>'
|
176
183
|
str << '<a:xfrm><a:off x="0" y="0"/><a:ext cx="2336800" cy="2161540"/></a:xfrm>'
|
177
184
|
str << '<a:prstGeom prst="rect"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic>'
|
178
|
-
|
179
185
|
end
|
180
186
|
|
181
187
|
private
|
@@ -34,13 +34,12 @@ module Axlsx
|
|
34
34
|
# @param [String] str
|
35
35
|
# @return [String]
|
36
36
|
def to_xml_string(str = '')
|
37
|
-
super(str) do
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@series.each { |ser| ser.to_xml_string(str_inner) }
|
37
|
+
super(str) do
|
38
|
+
str << '<c:pie3DChart>'
|
39
|
+
str << ('<c:varyColors val="' << vary_colors.to_s << '"/>')
|
40
|
+
@series.each { |ser| ser.to_xml_string(str) }
|
42
41
|
d_lbls.to_xml_string(str) if @d_lbls
|
43
|
-
|
42
|
+
str << '</c:pie3DChart>'
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
@@ -46,17 +46,17 @@ module Axlsx
|
|
46
46
|
# @param [String] str
|
47
47
|
# @return [String]
|
48
48
|
def to_xml_string(str = '')
|
49
|
-
super(str) do
|
50
|
-
|
49
|
+
super(str) do
|
50
|
+
str << '<c:explosion val="' + @explosion + '"/>' unless @explosion.nil?
|
51
51
|
colors.each_with_index do |c, index|
|
52
52
|
str << '<c:dPt>'
|
53
|
-
str << '<c:idx val="' << index.to_s << '"/>'
|
53
|
+
str << ('<c:idx val="' << index.to_s << '"/>')
|
54
54
|
str << '<c:spPr><a:solidFill>'
|
55
|
-
str << '<a:srgbClr val="' << c << '"/>'
|
55
|
+
str << ('<a:srgbClr val="' << c << '"/>')
|
56
56
|
str << '</a:solidFill></c:spPr></c:dPt>'
|
57
57
|
end
|
58
|
-
@labels.to_xml_string
|
59
|
-
@data.to_xml_string
|
58
|
+
@labels.to_xml_string str unless @labels.nil?
|
59
|
+
@data.to_xml_string str unless @data.nil?
|
60
60
|
end
|
61
61
|
str
|
62
62
|
end
|