caxlsx 3.3.0 → 3.4.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 +9 -0
- data/README.md +24 -5
- data/Rakefile +0 -1
- data/lib/axlsx/content_type/abstract_content_type.rb +2 -5
- data/lib/axlsx/content_type/content_type.rb +0 -4
- data/lib/axlsx/content_type/default.rb +1 -5
- data/lib/axlsx/content_type/override.rb +0 -4
- data/lib/axlsx/doc_props/app.rb +1 -6
- data/lib/axlsx/doc_props/core.rb +1 -6
- data/lib/axlsx/drawing/area_chart.rb +3 -6
- data/lib/axlsx/drawing/area_series.rb +1 -4
- data/lib/axlsx/drawing/ax_data_source.rb +1 -6
- data/lib/axlsx/drawing/axes.rb +5 -6
- data/lib/axlsx/drawing/axis.rb +7 -12
- data/lib/axlsx/drawing/bar_3D_chart.rb +7 -10
- data/lib/axlsx/drawing/bar_chart.rb +6 -9
- data/lib/axlsx/drawing/bar_series.rb +2 -8
- data/lib/axlsx/drawing/bubble_chart.rb +2 -5
- data/lib/axlsx/drawing/bubble_series.rb +3 -6
- data/lib/axlsx/drawing/cat_axis.rb +2 -7
- data/lib/axlsx/drawing/chart.rb +7 -12
- data/lib/axlsx/drawing/d_lbls.rb +23 -22
- data/lib/axlsx/drawing/drawing.rb +4 -8
- data/lib/axlsx/drawing/graphic_frame.rb +0 -3
- data/lib/axlsx/drawing/hyperlink.rb +4 -7
- data/lib/axlsx/drawing/line_3D_chart.rb +10 -14
- data/lib/axlsx/drawing/line_chart.rb +3 -6
- data/lib/axlsx/drawing/line_series.rb +1 -4
- data/lib/axlsx/drawing/marker.rb +5 -9
- data/lib/axlsx/drawing/num_data.rb +4 -9
- data/lib/axlsx/drawing/num_data_source.rb +3 -7
- data/lib/axlsx/drawing/num_val.rb +2 -5
- data/lib/axlsx/drawing/one_cell_anchor.rb +4 -6
- data/lib/axlsx/drawing/pic.rb +46 -13
- data/lib/axlsx/drawing/picture_locking.rb +3 -6
- data/lib/axlsx/drawing/pie_3D_chart.rb +2 -7
- data/lib/axlsx/drawing/pie_series.rb +1 -6
- data/lib/axlsx/drawing/scaling.rb +2 -5
- data/lib/axlsx/drawing/scatter_chart.rb +2 -5
- data/lib/axlsx/drawing/scatter_series.rb +2 -5
- data/lib/axlsx/drawing/ser_axis.rb +2 -6
- data/lib/axlsx/drawing/series.rb +3 -5
- data/lib/axlsx/drawing/series_title.rb +0 -2
- data/lib/axlsx/drawing/str_data.rb +3 -8
- data/lib/axlsx/drawing/str_val.rb +2 -5
- data/lib/axlsx/drawing/title.rb +12 -15
- data/lib/axlsx/drawing/two_cell_anchor.rb +5 -7
- data/lib/axlsx/drawing/val_axis.rb +1 -4
- data/lib/axlsx/drawing/view_3D.rb +24 -24
- data/lib/axlsx/drawing/vml_drawing.rb +2 -5
- data/lib/axlsx/drawing/vml_shape.rb +4 -7
- data/lib/axlsx/package.rb +35 -36
- data/lib/axlsx/rels/relationship.rb +21 -24
- data/lib/axlsx/rels/relationships.rb +3 -6
- data/lib/axlsx/stylesheet/border.rb +1 -4
- data/lib/axlsx/stylesheet/border_pr.rb +3 -5
- data/lib/axlsx/stylesheet/cell_alignment.rb +2 -10
- data/lib/axlsx/stylesheet/cell_protection.rb +1 -4
- data/lib/axlsx/stylesheet/cell_style.rb +3 -7
- data/lib/axlsx/stylesheet/color.rb +6 -5
- data/lib/axlsx/stylesheet/dxf.rb +2 -6
- data/lib/axlsx/stylesheet/fill.rb +0 -4
- data/lib/axlsx/stylesheet/font.rb +7 -6
- data/lib/axlsx/stylesheet/gradient_fill.rb +4 -6
- data/lib/axlsx/stylesheet/gradient_stop.rb +2 -3
- data/lib/axlsx/stylesheet/num_fmt.rb +1 -4
- data/lib/axlsx/stylesheet/pattern_fill.rb +3 -5
- data/lib/axlsx/stylesheet/styles.rb +53 -45
- data/lib/axlsx/stylesheet/table_style.rb +5 -8
- data/lib/axlsx/stylesheet/table_style_element.rb +1 -4
- data/lib/axlsx/stylesheet/table_styles.rb +3 -7
- data/lib/axlsx/stylesheet/xf.rb +3 -6
- data/lib/axlsx/util/accessors.rb +2 -4
- data/lib/axlsx/util/constants.rb +3 -5
- data/lib/axlsx/util/mime_type_utils.rb +13 -0
- data/lib/axlsx/util/options_parser.rb +1 -2
- data/lib/axlsx/util/serialized_attributes.rb +4 -5
- data/lib/axlsx/util/simple_typed_list.rb +18 -17
- data/lib/axlsx/util/storage.rb +32 -36
- data/lib/axlsx/util/validators.rb +7 -4
- data/lib/axlsx/util/zip_command.rb +0 -2
- data/lib/axlsx/version.rb +1 -2
- data/lib/axlsx/workbook/defined_name.rb +6 -5
- data/lib/axlsx/workbook/defined_names.rb +1 -2
- data/lib/axlsx/workbook/shared_strings_table.rb +3 -6
- data/lib/axlsx/workbook/workbook.rb +96 -91
- data/lib/axlsx/workbook/workbook_view.rb +5 -10
- data/lib/axlsx/workbook/workbook_views.rb +1 -3
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +9 -8
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +6 -6
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +13 -14
- data/lib/axlsx/workbook/worksheet/border_creator.rb +29 -26
- data/lib/axlsx/workbook/worksheet/break.rb +2 -5
- data/lib/axlsx/workbook/worksheet/cell.rb +46 -26
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +11 -11
- data/lib/axlsx/workbook/worksheet/cfvo.rb +2 -2
- data/lib/axlsx/workbook/worksheet/cfvos.rb +3 -5
- data/lib/axlsx/workbook/worksheet/col.rb +4 -7
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +4 -5
- data/lib/axlsx/workbook/worksheet/color_scale.rb +10 -12
- data/lib/axlsx/workbook/worksheet/cols.rb +6 -6
- data/lib/axlsx/workbook/worksheet/comment.rb +4 -5
- data/lib/axlsx/workbook/worksheet/comments.rb +6 -10
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +4 -5
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +2 -6
- data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +2 -4
- data/lib/axlsx/workbook/worksheet/data_bar.rb +20 -22
- data/lib/axlsx/workbook/worksheet/data_validation.rb +4 -5
- data/lib/axlsx/workbook/worksheet/data_validations.rb +2 -5
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +1 -3
- data/lib/axlsx/workbook/worksheet/dimension.rb +5 -4
- data/lib/axlsx/workbook/worksheet/header_footer.rb +0 -1
- data/lib/axlsx/workbook/worksheet/icon_set.rb +2 -3
- data/lib/axlsx/workbook/worksheet/merged_cells.rb +8 -8
- data/lib/axlsx/workbook/worksheet/outline_pr.rb +0 -1
- data/lib/axlsx/workbook/worksheet/page_margins.rb +2 -2
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -3
- data/lib/axlsx/workbook/worksheet/page_setup.rb +117 -120
- data/lib/axlsx/workbook/worksheet/pane.rb +16 -17
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +8 -11
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +8 -11
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +3 -4
- data/lib/axlsx/workbook/worksheet/print_options.rb +0 -1
- data/lib/axlsx/workbook/worksheet/protected_range.rb +4 -5
- data/lib/axlsx/workbook/worksheet/protected_ranges.rb +9 -9
- data/lib/axlsx/workbook/worksheet/rich_text.rb +4 -6
- data/lib/axlsx/workbook/worksheet/rich_text_run.rb +21 -5
- data/lib/axlsx/workbook/worksheet/row.rb +24 -15
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +3 -4
- data/lib/axlsx/workbook/worksheet/selection.rb +7 -9
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +5 -6
- data/lib/axlsx/workbook/worksheet/sheet_data.rb +4 -6
- data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +18 -18
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +4 -4
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +12 -13
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +35 -42
- data/lib/axlsx/workbook/worksheet/table.rb +7 -9
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +2 -3
- data/lib/axlsx/workbook/worksheet/tables.rb +4 -4
- data/lib/axlsx/workbook/worksheet/worksheet.rb +63 -35
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +6 -6
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +3 -2
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +5 -6
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +4 -4
- data/lib/axlsx.rb +23 -9
- data/lib/caxlsx.rb +0 -1
- metadata +3 -3
@@ -1,12 +1,10 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
#A CatAxis object defines a chart category axis
|
2
|
+
# A CatAxis object defines a chart category axis
|
4
3
|
class CatAxis < Axis
|
5
|
-
|
6
4
|
# Creates a new CatAxis object
|
7
5
|
# @option options [Integer] tick_lbl_skip
|
8
6
|
# @option options [Integer] tick_mark_skip
|
9
|
-
def initialize(options={})
|
7
|
+
def initialize(options = {})
|
10
8
|
@tick_lbl_skip = 1
|
11
9
|
@tick_mark_skip = 1
|
12
10
|
self.auto = 1
|
@@ -78,8 +76,5 @@ module Axlsx
|
|
78
76
|
str << ('<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>')
|
79
77
|
str << '</c:catAx>'
|
80
78
|
end
|
81
|
-
|
82
79
|
end
|
83
|
-
|
84
|
-
|
85
80
|
end
|
data/lib/axlsx/drawing/chart.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# A Chart is the superclass for specific charts
|
5
3
|
# @note Worksheet#add_chart is the recommended way to create charts for your worksheets.
|
6
4
|
# @see README for examples
|
7
5
|
class Chart
|
8
|
-
|
9
6
|
include Axlsx::OptionsParser
|
10
7
|
# Creates a new chart object
|
11
8
|
# @param [GraphicalFrame] frame The frame that holds this chart.
|
@@ -16,10 +13,10 @@ module Axlsx
|
|
16
13
|
# @option options [Array|String|Cell] end_at The X, Y coordinates defining the bottom right corner of the chart.
|
17
14
|
# @option options [Boolean] plot_visible_only (true) Whether only data from visible cells should be plotted.
|
18
15
|
# @option options [Boolean] rounded_corners (true) Whether the chart area shall have rounded corners.
|
19
|
-
def initialize(frame, options={})
|
16
|
+
def initialize(frame, options = {})
|
20
17
|
@style = 18
|
21
18
|
@view_3D = nil
|
22
|
-
@graphic_frame=frame
|
19
|
+
@graphic_frame = frame
|
23
20
|
@graphic_frame.anchor.drawing.worksheet.workbook.charts << self
|
24
21
|
@series = SimpleTypedList.new Series
|
25
22
|
@show_legend = true
|
@@ -52,7 +49,7 @@ module Axlsx
|
|
52
49
|
# @return [Series]
|
53
50
|
attr_reader :series_type
|
54
51
|
|
55
|
-
#TODO data labels!
|
52
|
+
# TODO data labels!
|
56
53
|
def d_lbls
|
57
54
|
@d_lbls ||= DLbls.new(self.class)
|
58
55
|
end
|
@@ -125,7 +122,7 @@ module Axlsx
|
|
125
122
|
# The part name for this chart
|
126
123
|
# @return [String]
|
127
124
|
def pn
|
128
|
-
"#{CHART_PN % (index+1)}"
|
125
|
+
"#{CHART_PN % (index + 1)}"
|
129
126
|
end
|
130
127
|
|
131
128
|
# The title object for the chart.
|
@@ -181,7 +178,7 @@ module Axlsx
|
|
181
178
|
# Adds a new series to the chart's series collection.
|
182
179
|
# @return [Series]
|
183
180
|
# @see Series
|
184
|
-
def add_series(options={})
|
181
|
+
def add_series(options = {})
|
185
182
|
@series_type.new(self, options)
|
186
183
|
@series.last
|
187
184
|
end
|
@@ -275,7 +272,7 @@ module Axlsx
|
|
275
272
|
# reference or cell to use in setting the start marker position.
|
276
273
|
# @param [Integer] y The row
|
277
274
|
# @return [Marker]
|
278
|
-
def start_at(x=0, y=0)
|
275
|
+
def start_at(x = 0, y = 0)
|
279
276
|
@graphic_frame.anchor.start_at(x, y)
|
280
277
|
end
|
281
278
|
|
@@ -286,14 +283,12 @@ module Axlsx
|
|
286
283
|
# @param [Integer] y The row - default 10
|
287
284
|
# @return [Marker]
|
288
285
|
# @see start_at
|
289
|
-
def end_at(x=10, y=10)
|
286
|
+
def end_at(x = 10, y = 10)
|
290
287
|
@graphic_frame.anchor.end_at(x, y)
|
291
288
|
end
|
292
289
|
|
293
290
|
# sets the view_3D object for the chart
|
294
291
|
def view_3D=(v) DataTypeValidator.validate "#{self.class}.view_3D", View3D, v; @view_3D = v; end
|
295
292
|
alias :view3D= :view_3D=
|
296
|
-
|
297
293
|
end
|
298
|
-
|
299
294
|
end
|
data/lib/axlsx/drawing/d_lbls.rb
CHANGED
@@ -2,15 +2,15 @@ module Axlsx
|
|
2
2
|
# There are more elements in the dLbls spec that allow for
|
3
3
|
# customizations and formatting. For now, I am just implementing the
|
4
4
|
# basics.
|
5
|
-
#The DLbls class manages serialization of data labels
|
5
|
+
# The DLbls class manages serialization of data labels
|
6
6
|
# showLeaderLines and leaderLines are not currently implemented
|
7
7
|
class DLbls
|
8
|
-
|
9
8
|
include Axlsx::Accessors
|
10
|
-
include Axlsx::OptionsParser
|
9
|
+
include Axlsx::OptionsParser
|
11
10
|
# creates a new DLbls object
|
12
|
-
def initialize(chart_type, options={})
|
11
|
+
def initialize(chart_type, options = {})
|
13
12
|
raise ArgumentError, 'chart_type must inherit from Chart' unless [Chart, LineChart].include?(chart_type.superclass)
|
13
|
+
|
14
14
|
@chart_type = chart_type
|
15
15
|
initialize_defaults
|
16
16
|
parse_options options
|
@@ -18,31 +18,31 @@ module Axlsx
|
|
18
18
|
|
19
19
|
# These attributes are all boolean so I'm doing a bit of a hand
|
20
20
|
# waving magic show to set up the attriubte accessors
|
21
|
-
# @note
|
22
|
-
# not all charts support all methods!
|
21
|
+
# @note
|
22
|
+
# not all charts support all methods!
|
23
23
|
# Bar3DChart and Line3DChart and ScatterChart do not support d_lbl_pos or show_leader_lines
|
24
|
-
#
|
25
|
-
boolean_attr_accessor :show_legend_key,
|
26
|
-
:show_val,
|
27
|
-
:show_cat_name,
|
28
|
-
:show_ser_name,
|
29
|
-
:show_percent,
|
30
|
-
:show_bubble_size,
|
24
|
+
#
|
25
|
+
boolean_attr_accessor :show_legend_key,
|
26
|
+
:show_val,
|
27
|
+
:show_cat_name,
|
28
|
+
:show_ser_name,
|
29
|
+
:show_percent,
|
30
|
+
:show_bubble_size,
|
31
31
|
:show_leader_lines
|
32
32
|
|
33
33
|
# Initialize all the values to false as Excel requires them to
|
34
34
|
# explicitly be disabled or all will show.
|
35
35
|
def initialize_defaults
|
36
|
-
[:show_legend_key, :show_val, :show_cat_name,
|
37
|
-
:show_ser_name, :show_percent, :show_bubble_size,
|
36
|
+
[:show_legend_key, :show_val, :show_cat_name,
|
37
|
+
:show_ser_name, :show_percent, :show_bubble_size,
|
38
38
|
:show_leader_lines].each do |attr|
|
39
39
|
self.send("#{attr}=", false)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
# The chart type that is using this data lables instance.
|
43
|
+
# The chart type that is using this data lables instance.
|
44
44
|
# This affects the xml output as not all chart types support the
|
45
|
-
# same data label attributes.
|
45
|
+
# same data label attributes.
|
46
46
|
attr_reader :chart_type
|
47
47
|
|
48
48
|
# The position of the data labels in the chart
|
@@ -50,6 +50,7 @@ module Axlsx
|
|
50
50
|
# @return [Symbol]
|
51
51
|
def d_lbl_pos
|
52
52
|
return unless [Pie3DChart, LineChart].include? @chart_type
|
53
|
+
|
53
54
|
@d_lbl_pos ||= :bestFit
|
54
55
|
end
|
55
56
|
|
@@ -61,11 +62,11 @@ module Axlsx
|
|
61
62
|
# @param [Symbol] label_position the postion you want to use.
|
62
63
|
def d_lbl_pos=(label_position)
|
63
64
|
return unless [Pie3DChart, LineChart].include? @chart_type
|
64
|
-
|
65
|
+
|
66
|
+
Axlsx::RestrictionValidator.validate 'DLbls#d_lbl_pos', [:bestFit, :b, :ctr, :inBase, :inEnd, :l, :outEnd, :r, :t], label_position
|
65
67
|
@d_lbl_pos = label_position
|
66
68
|
end
|
67
69
|
|
68
|
-
|
69
70
|
# serializes the data labels
|
70
71
|
# @return [String]
|
71
72
|
def to_xml_string(str = '')
|
@@ -74,7 +75,8 @@ module Axlsx
|
|
74
75
|
instance_vals = Axlsx.instance_values_for(self)
|
75
76
|
%w(d_lbl_pos show_legend_key show_val show_cat_name show_ser_name show_percent show_bubble_size show_leader_lines).each do |key|
|
76
77
|
next unless instance_vals.keys.include?(key) && instance_vals[key] != nil
|
77
|
-
|
78
|
+
|
79
|
+
str << "<c:#{Axlsx::camel(key, false)} val='#{instance_vals[key]}' />"
|
78
80
|
end
|
79
81
|
str << '</c:dLbls>'
|
80
82
|
end
|
@@ -82,10 +84,9 @@ module Axlsx
|
|
82
84
|
# 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.
|
83
85
|
def validate_attributes_for_chart_type
|
84
86
|
return if [Pie3DChart, LineChart].include? @chart_type
|
87
|
+
|
85
88
|
@d_lbl_pos = nil
|
86
89
|
@show_leader_lines = nil
|
87
90
|
end
|
88
|
-
|
89
|
-
|
90
91
|
end
|
91
92
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
2
|
require 'axlsx/drawing/d_lbls.rb'
|
4
3
|
require 'axlsx/drawing/title.rb'
|
@@ -58,7 +57,6 @@ module Axlsx
|
|
58
57
|
# @see Chart
|
59
58
|
# see examples/example.rb for an example of how to create a chart.
|
60
59
|
class Drawing
|
61
|
-
|
62
60
|
# The worksheet that owns the drawing
|
63
61
|
# @return [Worksheet]
|
64
62
|
attr_reader :worksheet
|
@@ -77,12 +75,11 @@ module Axlsx
|
|
77
75
|
@anchors = SimpleTypedList.new [TwoCellAnchor, OneCellAnchor]
|
78
76
|
end
|
79
77
|
|
80
|
-
|
81
78
|
# Adds an image to the chart If th end_at option is specified we create a two cell anchor. By default we use a one cell anchor.
|
82
79
|
# @note The recommended way to manage images is to use Worksheet.add_image. Please refer to that method for documentation.
|
83
80
|
# @see Worksheet#add_image
|
84
81
|
# @return [Pic]
|
85
|
-
def add_image(options={})
|
82
|
+
def add_image(options = {})
|
86
83
|
if options[:end_at]
|
87
84
|
TwoCellAnchor.new(self, options).add_pic(options)
|
88
85
|
else
|
@@ -94,7 +91,7 @@ module Axlsx
|
|
94
91
|
# Adds a chart to the drawing.
|
95
92
|
# @note The recommended way to manage charts is to use Worksheet.add_chart. Please refer to that method for documentation.
|
96
93
|
# @see Worksheet#add_chart
|
97
|
-
def add_chart(chart_type, options={})
|
94
|
+
def add_chart(chart_type, options = {})
|
98
95
|
TwoCellAnchor.new(self, options)
|
99
96
|
@anchors.last.add_chart(chart_type, options)
|
100
97
|
end
|
@@ -129,14 +126,14 @@ module Axlsx
|
|
129
126
|
# The part name for this drawing
|
130
127
|
# @return [String]
|
131
128
|
def pn
|
132
|
-
"#{DRAWING_PN % (index+1)}"
|
129
|
+
"#{DRAWING_PN % (index + 1)}"
|
133
130
|
end
|
134
131
|
|
135
132
|
# The relational part name for this drawing
|
136
133
|
# #NOTE This should be rewritten to return an Axlsx::Relationship object.
|
137
134
|
# @return [String]
|
138
135
|
def rels_pn
|
139
|
-
"#{DRAWING_RELS_PN % (index+1)}"
|
136
|
+
"#{DRAWING_RELS_PN % (index + 1)}"
|
140
137
|
end
|
141
138
|
|
142
139
|
# A list of objects this drawing holds.
|
@@ -162,6 +159,5 @@ module Axlsx
|
|
162
159
|
anchors.each { |anchor| anchor.to_xml_string(str) }
|
163
160
|
str << '</xdr:wsDr>'
|
164
161
|
end
|
165
|
-
|
166
162
|
end
|
167
163
|
end
|
@@ -1,10 +1,8 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
2
|
# A graphic frame defines a container for a chart object
|
4
3
|
# @note The recommended way to manage charts is Worksheet#add_chart
|
5
4
|
# @see Worksheet#add_chart
|
6
5
|
class GraphicFrame
|
7
|
-
|
8
6
|
# A reference to the chart object associated with this frame
|
9
7
|
# @return [Chart]
|
10
8
|
attr_reader :chart
|
@@ -49,6 +47,5 @@ module Axlsx
|
|
49
47
|
str << '</a:graphic>'
|
50
48
|
str << '</xdr:graphicFrame>'
|
51
49
|
end
|
52
|
-
|
53
50
|
end
|
54
51
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
2
|
# a hyperlink object adds an action to an image when clicked so that when the image is clicked the link is fecthed.
|
4
3
|
# @note using the hyperlink option when calling add_image on a drawing object is the recommended way to manage hyperlinks
|
5
4
|
# @see {file:README} README
|
6
5
|
class Hyperlink
|
7
|
-
|
8
6
|
include Axlsx::SerializedAttributes
|
9
7
|
include Axlsx::OptionsParser
|
10
8
|
|
11
|
-
#Creates a hyperlink object
|
9
|
+
# Creates a hyperlink object
|
12
10
|
# parent must be a Pic for now, although I expect that other object support this tag and its cNvPr parent
|
13
11
|
# @param [Pic] parent
|
14
12
|
# @option options [String] tooltip message shown when hyperlinked object is hovered over with mouse.
|
@@ -19,7 +17,7 @@ module Axlsx
|
|
19
17
|
# @option options [Boolean] endSnd terminate any sound events when processing this link
|
20
18
|
# @option options [Boolean] history include this link in the list of visited links for the applications history.
|
21
19
|
# @option options [Boolean] highlightClick indicate that the link has already been visited.
|
22
|
-
def initialize(parent, options={})
|
20
|
+
def initialize(parent, options = {})
|
23
21
|
DataTypeValidator.validate "Hyperlink.parent", [Pic], parent
|
24
22
|
@parent = parent
|
25
23
|
parse_options options
|
@@ -40,7 +38,7 @@ module Axlsx
|
|
40
38
|
alias :invalidUrl :invalid_url
|
41
39
|
alias :invalidUrl= :invalid_url=
|
42
40
|
|
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 http://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
|
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 http://msdn.microsoft.com/en-us/library/ff532419%28v=office.12%29.aspx
|
44
42
|
# @return [String]
|
45
43
|
attr_accessor :action
|
46
44
|
|
@@ -93,8 +91,7 @@ module Axlsx
|
|
93
91
|
# @param [String] str
|
94
92
|
# @return [String]
|
95
93
|
def to_xml_string(str = '')
|
96
|
-
serialized_tag 'a:hlinkClick', str, {:'r:id' => relationship.Id, :'xmlns:r' => XML_NS_R }
|
94
|
+
serialized_tag 'a:hlinkClick', str, { :'r:id' => relationship.Id, :'xmlns:r' => XML_NS_R }
|
97
95
|
end
|
98
|
-
|
99
96
|
end
|
100
97
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# The Line3DChart is a three dimentional line chart (who would have guessed?) that you can add to your worksheet.
|
5
3
|
# @example Creating a chart
|
6
4
|
# # This example creates a line in a single sheet.
|
@@ -20,7 +18,6 @@ module Axlsx
|
|
20
18
|
# @see Series
|
21
19
|
# @see Package#serialize
|
22
20
|
class Line3DChart < Axlsx::LineChart
|
23
|
-
|
24
21
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
25
22
|
# @return [String]
|
26
23
|
attr_reader :gap_depth
|
@@ -41,28 +38,27 @@ module Axlsx
|
|
41
38
|
# @see Chart
|
42
39
|
# @see lineChart
|
43
40
|
# @see View3D
|
44
|
-
def initialize(frame, options={})
|
41
|
+
def initialize(frame, options = {})
|
45
42
|
@gap_depth = nil
|
46
|
-
@view_3D = View3D.new({:r_ang_ax=>1}.merge(options))
|
43
|
+
@view_3D = View3D.new({ :r_ang_ax => 1 }.merge(options))
|
47
44
|
super(frame, options)
|
48
45
|
axes.add_axis :ser_axis, SerAxis
|
49
46
|
end
|
50
47
|
|
51
|
-
|
52
48
|
# @see gapDepth
|
53
49
|
def gap_depth=(v)
|
54
50
|
RegexValidator.validate "Line3DChart.gapWidth", GAP_AMOUNT_PERCENT, v
|
55
|
-
@gap_depth=(v)
|
51
|
+
@gap_depth = (v)
|
56
52
|
end
|
57
53
|
alias :gapDepth= :gap_depth=
|
58
54
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
55
|
+
# Serializes the object
|
56
|
+
# @param [String] str
|
57
|
+
# @return [String]
|
58
|
+
def to_xml_string(str = '')
|
59
|
+
super(str) do
|
60
|
+
str << ('<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil?
|
66
61
|
end
|
62
|
+
end
|
67
63
|
end
|
68
64
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
|
-
|
4
2
|
# The LineChart is a two dimentional line chart (who would have guessed?) that you can add to your worksheet.
|
5
3
|
# @example Creating a chart
|
6
4
|
# # This example creates a line in a single sheet.
|
@@ -20,7 +18,6 @@ module Axlsx
|
|
20
18
|
# @see Series
|
21
19
|
# @see Package#serialize
|
22
20
|
class LineChart < Chart
|
23
|
-
|
24
21
|
# the category axis
|
25
22
|
# @return [CatAxis]
|
26
23
|
def cat_axis
|
@@ -35,7 +32,7 @@ module Axlsx
|
|
35
32
|
end
|
36
33
|
alias :valAxis :val_axis
|
37
34
|
|
38
|
-
|
35
|
+
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
39
36
|
# @return [Symbol]
|
40
37
|
attr_reader :grouping
|
41
38
|
|
@@ -45,7 +42,7 @@ module Axlsx
|
|
45
42
|
# @option options [Boolean] show_legend
|
46
43
|
# @option options [Symbol] grouping
|
47
44
|
# @see Chart
|
48
|
-
def initialize(frame, options={})
|
45
|
+
def initialize(frame, options = {})
|
49
46
|
@vary_colors = false
|
50
47
|
@grouping = :standard
|
51
48
|
super(frame, options)
|
@@ -66,7 +63,7 @@ module Axlsx
|
|
66
63
|
def node_name
|
67
64
|
path = self.class.to_s
|
68
65
|
if i = path.rindex('::')
|
69
|
-
path = path[(i+2)..-1]
|
66
|
+
path = path[(i + 2)..-1]
|
70
67
|
end
|
71
68
|
path[0] = path[0].chr.downcase
|
72
69
|
path
|
@@ -1,11 +1,9 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
2
|
# A LineSeries defines the title, data and labels for line charts
|
4
3
|
# @note The recommended way to manage series is to use Chart#add_series
|
5
4
|
# @see Worksheet#add_chart
|
6
5
|
# @see Chart#add_series
|
7
6
|
class LineSeries < Series
|
8
|
-
|
9
7
|
# The data for this series.
|
10
8
|
# @return [ValAxisData]
|
11
9
|
attr_reader :data
|
@@ -35,7 +33,7 @@ module Axlsx
|
|
35
33
|
# @option options [Array, SimpleTypedList] data
|
36
34
|
# @option options [Array, SimpleTypedList] labels
|
37
35
|
# @param [Chart] chart
|
38
|
-
def initialize(chart, options={})
|
36
|
+
def initialize(chart, options = {})
|
39
37
|
@show_marker = false
|
40
38
|
@marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default
|
41
39
|
@smooth = false
|
@@ -105,6 +103,5 @@ module Axlsx
|
|
105
103
|
|
106
104
|
# assigns the labels for this series
|
107
105
|
def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end
|
108
|
-
|
109
106
|
end
|
110
107
|
end
|
data/lib/axlsx/drawing/marker.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
2
|
# The Marker class defines a point in the worksheet that drawing anchors attach to.
|
4
3
|
# @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.
|
5
4
|
# @see Worksheet#add_chart
|
6
5
|
class Marker
|
7
|
-
|
8
6
|
include Axlsx::OptionsParser
|
9
7
|
|
10
8
|
# Creates a new Marker object
|
@@ -12,7 +10,7 @@ module Axlsx
|
|
12
10
|
# @option options [Integer] colOff
|
13
11
|
# @option options [Integer] row
|
14
12
|
# @option options [Integer] rowOff
|
15
|
-
def initialize(options={})
|
13
|
+
def initialize(options = {})
|
16
14
|
@col, @colOff, @row, @rowOff = 0, 0, 0, 0
|
17
15
|
parse_options options
|
18
16
|
end
|
@@ -33,7 +31,7 @@ module Axlsx
|
|
33
31
|
# @return [Integer]
|
34
32
|
attr_reader :rowOff
|
35
33
|
|
36
|
-
|
34
|
+
# @see col
|
37
35
|
def col=(v) Axlsx::validate_unsigned_int v; @col = v end
|
38
36
|
# @see colOff
|
39
37
|
def colOff=(v) Axlsx::validate_int v; @colOff = v end
|
@@ -47,7 +45,7 @@ module Axlsx
|
|
47
45
|
# or an Array.
|
48
46
|
# @param row the row of the marker. This is ignored if the col parameter is a Cell or
|
49
47
|
# String or Array.
|
50
|
-
def coord(col, row=0)
|
48
|
+
def coord(col, row = 0)
|
51
49
|
coordinates = parse_coord_args(col, row)
|
52
50
|
self.col = coordinates[0]
|
53
51
|
self.row = coordinates[1]
|
@@ -61,11 +59,12 @@ module Axlsx
|
|
61
59
|
str << ('<xdr:' << k.to_s << '>' << self.send(k).to_s << '</xdr:' << k.to_s << '>')
|
62
60
|
end
|
63
61
|
end
|
62
|
+
|
64
63
|
private
|
65
64
|
|
66
65
|
# handles multiple inputs for setting the position of a marker
|
67
66
|
# @see Chart#start_at
|
68
|
-
def parse_coord_args(x, y=0)
|
67
|
+
def parse_coord_args(x, y = 0)
|
69
68
|
if x.is_a?(String)
|
70
69
|
x, y = *Axlsx::name_to_indices(x)
|
71
70
|
end
|
@@ -77,8 +76,5 @@ module Axlsx
|
|
77
76
|
end
|
78
77
|
[x, y]
|
79
78
|
end
|
80
|
-
|
81
|
-
|
82
79
|
end
|
83
|
-
|
84
80
|
end
|
@@ -1,16 +1,13 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
module Axlsx
|
3
|
-
|
4
|
-
#This class specifies data for a particular data point. It is used for both numCache and numLit object
|
2
|
+
# This class specifies data for a particular data point. It is used for both numCache and numLit object
|
5
3
|
class NumData
|
6
|
-
|
7
4
|
include Axlsx::OptionsParser
|
8
5
|
|
9
6
|
# creates a new NumVal object
|
10
7
|
# @option options [String] formatCode
|
11
8
|
# @option options [Array] :data
|
12
9
|
# @see StrData
|
13
|
-
def initialize(options={})
|
10
|
+
def initialize(options = {})
|
14
11
|
@format_code = "General"
|
15
12
|
@pt = SimpleTypedList.new NumVal
|
16
13
|
parse_options options
|
@@ -22,7 +19,7 @@ module Axlsx
|
|
22
19
|
|
23
20
|
# Creates the val objects for this data set. I am not overly confident this is going to play nicely with time and data types.
|
24
21
|
# @param [Array] values An array of cells or values.
|
25
|
-
def data=(values=[])
|
22
|
+
def data=(values = [])
|
26
23
|
@tag_name = values.first.is_a?(Cell) ? :numCache : :numLit
|
27
24
|
values.each do |value|
|
28
25
|
value = value.is_formula? ? 0 : value.value if value.is_a?(Cell)
|
@@ -31,7 +28,7 @@ module Axlsx
|
|
31
28
|
end
|
32
29
|
|
33
30
|
# @see format_code
|
34
|
-
def format_code=(v='General')
|
31
|
+
def format_code=(v = 'General')
|
35
32
|
Axlsx::validate_string(v)
|
36
33
|
@format_code = v
|
37
34
|
end
|
@@ -46,7 +43,5 @@ module Axlsx
|
|
46
43
|
end
|
47
44
|
str << ('</c:' << @tag_name.to_s << '>')
|
48
45
|
end
|
49
|
-
|
50
46
|
end
|
51
|
-
|
52
47
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
module Axlsx
|
2
|
-
|
3
2
|
# A numeric data source for use by charts.
|
4
3
|
class NumDataSource
|
5
|
-
|
6
4
|
include Axlsx::OptionsParser
|
7
5
|
|
8
6
|
# creates a new NumDataSource object
|
9
7
|
# @option options [Array] data An array of Cells or Numeric objects
|
10
8
|
# @option options [Symbol] tag_name see tag_name
|
11
|
-
def initialize(options={})
|
9
|
+
def initialize(options = {})
|
12
10
|
# override these three in child classes
|
13
11
|
@data_type ||= NumData
|
14
12
|
@tag_name ||= :val
|
@@ -22,7 +20,6 @@ module Axlsx
|
|
22
20
|
parse_options options
|
23
21
|
end
|
24
22
|
|
25
|
-
|
26
23
|
# The tag name to use when serializing this data source.
|
27
24
|
# Only items defined in allowed_tag_names are allowed
|
28
25
|
# @return [Symbol]
|
@@ -36,7 +33,7 @@ module Axlsx
|
|
36
33
|
[:yVal, :val, :bubbleSize]
|
37
34
|
end
|
38
35
|
|
39
|
-
|
36
|
+
# sets the tag name for this data source
|
40
37
|
# @param [Symbol] v One of the allowed_tag_names
|
41
38
|
def tag_name=(v)
|
42
39
|
Axlsx::RestrictionValidator.validate "#{self.class.name}.tag_name", self.class.allowed_tag_names, v
|
@@ -45,7 +42,7 @@ module Axlsx
|
|
45
42
|
|
46
43
|
# serialize the object
|
47
44
|
# @param [String] str
|
48
|
-
def to_xml_string(str="")
|
45
|
+
def to_xml_string(str = "")
|
49
46
|
str << ('<c:' << tag_name.to_s << '>')
|
50
47
|
if @f
|
51
48
|
str << ('<c:' << @ref_tag_name.to_s << '>')
|
@@ -59,4 +56,3 @@ module Axlsx
|
|
59
56
|
end
|
60
57
|
end
|
61
58
|
end
|
62
|
-
|
@@ -1,9 +1,6 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
module Axlsx
|
3
|
-
|
4
|
-
#This class specifies data for a particular data point.
|
2
|
+
# This class specifies data for a particular data point.
|
5
3
|
class NumVal < StrVal
|
6
|
-
|
7
4
|
# A string representing the format code to apply.
|
8
5
|
# For more information see see the SpreadsheetML numFmt element's (§18.8.30) formatCode attribute.
|
9
6
|
# @return [String]
|
@@ -12,7 +9,7 @@ module Axlsx
|
|
12
9
|
# creates a new NumVal object
|
13
10
|
# @option options [String] formatCode
|
14
11
|
# @option options [Integer] v
|
15
|
-
def initialize(options={})
|
12
|
+
def initialize(options = {})
|
16
13
|
@format_code = "General"
|
17
14
|
super(options)
|
18
15
|
end
|
@@ -1,11 +1,9 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
module Axlsx
|
3
2
|
# This class details a single cell anchor for drawings.
|
4
3
|
# @note The recommended way to manage drawings, images and charts is Worksheet#add_chart or Worksheet#add_image.
|
5
4
|
# @see Worksheet#add_chart
|
6
5
|
# @see Worksheet#add_image
|
7
6
|
class OneCellAnchor
|
8
|
-
|
9
7
|
include Axlsx::OptionsParser
|
10
8
|
|
11
9
|
# Creates a new OneCellAnchor object and an Pic associated with it.
|
@@ -16,7 +14,7 @@ module Axlsx
|
|
16
14
|
# @option options [String] image_src the file location of the image you will render
|
17
15
|
# @option options [String] name the name attribute for the rendered image
|
18
16
|
# @option options [String] descr the description of the image rendered
|
19
|
-
def initialize(drawing, options={})
|
17
|
+
def initialize(drawing, options = {})
|
20
18
|
@drawing = drawing
|
21
19
|
@width = 0
|
22
20
|
@height = 0
|
@@ -54,9 +52,10 @@ module Axlsx
|
|
54
52
|
# We just 'figure it out' for you.
|
55
53
|
# @param [Array, String, Cell, Integer] x Accepts many inputs for defining the starting position of the cell.
|
56
54
|
# @param [Integer] y When x is an integer, this value is used for the row index at which the anchor starts.
|
57
|
-
def start_at(x, y=0)
|
55
|
+
def start_at(x, y = 0)
|
58
56
|
from.coord x, y
|
59
57
|
end
|
58
|
+
|
60
59
|
#
|
61
60
|
# @see height
|
62
61
|
def height=(v) Axlsx::validate_unsigned_int(v); @height = v; end
|
@@ -92,8 +91,7 @@ module Axlsx
|
|
92
91
|
def ext
|
93
92
|
cy = @height * 914400 / 96
|
94
93
|
cx = @width * 914400 / 96
|
95
|
-
{:cy=>cy, :cx=>cx}
|
94
|
+
{ :cy => cy, :cx => cx }
|
96
95
|
end
|
97
|
-
|
98
96
|
end
|
99
97
|
end
|