axlsx 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README.md +70 -0
- data/lib/axlsx.rb~ +67 -0
- data/lib/axlsx/content_type/content_type.rb~ +20 -0
- data/lib/axlsx/content_type/default.rb~ +32 -0
- data/lib/axlsx/content_type/override.rb~ +30 -0
- data/lib/axlsx/doc_props/app.rb~ +127 -0
- data/lib/axlsx/doc_props/core.rb~ +25 -0
- data/lib/axlsx/drawing/axis.rb~ +0 -0
- data/lib/axlsx/drawing/bar_3D_chart.rb~ +64 -0
- data/lib/axlsx/drawing/bar_series.rb~ +92 -0
- data/lib/axlsx/drawing/cat_axis.rb~ +32 -0
- data/lib/axlsx/drawing/chart.rb~ +0 -0
- data/lib/axlsx/drawing/drawing.rb~ +102 -0
- data/lib/axlsx/drawing/graphic_frame.rb~ +40 -0
- data/lib/axlsx/drawing/marker.rb~ +50 -0
- data/lib/axlsx/drawing/pie_3D_chart.rb~ +132 -0
- data/lib/axlsx/drawing/pie_series.rb~ +0 -0
- data/lib/axlsx/drawing/scaling.rb~ +0 -0
- data/lib/axlsx/drawing/series.rb~ +114 -0
- data/lib/axlsx/drawing/title.rb~ +69 -0
- data/lib/axlsx/drawing/two_cell_anchor.rb~ +70 -0
- data/lib/axlsx/drawing/val_axis.rb~ +34 -0
- data/lib/axlsx/drawing/view_3D.rb~ +21 -0
- data/lib/axlsx/package.rb +3 -3
- data/lib/axlsx/package.rb~ +181 -0
- data/lib/axlsx/rels/relationship.rb~ +18 -0
- data/lib/axlsx/rels/relationships.rb~ +23 -0
- data/lib/axlsx/stylesheet/border.rb~ +24 -0
- data/lib/axlsx/stylesheet/border_pr.rb~ +64 -0
- data/lib/axlsx/stylesheet/cell_alignment.rb~ +93 -0
- data/lib/axlsx/stylesheet/cell_protection.rb~ +16 -0
- data/lib/axlsx/stylesheet/cell_style.rb~ +61 -0
- data/lib/axlsx/stylesheet/color.rb~ +56 -0
- data/lib/axlsx/stylesheet/fill.rb~ +31 -0
- data/lib/axlsx/stylesheet/font.rb~ +33 -0
- data/lib/axlsx/stylesheet/gradient_fill.rb~ +70 -0
- data/lib/axlsx/stylesheet/gradient_stop.rb~ +15 -0
- data/lib/axlsx/stylesheet/num_fmt.rb~ +60 -0
- data/lib/axlsx/stylesheet/pattern_fill.rb~ +63 -0
- data/lib/axlsx/stylesheet/styles.rb~ +279 -0
- data/lib/axlsx/stylesheet/table_style.rb~ +43 -0
- data/lib/axlsx/stylesheet/table_style_element.rb~ +66 -0
- data/lib/axlsx/stylesheet/table_styles.rb~ +36 -0
- data/lib/axlsx/stylesheet/xf.rb~ +37 -0
- data/lib/axlsx/util/constants.rb +1 -1
- data/lib/axlsx/util/constants.rb~ +187 -0
- data/lib/axlsx/util/monkey_patches_for_true_zip_stream.rb~ +61 -0
- data/lib/axlsx/util/simple_typed_list.rb~ +79 -0
- data/lib/axlsx/util/validators.rb +3 -3
- data/lib/axlsx/util/validators.rb~ +132 -0
- data/lib/axlsx/util/xml_escape.rb~ +6 -0
- data/lib/axlsx/workbook/workbook.rb +1 -0
- data/lib/axlsx/workbook/workbook.rb~ +130 -0
- data/lib/axlsx/workbook/worksheet/cell.rb~ +185 -0
- data/lib/axlsx/workbook/worksheet/row.rb +4 -4
- data/lib/axlsx/workbook/worksheet/row.rb~ +92 -0
- data/lib/axlsx/workbook/worksheet/worksheet.rb +3 -4
- data/lib/axlsx/workbook/worksheet/worksheet.rb~ +194 -0
- data/lib/schema/dc.xsd~ +118 -0
- data/lib/schema/dcterms.xsd~ +331 -0
- data/lib/schema/opc-coreProperties.xsd~ +50 -0
- data/test/drawing/tc_bar_3D_chart.rb +1 -1
- data/test/drawing/tc_bar_3D_chart.rb~ +62 -0
- data/test/drawing/tc_chart.rb +1 -1
- data/test/drawing/tc_chart.rb~ +1 -0
- data/test/drawing/tc_pie_3D_chart.rb +1 -1
- data/test/drawing/tc_pie_3D_chart.rb~ +3 -28
- data/test/drawing/tc_title.rb +1 -1
- data/test/drawing/tc_title.rb~ +16 -19
- data/test/drawing/tc_two_cell_anchor.rb +1 -1
- data/test/drawing/tc_two_cell_anchor.rb~ +16 -14
- data/test/tc_package.rb +1 -1
- data/test/workbook/worksheet/tc_row.rb +1 -1
- data/test/workbook/worksheet/tc_row.rb~ +30 -0
- data/test/workbook/worksheet/tc_worksheet.rb +3 -3
- data/test/workbook/worksheet/tc_worksheet.rb~ +85 -0
- metadata +84 -102
@@ -0,0 +1,92 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# A BarSeries defines the title, data and labels for bar charts
|
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 BarSeries < Series
|
7
|
+
|
8
|
+
# The series title.
|
9
|
+
# @return [String]
|
10
|
+
attr_accessor :title
|
11
|
+
|
12
|
+
# The data for this series.
|
13
|
+
# @return [Array, SimpleTypedList]
|
14
|
+
attr_reader :data
|
15
|
+
|
16
|
+
|
17
|
+
# The labels for this series.
|
18
|
+
# @return [Array, SimpleTypedList]
|
19
|
+
attr_reader :labels
|
20
|
+
|
21
|
+
|
22
|
+
# Creates a new series
|
23
|
+
# @option options [Array, SimpleTypedList] data
|
24
|
+
# @option options [Array, SimpleTypedList] labels
|
25
|
+
# @option options [String] title
|
26
|
+
# @param [Chart] chart
|
27
|
+
def initialize(chart, options={})
|
28
|
+
super(chart, options)
|
29
|
+
self.data = options[:data] || []
|
30
|
+
self.labels = options[:labels] || []
|
31
|
+
@title = options[:title] || ''
|
32
|
+
end
|
33
|
+
|
34
|
+
# Serializes the series
|
35
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
36
|
+
# @return [String]
|
37
|
+
def to_xml(xml)
|
38
|
+
xml.send('c:ser') {
|
39
|
+
xml.send('c:idx', :val=>index)
|
40
|
+
xml.send('c:order', :val=>index)
|
41
|
+
xml.send('c:tx') {
|
42
|
+
xml.send('c:v', self.title)
|
43
|
+
}
|
44
|
+
|
45
|
+
if !labels.empty?
|
46
|
+
xml.send('c:cat') {
|
47
|
+
xml.send('c:strRef') {
|
48
|
+
xml.send('c:f', range(labels))
|
49
|
+
xml.send('c:strCache') {
|
50
|
+
xml.send('c:ptCount', :val=>labels.size)
|
51
|
+
labels.each_with_index do |cell, index|
|
52
|
+
v = cell.is_a?(Cell) ? cell.value : cell
|
53
|
+
xml.send('c:pt', :idx=>index) {
|
54
|
+
xml.send('c:v', v)
|
55
|
+
}
|
56
|
+
end
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
end
|
61
|
+
xml.send('c:val') {
|
62
|
+
xml.send('c:numRef') {
|
63
|
+
xml.send('c:f', range(data))
|
64
|
+
xml.send('c:numCache') {
|
65
|
+
xml.send('c:formatCode', 'General')
|
66
|
+
xml.send('c:ptCount', :val=>data.size)
|
67
|
+
data.each_with_index do |cell, index|
|
68
|
+
v = cell.is_a?(Cell) ? cell.value : cell
|
69
|
+
xml.send('c:pt', :idx=>index) {
|
70
|
+
xml.send('c:v', v)
|
71
|
+
}
|
72
|
+
end
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
|
84
|
+
# assigns the data for this series
|
85
|
+
def data=(v) DataTypeValidator.validate "Series.data", [Array, SimpleTypedList], v; @data = v; end
|
86
|
+
|
87
|
+
# assigns the labels for this series
|
88
|
+
def labels=(v) DataTypeValidator.validate "Series.labels", [Array, SimpleTypedList], v; @labels = v; end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Axlsx
|
2
|
+
|
3
|
+
#A CatAxis object defines a chart category axis
|
4
|
+
class CatAxis
|
5
|
+
# <c:catAx>
|
6
|
+
# <c:axId val="545184360"/>
|
7
|
+
# <c:scaling>
|
8
|
+
# <c:orientation val="minMax"/>
|
9
|
+
# </c:scaling>
|
10
|
+
# <c:axPos val="l"/>
|
11
|
+
# <c:tickLblPos val="nextTo"/>
|
12
|
+
# <c:crossAx val="545218840"/>
|
13
|
+
# <c:crosses val="autoZero"/>
|
14
|
+
# <c:auto val="1"/>
|
15
|
+
# <c:lblAlgn val="ctr"/>
|
16
|
+
# <c:lblOffset val="100"/>
|
17
|
+
# </c:catAx>
|
18
|
+
|
19
|
+
attr_reader :axId
|
20
|
+
|
21
|
+
att_reader :scaling
|
22
|
+
|
23
|
+
# The position of the axis
|
24
|
+
# must be one of [:l, :r, :t, :b]
|
25
|
+
# @return [String]
|
26
|
+
attr_accessor :axPos
|
27
|
+
|
28
|
+
def axPos=(v) RestrictionValidator.validate "CatAxis.axPos", [:l, :r, :b, :t], v; @axPos = v; end
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
File without changes
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# A Drawing is a canvas for charts. Each worksheet has a single drawing that can specify multiple anchors which reference charts.
|
3
|
+
# @note The recommended way to manage drawings is to use the Worksheet.add_chart method, specifying the chart class, start and end marker locations.
|
4
|
+
# @see Worksheet#add_chart
|
5
|
+
# @see TwoCellAnchor
|
6
|
+
# @see Chart
|
7
|
+
class Drawing
|
8
|
+
|
9
|
+
# The workbook that owns the drawing
|
10
|
+
# @return [Workbook]
|
11
|
+
attr_reader :workbook
|
12
|
+
|
13
|
+
# A collection of anchors for this drawing
|
14
|
+
# @return [SimpleTypedList]
|
15
|
+
attr_reader :anchors
|
16
|
+
|
17
|
+
# An array of charts that are associated with this drawing's anchors
|
18
|
+
# @return [Array]
|
19
|
+
attr_reader :charts
|
20
|
+
|
21
|
+
# The index of this drawing in the owning workbooks's drawings collection.
|
22
|
+
# @return [Integer]
|
23
|
+
attr_reader :index
|
24
|
+
|
25
|
+
# The relation reference id for this drawing
|
26
|
+
# @return [String]
|
27
|
+
attr_reader :rId
|
28
|
+
|
29
|
+
# The part name for this drawing
|
30
|
+
# @return [String]
|
31
|
+
attr_reader :pn
|
32
|
+
|
33
|
+
# The relational part name for this drawing
|
34
|
+
# @return [String]
|
35
|
+
attr_reader :rels_pn
|
36
|
+
|
37
|
+
# The drawing's relationships.
|
38
|
+
# @return [Relationships]
|
39
|
+
attr_reader :relationships
|
40
|
+
|
41
|
+
# Creates a new Drawing object
|
42
|
+
# @param [Workbook] workbook The workbook that owns the drawing.
|
43
|
+
def initialize(workbook)
|
44
|
+
DataTypeValidator.validate "Drawing.workbook", Workbook, workbook
|
45
|
+
@workbook=workbook
|
46
|
+
@workbook.drawings << self
|
47
|
+
@anchors = SimpleTypedList.new TwoCellAnchor
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
# Adds a chart to the drawing.
|
52
|
+
# @note The recommended way to manage charts is to use Worksheet.add_chart.
|
53
|
+
# @param [Chart] chart_type The class of the chart to be added to the drawing
|
54
|
+
# @param [Hash] options
|
55
|
+
def add_chart(chart_type, options={})
|
56
|
+
DataTypeValidator.validate "Drawing.chart_type", [Chart, Pie3DChart], chart_type
|
57
|
+
chart = chart_type.new(@workbook, options)
|
58
|
+
TwoCellAnchor.new(self, chart, options)
|
59
|
+
@anchors.last.graphic_frame.chart
|
60
|
+
end
|
61
|
+
|
62
|
+
def charts
|
63
|
+
@anchors.map { |a| a.graphic_frame.chart }
|
64
|
+
end
|
65
|
+
|
66
|
+
def index
|
67
|
+
@workbook.drawings.index(self)
|
68
|
+
end
|
69
|
+
|
70
|
+
def rId
|
71
|
+
"rId#{index+1}"
|
72
|
+
end
|
73
|
+
|
74
|
+
def pn
|
75
|
+
"#{DRAWING_PN % (index+1)}"
|
76
|
+
end
|
77
|
+
|
78
|
+
def rels_pn
|
79
|
+
"#{DRAWING_RELS_PN % (index+1)}"
|
80
|
+
end
|
81
|
+
|
82
|
+
def relationships
|
83
|
+
r = Relationships.new
|
84
|
+
@anchors.each do |anchor|
|
85
|
+
chart = anchor.graphic_frame.chart
|
86
|
+
r << Relationship.new(CHART_R, "../#{chart.pn}")
|
87
|
+
end
|
88
|
+
r
|
89
|
+
end
|
90
|
+
|
91
|
+
# Serializes the pie chart
|
92
|
+
# @return [String]
|
93
|
+
def to_xml
|
94
|
+
builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
|
95
|
+
xml.send('xdr:wsDr', :'xmlns:xdr'=>XML_NS_XDR, :'xmlns:a'=>XML_NS_A) {
|
96
|
+
anchors.each {|anchor| anchor.to_xml(xml) }
|
97
|
+
}
|
98
|
+
end
|
99
|
+
builder.to_xml
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# A graphic frame defines a container for a chart object
|
3
|
+
# @note The recommended way to manage charts is Worksheet#add_chart
|
4
|
+
# @see Worksheet#add_chart
|
5
|
+
class GraphicFrame
|
6
|
+
#TODO add in support for other graphical objects, primarily images.
|
7
|
+
|
8
|
+
# A reference to the chart object associated with this frame
|
9
|
+
# @return [Chart]
|
10
|
+
attr_reader :chart
|
11
|
+
|
12
|
+
# Creates a new GraphicFrame object
|
13
|
+
# @param [Chart] chart
|
14
|
+
def initialize(chart)
|
15
|
+
@chart = chart
|
16
|
+
end
|
17
|
+
|
18
|
+
# Serializes the gradientStop
|
19
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
20
|
+
# @return [String]
|
21
|
+
def to_xml(xml)
|
22
|
+
xml.send('xdr:graphicFrame') {
|
23
|
+
xml.send('xdr:nvGraphicFramePr') {
|
24
|
+
xml.send('xdr:cNvPr', :id=>2, :name=>chart.title)
|
25
|
+
xml.send('xdr:cNvGraphicFramePr')
|
26
|
+
}
|
27
|
+
xml.send('xdr:xfrm') {
|
28
|
+
xml.send('a:off', :x=>0, :y=>0)
|
29
|
+
xml.send('a:ext', :cx=>0, :cy=>0)
|
30
|
+
}
|
31
|
+
xml.send('a:graphic') {
|
32
|
+
xml.send('a:graphicData', :uri=>XML_NS_C) {
|
33
|
+
xml.send('c:chart', :'xmlns:c'=>XML_NS_C, :'xmlns:r'=>XML_NS_R, :'r:id'=>chart.rId)
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Axlsx
|
2
|
+
# The Marker class defines a point in the worksheet that drawing anchors attach to.
|
3
|
+
# @note The recommended way to manage markers is Worksheet#add_chart Markers are created for a two cell anchor based on the :start and :end options.
|
4
|
+
# @see Worksheet#add_chart
|
5
|
+
class Marker
|
6
|
+
|
7
|
+
# The column this marker anchors to
|
8
|
+
# @return [Integer]
|
9
|
+
attr_accessor :col
|
10
|
+
|
11
|
+
# The offset distance from this marker's column
|
12
|
+
# @return [Integer]
|
13
|
+
attr_accessor :colOff
|
14
|
+
|
15
|
+
# The row this marker anchors to
|
16
|
+
# @return [Integer]
|
17
|
+
attr_accessor :row
|
18
|
+
|
19
|
+
# The offset distance from this marker's row
|
20
|
+
# @return [Integer]
|
21
|
+
attr_accessor :rowOff
|
22
|
+
|
23
|
+
# Creates a new Marker object
|
24
|
+
# @option options [Integer] col
|
25
|
+
# @option options [Integer] colOff
|
26
|
+
# @option options [Integer] row
|
27
|
+
# @option options [Integer] rowOff
|
28
|
+
def initialize(options={})
|
29
|
+
@col, @colOff, @row, @rowOff = 0, 0, 0, 0
|
30
|
+
options.each do |o|
|
31
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def col=(v) Axlsx::validate_unsigned_int v; @col = v end
|
36
|
+
def colOff=(v) Axlsx::validate_int v; @colOff = v end
|
37
|
+
def row=(v) Axlsx::validate_unsigned_int v; @row = v end
|
38
|
+
def rowOff=(v) Axlsx::validate_int v; @rowOff = v end
|
39
|
+
|
40
|
+
# Serializes the gradientStop
|
41
|
+
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
42
|
+
# @return [String]
|
43
|
+
def to_xml(xml)
|
44
|
+
[:col, :colOff, :row, :rowOff].each do |k|
|
45
|
+
xml.send("xdr:#{k.to_s}", self.send(k))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
module Axlsx
|
2
|
+
|
3
|
+
# A Chart is the class that real classes (e.g. Pie3DChart) inherit from. When you actually create a chart, you will not be creating a new instance of this class, but an instance of a subclass that defines the behavour and serialization for the chart.
|
4
|
+
# @note Worksheet#add_chart is the recommended way to create charts for your worksheets.
|
5
|
+
class Chart
|
6
|
+
|
7
|
+
# The title object for the chart.
|
8
|
+
# @return [Title]
|
9
|
+
attr_reader :title
|
10
|
+
|
11
|
+
# A reference to the workbook that owns this chart
|
12
|
+
# @return [Workbook]
|
13
|
+
attr_reader :workbook
|
14
|
+
|
15
|
+
# A collection of series objects that are applied to the chart
|
16
|
+
# @return [SimpleTypedList]
|
17
|
+
attr_reader :series
|
18
|
+
|
19
|
+
# The relation referece id for this object.
|
20
|
+
# @return [String]
|
21
|
+
attr_reader :rId
|
22
|
+
|
23
|
+
# The index of this chart in the workbooks charts collection
|
24
|
+
# @return [Integer]
|
25
|
+
attr_reader :index
|
26
|
+
|
27
|
+
# The part name for this chart
|
28
|
+
# @return [String]
|
29
|
+
attr_reader :pn
|
30
|
+
|
31
|
+
|
32
|
+
# Creates a new chart object
|
33
|
+
# @param [Workbook] workbook The workbook that owns this chart.
|
34
|
+
# @option options [Cell, String] title
|
35
|
+
def initialize(workbook, options={})
|
36
|
+
@workbook=workbook
|
37
|
+
@workbook.charts << self
|
38
|
+
@title = Title.new options[:title]
|
39
|
+
@series = SimpleTypedList.new Series
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def rId
|
44
|
+
"rId#{index+1}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def index
|
48
|
+
@workbook.charts.index(self)
|
49
|
+
end
|
50
|
+
|
51
|
+
def pn
|
52
|
+
"#{CHART_PN % (index+1)}"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Adds a new series to the chart's series collection.
|
56
|
+
#
|
57
|
+
# @return [Series]
|
58
|
+
# @see Series
|
59
|
+
def add_series(options={})
|
60
|
+
Series.new(self, options)
|
61
|
+
@series.last
|
62
|
+
end
|
63
|
+
|
64
|
+
# @raise [StandardError] This method must be overridden in subclasses.
|
65
|
+
def to_xml
|
66
|
+
raise "This method must be overriden in subclasses."
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# The Pie3DChart is a three dimentional piechart (who would have guessed?) that you can add to your worksheet.
|
71
|
+
# @example Creating a chart
|
72
|
+
# # This example creates two charts in a single sheet.
|
73
|
+
# # The first uses data directly fed to the sheet, while the second references cells withing the worksheet for data.
|
74
|
+
#
|
75
|
+
# require "rubygems" # if that is your preferred way to manage gems!
|
76
|
+
# require "axlsx"
|
77
|
+
#
|
78
|
+
# p = Axlsx::Package.new
|
79
|
+
# ws = p.workbook.add_worksheet
|
80
|
+
# ws.add_row :values => ["This is a chart with no data in the sheet"]
|
81
|
+
#
|
82
|
+
# chart = ws.add_chart(Axlsx::Pie3DChart, :start_at=> [0,1], :end_at=>[0,6], :title=>"Most Popular Pets")
|
83
|
+
# chart.add_series :data => [1, 9, 10], :labels => ["Slimy Reptiles", "Fuzzy Bunnies", "Rottweiler"]
|
84
|
+
#
|
85
|
+
# ws.add_row :values => ["This chart uses the data below"]
|
86
|
+
# title_row = ws.add_row :values => ["Least Popular Pets"]
|
87
|
+
# label_row = ws.add_row :values => ["", "Dry Skinned Reptiles", "Bald Cats", "Violent Parrots"]
|
88
|
+
# data_row = ws.add_row :values => ["Votes", 6, 4, 1]
|
89
|
+
#
|
90
|
+
# chart = ws.add_chart(Axlsx::Pie3DChart, :start_at => [0,11], :end_at =>[0,16], :title => title_row.cells.last)
|
91
|
+
# chart.add_series :data => data_row.cells[(1..-1)], :labels => label_row.cells
|
92
|
+
#
|
93
|
+
# f = File.open('example_pie_3d_chart.xlsx', 'w')
|
94
|
+
# p.serialize(f)
|
95
|
+
#
|
96
|
+
# @see Worksheet#add_chart
|
97
|
+
# @see Worksheet#add_row
|
98
|
+
# @see Chart#add_series
|
99
|
+
# @see Series
|
100
|
+
# @see Package#serialize
|
101
|
+
class Pie3DChart < Chart
|
102
|
+
|
103
|
+
# Serializes the pie chart
|
104
|
+
# @return [String]
|
105
|
+
def to_xml
|
106
|
+
builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
|
107
|
+
xml.send('c:chartSpace',:'xmlns:c' => XML_NS_C,
|
108
|
+
:'xmlns:a' => XML_NS_A) {
|
109
|
+
xml.send('c:chart') {
|
110
|
+
@title.to_xml(xml)
|
111
|
+
xml.send('c:view3D') {
|
112
|
+
xml.send('c:rotX', :val=>30)
|
113
|
+
xml.send('c:perspective', :val=>30)
|
114
|
+
}
|
115
|
+
xml.send('c:plotArea') {
|
116
|
+
xml.send('c:layout')
|
117
|
+
xml.send('c:pie3DChart') {
|
118
|
+
xml.send('c:varyColors', :val=>1)
|
119
|
+
@series.each { |ser| ser.to_xml(xml) }
|
120
|
+
}
|
121
|
+
}
|
122
|
+
xml.send('c:legend') {
|
123
|
+
xml.send('c:legendPos', :val => "r")
|
124
|
+
xml.send('c:layout')
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
end
|
129
|
+
builder.to_xml
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|