axlsx 1.0.12 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -3
- data/lib/axlsx.rb +57 -0
- data/lib/axlsx/content_type/content_type.rb +23 -0
- data/lib/axlsx/content_type/default.rb +37 -0
- data/lib/axlsx/content_type/override.rb +37 -0
- data/lib/axlsx/doc_props/app.rb +178 -0
- data/lib/axlsx/doc_props/core.rb +34 -0
- data/lib/axlsx/drawing/axis.rb +90 -0
- data/lib/axlsx/drawing/bar_3D_chart.rb +128 -0
- data/lib/axlsx/drawing/bar_series.rb +64 -0
- data/lib/axlsx/drawing/cat_axis.rb +63 -0
- data/lib/axlsx/drawing/cat_axis_data.rb +35 -0
- data/lib/axlsx/drawing/chart.rb +179 -0
- data/lib/axlsx/drawing/drawing.rb +137 -0
- data/lib/axlsx/drawing/graphic_frame.rb +52 -0
- data/lib/axlsx/drawing/line_3D_chart.rb +106 -0
- data/lib/axlsx/drawing/line_series.rb +46 -0
- data/lib/axlsx/drawing/marker.rb +61 -0
- data/lib/axlsx/drawing/one_cell_anchor.rb +89 -0
- data/lib/axlsx/drawing/pic.rb +153 -0
- data/lib/axlsx/drawing/picture_locking.rb +72 -0
- data/lib/axlsx/drawing/picture_locking.rb~ +36 -0
- data/lib/axlsx/drawing/pie_3D_chart.rb +41 -0
- data/lib/axlsx/drawing/pie_series.rb +56 -0
- data/lib/axlsx/drawing/scaling.rb +59 -0
- data/lib/axlsx/drawing/ser_axis.rb +45 -0
- data/lib/axlsx/drawing/series.rb +71 -0
- data/lib/axlsx/drawing/series_title.rb +22 -0
- data/lib/axlsx/drawing/title.rb +61 -0
- data/lib/axlsx/drawing/two_cell_anchor.rb +76 -0
- data/lib/axlsx/drawing/val_axis.rb +34 -0
- data/lib/axlsx/drawing/val_axis_data.rb +28 -0
- data/lib/axlsx/drawing/view_3D.rb +85 -0
- data/lib/axlsx/package.rb +215 -0
- data/lib/axlsx/rels/relationship.rb +44 -0
- data/lib/axlsx/rels/relationships.rb +25 -0
- data/lib/axlsx/stylesheet/border.rb +57 -0
- data/lib/axlsx/stylesheet/border_pr.rb +68 -0
- data/lib/axlsx/stylesheet/cell_alignment.rb +105 -0
- data/lib/axlsx/stylesheet/cell_protection.rb +36 -0
- data/lib/axlsx/stylesheet/cell_style.rb +65 -0
- data/lib/axlsx/stylesheet/color.rb +69 -0
- data/lib/axlsx/stylesheet/fill.rb +32 -0
- data/lib/axlsx/stylesheet/font.rb +139 -0
- data/lib/axlsx/stylesheet/gradient_fill.rb +76 -0
- data/lib/axlsx/stylesheet/gradient_stop.rb +33 -0
- data/lib/axlsx/stylesheet/num_fmt.rb +63 -0
- data/lib/axlsx/stylesheet/pattern_fill.rb +66 -0
- data/lib/axlsx/stylesheet/styles.rb +298 -0
- data/lib/axlsx/stylesheet/table_style.rb +47 -0
- data/lib/axlsx/stylesheet/table_style_element.rb +71 -0
- data/lib/axlsx/stylesheet/table_styles.rb +39 -0
- data/lib/axlsx/stylesheet/xf.rb +138 -0
- data/lib/axlsx/util/constants.rb +220 -0
- data/lib/axlsx/util/parser.rb +43 -0
- data/lib/axlsx/util/parser.rb~ +6 -0
- data/lib/axlsx/util/simple_typed_list.rb +160 -0
- data/lib/axlsx/util/validators.rb +132 -0
- data/lib/axlsx/version.rb +4 -0
- data/lib/axlsx/workbook/#workbook.rb# +165 -0
- data/lib/axlsx/workbook/workbook.rb +160 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +337 -0
- data/lib/axlsx/workbook/worksheet/row.rb +107 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +279 -0
- metadata +93 -141
- data/examples/follow_20111202.xlsx +0 -0
- data/test/content_type/tc_content_type.rb +0 -81
- data/test/content_type/tc_default.rb +0 -40
- data/test/content_type/tc_override.rb +0 -40
- data/test/doc_props/tc_app.rb +0 -19
- data/test/doc_props/tc_core.rb +0 -34
- data/test/drawing/tc_axis.rb +0 -40
- data/test/drawing/tc_bar_3D_chart.rb +0 -66
- data/test/drawing/tc_bar_series.rb +0 -34
- data/test/drawing/tc_cat_axis.rb +0 -32
- data/test/drawing/tc_cat_axis_data.rb +0 -18
- data/test/drawing/tc_chart.rb +0 -73
- data/test/drawing/tc_drawing.rb +0 -80
- data/test/drawing/tc_graphic_frame.rb +0 -26
- data/test/drawing/tc_line_3d_chart.rb +0 -48
- data/test/drawing/tc_line_series.rb +0 -27
- data/test/drawing/tc_marker.rb +0 -45
- data/test/drawing/tc_one_cell_anchor.rb +0 -67
- data/test/drawing/tc_pic.rb +0 -71
- data/test/drawing/tc_picture_locking.rb +0 -73
- data/test/drawing/tc_pie_3D_chart.rb +0 -33
- data/test/drawing/tc_pie_series.rb +0 -35
- data/test/drawing/tc_scaling.rb +0 -37
- data/test/drawing/tc_ser_axis.rb +0 -31
- data/test/drawing/tc_series.rb +0 -24
- data/test/drawing/tc_series_title.rb +0 -34
- data/test/drawing/tc_title.rb +0 -34
- data/test/drawing/tc_two_cell_anchor.rb +0 -38
- data/test/drawing/tc_val_axis.rb +0 -25
- data/test/drawing/tc_val_axis_data.rb +0 -18
- data/test/drawing/tc_view_3D.rb +0 -55
- data/test/rels/tc_relationship.rb +0 -16
- data/test/rels/tc_relationships.rb +0 -27
- data/test/stylesheet/tc_border.rb +0 -38
- data/test/stylesheet/tc_border_pr.rb +0 -33
- data/test/stylesheet/tc_cell_alignment.rb +0 -77
- data/test/stylesheet/tc_cell_protection.rb +0 -30
- data/test/stylesheet/tc_cell_style.rb +0 -58
- data/test/stylesheet/tc_color.rb +0 -38
- data/test/stylesheet/tc_fill.rb +0 -19
- data/test/stylesheet/tc_font.rb +0 -114
- data/test/stylesheet/tc_gradient_fill.rb +0 -65
- data/test/stylesheet/tc_gradient_stop.rb +0 -32
- data/test/stylesheet/tc_num_fmt.rb +0 -31
- data/test/stylesheet/tc_pattern_fill.rb +0 -38
- data/test/stylesheet/tc_styles.rb +0 -52
- data/test/stylesheet/tc_table_style.rb +0 -37
- data/test/stylesheet/tc_table_style_element.rb +0 -37
- data/test/stylesheet/tc_table_styles.rb +0 -30
- data/test/stylesheet/tc_xf.rb +0 -121
- data/test/tc_package.rb +0 -68
- data/test/util/tc_simple_typed_list.rb +0 -66
- data/test/util/tc_validators.rb +0 -76
- data/test/workbook/tc_workbook.rb +0 -60
- data/test/workbook/worksheet/tc_cell.rb +0 -179
- data/test/workbook/worksheet/tc_row.rb +0 -36
- data/test/workbook/worksheet/tc_worksheet.rb +0 -138
@@ -0,0 +1,153 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Axlsx
|
3
|
+
# a Pic object represents an image in your worksheet
|
4
|
+
# Worksheet#add_image is the recommended way to manage images in your sheets
|
5
|
+
# @see Worksheet#add_image
|
6
|
+
class Pic
|
7
|
+
|
8
|
+
# allowed file extenstions
|
9
|
+
ALLOWED_EXTENSIONS = ['gif', 'jpeg', 'png', 'jpg']
|
10
|
+
|
11
|
+
# The name to use for this picture
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :name
|
14
|
+
|
15
|
+
|
16
|
+
# A description of the picture
|
17
|
+
# @return [String]
|
18
|
+
attr_reader :descr
|
19
|
+
|
20
|
+
# The path to the image you want to include
|
21
|
+
# Only local images are supported at this time and only jpg support
|
22
|
+
# @return [String]
|
23
|
+
attr_reader :image_src
|
24
|
+
|
25
|
+
# The anchor for this image
|
26
|
+
# @return [OneCellAnchor]
|
27
|
+
attr_reader :anchor
|
28
|
+
|
29
|
+
# The picture locking attributes for this picture
|
30
|
+
attr_reader :picture_locking
|
31
|
+
|
32
|
+
# Creates a new Pic(ture) object
|
33
|
+
# @param [Anchor] anchor the anchor that holds this image
|
34
|
+
# @option options [String] name
|
35
|
+
# @option options [String] descr
|
36
|
+
# @option options [String] image_src
|
37
|
+
# @option options [Array] start_at
|
38
|
+
# @option options [Intger] width
|
39
|
+
# @option options [Intger] height
|
40
|
+
def initialize(anchor, options={})
|
41
|
+
@anchor = anchor
|
42
|
+
@anchor.drawing.worksheet.workbook.images << self
|
43
|
+
options.each do |o|
|
44
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
45
|
+
end
|
46
|
+
start_at(*options[:start_at]) if options[:start_at]
|
47
|
+
yield self if block_given?
|
48
|
+
@picture_locking = PictureLocking.new(options)
|
49
|
+
end
|
50
|
+
|
51
|
+
def image_src=(v)
|
52
|
+
Axlsx::validate_string(v)
|
53
|
+
RestrictionValidator.validate 'Pic.image_src', ALLOWED_EXTENSIONS, File.extname(v).delete('.')
|
54
|
+
raise ArgumentError, "File does not exist" unless File.exist?(v)
|
55
|
+
@image_src = v
|
56
|
+
end
|
57
|
+
|
58
|
+
# @see name
|
59
|
+
def name=(v) Axlsx::validate_string(v); @name = v; end
|
60
|
+
|
61
|
+
# @see descr
|
62
|
+
def descr=(v) Axlsx::validate_string(v); @descr = v; end
|
63
|
+
|
64
|
+
|
65
|
+
# The file name of image_src without any path information
|
66
|
+
# @return [String]
|
67
|
+
def file_name
|
68
|
+
File.basename(image_src) unless image_src.nil?
|
69
|
+
end
|
70
|
+
|
71
|
+
# returns the extension of image_src without the preceeding '.'
|
72
|
+
# @return [String]
|
73
|
+
def extname
|
74
|
+
File.extname(image_src).delete('.') unless image_src.nil?
|
75
|
+
end
|
76
|
+
|
77
|
+
# The index of this image in the workbooks images collections
|
78
|
+
# @return [Index]
|
79
|
+
def index
|
80
|
+
@anchor.drawing.worksheet.workbook.images.index(self)
|
81
|
+
end
|
82
|
+
|
83
|
+
# The part name for this image used in serialization and relationship building
|
84
|
+
# @return [String]
|
85
|
+
def pn
|
86
|
+
"#{IMAGE_PN % [(index+1), extname]}"
|
87
|
+
end
|
88
|
+
|
89
|
+
# providing access to the anchor's width attribute
|
90
|
+
# @param [Integer] v
|
91
|
+
# @see OneCellAnchor.width
|
92
|
+
def width
|
93
|
+
@anchor.width
|
94
|
+
end
|
95
|
+
|
96
|
+
# @see width
|
97
|
+
def width=(v)
|
98
|
+
@anchor.width = v
|
99
|
+
end
|
100
|
+
|
101
|
+
# providing access to update the anchor's height attribute
|
102
|
+
# @param [Integer] v
|
103
|
+
# @see OneCellAnchor.width
|
104
|
+
def height
|
105
|
+
@anchor.height
|
106
|
+
end
|
107
|
+
|
108
|
+
# @see height
|
109
|
+
def height=(v)
|
110
|
+
@anchor.height = v
|
111
|
+
end
|
112
|
+
|
113
|
+
# This is a short cut method to set the start anchor position
|
114
|
+
# If you need finer granularity in positioning use
|
115
|
+
# graphic_frame.anchor.from.colOff / rowOff
|
116
|
+
# @param [Integer] x The column
|
117
|
+
# @param [Integer] y The row
|
118
|
+
# @return [Marker]
|
119
|
+
def start_at(x, y)
|
120
|
+
@anchor.from.col = x
|
121
|
+
@anchor.from.row = y
|
122
|
+
end
|
123
|
+
|
124
|
+
# Serializes the picture
|
125
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
126
|
+
# @return [String]
|
127
|
+
def to_xml(xml)
|
128
|
+
xml.send('xdr:pic') {
|
129
|
+
xml.send('xdr:nvPicPr') {
|
130
|
+
xml.send('xdr:cNvPr', :id=>"2", :name=>name, :descr=>descr)
|
131
|
+
xml.send('xdr:cNvPicPr') {
|
132
|
+
picture_locking.to_xml(xml)
|
133
|
+
}
|
134
|
+
}
|
135
|
+
xml.send('xdr:blipFill') {
|
136
|
+
xml.send('a:blip', :'xmlns:r' => XML_NS_R, :'r:embed'=>"rId1")
|
137
|
+
xml.send('a:stretch') {
|
138
|
+
xml.send('a:fillRect')
|
139
|
+
}
|
140
|
+
}
|
141
|
+
xml.send('xdr:spPr') {
|
142
|
+
xml.send('a:xfrm') {
|
143
|
+
xml.send('a:off', :x=>0, :y=>0)
|
144
|
+
xml.send('a:ext', :cx=>2336800, :cy=>2161540)
|
145
|
+
}
|
146
|
+
xml.send('a:prstGeom', :prst=>:rect) {
|
147
|
+
xml.send('a:avLst')
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# The picture locking class defines the locking properties for pictures in your workbook.
|
3
|
+
class PictureLocking
|
4
|
+
|
5
|
+
|
6
|
+
attr_reader :noGrp
|
7
|
+
attr_reader :noSelect
|
8
|
+
attr_reader :noRot
|
9
|
+
attr_reader :noChangeAspect
|
10
|
+
attr_reader :noMove
|
11
|
+
attr_reader :noResize
|
12
|
+
attr_reader :noEditPoints
|
13
|
+
attr_reader :noAdjustHandles
|
14
|
+
attr_reader :noChangeArrowheads
|
15
|
+
attr_reader :noChangeShapeType
|
16
|
+
|
17
|
+
# Creates a new PictureLocking object
|
18
|
+
# @option options [Boolean] noGrp
|
19
|
+
# @option options [Boolean] noSelect
|
20
|
+
# @option options [Boolean] noRot
|
21
|
+
# @option options [Boolean] noChangeAspect
|
22
|
+
# @option options [Boolean] noMove
|
23
|
+
# @option options [Boolean] noResize
|
24
|
+
# @option options [Boolean] noEditPoints
|
25
|
+
# @option options [Boolean] noAdjustHandles
|
26
|
+
# @option options [Boolean] noChangeArrowheads
|
27
|
+
# @option options [Boolean] noChangeShapeType
|
28
|
+
def initialize(options={})
|
29
|
+
@noChangeAspect = true
|
30
|
+
options.each do |o|
|
31
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# @see noGrp
|
36
|
+
def noGrp=(v) Axlsx::validate_boolean v; @noGrp = v end
|
37
|
+
|
38
|
+
# @see noSelect
|
39
|
+
def noSelect=(v) Axlsx::validate_boolean v; @noSelect = v end
|
40
|
+
|
41
|
+
# @see noRot
|
42
|
+
def noRot=(v) Axlsx::validate_boolean v; @noRot = v end
|
43
|
+
|
44
|
+
# @see noChangeAspect
|
45
|
+
def noChangeAspect=(v) Axlsx::validate_boolean v; @noChangeAspect = v end
|
46
|
+
|
47
|
+
# @see noMove
|
48
|
+
def noMove=(v) Axlsx::validate_boolean v; @noMove = v end
|
49
|
+
|
50
|
+
# @see noResize
|
51
|
+
def noResize=(v) Axlsx::validate_boolean v; @noResize = v end
|
52
|
+
|
53
|
+
# @see noEditPoints
|
54
|
+
def noEditPoints=(v) Axlsx::validate_boolean v; @noEditPoints = v end
|
55
|
+
|
56
|
+
# @see noAdjustHandles
|
57
|
+
def noAdjustHandles=(v) Axlsx::validate_boolean v; @noAdjustHandles = v end
|
58
|
+
|
59
|
+
# @see noChangeArrowheads
|
60
|
+
def noChangeArrowheads=(v) Axlsx::validate_boolean v; @noChangeArrowheads = v end
|
61
|
+
|
62
|
+
# @see noChangeShapeType
|
63
|
+
def noChangeShapeType=(v) Axlsx::validate_boolean v; @noChangeShapeType = v end
|
64
|
+
|
65
|
+
# Serializes the picture locking
|
66
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
67
|
+
# @return [String]
|
68
|
+
def to_xml(xml)
|
69
|
+
xml[:a].picLocks(self.instance_values)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# The picture locking class defines the locking properties for pictures in your workbook.
|
3
|
+
class PictureLocking
|
4
|
+
|
5
|
+
|
6
|
+
attr_reader :noGrp
|
7
|
+
attr_reader :noSelect
|
8
|
+
attr_reader :noRot
|
9
|
+
attr_reader :noChangeAspect
|
10
|
+
attr_reader :noMove
|
11
|
+
attr_reader :noResize
|
12
|
+
attr_reader :noEditPoints
|
13
|
+
attr_reader :noAdjustHandles
|
14
|
+
attr_reader :noChangeArrowheads
|
15
|
+
attr_reader :noChangeShapeType
|
16
|
+
|
17
|
+
# Creates a new PictureLocking object
|
18
|
+
# @option options [Boolean] noGrp
|
19
|
+
# @option options [Boolean] noSelect
|
20
|
+
# @option options [Boolean] noRot
|
21
|
+
# @option options [Boolean] noChangeAspect
|
22
|
+
# @option options [Boolean] noMove
|
23
|
+
# @option options [Boolean] noResize
|
24
|
+
# @option options [Boolean] noEditPoints
|
25
|
+
# @option options [Boolean] noAdjustHandles
|
26
|
+
# @option options [Boolean] noChangeArrowheads
|
27
|
+
# @option options [Boolean] noChangeShapeType
|
28
|
+
def initialize(options={})
|
29
|
+
options.each do |o|
|
30
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Axlsx
|
2
|
+
|
3
|
+
|
4
|
+
# The Pie3DChart is a three dimentional piechart (who would have guessed?) that you can add to your worksheet.
|
5
|
+
# @see Worksheet#add_chart
|
6
|
+
# @see Chart#add_series
|
7
|
+
# @see README for an example
|
8
|
+
class Pie3DChart < Chart
|
9
|
+
|
10
|
+
# Creates a new pie chart object
|
11
|
+
# @param [GraphicFrame] frame The workbook that owns this chart.
|
12
|
+
# @option options [Cell, String] title
|
13
|
+
# @option options [Boolean] show_legend
|
14
|
+
# @option options [Symbol] grouping
|
15
|
+
# @option options [String] gapDepth
|
16
|
+
# @option options [Integer] rotX
|
17
|
+
# @option options [String] hPercent
|
18
|
+
# @option options [Integer] rotY
|
19
|
+
# @option options [String] depthPercent
|
20
|
+
# @option options [Boolean] rAngAx
|
21
|
+
# @option options [Integer] perspective
|
22
|
+
# @see Chart
|
23
|
+
# @see View3D
|
24
|
+
def initialize(frame, options={})
|
25
|
+
super(frame, options)
|
26
|
+
@series_type = PieSeries
|
27
|
+
@view3D = View3D.new({:rotX=>30, :perspective=>30}.merge(options))
|
28
|
+
end
|
29
|
+
|
30
|
+
# Serializes the pie chart
|
31
|
+
# @return [String]
|
32
|
+
def to_xml
|
33
|
+
super() do |xml|
|
34
|
+
xml.send('c:pie3DChart') {
|
35
|
+
xml.send('c:varyColors', :val=>1)
|
36
|
+
@series.each { |ser| ser.to_xml(xml) }
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# A PieSeries defines the data and labels and explosion for pie charts series.
|
3
|
+
# @note The recommended way to manage series is to use Chart#add_series
|
4
|
+
# @see Worksheet#add_chart
|
5
|
+
# @see Chart#add_series
|
6
|
+
class PieSeries < Series
|
7
|
+
|
8
|
+
# The data for this series.
|
9
|
+
# @return [SimpleTypedList]
|
10
|
+
attr_reader :data
|
11
|
+
|
12
|
+
# The labels for this series.
|
13
|
+
# @return [SimpleTypedList]
|
14
|
+
attr_reader :labels
|
15
|
+
|
16
|
+
# The explosion for this series
|
17
|
+
# @return [Integert]
|
18
|
+
attr_reader :explosion
|
19
|
+
|
20
|
+
# Creates a new series
|
21
|
+
# @option options [Array, SimpleTypedList] data
|
22
|
+
# @option options [Array, SimpleTypedList] labels
|
23
|
+
# @option options [String] title
|
24
|
+
# @option options [Integer] explosion
|
25
|
+
# @param [Chart] chart
|
26
|
+
def initialize(chart, options={})
|
27
|
+
@explosion = nil
|
28
|
+
super(chart, options)
|
29
|
+
self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil?
|
30
|
+
self.data = ValAxisData.new(options[:data]) unless options[:data].nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
# @see explosion
|
34
|
+
def explosion=(v) Axlsx::validate_unsigned_int(v); @explosion = v; end
|
35
|
+
|
36
|
+
# Serializes the series
|
37
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
38
|
+
# @return [String]
|
39
|
+
def to_xml(xml)
|
40
|
+
super(xml) do |xml_inner|
|
41
|
+
xml_inner.send('c:explosion', :val=>@explosion) unless @explosion.nil?
|
42
|
+
@labels.to_xml(xml_inner) unless @labels.nil?
|
43
|
+
@data.to_xml(xml_inner) unless @data.nil?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
private
|
47
|
+
|
48
|
+
# assigns the data for this series
|
49
|
+
def data=(v) DataTypeValidator.validate "Series.data", [SimpleTypedList], v; @data = v; end
|
50
|
+
|
51
|
+
# assigns the labels for this series
|
52
|
+
def labels=(v) DataTypeValidator.validate "Series.labels", [SimpleTypedList], v; @labels = v; end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# The Scaling class defines axis scaling
|
3
|
+
class Scaling
|
4
|
+
|
5
|
+
# logarithmic base for a logarithmic axis.
|
6
|
+
# must be between 2 and 1000
|
7
|
+
# @return [Integer]
|
8
|
+
attr_reader :logBase
|
9
|
+
|
10
|
+
# the orientation of the axis
|
11
|
+
# must be one of [:minMax, :maxMin]
|
12
|
+
# @return [Symbol]
|
13
|
+
attr_reader :orientation
|
14
|
+
|
15
|
+
# the maximum scaling
|
16
|
+
# @return [Float]
|
17
|
+
attr_reader :max
|
18
|
+
|
19
|
+
# the minimu scaling
|
20
|
+
# @return [Float]
|
21
|
+
attr_reader :min
|
22
|
+
|
23
|
+
# creates a new Scaling object
|
24
|
+
# @option options [Integer, Fixnum] logBase
|
25
|
+
# @option options [Symbol] orientation
|
26
|
+
# @option options [Float] max
|
27
|
+
# @option options [Float] min
|
28
|
+
def initialize(options={})
|
29
|
+
@orientation = :minMax
|
30
|
+
@logBase, @min, @max = nil, nil, nil
|
31
|
+
options.each do |o|
|
32
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# @see logBase
|
37
|
+
def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer, Fixnum], v, lambda { |arg| arg >= 2 && arg <= 1000}; @logBase = v; end
|
38
|
+
# @see orientation
|
39
|
+
def orientation=(v) RestrictionValidator.validate "Scaling.orientation", [:minMax, :maxMin], v; @orientation = v; end
|
40
|
+
# @see max
|
41
|
+
def max=(v) DataTypeValidator.validate "Scaling.max", Float, v; @max = v; end
|
42
|
+
|
43
|
+
# @see min
|
44
|
+
def min=(v) DataTypeValidator.validate "Scaling.min", Float, v; @min = v; end
|
45
|
+
|
46
|
+
# Serializes the axId
|
47
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
48
|
+
# @return [String]
|
49
|
+
def to_xml(xml)
|
50
|
+
xml.send('c:scaling') {
|
51
|
+
xml.send('c:logBase', :val=> @logBase) unless @logBase.nil?
|
52
|
+
xml.send('c:orientation', :val=> @orientation) unless @orientation.nil?
|
53
|
+
xml.send('c:min', :val => @min) unless @min.nil?
|
54
|
+
xml.send('c:max', :val => @max) unless @max.nil?
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Axlsx
|
2
|
+
#A SerAxis object defines a series axis
|
3
|
+
class SerAxis < Axis
|
4
|
+
|
5
|
+
# The number of tick lables to skip between labels
|
6
|
+
# @return [Integer]
|
7
|
+
attr_reader :tickLblSkip
|
8
|
+
|
9
|
+
# The number of tickmarks to be skipped before the next one is rendered.
|
10
|
+
# @return [Boolean]
|
11
|
+
attr_reader :tickMarkSkip
|
12
|
+
|
13
|
+
# Creates a new SerAxis object
|
14
|
+
# @param [Integer] axId the id of this axis. Inherited
|
15
|
+
# @param [Integer] crossAx the id of the perpendicular axis. Inherited
|
16
|
+
# @option options [Symbol] axPos. Inherited
|
17
|
+
# @option options [Symbol] tickLblPos. Inherited
|
18
|
+
# @option options [Symbol] crosses. Inherited
|
19
|
+
# @option options [Integer] tickLblSkip
|
20
|
+
# @option options [Integer] tickMarkSkip
|
21
|
+
def initialize(axId, crossAx, options={})
|
22
|
+
@tickLblSkip, @tickMarkSkip = nil, nil
|
23
|
+
super(axId, crossAx, options)
|
24
|
+
end
|
25
|
+
|
26
|
+
# @see tickLblSkip
|
27
|
+
def tickLblSkip=(v) Axlsx::validate_unsigned_int(v); @tickLblSkip = v; end
|
28
|
+
|
29
|
+
# @see tickMarkSkip
|
30
|
+
def tickMarkSkip=(v) Axlsx::validate_unsigned_int(v); @tickMarkSkip = v; end
|
31
|
+
|
32
|
+
# Serializes the series axis
|
33
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
34
|
+
# @return [String]
|
35
|
+
def to_xml(xml)
|
36
|
+
xml.send('c:serAx') {
|
37
|
+
super(xml)
|
38
|
+
xml.send('c:tickLblSkip', :val=>@tickLblSkip) unless @tickLblSkip.nil?
|
39
|
+
xml.send('c:tickMarkSkip', :val=>@tickMarkSkip) unless @tickMarkSkip.nil?
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end
|