axlsx 1.0.12 → 1.0.14
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/README.md +165 -134
- data/examples/example.rb +133 -153
- data/lib/axlsx/#cfb.xlsx# +0 -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 +93 -0
- data/lib/axlsx/drawing/bar_3D_chart.rb +136 -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 +193 -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 +114 -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 +65 -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 +26 -0
- data/lib/axlsx/drawing/view_3D.rb +85 -0
- data/lib/axlsx/package.rb +223 -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 +216 -0
- data/lib/axlsx/util/ms_off_crypto.rb +88 -0
- data/lib/axlsx/util/ms_off_crypto.rb~ +3 -0
- data/lib/axlsx/util/ms_offcrypto.rb~ +0 -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 +161 -0
- data/lib/axlsx/workbook/worksheet/cell.rb +350 -0
- data/lib/axlsx/workbook/worksheet/row.rb +107 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +335 -0
- data/lib/axlsx.rb +59 -0
- data/test/drawing/tc_axis.rb +1 -1
- data/test/drawing/tc_cat_axis.rb +1 -1
- data/test/drawing/tc_line_series.tc~ +34 -0
- data/test/drawing/tc_picture_locking.rb~ +77 -0
- data/test/tc_package.rb +10 -0
- data/test/workbook/worksheet/tc_cell.rb +15 -0
- data/test/workbook/worksheet/tc_worksheet.rb +22 -1
- metadata +117 -5
- data/examples/follow_20111202.xlsx +0 -0
|
@@ -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[:c].pie3DChart {
|
|
35
|
+
xml[: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.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[:c].scaling {
|
|
51
|
+
xml[:c].logBase :val=> @logBase unless @logBase.nil?
|
|
52
|
+
xml[:c].orientation :val=> @orientation unless @orientation.nil?
|
|
53
|
+
xml[:c].min :val => @min unless @min.nil?
|
|
54
|
+
xml[: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[:c].serAx {
|
|
37
|
+
super(xml)
|
|
38
|
+
xml[:c].tickLblSkip :val=>@tickLblSkip unless @tickLblSkip.nil?
|
|
39
|
+
xml[:c].tickMarkSkip :val=>@tickMarkSkip unless @tickMarkSkip.nil?
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# A Series defines the common series attributes and is the super class for all concrete series types.
|
|
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 Series
|
|
7
|
+
|
|
8
|
+
# The chart that owns this series
|
|
9
|
+
# @return [Chart]
|
|
10
|
+
attr_reader :chart
|
|
11
|
+
|
|
12
|
+
# The title of the series
|
|
13
|
+
# @return [SeriesTitle]
|
|
14
|
+
attr_reader :title
|
|
15
|
+
|
|
16
|
+
# Creates a new series
|
|
17
|
+
# @param [Chart] chart
|
|
18
|
+
# @option options [Integer] order
|
|
19
|
+
# @option options [String] title
|
|
20
|
+
def initialize(chart, options={})
|
|
21
|
+
@order = nil
|
|
22
|
+
self.chart = chart
|
|
23
|
+
@chart.series << self
|
|
24
|
+
options.each do |o|
|
|
25
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# The index of this series in the chart's series.
|
|
30
|
+
# @return [Integer]
|
|
31
|
+
def index
|
|
32
|
+
@chart.series.index(self)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# The order of this series in the chart's series. By default the order is the index of the series.
|
|
37
|
+
# @return [Integer]
|
|
38
|
+
def order
|
|
39
|
+
@order || index
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @see order
|
|
43
|
+
def order=(v) Axlsx::validate_unsigned_int(v); @order = v; end
|
|
44
|
+
|
|
45
|
+
# @see title
|
|
46
|
+
def title=(v)
|
|
47
|
+
v = SeriesTitle.new(v) if v.is_a?(String) || v.is_a?(Cell)
|
|
48
|
+
DataTypeValidator.validate "#{self.class}.title", SeriesTitle, v
|
|
49
|
+
@title = v
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
# assigns the chart for this series
|
|
55
|
+
def chart=(v) DataTypeValidator.validate "Series.chart", Chart, v; @chart = v; end
|
|
56
|
+
|
|
57
|
+
# Serializes the series
|
|
58
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
|
59
|
+
# @return [String]
|
|
60
|
+
def to_xml(xml)
|
|
61
|
+
xml.ser {
|
|
62
|
+
xml.idx :val=>index
|
|
63
|
+
xml.order :val=>order || index
|
|
64
|
+
title.to_xml(xml) unless title.nil?
|
|
65
|
+
yield xml if block_given?
|
|
66
|
+
}
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# A series title is a Title with a slightly different serialization than chart titles.
|
|
3
|
+
class SeriesTitle < Title
|
|
4
|
+
|
|
5
|
+
# Serializes the series title
|
|
6
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
|
7
|
+
# @return [String]
|
|
8
|
+
def to_xml(xml)
|
|
9
|
+
xml[:c].tx {
|
|
10
|
+
xml[:c].strRef {
|
|
11
|
+
xml[:c].f Axlsx::cell_range([@cell])
|
|
12
|
+
xml[:c].strCache {
|
|
13
|
+
xml[:c].ptCount :val=>1
|
|
14
|
+
xml[:c].pt(:idx=>0) {
|
|
15
|
+
xml[:c].v @text
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# A Title stores information about the title of a chart
|
|
3
|
+
class Title
|
|
4
|
+
|
|
5
|
+
# The text to be shown. Setting this property directly with a string will remove the cell reference.
|
|
6
|
+
# @return [String]
|
|
7
|
+
attr_reader :text
|
|
8
|
+
|
|
9
|
+
# The cell that holds the text for the title. Setting this property will automatically update the text attribute.
|
|
10
|
+
# @return [Cell]
|
|
11
|
+
attr_reader :cell
|
|
12
|
+
|
|
13
|
+
# Creates a new Title object
|
|
14
|
+
# @param [String, Cell] title The cell or string to be used for the chart's title
|
|
15
|
+
def initialize(title="")
|
|
16
|
+
self.cell = title if title.is_a?(Cell)
|
|
17
|
+
self.text = title.to_s unless title.is_a?(Cell)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @see text
|
|
21
|
+
def text=(v)
|
|
22
|
+
DataTypeValidator.validate 'Title.text', String, v
|
|
23
|
+
@text = v
|
|
24
|
+
@cell = nil
|
|
25
|
+
v
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @see cell
|
|
29
|
+
def cell=(v)
|
|
30
|
+
DataTypeValidator.validate 'Title.text', Cell, v
|
|
31
|
+
@cell = v
|
|
32
|
+
@text = v.value.to_s
|
|
33
|
+
v
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Not implemented at this time.
|
|
37
|
+
#def layout=(v) DataTypeValidator.validate 'Title.layout', Layout, v; @layout = v; end
|
|
38
|
+
#def overlay=(v) Axlsx::validate_boolean v; @overlay=v; end
|
|
39
|
+
#def spPr=(v) DataTypeValidator.validate 'Title.spPr', SpPr, v; @spPr = v; end
|
|
40
|
+
|
|
41
|
+
# Serializes the chart title
|
|
42
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
|
43
|
+
# @return [String]
|
|
44
|
+
def to_xml(xml)
|
|
45
|
+
xml[:c].title {
|
|
46
|
+
unless @text.empty?
|
|
47
|
+
xml[:c].tx {
|
|
48
|
+
xml[:c].strRef {
|
|
49
|
+
xml[:c].f Axlsx::cell_range([@cell])
|
|
50
|
+
xml[:c].strCache {
|
|
51
|
+
xml[:c].ptCount :val=>1
|
|
52
|
+
xml[:c].pt(:idx=>0) {
|
|
53
|
+
xml[:c].v @text
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
xml[:c].layout
|
|
60
|
+
xml[:c].overlay :val=>0
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# This class details the anchor points for drawings.
|
|
3
|
+
# @note The recommended way to manage drawings and charts is Worksheet#add_chart. Anchors are specified by the :start_at and :end_at options to that method.
|
|
4
|
+
# @see Worksheet#add_chart
|
|
5
|
+
class TwoCellAnchor
|
|
6
|
+
|
|
7
|
+
# A marker that defines the from cell anchor. The default from column and row are 0 and 0 respectively
|
|
8
|
+
# @return [Marker]
|
|
9
|
+
attr_reader :from
|
|
10
|
+
# A marker that returns the to cell anchor. The default to column and row are 5 and 10 respectively
|
|
11
|
+
# @return [Marker]
|
|
12
|
+
attr_reader :to
|
|
13
|
+
|
|
14
|
+
# The frame for your chart
|
|
15
|
+
# @note this will be discontinued in version 2.0 please use object
|
|
16
|
+
# @return [GraphicFrame]
|
|
17
|
+
# attr_reader :graphic_frame
|
|
18
|
+
|
|
19
|
+
# The object this anchor hosts
|
|
20
|
+
# @return [Pic, GraphicFrame]
|
|
21
|
+
attr_reader :object
|
|
22
|
+
|
|
23
|
+
# The drawing that holds this anchor
|
|
24
|
+
# @return [Drawing]
|
|
25
|
+
attr_reader :drawing
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Creates a new TwoCellAnchor object and sets up a reference to the from and to markers in the
|
|
29
|
+
# graphic_frame's chart. That means that you can do stuff like
|
|
30
|
+
# c = worksheet.add_chart Axlsx::Chart
|
|
31
|
+
# c.start_at 5, 9
|
|
32
|
+
# @note the chart_type parameter will be replaced with object in v. 2.0.0
|
|
33
|
+
# @param [Drawing] drawing
|
|
34
|
+
# @param [Class] chart_type This is passed to the graphic frame for instantiation. must be Chart or a subclass of Chart
|
|
35
|
+
# @param object The object this anchor holds.
|
|
36
|
+
# @option options [Array] start_at the col, row to start at
|
|
37
|
+
# @option options [Array] end_at the col, row to end at
|
|
38
|
+
def initialize(drawing, options={})
|
|
39
|
+
@drawing = drawing
|
|
40
|
+
drawing.anchors << self
|
|
41
|
+
@from, @to = Marker.new, Marker.new(:col => 5, :row=>10)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Creates a graphic frame and chart object associated with this anchor
|
|
45
|
+
# @return [Chart]
|
|
46
|
+
def add_chart(chart_type, options)
|
|
47
|
+
@object = GraphicFrame.new(self, chart_type, options)
|
|
48
|
+
@object.chart
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# The index of this anchor in the drawing
|
|
52
|
+
# @return [Integer]
|
|
53
|
+
def index
|
|
54
|
+
@drawing.anchors.index(self)
|
|
55
|
+
end
|
|
56
|
+
# Serializes the two cell anchor
|
|
57
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
|
58
|
+
# @return [String]
|
|
59
|
+
def to_xml(xml)
|
|
60
|
+
#build it for now, break it down later!
|
|
61
|
+
xml[:xdr].twoCellAnchor {
|
|
62
|
+
xml.from {
|
|
63
|
+
from.to_xml(xml)
|
|
64
|
+
}
|
|
65
|
+
xml.to {
|
|
66
|
+
to.to_xml(xml)
|
|
67
|
+
}
|
|
68
|
+
@object.to_xml(xml)
|
|
69
|
+
xml.clientData
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# the ValAxis class defines a chart value axis.
|
|
3
|
+
class ValAxis < Axis
|
|
4
|
+
|
|
5
|
+
# This element specifies how the value axis crosses the category axis.
|
|
6
|
+
# must be one of [:between, :midCat]
|
|
7
|
+
# @return [Symbol]
|
|
8
|
+
attr_reader :crossBetween
|
|
9
|
+
|
|
10
|
+
# Creates a new ValAxis object
|
|
11
|
+
# @param [Integer] axId the id of this axis
|
|
12
|
+
# @param [Integer] crossAx the id of the perpendicular axis
|
|
13
|
+
# @option options [Symbol] axPos
|
|
14
|
+
# @option options [Symbol] tickLblPos
|
|
15
|
+
# @option options [Symbol] crosses
|
|
16
|
+
# @option options [Symbol] crossesBetween
|
|
17
|
+
def initialize(axId, crossAx, options={})
|
|
18
|
+
self.crossBetween = :between
|
|
19
|
+
super(axId, crossAx, options)
|
|
20
|
+
end
|
|
21
|
+
# @see crossBetween
|
|
22
|
+
def crossBetween=(v) RestrictionValidator.validate "ValAxis.crossBetween", [:between, :midCat], v; @crossBetween = v; end
|
|
23
|
+
|
|
24
|
+
# Serializes the value axis
|
|
25
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
|
26
|
+
# @return [String]
|
|
27
|
+
def to_xml(xml)
|
|
28
|
+
xml.valAx {
|
|
29
|
+
super(xml)
|
|
30
|
+
xml.crossBetween :val=>@crossBetween
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# The ValAxisData class manages the values for a chart value series.
|
|
3
|
+
class ValAxisData < CatAxisData
|
|
4
|
+
|
|
5
|
+
# Serializes the value axis data
|
|
6
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
|
7
|
+
# @return [String]
|
|
8
|
+
def to_xml(xml)
|
|
9
|
+
xml.val {
|
|
10
|
+
xml.numRef {
|
|
11
|
+
xml.f Axlsx::cell_range(@list)
|
|
12
|
+
xml.numCache {
|
|
13
|
+
xml.formatCode 'General'
|
|
14
|
+
xml.ptCount :val=>size
|
|
15
|
+
each_with_index do |item, index|
|
|
16
|
+
v = item.is_a?(Cell) ? item.value : item
|
|
17
|
+
xml.pt(:idx=>index) { xml.v v }
|
|
18
|
+
end
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module Axlsx
|
|
2
|
+
# 3D attributes for a chart.
|
|
3
|
+
class View3D
|
|
4
|
+
|
|
5
|
+
# Validation for hPercent
|
|
6
|
+
H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/
|
|
7
|
+
|
|
8
|
+
# validation for depthPercent
|
|
9
|
+
DEPTH_PERCENT_REGEX = /0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)%/
|
|
10
|
+
|
|
11
|
+
# x rotation for the chart
|
|
12
|
+
# must be between -90 and 90
|
|
13
|
+
# @return [Integer]
|
|
14
|
+
attr_reader :rotX
|
|
15
|
+
|
|
16
|
+
# height of chart as % of chart
|
|
17
|
+
# must be between 5% and 500%
|
|
18
|
+
# @return [String]
|
|
19
|
+
attr_reader :hPercent
|
|
20
|
+
|
|
21
|
+
# y rotation for the chart
|
|
22
|
+
# must be between 0 and 360
|
|
23
|
+
# @return [Integer]
|
|
24
|
+
attr_reader :rotY
|
|
25
|
+
|
|
26
|
+
# depth or chart as % of chart width
|
|
27
|
+
# must be between 20% and 2000%
|
|
28
|
+
# @return [String]
|
|
29
|
+
attr_reader :depthPercent
|
|
30
|
+
|
|
31
|
+
# Chart axis are at right angles
|
|
32
|
+
# @return [Boolean]
|
|
33
|
+
attr_reader :rAngAx
|
|
34
|
+
|
|
35
|
+
# field of view angle
|
|
36
|
+
# @return [Integer]
|
|
37
|
+
attr_reader :perspective
|
|
38
|
+
|
|
39
|
+
# Creates a new View3D for charts
|
|
40
|
+
# @option options [Integer] rotX
|
|
41
|
+
# @option options [String] hPercent
|
|
42
|
+
# @option options [Integer] rotY
|
|
43
|
+
# @option options [String] depthPercent
|
|
44
|
+
# @option options [Boolean] rAngAx
|
|
45
|
+
# @option options [Integer] perspective
|
|
46
|
+
def initialize(options={})
|
|
47
|
+
@rotX, @hPercent, @rotY, @depthPercent, @rAngAx, @perspective = nil, nil, nil, nil, nil, nil
|
|
48
|
+
options.each do |o|
|
|
49
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# @see rotX
|
|
54
|
+
def rotX=(v) DataTypeValidator.validate "#{self.class}.rotX", [Integer, Fixnum], v, lambda {|arg| arg >= -90 && arg <= 90 }; @rotX = v; end
|
|
55
|
+
|
|
56
|
+
# @see hPercent
|
|
57
|
+
def hPercent=(v) RegexValidator.validate "#{self.class}.rotX", H_PERCENT_REGEX, v; @hPercent = v; end
|
|
58
|
+
|
|
59
|
+
# @see rotY
|
|
60
|
+
def rotY=(v) DataTypeValidator.validate "#{self.class}.rotY", [Integer, Fixnum], v, lambda {|arg| arg >= 0 && arg <= 360 }; @rotY = v; end
|
|
61
|
+
|
|
62
|
+
# @see depthPercent
|
|
63
|
+
def depthPercent=(v) RegexValidator.validate "#{self.class}.depthPercent", DEPTH_PERCENT_REGEX, v; @depthPercent = v; end
|
|
64
|
+
|
|
65
|
+
# @see rAngAx
|
|
66
|
+
def rAngAx=(v) Axlsx::validate_boolean(v); @rAngAx = v; end
|
|
67
|
+
|
|
68
|
+
# @see perspective
|
|
69
|
+
def perspective=(v) DataTypeValidator.validate "#{self.class}.perspective", [Integer, Fixnum], v, lambda {|arg| arg >= 0 && arg <= 240 }; @perspective = v; end
|
|
70
|
+
|
|
71
|
+
# Serializes the view3D properties
|
|
72
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
|
73
|
+
# @return [String]
|
|
74
|
+
def to_xml(xml)
|
|
75
|
+
xml[:c].view3D {
|
|
76
|
+
xml[:c].rotX :val=>@rotX unless @rotX.nil?
|
|
77
|
+
xml[:c].hPercent :val=>@hPercent unless @hPercent.nil?
|
|
78
|
+
xml[:c].rotY :val=>@rotY unless @rotY.nil?
|
|
79
|
+
xml[:c].depthPercent :val=>@depthPercent unless @depthPercent.nil?
|
|
80
|
+
xml[:c].rAngAx :val=>@rAngAx unless @rAngAx.nil?
|
|
81
|
+
xml[:c].perspective :val=>@perspective unless @perspective.nil?
|
|
82
|
+
}
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|