axlsx 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +3 -2
- data/.yardopts_guide +19 -0
- data/CHANGELOG.md +64 -1
- data/README.md +105 -87
- data/Rakefile +0 -5
- data/examples/2010_comments.rb +17 -0
- data/examples/anchor_swapping.rb +28 -0
- data/examples/auto_filter.rb +16 -0
- data/examples/basic_charts.rb +4 -0
- data/examples/colored_links.rb +59 -0
- data/examples/conditional_formatting/example_conditional_formatting.rb +4 -2
- data/examples/example.rb +569 -258
- data/examples/ios_preview.rb +14 -0
- data/examples/page_setup.rb +11 -0
- data/examples/pivot_table.rb +39 -0
- data/examples/skydrive/real_example.rb +8 -8
- data/examples/styles.rb +66 -0
- data/examples/underline.rb +13 -0
- data/examples/wrap_text.rb +21 -0
- data/lib/axlsx/content_type/abstract_content_type.rb +32 -0
- data/lib/axlsx/content_type/content_type.rb +1 -1
- data/lib/axlsx/content_type/default.rb +6 -37
- data/lib/axlsx/content_type/override.rb +6 -38
- data/lib/axlsx/doc_props/app.rb +10 -7
- data/lib/axlsx/doc_props/core.rb +6 -1
- data/lib/axlsx/drawing/axes.rb +61 -0
- data/lib/axlsx/drawing/axis.rb +20 -17
- data/lib/axlsx/drawing/bar_3D_chart.rb +31 -22
- data/lib/axlsx/drawing/cat_axis.rb +2 -10
- data/lib/axlsx/drawing/chart.rb +33 -6
- data/lib/axlsx/drawing/d_lbls.rb +21 -31
- data/lib/axlsx/drawing/drawing.rb +11 -17
- data/lib/axlsx/drawing/graphic_frame.rb +3 -3
- data/lib/axlsx/drawing/hyperlink.rb +42 -36
- data/lib/axlsx/drawing/line_3D_chart.rb +28 -70
- data/lib/axlsx/drawing/line_chart.rb +99 -0
- data/lib/axlsx/drawing/line_series.rb +20 -2
- data/lib/axlsx/drawing/marker.rb +38 -18
- data/lib/axlsx/drawing/num_data.rb +6 -6
- data/lib/axlsx/drawing/num_data_source.rb +17 -16
- data/lib/axlsx/drawing/one_cell_anchor.rb +28 -21
- data/lib/axlsx/drawing/pic.rb +43 -45
- data/lib/axlsx/drawing/picture_locking.rb +12 -44
- data/lib/axlsx/drawing/pie_3D_chart.rb +2 -1
- data/lib/axlsx/drawing/scaling.rb +13 -13
- data/lib/axlsx/drawing/scatter_chart.rb +32 -21
- data/lib/axlsx/drawing/ser_axis.rb +15 -16
- data/lib/axlsx/drawing/series.rb +3 -6
- data/lib/axlsx/drawing/str_data.rb +3 -3
- data/lib/axlsx/drawing/str_val.rb +7 -8
- data/lib/axlsx/drawing/two_cell_anchor.rb +7 -27
- data/lib/axlsx/drawing/val_axis.rb +14 -13
- data/lib/axlsx/drawing/view_3D.rb +52 -38
- data/lib/axlsx/drawing/vml_shape.rb +20 -79
- data/lib/axlsx/package.rb +58 -28
- data/lib/axlsx/rels/relationship.rb +75 -9
- data/lib/axlsx/rels/relationships.rb +8 -1
- data/lib/axlsx/stylesheet/border.rb +29 -20
- data/lib/axlsx/stylesheet/border_pr.rb +5 -4
- data/lib/axlsx/stylesheet/cell_alignment.rb +55 -29
- data/lib/axlsx/stylesheet/cell_protection.rb +7 -4
- data/lib/axlsx/stylesheet/cell_style.rb +19 -14
- data/lib/axlsx/stylesheet/color.rb +20 -17
- data/lib/axlsx/stylesheet/dxf.rb +4 -4
- data/lib/axlsx/stylesheet/font.rb +22 -22
- data/lib/axlsx/stylesheet/gradient_fill.rb +45 -21
- data/lib/axlsx/stylesheet/num_fmt.rb +23 -14
- data/lib/axlsx/stylesheet/pattern_fill.rb +12 -21
- data/lib/axlsx/stylesheet/styles.rb +37 -22
- data/lib/axlsx/stylesheet/table_style.rb +17 -16
- data/lib/axlsx/stylesheet/table_style_element.rb +15 -11
- data/lib/axlsx/stylesheet/table_styles.rb +14 -11
- data/lib/axlsx/stylesheet/xf.rb +28 -26
- data/lib/axlsx/util/accessors.rb +64 -0
- data/lib/axlsx/util/constants.rb +127 -6
- data/lib/axlsx/util/options_parser.rb +15 -0
- data/lib/axlsx/util/serialized_attributes.rb +79 -0
- data/lib/axlsx/util/simple_typed_list.rb +50 -15
- data/lib/axlsx/util/validators.rb +51 -16
- data/lib/axlsx/version.rb +2 -2
- data/lib/axlsx/workbook/defined_name.rb +14 -59
- data/lib/axlsx/workbook/shared_strings_table.rb +13 -4
- data/lib/axlsx/workbook/workbook.rb +85 -6
- data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +77 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +94 -0
- data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +246 -0
- data/lib/axlsx/workbook/worksheet/break.rb +37 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +109 -107
- data/lib/axlsx/workbook/worksheet/cell_serializer.rb +144 -0
- data/lib/axlsx/workbook/worksheet/cfvo.rb +15 -15
- data/lib/axlsx/workbook/worksheet/cfvos.rb +15 -0
- data/lib/axlsx/workbook/worksheet/col.rb +43 -29
- data/lib/axlsx/workbook/worksheet/col_breaks.rb +35 -0
- data/lib/axlsx/workbook/worksheet/color_scale.rb +62 -28
- data/lib/axlsx/workbook/worksheet/comment.rb +28 -37
- data/lib/axlsx/workbook/worksheet/comments.rb +3 -3
- data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +11 -11
- data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +31 -27
- data/lib/axlsx/workbook/worksheet/data_bar.rb +75 -41
- data/lib/axlsx/workbook/worksheet/data_validation.rb +61 -62
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +6 -5
- data/lib/axlsx/workbook/worksheet/dimension.rb +0 -1
- data/lib/axlsx/workbook/worksheet/header_footer.rb +54 -0
- data/lib/axlsx/workbook/worksheet/icon_set.rb +20 -20
- data/lib/axlsx/workbook/worksheet/page_margins.rb +21 -19
- data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +44 -0
- data/lib/axlsx/workbook/worksheet/page_setup.rb +152 -23
- data/lib/axlsx/workbook/worksheet/pane.rb +48 -51
- data/lib/axlsx/workbook/worksheet/pivot_table.rb +273 -0
- data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +66 -0
- data/lib/axlsx/workbook/worksheet/pivot_tables.rb +24 -0
- data/lib/axlsx/workbook/worksheet/print_options.rb +8 -30
- data/lib/axlsx/workbook/worksheet/protected_range.rb +16 -13
- data/lib/axlsx/workbook/worksheet/row.rb +59 -83
- data/lib/axlsx/workbook/worksheet/row_breaks.rb +33 -0
- data/lib/axlsx/workbook/worksheet/selection.rb +30 -38
- data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +29 -0
- data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +60 -0
- data/lib/axlsx/workbook/worksheet/sheet_pr.rb +49 -4
- data/lib/axlsx/workbook/worksheet/sheet_protection.rb +51 -155
- data/lib/axlsx/workbook/worksheet/sheet_view.rb +68 -234
- data/lib/axlsx/workbook/worksheet/table.rb +25 -19
- data/lib/axlsx/workbook/worksheet/table_style_info.rb +51 -0
- data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
- data/lib/axlsx/workbook/worksheet/worksheet.rb +174 -35
- data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +6 -5
- data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +4 -10
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +74 -0
- data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +38 -0
- data/lib/axlsx.rb +55 -5
- data/lib/schema/sml.xsd +4 -0
- data/test/axlsx.qcachegrind +2226 -0
- data/test/benchmark.rb +2 -3
- data/test/content_type/tc_default.rb +0 -11
- data/test/content_type/tc_override.rb +0 -13
- data/test/doc_props/tc_core.rb +7 -0
- data/test/drawing/tc_axes.rb +8 -0
- data/test/drawing/tc_axis.rb +15 -17
- data/test/drawing/tc_bar_3D_chart.rb +6 -0
- data/test/drawing/tc_cat_axis.rb +9 -9
- data/test/drawing/tc_chart.rb +20 -0
- data/test/drawing/tc_d_lbls.rb +14 -4
- data/test/drawing/tc_drawing.rb +0 -5
- data/test/drawing/tc_graphic_frame.rb +5 -3
- data/test/drawing/tc_hyperlink.rb +0 -4
- data/test/drawing/tc_line_chart.rb +39 -0
- data/test/drawing/tc_line_series.rb +8 -2
- data/test/drawing/tc_pic.rb +14 -3
- data/test/drawing/tc_ser_axis.rb +13 -12
- data/test/drawing/tc_two_cell_anchor.rb +3 -3
- data/test/drawing/tc_val_axis.rb +6 -6
- data/test/drawing/tc_vml_shape.rb +9 -3
- data/test/profile.rb +11 -21
- data/test/rels/tc_relationship.rb +32 -9
- data/test/rels/tc_relationships.rb +12 -1
- data/test/stylesheet/tc_color.rb +6 -0
- data/test/stylesheet/tc_styles.rb +15 -2
- data/test/tc_axlsx.rb +35 -2
- data/test/tc_helper.rb +7 -1
- data/test/tc_package.rb +44 -5
- data/test/util/tc_serialized_attributes.rb +19 -0
- data/test/util/tc_validators.rb +26 -1
- data/test/workbook/tc_defined_name.rb +2 -2
- data/test/workbook/tc_shared_strings_table.rb +6 -0
- data/test/workbook/tc_workbook.rb +38 -1
- data/test/workbook/worksheet/auto_filter/tc_auto_filter.rb +38 -0
- data/test/workbook/worksheet/auto_filter/tc_filter_column.rb +76 -0
- data/test/workbook/worksheet/auto_filter/tc_filters.rb +50 -0
- data/test/workbook/worksheet/tc_break.rb +49 -0
- data/test/workbook/worksheet/tc_cell.rb +40 -6
- data/test/workbook/worksheet/tc_col.rb +11 -1
- data/test/workbook/worksheet/tc_color_scale.rb +31 -2
- data/test/workbook/worksheet/tc_comment.rb +21 -6
- data/test/workbook/worksheet/tc_comments.rb +2 -2
- data/test/workbook/worksheet/tc_conditional_formatting.rb +7 -0
- data/test/workbook/worksheet/tc_data_bar.rb +7 -0
- data/test/workbook/worksheet/tc_date_time_converter.rb +3 -11
- data/test/workbook/worksheet/tc_header_footer.rb +151 -0
- data/test/workbook/worksheet/tc_page_set_up_pr.rb +15 -0
- data/test/workbook/worksheet/tc_page_setup.rb +6 -1
- data/test/workbook/worksheet/tc_pane.rb +5 -45
- data/test/workbook/worksheet/tc_pivot_table.rb +120 -0
- data/test/workbook/worksheet/tc_pivot_table_cache_definition.rb +54 -0
- data/test/workbook/worksheet/tc_row.rb +4 -4
- data/test/workbook/worksheet/tc_selection.rb +9 -48
- data/test/workbook/worksheet/tc_sheet_calc_pr.rb +18 -0
- data/test/workbook/worksheet/tc_sheet_format_pr.rb +88 -0
- data/test/workbook/worksheet/tc_sheet_pr.rb +27 -0
- data/test/workbook/worksheet/tc_sheet_view.rb +39 -39
- data/test/workbook/worksheet/{table/tc_table.rb → tc_table.rb} +8 -3
- data/test/workbook/worksheet/tc_table_style_info.rb +53 -0
- data/test/workbook/worksheet/tc_worksheet.rb +131 -16
- data/test/workbook/worksheet/tc_worksheet_hyperlink.rb +55 -0
- metadata +97 -64
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/extractive.pdf +0 -0
- data/examples/image1.gif +0 -0
- data/examples/image1.jpg +0 -0
- data/examples/image1.png +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/sample.png +0 -0
- data/examples/scraping_html.rb +0 -91
- data/examples/shared_strings_example.xlsx +0 -0
- data/examples/sheet_view.rb +0 -34
- data/examples/two_cell_anchor_image.rb +0 -11
- data/lib/axlsx/workbook/worksheet/auto_filter.rb +0 -34
|
@@ -3,6 +3,19 @@ module Axlsx
|
|
|
3
3
|
# The Scaling class defines axis scaling
|
|
4
4
|
class Scaling
|
|
5
5
|
|
|
6
|
+
include Axlsx::OptionsParser
|
|
7
|
+
|
|
8
|
+
# creates a new Scaling object
|
|
9
|
+
# @option options [Integer, Fixnum] logBase
|
|
10
|
+
# @option options [Symbol] orientation
|
|
11
|
+
# @option options [Float] max
|
|
12
|
+
# @option options [Float] min
|
|
13
|
+
def initialize(options={})
|
|
14
|
+
@orientation = :minMax
|
|
15
|
+
@logBase, @min, @max = nil, nil, nil
|
|
16
|
+
parse_options options
|
|
17
|
+
end
|
|
18
|
+
|
|
6
19
|
# logarithmic base for a logarithmic axis.
|
|
7
20
|
# must be between 2 and 1000
|
|
8
21
|
# @return [Integer]
|
|
@@ -21,19 +34,6 @@ module Axlsx
|
|
|
21
34
|
# @return [Float]
|
|
22
35
|
attr_reader :min
|
|
23
36
|
|
|
24
|
-
# creates a new Scaling object
|
|
25
|
-
# @option options [Integer, Fixnum] logBase
|
|
26
|
-
# @option options [Symbol] orientation
|
|
27
|
-
# @option options [Float] max
|
|
28
|
-
# @option options [Float] min
|
|
29
|
-
def initialize(options={})
|
|
30
|
-
@orientation = :minMax
|
|
31
|
-
@logBase, @min, @max = nil, nil, nil
|
|
32
|
-
options.each do |o|
|
|
33
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
37
|
# @see logBase
|
|
38
38
|
def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer, Fixnum], v, lambda { |arg| arg >= 2 && arg <= 1000}; @logBase = v; end
|
|
39
39
|
# @see orientation
|
|
@@ -7,39 +7,45 @@ module Axlsx
|
|
|
7
7
|
# @see README for an example
|
|
8
8
|
class ScatterChart < Chart
|
|
9
9
|
|
|
10
|
+
include Axlsx::OptionsParser
|
|
11
|
+
|
|
10
12
|
# The Style for the scatter chart
|
|
11
13
|
# must be one of :none | :line | :lineMarker | :marker | :smooth | :smoothMarker
|
|
12
14
|
# return [Symbol]
|
|
13
|
-
attr_reader :
|
|
15
|
+
attr_reader :scatter_style
|
|
16
|
+
alias :scatterStyle :scatter_style
|
|
14
17
|
|
|
15
18
|
# the x value axis
|
|
16
19
|
# @return [ValAxis]
|
|
17
|
-
|
|
20
|
+
def x_val_axis
|
|
21
|
+
axes[:x_val_axis]
|
|
22
|
+
end
|
|
23
|
+
alias :xValAxis :x_val_axis
|
|
18
24
|
|
|
19
25
|
# the y value axis
|
|
20
26
|
# @return [ValAxis]
|
|
21
|
-
|
|
27
|
+
def y_val_axis
|
|
28
|
+
axes[:x_val_axis]
|
|
29
|
+
end
|
|
30
|
+
alias :yValAxis :y_val_axis
|
|
22
31
|
|
|
23
32
|
# Creates a new scatter chart
|
|
24
33
|
def initialize(frame, options={})
|
|
25
|
-
@
|
|
26
|
-
@
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@yValAxis = ValAxis.new(@yValAxId, @xValAxId)
|
|
30
|
-
super(frame, options)
|
|
34
|
+
@vary_colors = 0
|
|
35
|
+
@scatter_style = :lineMarker
|
|
36
|
+
|
|
37
|
+
super(frame, options)
|
|
31
38
|
@series_type = ScatterSeries
|
|
32
39
|
@d_lbls = nil
|
|
33
|
-
options
|
|
34
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
35
|
-
end
|
|
40
|
+
parse_options options
|
|
36
41
|
end
|
|
37
42
|
|
|
38
43
|
# see #scatterStyle
|
|
39
|
-
def
|
|
44
|
+
def scatter_style=(v)
|
|
40
45
|
Axlsx.validate_scatter_style(v)
|
|
41
|
-
@
|
|
46
|
+
@scatter_style = v
|
|
42
47
|
end
|
|
48
|
+
alias :scatterStyle= :scatter_style=
|
|
43
49
|
|
|
44
50
|
# Serializes the object
|
|
45
51
|
# @param [String] str
|
|
@@ -47,17 +53,22 @@ module Axlsx
|
|
|
47
53
|
def to_xml_string(str = '')
|
|
48
54
|
super(str) do |str_inner|
|
|
49
55
|
str_inner << '<c:scatterChart>'
|
|
50
|
-
str_inner << '<c:scatterStyle val="' <<
|
|
51
|
-
str_inner << '<c:varyColors val="
|
|
56
|
+
str_inner << '<c:scatterStyle val="' << scatter_style.to_s << '"/>'
|
|
57
|
+
str_inner << '<c:varyColors val="' << vary_colors.to_s << '"/>'
|
|
52
58
|
@series.each { |ser| ser.to_xml_string(str_inner) }
|
|
53
|
-
d_lbls.to_xml_string(
|
|
54
|
-
str_inner
|
|
55
|
-
str_inner << '<c:axId val="' << @yValAxId.to_s << '"/>'
|
|
59
|
+
d_lbls.to_xml_string(str_inner) if @d_lbls
|
|
60
|
+
axes.to_xml_string(str_inner, :ids => true)
|
|
56
61
|
str_inner << '</c:scatterChart>'
|
|
57
|
-
|
|
58
|
-
@yValAxis.to_xml_string str_inner
|
|
62
|
+
axes.to_xml_string(str_inner)
|
|
59
63
|
end
|
|
60
64
|
str
|
|
61
65
|
end
|
|
66
|
+
|
|
67
|
+
# The axes for the scatter chart. ScatterChart has an x_val_axis and
|
|
68
|
+
# a y_val_axis
|
|
69
|
+
# @return [Axes]
|
|
70
|
+
def axes
|
|
71
|
+
@axes ||= Axes.new(:x_val_axis => ValAxis, :y_val_axis => ValAxis)
|
|
72
|
+
end
|
|
62
73
|
end
|
|
63
74
|
end
|
|
@@ -5,30 +5,29 @@ module Axlsx
|
|
|
5
5
|
|
|
6
6
|
# The number of tick lables to skip between labels
|
|
7
7
|
# @return [Integer]
|
|
8
|
-
attr_reader :
|
|
8
|
+
attr_reader :tick_lbl_skip
|
|
9
|
+
alias :tickLblSkip :tick_lbl_skip
|
|
9
10
|
|
|
10
11
|
# The number of tickmarks to be skipped before the next one is rendered.
|
|
11
12
|
# @return [Boolean]
|
|
12
|
-
attr_reader :
|
|
13
|
+
attr_reader :tick_mark_skip
|
|
14
|
+
alias :tickMarkSkip :tick_mark_skip
|
|
13
15
|
|
|
14
16
|
# Creates a new SerAxis object
|
|
15
|
-
# @
|
|
16
|
-
# @
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# @option options [Integer] tickLblSkip
|
|
21
|
-
# @option options [Integer] tickMarkSkip
|
|
22
|
-
def initialize(axId, crossAx, options={})
|
|
23
|
-
@tickLblSkip, @tickMarkSkip = 1, 1
|
|
24
|
-
super(axId, crossAx, options)
|
|
17
|
+
# @option options [Integer] tick_lbl_skip
|
|
18
|
+
# @option options [Integer] tick_mark_skip
|
|
19
|
+
def initialize(options={})
|
|
20
|
+
@tick_lbl_skip, @tick_mark_skip = 1, 1
|
|
21
|
+
super(options)
|
|
25
22
|
end
|
|
26
23
|
|
|
27
24
|
# @see tickLblSkip
|
|
28
|
-
def
|
|
25
|
+
def tick_lbl_skip=(v) Axlsx::validate_unsigned_int(v); @tick_lbl_skip = v; end
|
|
26
|
+
alias :tickLblSkip= :tick_lbl_skip=
|
|
29
27
|
|
|
30
28
|
# @see tickMarkSkip
|
|
31
|
-
def
|
|
29
|
+
def tick_mark_skip=(v) Axlsx::validate_unsigned_int(v); @tick_mark_skip = v; end
|
|
30
|
+
alias :tickMarkSkip= :tick_mark_skip=
|
|
32
31
|
|
|
33
32
|
# Serializes the object
|
|
34
33
|
# @param [String] str
|
|
@@ -36,8 +35,8 @@ module Axlsx
|
|
|
36
35
|
def to_xml_string(str = '')
|
|
37
36
|
str << '<c:serAx>'
|
|
38
37
|
super(str)
|
|
39
|
-
str << '<c:tickLblSkip val="' << @
|
|
40
|
-
str << '<c:tickMarkSkip val="' << @
|
|
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?
|
|
41
40
|
str << '</c:serAx>'
|
|
42
41
|
end
|
|
43
42
|
end
|
data/lib/axlsx/drawing/series.rb
CHANGED
|
@@ -6,6 +6,8 @@ module Axlsx
|
|
|
6
6
|
# @see Chart#add_series
|
|
7
7
|
class Series
|
|
8
8
|
|
|
9
|
+
include Axlsx::OptionsParser
|
|
10
|
+
|
|
9
11
|
# The chart that owns this series
|
|
10
12
|
# @return [Chart]
|
|
11
13
|
attr_reader :chart
|
|
@@ -22,19 +24,15 @@ module Axlsx
|
|
|
22
24
|
@order = nil
|
|
23
25
|
self.chart = chart
|
|
24
26
|
@chart.series << self
|
|
25
|
-
options
|
|
26
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
27
|
-
end
|
|
27
|
+
parse_options options
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
|
|
31
30
|
# The index of this series in the chart's series.
|
|
32
31
|
# @return [Integer]
|
|
33
32
|
def index
|
|
34
33
|
@chart.series.index(self)
|
|
35
34
|
end
|
|
36
35
|
|
|
37
|
-
|
|
38
36
|
# The order of this series in the chart's series. By default the order is the index of the series.
|
|
39
37
|
# @return [Integer]
|
|
40
38
|
def order
|
|
@@ -68,5 +66,4 @@ module Axlsx
|
|
|
68
66
|
str << '</c:ser>'
|
|
69
67
|
end
|
|
70
68
|
end
|
|
71
|
-
|
|
72
69
|
end
|
|
@@ -5,6 +5,8 @@ module Axlsx
|
|
|
5
5
|
# This class is extended for NumData to include the formatCode attribute required for numLit and numCache
|
|
6
6
|
class StrData
|
|
7
7
|
|
|
8
|
+
include Axlsx::OptionsParser
|
|
9
|
+
|
|
8
10
|
# creates a new StrVal object
|
|
9
11
|
# @option options [Array] :data
|
|
10
12
|
# @option options [String] :tag_name
|
|
@@ -12,9 +14,7 @@ module Axlsx
|
|
|
12
14
|
@tag_prefix = :str
|
|
13
15
|
@type = StrVal
|
|
14
16
|
@pt = SimpleTypedList.new(@type)
|
|
15
|
-
options
|
|
16
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
17
|
-
end
|
|
17
|
+
parse_options options
|
|
18
18
|
end
|
|
19
19
|
|
|
20
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.
|
|
@@ -4,19 +4,20 @@ module Axlsx
|
|
|
4
4
|
#This class specifies data for a particular data point.
|
|
5
5
|
class StrVal
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
# @return [String]
|
|
9
|
-
attr_reader :v
|
|
7
|
+
include Axlsx::OptionsParser
|
|
10
8
|
|
|
11
9
|
# creates a new StrVal object
|
|
12
10
|
# @option options [String] v
|
|
13
11
|
def initialize(options={})
|
|
14
12
|
@v = ""
|
|
15
13
|
@idx = 0
|
|
16
|
-
options
|
|
17
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
18
|
-
end
|
|
14
|
+
parse_options options
|
|
19
15
|
end
|
|
16
|
+
|
|
17
|
+
# a string value.
|
|
18
|
+
# @return [String]
|
|
19
|
+
attr_reader :v
|
|
20
|
+
|
|
20
21
|
# @see v
|
|
21
22
|
def v=(v)
|
|
22
23
|
@v = v.to_s
|
|
@@ -27,7 +28,5 @@ module Axlsx
|
|
|
27
28
|
Axlsx::validate_unsigned_int(idx)
|
|
28
29
|
str << '<c:pt idx="' << idx.to_s << '"><c:v>' << v.to_s << '</c:v></c:pt>'
|
|
29
30
|
end
|
|
30
|
-
|
|
31
31
|
end
|
|
32
|
-
|
|
33
32
|
end
|
|
@@ -5,6 +5,8 @@ module Axlsx
|
|
|
5
5
|
# @see Worksheet#add_chart
|
|
6
6
|
class TwoCellAnchor
|
|
7
7
|
|
|
8
|
+
include Axlsx::OptionsParser
|
|
9
|
+
|
|
8
10
|
# A marker that defines the from cell anchor. The default from column and row are 0 and 0 respectively
|
|
9
11
|
# @return [Marker]
|
|
10
12
|
attr_reader :from
|
|
@@ -34,22 +36,23 @@ module Axlsx
|
|
|
34
36
|
@drawing = drawing
|
|
35
37
|
drawing.anchors << self
|
|
36
38
|
@from, @to = Marker.new, Marker.new(:col => 5, :row=>10)
|
|
39
|
+
parse_options options
|
|
37
40
|
end
|
|
38
41
|
|
|
39
42
|
# sets the col, row attributes for the from marker.
|
|
40
43
|
# @note The recommended way to set the start position for graphical
|
|
41
44
|
# objects is directly thru the object.
|
|
42
45
|
# @see Chart#start_at
|
|
43
|
-
def start_at(x, y)
|
|
44
|
-
|
|
46
|
+
def start_at(x, y=nil)
|
|
47
|
+
from.coord x, y
|
|
45
48
|
end
|
|
46
49
|
|
|
47
50
|
# sets the col, row attributes for the to marker
|
|
48
51
|
# @note the recommended way to set the to position for graphical
|
|
49
52
|
# objects is directly thru the object
|
|
50
53
|
# @see Char#end_at
|
|
51
|
-
def end_at(x, y)
|
|
52
|
-
|
|
54
|
+
def end_at(x, y=nil)
|
|
55
|
+
to.coord x, y
|
|
53
56
|
end
|
|
54
57
|
|
|
55
58
|
# Creates a graphic frame and chart object associated with this anchor
|
|
@@ -85,28 +88,5 @@ module Axlsx
|
|
|
85
88
|
str << '<xdr:clientData/>'
|
|
86
89
|
str << '</xdr:twoCellAnchor>'
|
|
87
90
|
end
|
|
88
|
-
private
|
|
89
|
-
|
|
90
|
-
# parses coordinates and sets up a marker's row/col propery
|
|
91
|
-
def set_marker_coords(x, y, marker)
|
|
92
|
-
marker.col, marker.row = *parse_coord_args(x, y)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
# handles multiple inputs for setting the position of a marker
|
|
96
|
-
# @see Chart#start_at
|
|
97
|
-
def parse_coord_args(x, y=0)
|
|
98
|
-
if x.is_a?(String)
|
|
99
|
-
x, y = *Axlsx::name_to_indices(x)
|
|
100
|
-
end
|
|
101
|
-
if x.is_a?(Cell)
|
|
102
|
-
x, y = *x.pos
|
|
103
|
-
end
|
|
104
|
-
if x.is_a?(Array)
|
|
105
|
-
x, y = *x
|
|
106
|
-
end
|
|
107
|
-
[x, y]
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
|
|
111
91
|
end
|
|
112
92
|
end
|
|
@@ -6,21 +6,22 @@ module Axlsx
|
|
|
6
6
|
# This element specifies how the value axis crosses the category axis.
|
|
7
7
|
# must be one of [:between, :midCat]
|
|
8
8
|
# @return [Symbol]
|
|
9
|
-
attr_reader :
|
|
9
|
+
attr_reader :cross_between
|
|
10
|
+
alias :crossBetween :cross_between
|
|
10
11
|
|
|
11
12
|
# Creates a new ValAxis object
|
|
12
|
-
# @
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# @option options [Symbol] crosses
|
|
17
|
-
# @option options [Symbol] crossesBetween
|
|
18
|
-
def initialize(axId, crossAx, options={})
|
|
19
|
-
self.crossBetween = :between
|
|
20
|
-
super(axId, crossAx, options)
|
|
13
|
+
# @option options [Symbol] crosses_between
|
|
14
|
+
def initialize(options={})
|
|
15
|
+
self.cross_between = :between
|
|
16
|
+
super(options)
|
|
21
17
|
end
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
|
|
19
|
+
# @see cross_between
|
|
20
|
+
def cross_between=(v)
|
|
21
|
+
RestrictionValidator.validate "ValAxis.cross_between", [:between, :midCat], v
|
|
22
|
+
@cross_between = v
|
|
23
|
+
end
|
|
24
|
+
alias :crossBetween= :cross_between=
|
|
24
25
|
|
|
25
26
|
# Serializes the object
|
|
26
27
|
# @param [String] str
|
|
@@ -28,7 +29,7 @@ module Axlsx
|
|
|
28
29
|
def to_xml_string(str = '')
|
|
29
30
|
str << '<c:valAx>'
|
|
30
31
|
super(str)
|
|
31
|
-
str << '<c:crossBetween val="' << @
|
|
32
|
+
str << '<c:crossBetween val="' << @cross_between.to_s << '"/>'
|
|
32
33
|
str << '</c:valAx>'
|
|
33
34
|
end
|
|
34
35
|
|
|
@@ -3,6 +3,20 @@ module Axlsx
|
|
|
3
3
|
# 3D attributes for a chart.
|
|
4
4
|
class View3D
|
|
5
5
|
|
|
6
|
+
include Axlsx::OptionsParser
|
|
7
|
+
|
|
8
|
+
# Creates a new View3D for charts
|
|
9
|
+
# @option options [Integer] rot_x
|
|
10
|
+
# @option options [String] h_percent
|
|
11
|
+
# @option options [Integer] rot_y
|
|
12
|
+
# @option options [String] depth_percent
|
|
13
|
+
# @option options [Boolean] r_ang_ax
|
|
14
|
+
# @option options [Integer] perspective
|
|
15
|
+
def initialize(options={})
|
|
16
|
+
@rot_x, @h_percent, @rot_y, @depth_percent, @r_ang_ax, @perspective = nil, nil, nil, nil, nil, nil
|
|
17
|
+
parse_options options
|
|
18
|
+
end
|
|
19
|
+
|
|
6
20
|
# Validation for hPercent
|
|
7
21
|
H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)/
|
|
8
22
|
|
|
@@ -14,8 +28,8 @@ module Axlsx
|
|
|
14
28
|
# @return [Integer]
|
|
15
29
|
attr_reader :rot_x
|
|
16
30
|
alias :rotX :rot_x
|
|
17
|
-
|
|
18
|
-
# height of chart as % of chart
|
|
31
|
+
|
|
32
|
+
# height of chart as % of chart width
|
|
19
33
|
# must be between 5% and 500%
|
|
20
34
|
# @return [String]
|
|
21
35
|
attr_reader :h_percent
|
|
@@ -26,7 +40,7 @@ module Axlsx
|
|
|
26
40
|
# @return [Integer]
|
|
27
41
|
attr_reader :rot_y
|
|
28
42
|
alias :rotY :rot_y
|
|
29
|
-
|
|
43
|
+
|
|
30
44
|
# depth or chart as % of chart width
|
|
31
45
|
# must be between 20% and 2000%
|
|
32
46
|
# @return [String]
|
|
@@ -42,60 +56,60 @@ module Axlsx
|
|
|
42
56
|
# @return [Integer]
|
|
43
57
|
attr_reader :perspective
|
|
44
58
|
|
|
45
|
-
# Creates a new View3D for charts
|
|
46
|
-
# @option options [Integer] rot_x
|
|
47
|
-
# @option options [String] h_percent
|
|
48
|
-
# @option options [Integer] rot_y
|
|
49
|
-
# @option options [String] depth_percent
|
|
50
|
-
# @option options [Boolean] r_ang_ax
|
|
51
|
-
# @option options [Integer] perspective
|
|
52
|
-
def initialize(options={})
|
|
53
|
-
@rot_x, @h_percent, @rot_y, @depth_percent, @r_ang_ax, @perspective = nil, nil, nil, nil, nil, nil
|
|
54
|
-
options.each do |o|
|
|
55
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
59
|
# @see rot_x
|
|
60
|
-
def rot_x=(v)
|
|
60
|
+
def rot_x=(v)
|
|
61
|
+
RangeValidator.validate "View3D.rot_x", -90, 90, v
|
|
62
|
+
@rot_x = v
|
|
63
|
+
end
|
|
61
64
|
alias :rotX= :rot_x=
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
# @see h_percent
|
|
67
|
+
def h_percent=(v)
|
|
68
|
+
RegexValidator.validate "#{self.class}.h_percent", H_PERCENT_REGEX, v
|
|
69
|
+
@h_percent = v
|
|
70
|
+
end
|
|
68
71
|
alias :hPercent= :h_percent=
|
|
69
72
|
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
# @see rot_y
|
|
74
|
+
def rot_y=(v)
|
|
75
|
+
RangeValidator.validate "View3D.rot_y", 0, 360, v
|
|
76
|
+
@rot_y = v
|
|
77
|
+
end
|
|
72
78
|
alias :rotY= :rot_y=
|
|
73
79
|
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
# @see depth_percent
|
|
81
|
+
def depth_percent=(v) RegexValidator.validate "#{self.class}.depth_percent", DEPTH_PERCENT_REGEX, v; @depth_percent = v; end
|
|
76
82
|
alias :depthPercent= :depth_percent=
|
|
77
83
|
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
# @see r_ang_ax
|
|
85
|
+
def r_ang_ax=(v) Axlsx::validate_boolean(v); @r_ang_ax = v; end
|
|
80
86
|
alias :rAngAx= :r_ang_ax=
|
|
81
|
-
|
|
82
|
-
# @see perspective
|
|
83
|
-
def perspective=(v) DataTypeValidator.validate "#{self.class}.perspective", [Integer, Fixnum], v, lambda {|arg| arg >= 0 && arg <= 240 }; @perspective = v; end
|
|
84
87
|
|
|
88
|
+
# @see perspective
|
|
89
|
+
def perspective=(v)
|
|
90
|
+
RangeValidator.validate "View3D.perspective", 0, 240, v
|
|
91
|
+
@perspective = v
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# DataTypeValidator.validate "#{self.class}.perspective", [Integer, Fixnum], v, lambda {|arg| arg >= 0 && arg <= 240 }; @perspective = v; end
|
|
85
95
|
|
|
86
96
|
# Serializes the object
|
|
87
97
|
# @param [String] str
|
|
88
98
|
# @return [String]
|
|
89
99
|
def to_xml_string(str = '')
|
|
90
100
|
str << '<c:view3D>'
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
str << '<c:depthPercent val="' << @depth_percent.to_s << '"/>' unless @depth_percent.nil?
|
|
95
|
-
str << '<c:rAngAx val="' << @r_ang_ax.to_s << '"/>' unless @r_ang_ax.nil?
|
|
96
|
-
str << '<c:perspective val="' << @perspective.to_s << '"/>' unless @perspective.nil?
|
|
101
|
+
%w(rot_x h_percent rot_y depth_percent r_ang_ax perspective).each do |key|
|
|
102
|
+
str << element_for_attribute(key, 'c')
|
|
103
|
+
end
|
|
97
104
|
str << '</c:view3D>'
|
|
98
105
|
end
|
|
99
106
|
|
|
107
|
+
private
|
|
108
|
+
# Note: move this to Axlsx module if we find the smae pattern elsewhere.
|
|
109
|
+
def element_for_attribute(name, namespace='')
|
|
110
|
+
val = instance_values[name]
|
|
111
|
+
return "" if val == nil
|
|
112
|
+
"<%s:%s val='%s'/>" % [namespace, Axlsx::camel(name, false), val]
|
|
113
|
+
end
|
|
100
114
|
end
|
|
101
115
|
end
|
|
@@ -3,96 +3,36 @@ module Axlsx
|
|
|
3
3
|
# A VmlShape is used to position and render a comment.
|
|
4
4
|
class VmlShape
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
attr_reader :row
|
|
9
|
-
|
|
10
|
-
# The column anchor position for this shape determined by the comment's ref value
|
|
11
|
-
# @return [Integer]
|
|
12
|
-
attr_reader :column
|
|
13
|
-
|
|
14
|
-
# The left column for this shape
|
|
15
|
-
# @return [Integer]
|
|
16
|
-
attr_reader :left_column
|
|
17
|
-
|
|
18
|
-
# The left offset for this shape
|
|
19
|
-
# @return [Integer]
|
|
20
|
-
attr_reader :left_offset
|
|
21
|
-
|
|
22
|
-
# The top row for this shape
|
|
23
|
-
# @return [Integer]
|
|
24
|
-
attr_reader :top_row
|
|
25
|
-
|
|
26
|
-
# The top offset for this shape
|
|
27
|
-
# @return [Integer]
|
|
28
|
-
attr_reader :top_offset
|
|
29
|
-
|
|
30
|
-
# The right column for this shape
|
|
31
|
-
# @return [Integer]
|
|
32
|
-
attr_reader :right_column
|
|
33
|
-
|
|
34
|
-
# The right offset for this shape
|
|
35
|
-
# @return [Integer]
|
|
36
|
-
attr_reader :right_offset
|
|
37
|
-
|
|
38
|
-
# The botttom row for this shape
|
|
39
|
-
# @return [Integer]
|
|
40
|
-
attr_reader :bottom_row
|
|
41
|
-
|
|
42
|
-
# The bottom offset for this shape
|
|
43
|
-
# @return [Integer]
|
|
44
|
-
attr_reader :bottom_offset
|
|
6
|
+
include Axlsx::OptionsParser
|
|
7
|
+
include Axlsx::Accessors
|
|
45
8
|
|
|
46
9
|
# Creates a new VmlShape
|
|
47
|
-
# @option options [Integer
|
|
48
|
-
# @option options [Integer
|
|
49
|
-
# @option options [Integer
|
|
50
|
-
# @option options [Integer
|
|
51
|
-
# @option options [Integer
|
|
52
|
-
# @option options [Integer
|
|
53
|
-
# @option options [Integer
|
|
54
|
-
# @option options [Integer
|
|
10
|
+
# @option options [Integer] row
|
|
11
|
+
# @option options [Integer] column
|
|
12
|
+
# @option options [Integer] left_column
|
|
13
|
+
# @option options [Integer] left_offset
|
|
14
|
+
# @option options [Integer] top_row
|
|
15
|
+
# @option options [Integer] top_offset
|
|
16
|
+
# @option options [Integer] right_column
|
|
17
|
+
# @option options [Integer] right_offset
|
|
18
|
+
# @option options [Integer] bottom_row
|
|
19
|
+
# @option options [Integer] bottom_offset
|
|
55
20
|
def initialize(options={})
|
|
56
21
|
@row = @column = @left_column = @top_row = @right_column = @bottom_row = 0
|
|
57
22
|
@left_offset = 15
|
|
58
23
|
@top_offset = 2
|
|
59
24
|
@right_offset = 50
|
|
60
25
|
@bottom_offset = 5
|
|
26
|
+
@visible = true
|
|
61
27
|
@id = (0...8).map{65.+(rand(25)).chr}.join
|
|
62
|
-
options
|
|
63
|
-
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
64
|
-
end
|
|
28
|
+
parse_options options
|
|
65
29
|
yield self if block_given?
|
|
66
30
|
end
|
|
67
31
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
# @see row
|
|
72
|
-
def row=(v); Axlsx::validate_integerish(v); @row = v.to_i end
|
|
73
|
-
# @see left_column
|
|
74
|
-
def left_column=(v); Axlsx::validate_integerish(v); @left_column = v.to_i end
|
|
75
|
-
|
|
76
|
-
# @see left_offset
|
|
77
|
-
def left_offset=(v); Axlsx::validate_integerish(v); @left_offset = v.to_i end
|
|
78
|
-
|
|
79
|
-
# @see top_row
|
|
80
|
-
def top_row=(v); Axlsx::validate_integerish(v); @top_row = v.to_i end
|
|
81
|
-
|
|
82
|
-
# @see top_offset
|
|
83
|
-
def top_offset=(v); Axlsx::validate_integerish(v); @top_offset = v.to_i end
|
|
84
|
-
|
|
85
|
-
# @see right_column
|
|
86
|
-
def right_column=(v); Axlsx::validate_integerish(v); @right_column = v.to_i end
|
|
87
|
-
|
|
88
|
-
# @see right_offset
|
|
89
|
-
def right_offset=(v); Axlsx::validate_integerish(v); @right_offset = v.to_i end
|
|
90
|
-
|
|
91
|
-
# @see bottom_row
|
|
92
|
-
def bottom_row=(v); Axlsx::validate_integerish(v); @bottom_row = v.to_i end
|
|
32
|
+
unsigned_int_attr_accessor :row, :column, :left_column, :left_offset, :top_row, :top_offset,
|
|
33
|
+
:right_column, :right_offset, :bottom_row, :bottom_offset
|
|
93
34
|
|
|
94
|
-
|
|
95
|
-
def bottom_offset=(v); Axlsx::validate_integerish(v); @bottom_offset = v.to_i end
|
|
35
|
+
boolean_attr_accessor :visible
|
|
96
36
|
|
|
97
37
|
# serialize the shape to a string
|
|
98
38
|
# @param [String] str
|
|
@@ -100,7 +40,8 @@ module Axlsx
|
|
|
100
40
|
def to_xml_string(str ='')
|
|
101
41
|
str << <<SHAME_ON_YOU
|
|
102
42
|
|
|
103
|
-
<v:shape id="#{@id}" type="#_x0000_t202" fillcolor="#ffffa1 [80]" o:insetmode="auto"
|
|
43
|
+
<v:shape id="#{@id}" type="#_x0000_t202" fillcolor="#ffffa1 [80]" o:insetmode="auto"
|
|
44
|
+
style="visibility:#{@visible ? 'visible' : 'hidden'}">
|
|
104
45
|
<v:fill color2="#ffffa1 [80]"/>
|
|
105
46
|
<v:shadow on="t" obscured="t"/>
|
|
106
47
|
<v:path o:connecttype="none"/>
|
|
@@ -115,7 +56,7 @@ str << <<SHAME_ON_YOU
|
|
|
115
56
|
<x:AutoFill>False</x:AutoFill>
|
|
116
57
|
<x:Row>#{row}</x:Row>
|
|
117
58
|
<x:Column>#{column}</x:Column>
|
|
118
|
-
<x:Visible/>
|
|
59
|
+
#{@visible ? '<x:Visible/>' : ''}
|
|
119
60
|
</x:ClientData>
|
|
120
61
|
</v:shape>
|
|
121
62
|
SHAME_ON_YOU
|