axlsx 1.0.15 → 1.1.1
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.
- data/.yardopts +1 -0
- data/CHANGELOG.md +58 -2
- data/README.md +425 -207
- data/Rakefile +6 -2
- data/examples/axlsx.xlsx +0 -0
- data/examples/example.csv +1000 -0
- data/examples/example.rb +266 -132
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/real_example.rb +63 -0
- data/examples/sample.png +0 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/lib/axlsx/content_type/content_type.rb +13 -12
- data/lib/axlsx/content_type/default.rb +10 -6
- data/lib/axlsx/content_type/override.rb +13 -8
- data/lib/axlsx/doc_props/app.rb +38 -41
- data/lib/axlsx/doc_props/core.rb +13 -17
- data/lib/axlsx/drawing/axis.rb +39 -19
- data/lib/axlsx/drawing/bar_3D_chart.rb +34 -32
- data/lib/axlsx/drawing/bar_series.rb +14 -14
- data/lib/axlsx/drawing/cat_axis.rb +16 -14
- data/lib/axlsx/drawing/cat_axis_data.rb +17 -18
- data/lib/axlsx/drawing/chart.rb +40 -41
- data/lib/axlsx/drawing/drawing.rb +27 -12
- data/lib/axlsx/drawing/graphic_frame.rb +22 -21
- data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
- data/lib/axlsx/drawing/hyperlink.rb +96 -0
- data/lib/axlsx/drawing/hyperlink.rb~ +64 -0
- data/lib/axlsx/drawing/line_3D_chart.rb +31 -28
- data/lib/axlsx/drawing/line_series.rb +12 -11
- data/lib/axlsx/drawing/marker.rb +11 -8
- data/lib/axlsx/drawing/named_axis_data.rb +36 -0
- data/lib/axlsx/drawing/one_cell_anchor.rb +18 -16
- data/lib/axlsx/drawing/pic.rb +47 -33
- data/lib/axlsx/drawing/picture_locking.rb +22 -18
- data/lib/axlsx/drawing/pie_3D_chart.rb +11 -8
- data/lib/axlsx/drawing/pie_series.rb +16 -12
- data/lib/axlsx/drawing/scaling.rb +11 -10
- data/lib/axlsx/drawing/scatter_chart.rb +69 -0
- data/lib/axlsx/drawing/scatter_series.rb +39 -0
- data/lib/axlsx/drawing/ser_axis.rb +11 -10
- data/lib/axlsx/drawing/series.rb +16 -15
- data/lib/axlsx/drawing/series_title.rb +15 -14
- data/lib/axlsx/drawing/title.rb +27 -26
- data/lib/axlsx/drawing/two_cell_anchor.rb +19 -20
- data/lib/axlsx/drawing/val_axis.rb +9 -7
- data/lib/axlsx/drawing/val_axis_data.rb +18 -17
- data/lib/axlsx/drawing/view_3D.rb +23 -20
- data/lib/axlsx/package.rb +117 -52
- data/lib/axlsx/rels/relationship.rb +27 -8
- data/lib/axlsx/rels/relationships.rb +9 -2
- data/lib/axlsx/stylesheet/border.rb +28 -23
- data/lib/axlsx/stylesheet/border_pr.rb +17 -15
- data/lib/axlsx/stylesheet/cell_alignment.rb +24 -21
- data/lib/axlsx/stylesheet/cell_protection.rb +11 -7
- data/lib/axlsx/stylesheet/cell_style.rb +9 -5
- data/lib/axlsx/stylesheet/color.rb +20 -14
- data/lib/axlsx/stylesheet/fill.rb +8 -5
- data/lib/axlsx/stylesheet/font.rb +22 -14
- data/lib/axlsx/stylesheet/gradient_fill.rb +20 -17
- data/lib/axlsx/stylesheet/gradient_stop.rb +10 -6
- data/lib/axlsx/stylesheet/num_fmt.rb +13 -6
- data/lib/axlsx/stylesheet/pattern_fill.rb +26 -10
- data/lib/axlsx/stylesheet/styles.rb +55 -41
- data/lib/axlsx/stylesheet/table_style.rb +10 -4
- data/lib/axlsx/stylesheet/table_style_element.rb +11 -7
- data/lib/axlsx/stylesheet/table_styles.rb +12 -8
- data/lib/axlsx/stylesheet/xf.rb +30 -25
- data/lib/axlsx/util/cbf.rb +69 -33
- data/lib/axlsx/util/constants.rb +39 -20
- data/lib/axlsx/util/doc/_index.html +84 -0
- data/lib/axlsx/util/doc/class_list.html +47 -0
- data/lib/axlsx/util/doc/css/common.css +1 -0
- data/lib/axlsx/util/doc/css/full_list.css +55 -0
- data/lib/axlsx/util/doc/css/style.css +322 -0
- data/lib/axlsx/util/doc/file_list.html +46 -0
- data/lib/axlsx/util/doc/frames.html +13 -0
- data/lib/axlsx/util/doc/index.html +84 -0
- data/lib/axlsx/util/doc/js/app.js +205 -0
- data/lib/axlsx/util/doc/js/full_list.js +173 -0
- data/lib/axlsx/util/doc/js/jquery.js +16 -0
- data/lib/axlsx/util/doc/method_list.html +46 -0
- data/lib/axlsx/util/doc/top-level-namespace.html +95 -0
- data/lib/axlsx/util/font_tables.rb~ +0 -0
- data/lib/axlsx/util/ms_off_crypto.rb +10 -10
- data/lib/axlsx/util/parser.rb +1 -0
- data/lib/axlsx/util/simple_typed_list.rb +20 -10
- data/lib/axlsx/util/storage.rb +1 -1
- data/lib/axlsx/util/validators.rb +23 -7
- data/lib/axlsx/version.rb +5 -2
- data/lib/axlsx/workbook/shared_strings_table.rb +68 -0
- data/lib/axlsx/workbook/shared_strings_table.rb~ +69 -0
- data/lib/axlsx/workbook/workbook.rb +82 -26
- data/lib/axlsx/workbook/worksheet/cell.rb +166 -130
- data/lib/axlsx/workbook/worksheet/col.rb +114 -0
- data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/date_time_converter.rb +29 -0
- data/lib/axlsx/workbook/worksheet/page_margins.rb +97 -0
- data/lib/axlsx/workbook/worksheet/row.rb +53 -21
- data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
- data/lib/axlsx/workbook/worksheet/table.rb +96 -0
- data/lib/axlsx/workbook/worksheet/table.rb~ +97 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +275 -124
- data/lib/axlsx.rb +41 -14
- data/lib/schema/dc.xsd +5 -5
- data/lib/schema/dcmitype.xsd +5 -3
- data/lib/schema/dcterms.xsd +15 -15
- data/lib/schema/opc-coreProperties.xsd +6 -2
- data/lib/schema/xml.xsd +7 -8
- data/test/benchmark.rb +73 -0
- data/test/content_type/tc_content_type.rb +31 -31
- data/test/content_type/tc_default.rb +9 -22
- data/test/content_type/tc_override.rb +8 -21
- data/test/doc_props/tc_app.rb +2 -8
- data/test/doc_props/tc_core.rb +6 -7
- data/test/drawing/tc_axis.rb +7 -3
- data/test/drawing/tc_bar_3D_chart.rb +6 -7
- data/test/drawing/tc_bar_series.rb +4 -5
- data/test/drawing/tc_cat_axis.rb +2 -3
- data/test/drawing/tc_cat_axis_data.rb +2 -3
- data/test/drawing/tc_chart.rb +13 -14
- data/test/drawing/tc_drawing.rb +7 -8
- data/test/drawing/tc_graphic_frame.rb +3 -4
- data/test/drawing/tc_hyperlink.rb +69 -0
- data/test/drawing/tc_line_3d_chart.rb +5 -6
- data/test/drawing/tc_line_series.rb +3 -4
- data/test/drawing/tc_marker.rb +3 -4
- data/test/drawing/tc_one_cell_anchor.rb +6 -7
- data/test/drawing/tc_pic.rb +13 -8
- data/test/drawing/tc_picture_locking.rb +2 -3
- data/test/drawing/tc_pie_3D_chart.rb +5 -6
- data/test/drawing/tc_pie_series.rb +4 -5
- data/test/drawing/tc_scaling.rb +3 -4
- data/test/drawing/tc_scatter_chart.rb +43 -0
- data/test/drawing/tc_scatter_series.rb +20 -0
- data/test/drawing/tc_ser_axis.rb +2 -3
- data/test/drawing/tc_series.rb +4 -5
- data/test/drawing/tc_series_title.rb +4 -5
- data/test/drawing/tc_title.rb +4 -5
- data/test/drawing/tc_two_cell_anchor.rb +4 -5
- data/test/drawing/tc_val_axis.rb +2 -3
- data/test/drawing/tc_val_axis_data.rb +2 -3
- data/test/drawing/tc_view_3D.rb +6 -7
- data/test/profile.rb +34 -0
- data/test/rels/tc_relationship.rb +10 -6
- data/test/rels/tc_relationships.rb +4 -5
- data/test/stylesheet/tc_border.rb +3 -4
- data/test/stylesheet/tc_border_pr.rb +3 -4
- data/test/stylesheet/tc_cell_alignment.rb +10 -6
- data/test/stylesheet/tc_cell_protection.rb +2 -3
- data/test/stylesheet/tc_cell_style.rb +2 -3
- data/test/stylesheet/tc_color.rb +2 -3
- data/test/stylesheet/tc_fill.rb +1 -2
- data/test/stylesheet/tc_font.rb +12 -5
- data/test/stylesheet/tc_gradient_fill.rb +1 -2
- data/test/stylesheet/tc_gradient_stop.rb +1 -2
- data/test/stylesheet/tc_num_fmt.rb +1 -2
- data/test/stylesheet/tc_pattern_fill.rb +3 -4
- data/test/stylesheet/tc_styles.rb +31 -6
- data/test/stylesheet/tc_table_style.rb +2 -3
- data/test/stylesheet/tc_table_style_element.rb +2 -3
- data/test/stylesheet/tc_table_styles.rb +3 -4
- data/test/stylesheet/tc_xf.rb +16 -17
- data/test/tc_axlsx.rb +39 -0
- data/test/tc_helper.rb +3 -0
- data/test/tc_package.rb +43 -9
- data/test/util/tc_simple_typed_list.rb +8 -9
- data/test/util/tc_validators.rb +7 -8
- data/test/workbook/tc_shared_strings_table.rb +38 -0
- data/test/workbook/tc_workbook.rb +32 -6
- data/test/workbook/worksheet/table/tc_table.rb +71 -0
- data/test/workbook/worksheet/table/tc_table.rb~ +72 -0
- data/test/workbook/worksheet/tc_cell.rb +80 -13
- data/test/workbook/worksheet/tc_col.rb +59 -0
- data/test/workbook/worksheet/tc_col.rb~ +10 -0
- data/test/workbook/worksheet/tc_date_time_converter.rb +132 -0
- data/test/workbook/worksheet/tc_page_margins.rb +97 -0
- data/test/workbook/worksheet/tc_row.rb +54 -4
- data/test/workbook/worksheet/tc_worksheet.rb +205 -31
- metadata +78 -84
- data/examples/example.rb~ +0 -112
- data/test/drawing/tc_line_series.tc~ +0 -34
- data/test/drawing/tc_picture_locking.rb~ +0 -77
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# TODO: review cat, val and named access data to extend this and reduce replicated code.
|
|
3
|
+
module Axlsx
|
|
4
|
+
# The ValAxisData class manages the values for a chart value series.
|
|
5
|
+
class NamedAxisData < CatAxisData
|
|
6
|
+
|
|
7
|
+
# creates a new NamedAxisData Object
|
|
8
|
+
# @param [String] name The serialized node name for the axis data object
|
|
9
|
+
# @param [Array] The data to associate with the axis data object
|
|
10
|
+
def initialize(name, data=[])
|
|
11
|
+
super(data)
|
|
12
|
+
@name = name
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Serializes the object
|
|
16
|
+
# @param [String] str
|
|
17
|
+
# @return [String]
|
|
18
|
+
def to_xml_string(str = '')
|
|
19
|
+
str << '<c:' << @name.to_s << '>'
|
|
20
|
+
str << '<c:numRef>'
|
|
21
|
+
str << '<c:f>' << Axlsx::cell_range(@list) << '</c:f>'
|
|
22
|
+
str << '<c:numCache>'
|
|
23
|
+
str << '<c:formatCode>General</c:formatCode>'
|
|
24
|
+
str << '<c:ptCount val="' << size.to_s << '"/>'
|
|
25
|
+
each_with_index do |item, index|
|
|
26
|
+
v = item.is_a?(Cell) ? item.value.to_s : item
|
|
27
|
+
str << '<c:pt idx="' << index.to_s << '"><c:v>' << v << '</c:v></c:pt>'
|
|
28
|
+
end
|
|
29
|
+
str << '</c:numCache>'
|
|
30
|
+
str << '</c:numRef>'
|
|
31
|
+
str << '</c:' << @name.to_s << '>'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
3
|
# This class details a single cell anchor for drawings.
|
|
3
4
|
# @note The recommended way to manage drawings, images and charts is Worksheet#add_chart or Worksheet#add_image.
|
|
@@ -32,15 +33,15 @@ module Axlsx
|
|
|
32
33
|
# @param [Drawing] drawing
|
|
33
34
|
# @option options [Array] start_at the col, row to start at
|
|
34
35
|
# @option options [Integer] width
|
|
35
|
-
# @option options [Integer] height
|
|
36
|
+
# @option options [Integer] height
|
|
36
37
|
# @option options [String] image_src the file location of the image you will render
|
|
37
38
|
# @option options [String] name the name attribute for the rendered image
|
|
38
|
-
# @option options [String] descr the description of the image rendered
|
|
39
|
+
# @option options [String] descr the description of the image rendered
|
|
39
40
|
def initialize(drawing, options={})
|
|
40
41
|
@drawing = drawing
|
|
41
42
|
@width = 0
|
|
42
43
|
@height = 0
|
|
43
|
-
drawing.anchors << self
|
|
44
|
+
drawing.anchors << self
|
|
44
45
|
@from = Marker.new
|
|
45
46
|
options.each do |o|
|
|
46
47
|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
@@ -60,23 +61,24 @@ module Axlsx
|
|
|
60
61
|
@drawing.anchors.index(self)
|
|
61
62
|
end
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
#
|
|
64
|
+
|
|
65
|
+
# Serializes the object
|
|
66
|
+
# @param [String] str
|
|
65
67
|
# @return [String]
|
|
66
|
-
def
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
end
|
|
68
|
+
def to_xml_string(str = '')
|
|
69
|
+
str << '<xdr:oneCellAnchor>'
|
|
70
|
+
str << '<xdr:from>'
|
|
71
|
+
from.to_xml_string(str)
|
|
72
|
+
str << '</xdr:from>'
|
|
73
|
+
str << '<xdr:ext cx="' << ext[:cx].to_s << '" cy="' << ext[:cy].to_s << '"/>'
|
|
74
|
+
@object.to_xml_string(str)
|
|
75
|
+
str << '<xdr:clientData/>'
|
|
76
|
+
str << '</xdr:oneCellAnchor>'
|
|
77
|
+
end
|
|
76
78
|
|
|
77
79
|
private
|
|
78
80
|
|
|
79
|
-
# converts the pixel width and height to EMU units and returns a hash of
|
|
81
|
+
# converts the pixel width and height to EMU units and returns a hash of
|
|
80
82
|
# !{:cx=>[Integer], :cy=>[Integer]
|
|
81
83
|
# @return [Hash]
|
|
82
84
|
def ext
|
data/lib/axlsx/drawing/pic.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# encoding: UTF-8
|
|
2
2
|
module Axlsx
|
|
3
3
|
# a Pic object represents an image in your worksheet
|
|
4
4
|
# Worksheet#add_image is the recommended way to manage images in your sheets
|
|
@@ -28,7 +28,7 @@ module Axlsx
|
|
|
28
28
|
|
|
29
29
|
# The picture locking attributes for this picture
|
|
30
30
|
attr_reader :picture_locking
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
# Creates a new Pic(ture) object
|
|
33
33
|
# @param [Anchor] anchor the anchor that holds this image
|
|
34
34
|
# @option options [String] name
|
|
@@ -39,6 +39,7 @@ module Axlsx
|
|
|
39
39
|
# @option options [Intger] height
|
|
40
40
|
def initialize(anchor, options={})
|
|
41
41
|
@anchor = anchor
|
|
42
|
+
@hyperlink = nil
|
|
42
43
|
@anchor.drawing.worksheet.workbook.images << self
|
|
43
44
|
options.each do |o|
|
|
44
45
|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
@@ -47,8 +48,25 @@ module Axlsx
|
|
|
47
48
|
yield self if block_given?
|
|
48
49
|
@picture_locking = PictureLocking.new(options)
|
|
49
50
|
end
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
attr_reader :hyperlink
|
|
53
|
+
|
|
54
|
+
# sets or updates a hyperlink for this image.
|
|
55
|
+
# @param [String] v The href value for the hyper link
|
|
56
|
+
# @option options @see Hyperlink#initialize All options available to the Hyperlink class apply - however href will be overridden with the v parameter value.
|
|
57
|
+
def hyperlink=(v, options={})
|
|
58
|
+
options[:href] = v
|
|
59
|
+
if @hyperlink.is_a?(Hyperlink)
|
|
60
|
+
options.each do |o|
|
|
61
|
+
@hyperlink.send("#{o[0]}=", o[1]) if @hyperlink.respond_to? "#{o[0]}="
|
|
62
|
+
end
|
|
63
|
+
else
|
|
64
|
+
@hyperlink = Hyperlink.new(self, options)
|
|
65
|
+
end
|
|
66
|
+
@hyperlink
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def image_src=(v)
|
|
52
70
|
Axlsx::validate_string(v)
|
|
53
71
|
RestrictionValidator.validate 'Pic.image_src', ALLOWED_EXTENSIONS, File.extname(v).delete('.')
|
|
54
72
|
raise ArgumentError, "File does not exist" unless File.exist?(v)
|
|
@@ -66,8 +84,8 @@ module Axlsx
|
|
|
66
84
|
# @return [String]
|
|
67
85
|
def file_name
|
|
68
86
|
File.basename(image_src) unless image_src.nil?
|
|
69
|
-
end
|
|
70
|
-
|
|
87
|
+
end
|
|
88
|
+
|
|
71
89
|
# returns the extension of image_src without the preceeding '.'
|
|
72
90
|
# @return [String]
|
|
73
91
|
def extname
|
|
@@ -86,6 +104,11 @@ module Axlsx
|
|
|
86
104
|
"#{IMAGE_PN % [(index+1), extname]}"
|
|
87
105
|
end
|
|
88
106
|
|
|
107
|
+
# The relational id withing the drawing's relationships
|
|
108
|
+
def id
|
|
109
|
+
@anchor.drawing.charts.size + @anchor.drawing.images.index(self) + 1
|
|
110
|
+
end
|
|
111
|
+
|
|
89
112
|
# providing access to the anchor's width attribute
|
|
90
113
|
# @param [Integer] v
|
|
91
114
|
# @see OneCellAnchor.width
|
|
@@ -97,7 +120,7 @@ module Axlsx
|
|
|
97
120
|
def width=(v)
|
|
98
121
|
@anchor.width = v
|
|
99
122
|
end
|
|
100
|
-
|
|
123
|
+
|
|
101
124
|
# providing access to update the anchor's height attribute
|
|
102
125
|
# @param [Integer] v
|
|
103
126
|
# @see OneCellAnchor.width
|
|
@@ -121,33 +144,24 @@ module Axlsx
|
|
|
121
144
|
@anchor.from.row = y
|
|
122
145
|
end
|
|
123
146
|
|
|
124
|
-
# Serializes the
|
|
125
|
-
# @param [
|
|
147
|
+
# Serializes the object
|
|
148
|
+
# @param [String] str
|
|
126
149
|
# @return [String]
|
|
127
|
-
def
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
xml.spPr {
|
|
142
|
-
xml[:a].xfrm {
|
|
143
|
-
xml.off :x=>0, :y=>0
|
|
144
|
-
xml.ext :cx=>2336800, :cy=>2161540
|
|
145
|
-
}
|
|
146
|
-
xml[:a].prstGeom(:prst=>:rect) {
|
|
147
|
-
xml.avLst
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
150
|
+
def to_xml_string(str = '')
|
|
151
|
+
str << '<xdr:pic>'
|
|
152
|
+
str << '<xdr:nvPicPr>'
|
|
153
|
+
str << '<xdr:cNvPr id="2" name="' << name.to_s << '" descr="' << descr.to_s << '">'
|
|
154
|
+
@hyperlink.to_xml_string(str) if @hyperlink.is_a?(Hyperlink)
|
|
155
|
+
str << '</xdr:cNvPr><xdr:cNvPicPr>'
|
|
156
|
+
picture_locking.to_xml_string(str)
|
|
157
|
+
str << '</xdr:cNvPicPr></xdr:nvPicPr>'
|
|
158
|
+
str << '<xdr:blipFill>'
|
|
159
|
+
str << '<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="rId' << id.to_s << '"/>'
|
|
160
|
+
str << '<a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr>'
|
|
161
|
+
str << '<a:xfrm><a:off x="0" y="0"/><a:ext cx="2336800" cy="2161540"/></a:xfrm>'
|
|
162
|
+
str << '<a:prstGeom prst="rect"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic>'
|
|
163
|
+
|
|
151
164
|
end
|
|
165
|
+
|
|
152
166
|
end
|
|
153
167
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
|
-
# The picture locking class defines the locking properties for pictures in your workbook.
|
|
3
|
+
# The picture locking class defines the locking properties for pictures in your workbook.
|
|
3
4
|
class PictureLocking
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
|
|
6
7
|
attr_reader :noGrp
|
|
7
8
|
attr_reader :noSelect
|
|
8
9
|
attr_reader :noRot
|
|
@@ -30,43 +31,46 @@ module Axlsx
|
|
|
30
31
|
options.each do |o|
|
|
31
32
|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
32
33
|
end
|
|
33
|
-
end
|
|
34
|
+
end
|
|
34
35
|
|
|
35
36
|
# @see noGrp
|
|
36
|
-
def noGrp=(v) Axlsx::validate_boolean v; @noGrp = v end
|
|
37
|
+
def noGrp=(v) Axlsx::validate_boolean v; @noGrp = v end
|
|
37
38
|
|
|
38
39
|
# @see noSelect
|
|
39
|
-
def noSelect=(v) Axlsx::validate_boolean v; @noSelect = v end
|
|
40
|
+
def noSelect=(v) Axlsx::validate_boolean v; @noSelect = v end
|
|
40
41
|
|
|
41
42
|
# @see noRot
|
|
42
|
-
def noRot=(v) Axlsx::validate_boolean v; @noRot = v end
|
|
43
|
+
def noRot=(v) Axlsx::validate_boolean v; @noRot = v end
|
|
43
44
|
|
|
44
45
|
# @see noChangeAspect
|
|
45
|
-
def noChangeAspect=(v) Axlsx::validate_boolean v; @noChangeAspect = v end
|
|
46
|
+
def noChangeAspect=(v) Axlsx::validate_boolean v; @noChangeAspect = v end
|
|
46
47
|
|
|
47
48
|
# @see noMove
|
|
48
|
-
def noMove=(v) Axlsx::validate_boolean v; @noMove = v end
|
|
49
|
+
def noMove=(v) Axlsx::validate_boolean v; @noMove = v end
|
|
49
50
|
|
|
50
51
|
# @see noResize
|
|
51
|
-
def noResize=(v) Axlsx::validate_boolean v; @noResize = v end
|
|
52
|
+
def noResize=(v) Axlsx::validate_boolean v; @noResize = v end
|
|
52
53
|
|
|
53
54
|
# @see noEditPoints
|
|
54
|
-
def noEditPoints=(v) Axlsx::validate_boolean v; @noEditPoints = v end
|
|
55
|
+
def noEditPoints=(v) Axlsx::validate_boolean v; @noEditPoints = v end
|
|
55
56
|
|
|
56
57
|
# @see noAdjustHandles
|
|
57
|
-
def noAdjustHandles=(v) Axlsx::validate_boolean v; @noAdjustHandles = v end
|
|
58
|
+
def noAdjustHandles=(v) Axlsx::validate_boolean v; @noAdjustHandles = v end
|
|
58
59
|
|
|
59
60
|
# @see noChangeArrowheads
|
|
60
|
-
def noChangeArrowheads=(v) Axlsx::validate_boolean v; @noChangeArrowheads = v end
|
|
61
|
+
def noChangeArrowheads=(v) Axlsx::validate_boolean v; @noChangeArrowheads = v end
|
|
61
62
|
|
|
62
63
|
# @see noChangeShapeType
|
|
63
|
-
def noChangeShapeType=(v) Axlsx::validate_boolean v; @noChangeShapeType = v end
|
|
64
|
+
def noChangeShapeType=(v) Axlsx::validate_boolean v; @noChangeShapeType = v end
|
|
64
65
|
|
|
65
|
-
# Serializes the
|
|
66
|
-
# @param [
|
|
66
|
+
# Serializes the object
|
|
67
|
+
# @param [String] str
|
|
67
68
|
# @return [String]
|
|
68
|
-
def
|
|
69
|
-
|
|
69
|
+
def to_xml_string(str = '')
|
|
70
|
+
str << '<a:picLocks '
|
|
71
|
+
str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
|
|
72
|
+
str << '/>'
|
|
70
73
|
end
|
|
74
|
+
|
|
71
75
|
end
|
|
72
76
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
3
|
|
|
3
4
|
|
|
@@ -10,7 +11,7 @@ module Axlsx
|
|
|
10
11
|
# Creates a new pie chart object
|
|
11
12
|
# @param [GraphicFrame] frame The workbook that owns this chart.
|
|
12
13
|
# @option options [Cell, String] title
|
|
13
|
-
# @option options [Boolean] show_legend
|
|
14
|
+
# @option options [Boolean] show_legend
|
|
14
15
|
# @option options [Symbol] grouping
|
|
15
16
|
# @option options [String] gapDepth
|
|
16
17
|
# @option options [Integer] rotX
|
|
@@ -27,15 +28,17 @@ module Axlsx
|
|
|
27
28
|
@view3D = View3D.new({:rotX=>30, :perspective=>30}.merge(options))
|
|
28
29
|
end
|
|
29
30
|
|
|
30
|
-
# Serializes the
|
|
31
|
+
# Serializes the object
|
|
32
|
+
# @param [String] str
|
|
31
33
|
# @return [String]
|
|
32
|
-
def
|
|
33
|
-
super() do |
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
def to_xml_string(str = '')
|
|
35
|
+
super(str) do |str_inner|
|
|
36
|
+
str_inner << '<c:pie3DChart>'
|
|
37
|
+
str_inner << '<c:varyColors val="1"/>'
|
|
38
|
+
@series.each { |ser| ser.to_xml_string(str_inner) }
|
|
39
|
+
str_inner << '</c:pie3DChart>'
|
|
38
40
|
end
|
|
39
41
|
end
|
|
42
|
+
|
|
40
43
|
end
|
|
41
44
|
end
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
3
|
+
|
|
2
4
|
# A PieSeries defines the data and labels and explosion for pie charts series.
|
|
3
5
|
# @note The recommended way to manage series is to use Chart#add_series
|
|
4
6
|
# @see Worksheet#add_chart
|
|
5
7
|
# @see Chart#add_series
|
|
6
8
|
class PieSeries < Series
|
|
7
9
|
|
|
8
|
-
# The data for this series.
|
|
10
|
+
# The data for this series.
|
|
9
11
|
# @return [SimpleTypedList]
|
|
10
12
|
attr_reader :data
|
|
11
13
|
|
|
@@ -28,22 +30,24 @@ module Axlsx
|
|
|
28
30
|
super(chart, options)
|
|
29
31
|
self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil?
|
|
30
32
|
self.data = ValAxisData.new(options[:data]) unless options[:data].nil?
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
+
end
|
|
34
|
+
|
|
33
35
|
# @see explosion
|
|
34
36
|
def explosion=(v) Axlsx::validate_unsigned_int(v); @explosion = v; end
|
|
35
37
|
|
|
36
|
-
# Serializes the
|
|
37
|
-
# @param [
|
|
38
|
+
# Serializes the object
|
|
39
|
+
# @param [String] str
|
|
38
40
|
# @return [String]
|
|
39
|
-
def
|
|
40
|
-
super(
|
|
41
|
-
|
|
42
|
-
@labels.
|
|
43
|
-
@data.
|
|
44
|
-
end
|
|
41
|
+
def to_xml_string(str = '')
|
|
42
|
+
super(str) do |str_inner|
|
|
43
|
+
str_inner << '<c:explosion val="' << @explosion << '"/>' unless @explosion.nil?
|
|
44
|
+
@labels.to_xml_string str_inner unless @labels.nil?
|
|
45
|
+
@data.to_xml_string str_inner unless @data.nil?
|
|
46
|
+
end
|
|
47
|
+
str
|
|
45
48
|
end
|
|
46
|
-
|
|
49
|
+
|
|
50
|
+
private
|
|
47
51
|
|
|
48
52
|
# assigns the data for this series
|
|
49
53
|
def data=(v) DataTypeValidator.validate "Series.data", [SimpleTypedList], v; @data = v; end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
3
|
# The Scaling class defines axis scaling
|
|
3
4
|
class Scaling
|
|
@@ -32,7 +33,7 @@ module Axlsx
|
|
|
32
33
|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
33
34
|
end
|
|
34
35
|
end
|
|
35
|
-
|
|
36
|
+
|
|
36
37
|
# @see logBase
|
|
37
38
|
def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer, Fixnum], v, lambda { |arg| arg >= 2 && arg <= 1000}; @logBase = v; end
|
|
38
39
|
# @see orientation
|
|
@@ -43,16 +44,16 @@ module Axlsx
|
|
|
43
44
|
# @see min
|
|
44
45
|
def min=(v) DataTypeValidator.validate "Scaling.min", Float, v; @min = v; end
|
|
45
46
|
|
|
46
|
-
# Serializes the
|
|
47
|
-
# @param [
|
|
47
|
+
# Serializes the object
|
|
48
|
+
# @param [String] str
|
|
48
49
|
# @return [String]
|
|
49
|
-
def
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
def to_xml_string(str = '')
|
|
51
|
+
str << '<c:scaling>'
|
|
52
|
+
str << '<c:logBase val="' << @logBase.to_s << '"/>' unless @logBase.nil?
|
|
53
|
+
str << '<c:orientation val="' << @orientation.to_s << '"/>' unless @orientation.nil?
|
|
54
|
+
str << '<c:min val="' << @min.to_s << '"/>' unless @min.nil?
|
|
55
|
+
str << '<c:max val="' << @max.to_s << '"/>' unless @max.nil?
|
|
56
|
+
str << '</c:scaling>'
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
module Axlsx
|
|
3
|
+
|
|
4
|
+
# The ScatterChart allows you to insert a scatter chart into your worksheet
|
|
5
|
+
# @see Worksheet#add_chart
|
|
6
|
+
# @see Chart#add_series
|
|
7
|
+
# @see README for an example
|
|
8
|
+
class ScatterChart < Chart
|
|
9
|
+
|
|
10
|
+
# The Style for the scatter chart
|
|
11
|
+
# must be one of :none | :line | :lineMarker | :marker | :smooth | :smoothMarker
|
|
12
|
+
# return [Symbol]
|
|
13
|
+
attr_reader :scatterStyle
|
|
14
|
+
|
|
15
|
+
# the x value axis
|
|
16
|
+
# @return [ValAxis]
|
|
17
|
+
attr_reader :xValAxis
|
|
18
|
+
|
|
19
|
+
# the y value axis
|
|
20
|
+
# @return [ValAxis]
|
|
21
|
+
attr_reader :yValAxis
|
|
22
|
+
|
|
23
|
+
# Creates a new scatter chart
|
|
24
|
+
def initialize(frame, options={})
|
|
25
|
+
@scatterStyle = :lineMarker
|
|
26
|
+
@xValAxId = rand(8 ** 8)
|
|
27
|
+
@yValAxId = rand(8 ** 8)
|
|
28
|
+
@xValAxis = ValAxis.new(@xValAxId, @yValAxId)
|
|
29
|
+
@yValAxis = ValAxis.new(@yValAxId, @xValAxId)
|
|
30
|
+
super(frame, options)
|
|
31
|
+
@series_type = ScatterSeries
|
|
32
|
+
options.each do |o|
|
|
33
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# see #scatterStyle
|
|
38
|
+
def scatterStyle=(v)
|
|
39
|
+
Axlsx.validate_scatter_style(v)
|
|
40
|
+
@scatterStyle = v
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Serializes the object
|
|
44
|
+
# @param [String] str
|
|
45
|
+
# @return [String]
|
|
46
|
+
def to_xml_string(str = '')
|
|
47
|
+
super(str) do |str_inner|
|
|
48
|
+
str_inner << '<c:scatterChart>'
|
|
49
|
+
str_inner << '<c:scatterStyle val="' << scatterStyle.to_s << '"/>'
|
|
50
|
+
str_inner << '<c:varyColors val="1"/>'
|
|
51
|
+
@series.each { |ser| ser.to_xml_string(str_inner) }
|
|
52
|
+
str_inner << '<c:dLbls>'
|
|
53
|
+
str_inner << '<c:showLegendKey val="0"/>'
|
|
54
|
+
str_inner << '<c:showVal val="0"/>'
|
|
55
|
+
str_inner << '<c:showCatName val="0"/>'
|
|
56
|
+
str_inner << '<c:showSerName val="0"/>'
|
|
57
|
+
str_inner << '<c:showPercent val="0"/>'
|
|
58
|
+
str_inner << '<c:showBubbleSize val="0"/>'
|
|
59
|
+
str_inner << '</c:dLbls>'
|
|
60
|
+
str_inner << '<c:axId val="' << @xValAxId.to_s << '"/>'
|
|
61
|
+
str_inner << '<c:axId val="' << @yValAxId.to_s << '"/>'
|
|
62
|
+
str_inner << '</c:scatterChart>'
|
|
63
|
+
@xValAxis.to_xml_string str_inner
|
|
64
|
+
@yValAxis.to_xml_string str_inner
|
|
65
|
+
end
|
|
66
|
+
str
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
module Axlsx
|
|
3
|
+
|
|
4
|
+
# A ScatterSeries defines the x and y position of data in the chart
|
|
5
|
+
# @note The recommended way to manage series is to use Chart#add_series
|
|
6
|
+
# @see Worksheet#add_chart
|
|
7
|
+
# @see Chart#add_series
|
|
8
|
+
# @see examples/example.rb
|
|
9
|
+
class ScatterSeries < Series
|
|
10
|
+
|
|
11
|
+
# The x data for this series.
|
|
12
|
+
# @return [NamedAxisData]
|
|
13
|
+
attr_reader :xData
|
|
14
|
+
|
|
15
|
+
# The y data for this series.
|
|
16
|
+
# @return [NamedAxisData]
|
|
17
|
+
attr_reader :yData
|
|
18
|
+
|
|
19
|
+
# Creates a new ScatterSeries
|
|
20
|
+
def initialize(chart, options={})
|
|
21
|
+
@xData, @yData = nil
|
|
22
|
+
super(chart, options)
|
|
23
|
+
|
|
24
|
+
@xData = NamedAxisData.new("xVal", options[:xData]) unless options[:xData].nil?
|
|
25
|
+
@yData = NamedAxisData.new("yVal", options[:yData]) unless options[:yData].nil?
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Serializes the object
|
|
29
|
+
# @param [String] str
|
|
30
|
+
# @return [String]
|
|
31
|
+
def to_xml_string(str = '')
|
|
32
|
+
super(str) do |inner_str|
|
|
33
|
+
@xData.to_xml_string(inner_str) unless @xData.nil?
|
|
34
|
+
@yData.to_xml_string(inner_str) unless @yData.nil?
|
|
35
|
+
end
|
|
36
|
+
str
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
3
|
#A SerAxis object defines a series axis
|
|
3
4
|
class SerAxis < Axis
|
|
@@ -21,7 +22,7 @@ module Axlsx
|
|
|
21
22
|
def initialize(axId, crossAx, options={})
|
|
22
23
|
@tickLblSkip, @tickMarkSkip = nil, nil
|
|
23
24
|
super(axId, crossAx, options)
|
|
24
|
-
end
|
|
25
|
+
end
|
|
25
26
|
|
|
26
27
|
# @see tickLblSkip
|
|
27
28
|
def tickLblSkip=(v) Axlsx::validate_unsigned_int(v); @tickLblSkip = v; end
|
|
@@ -29,17 +30,17 @@ module Axlsx
|
|
|
29
30
|
# @see tickMarkSkip
|
|
30
31
|
def tickMarkSkip=(v) Axlsx::validate_unsigned_int(v); @tickMarkSkip = v; end
|
|
31
32
|
|
|
32
|
-
# Serializes the
|
|
33
|
-
# @param [
|
|
33
|
+
# Serializes the object
|
|
34
|
+
# @param [String] str
|
|
34
35
|
# @return [String]
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
def to_xml_string(str = '')
|
|
37
|
+
str << '<c:serAx>'
|
|
38
|
+
super(str)
|
|
39
|
+
str << '<c:tickLblSkip val="' << @tickLblSkip.to_s << '"/>' unless @tickLblSkip.nil?
|
|
40
|
+
str << '<c:tickMarkSkip val="' << @tickMarkSkip.to_s << '"/>' unless @tickMarkSkip.nil?
|
|
41
|
+
str << '</c:serAx>'
|
|
41
42
|
end
|
|
42
43
|
end
|
|
43
|
-
|
|
44
|
+
|
|
44
45
|
|
|
45
46
|
end
|
data/lib/axlsx/drawing/series.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
1
2
|
module Axlsx
|
|
2
3
|
# A Series defines the common series attributes and is the super class for all concrete series types.
|
|
3
4
|
# @note The recommended way to manage series is to use Chart#add_series
|
|
@@ -24,7 +25,7 @@ module Axlsx
|
|
|
24
25
|
options.each do |o|
|
|
25
26
|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
26
27
|
end
|
|
27
|
-
end
|
|
28
|
+
end
|
|
28
29
|
|
|
29
30
|
# The index of this series in the chart's series.
|
|
30
31
|
# @return [Integer]
|
|
@@ -43,27 +44,27 @@ module Axlsx
|
|
|
43
44
|
def order=(v) Axlsx::validate_unsigned_int(v); @order = v; end
|
|
44
45
|
|
|
45
46
|
# @see title
|
|
46
|
-
def title=(v)
|
|
47
|
+
def title=(v)
|
|
47
48
|
v = SeriesTitle.new(v) if v.is_a?(String) || v.is_a?(Cell)
|
|
48
49
|
DataTypeValidator.validate "#{self.class}.title", SeriesTitle, v
|
|
49
50
|
@title = v
|
|
50
51
|
end
|
|
51
|
-
|
|
52
|
-
private
|
|
53
|
-
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
54
55
|
# assigns the chart for this series
|
|
55
|
-
def chart=(v) DataTypeValidator.validate "Series.chart", Chart, v; @chart = v; end
|
|
56
|
+
def chart=(v) DataTypeValidator.validate "Series.chart", Chart, v; @chart = v; end
|
|
56
57
|
|
|
57
|
-
# Serializes the
|
|
58
|
-
# @param [
|
|
58
|
+
# Serializes the object
|
|
59
|
+
# @param [String] str
|
|
59
60
|
# @return [String]
|
|
60
|
-
def
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
def to_xml_string(str = '')
|
|
62
|
+
str << '<c:ser>'
|
|
63
|
+
str << '<c:idx val="' << index.to_s << '"/>'
|
|
64
|
+
str << '<c:order val="' << (order || index).to_s << '"/>'
|
|
65
|
+
title.to_xml_string(str) unless title.nil?
|
|
66
|
+
yield str if block_given?
|
|
67
|
+
str << '</c:ser>'
|
|
67
68
|
end
|
|
68
69
|
|
|
69
70
|
end
|