axlsx 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/LICENSE +22 -0
  2. data/README.md +70 -0
  3. data/lib/axlsx.rb~ +67 -0
  4. data/lib/axlsx/content_type/content_type.rb~ +20 -0
  5. data/lib/axlsx/content_type/default.rb~ +32 -0
  6. data/lib/axlsx/content_type/override.rb~ +30 -0
  7. data/lib/axlsx/doc_props/app.rb~ +127 -0
  8. data/lib/axlsx/doc_props/core.rb~ +25 -0
  9. data/lib/axlsx/drawing/axis.rb~ +0 -0
  10. data/lib/axlsx/drawing/bar_3D_chart.rb~ +64 -0
  11. data/lib/axlsx/drawing/bar_series.rb~ +92 -0
  12. data/lib/axlsx/drawing/cat_axis.rb~ +32 -0
  13. data/lib/axlsx/drawing/chart.rb~ +0 -0
  14. data/lib/axlsx/drawing/drawing.rb~ +102 -0
  15. data/lib/axlsx/drawing/graphic_frame.rb~ +40 -0
  16. data/lib/axlsx/drawing/marker.rb~ +50 -0
  17. data/lib/axlsx/drawing/pie_3D_chart.rb~ +132 -0
  18. data/lib/axlsx/drawing/pie_series.rb~ +0 -0
  19. data/lib/axlsx/drawing/scaling.rb~ +0 -0
  20. data/lib/axlsx/drawing/series.rb~ +114 -0
  21. data/lib/axlsx/drawing/title.rb~ +69 -0
  22. data/lib/axlsx/drawing/two_cell_anchor.rb~ +70 -0
  23. data/lib/axlsx/drawing/val_axis.rb~ +34 -0
  24. data/lib/axlsx/drawing/view_3D.rb~ +21 -0
  25. data/lib/axlsx/package.rb +3 -3
  26. data/lib/axlsx/package.rb~ +181 -0
  27. data/lib/axlsx/rels/relationship.rb~ +18 -0
  28. data/lib/axlsx/rels/relationships.rb~ +23 -0
  29. data/lib/axlsx/stylesheet/border.rb~ +24 -0
  30. data/lib/axlsx/stylesheet/border_pr.rb~ +64 -0
  31. data/lib/axlsx/stylesheet/cell_alignment.rb~ +93 -0
  32. data/lib/axlsx/stylesheet/cell_protection.rb~ +16 -0
  33. data/lib/axlsx/stylesheet/cell_style.rb~ +61 -0
  34. data/lib/axlsx/stylesheet/color.rb~ +56 -0
  35. data/lib/axlsx/stylesheet/fill.rb~ +31 -0
  36. data/lib/axlsx/stylesheet/font.rb~ +33 -0
  37. data/lib/axlsx/stylesheet/gradient_fill.rb~ +70 -0
  38. data/lib/axlsx/stylesheet/gradient_stop.rb~ +15 -0
  39. data/lib/axlsx/stylesheet/num_fmt.rb~ +60 -0
  40. data/lib/axlsx/stylesheet/pattern_fill.rb~ +63 -0
  41. data/lib/axlsx/stylesheet/styles.rb~ +279 -0
  42. data/lib/axlsx/stylesheet/table_style.rb~ +43 -0
  43. data/lib/axlsx/stylesheet/table_style_element.rb~ +66 -0
  44. data/lib/axlsx/stylesheet/table_styles.rb~ +36 -0
  45. data/lib/axlsx/stylesheet/xf.rb~ +37 -0
  46. data/lib/axlsx/util/constants.rb +1 -1
  47. data/lib/axlsx/util/constants.rb~ +187 -0
  48. data/lib/axlsx/util/monkey_patches_for_true_zip_stream.rb~ +61 -0
  49. data/lib/axlsx/util/simple_typed_list.rb~ +79 -0
  50. data/lib/axlsx/util/validators.rb +3 -3
  51. data/lib/axlsx/util/validators.rb~ +132 -0
  52. data/lib/axlsx/util/xml_escape.rb~ +6 -0
  53. data/lib/axlsx/workbook/workbook.rb +1 -0
  54. data/lib/axlsx/workbook/workbook.rb~ +130 -0
  55. data/lib/axlsx/workbook/worksheet/cell.rb~ +185 -0
  56. data/lib/axlsx/workbook/worksheet/row.rb +4 -4
  57. data/lib/axlsx/workbook/worksheet/row.rb~ +92 -0
  58. data/lib/axlsx/workbook/worksheet/worksheet.rb +3 -4
  59. data/lib/axlsx/workbook/worksheet/worksheet.rb~ +194 -0
  60. data/lib/schema/dc.xsd~ +118 -0
  61. data/lib/schema/dcterms.xsd~ +331 -0
  62. data/lib/schema/opc-coreProperties.xsd~ +50 -0
  63. data/test/drawing/tc_bar_3D_chart.rb +1 -1
  64. data/test/drawing/tc_bar_3D_chart.rb~ +62 -0
  65. data/test/drawing/tc_chart.rb +1 -1
  66. data/test/drawing/tc_chart.rb~ +1 -0
  67. data/test/drawing/tc_pie_3D_chart.rb +1 -1
  68. data/test/drawing/tc_pie_3D_chart.rb~ +3 -28
  69. data/test/drawing/tc_title.rb +1 -1
  70. data/test/drawing/tc_title.rb~ +16 -19
  71. data/test/drawing/tc_two_cell_anchor.rb +1 -1
  72. data/test/drawing/tc_two_cell_anchor.rb~ +16 -14
  73. data/test/tc_package.rb +1 -1
  74. data/test/workbook/worksheet/tc_row.rb +1 -1
  75. data/test/workbook/worksheet/tc_row.rb~ +30 -0
  76. data/test/workbook/worksheet/tc_worksheet.rb +3 -3
  77. data/test/workbook/worksheet/tc_worksheet.rb~ +85 -0
  78. metadata +84 -102
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2011 Randy Morgan
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,70 @@
1
+ Axlsx: Office Open XML Spreadsheet Generation
2
+ ====================================
3
+
4
+ **IRC**: [irc.freenode.net / #axlsx](irc://irc.freenode.net/axlsx)
5
+ **Git**: [http://github.com/randym/axlsx](http://github.com/randym/axlsx)
6
+ **Author**: Randy Morgan
7
+ **Copyright**: 2011
8
+ **License**: MIT License
9
+ **Latest Version**: 1.0.0
10
+ **Release Date**: November 20th 2011
11
+
12
+ Synopsis
13
+ --------
14
+
15
+ Axlsx is an Office Open XML Spreadsheet generator for the Ruby programming language.
16
+ It enables the you to generate 100% valid xlsx files that include customised styling 3D pie, bar and line charts. Below is a summary of salient features.
17
+
18
+ Feature List
19
+ ------------
20
+
21
+ **1. Author xlsx documents: Axlsx is made to let you easily and quickly generate profesional xlsx based reports that can be validated before serialiation.
22
+
23
+ **2. Generate 3D Pie and Bar Charts: With Axlsx chart generation and management is as easy as a few lines of code. You can build charts based off data in your worksheet or generate charts without any data in your sheet at all.
24
+
25
+ **3. Custom Styles: With guaranteed document validity, you can style borders, alignment, fills, fonts, and number formats in a single line of code. Those styles can be applied to an entire row, or a single cell anywhere in your workbook.
26
+
27
+ **4. Automatic type support: Axlsx will automatically determine the type of data you are generating. In this release Float, Integer, String and Time types are automatically identified and serialized to your spreadsheet.
28
+
29
+ Installing
30
+ ----------
31
+
32
+ To install Axlsx, use the following command:
33
+
34
+ $ gem install axlsx
35
+
36
+ Usage
37
+ -----
38
+
39
+ Generating a workbook with styles and a chart:
40
+ p = Axlsx::Package.new do |package|
41
+ package.workbook.add_worksheet do |sheet|
42
+ sheet.add_row ["First", "Second", "Third"], :style => Axlsx::STYLE_THIN_BORDER
43
+ sheet.add_row [1, 2, 3], :style => Axlsx::STYLE_THIN_BORDER
44
+ sheet.add_chart(Axlsx::Bar3DChart, :start_at => [0,2], :end_at => [5, 15], :title=>"example 1: Chart") do |chart|
45
+ chart.add_series :data=>sheet.rows.last.cells, :labels=> sheet.rows.first.cells
46
+ end
47
+ end
48
+ package.serialize("example1.xlsx")
49
+ end
50
+
51
+
52
+ ### Documentation
53
+ This gem is 100% documented with YARD, an exceptional documentation library. To see documentation for this, and all the gems installed on your system use:
54
+
55
+ yard server -g
56
+
57
+
58
+ ### Specs
59
+ This gem has 100% test coverage. To execute tests for this gem, simply run rake in the gem directory.
60
+
61
+ Changelog
62
+ ---------
63
+
64
+ - **October.10.11**: 0.1.0 release
65
+
66
+ Copyright
67
+ ---------
68
+
69
+ Axlsx © 2011 by [Randy Morgan](mailto:digial.ipseity@gmail.com). Axlsx is
70
+ licensed under the MIT license. Please see the {file:LICENSE} document for more information.
@@ -0,0 +1,67 @@
1
+
2
+ require 'axlsx/util/simple_typed_list.rb'
3
+ require 'axlsx/util/constants.rb'
4
+ require 'axlsx/util/validators.rb'
5
+
6
+ require 'axlsx/stylesheet/border.rb'
7
+ require 'axlsx/stylesheet/border_pr.rb'
8
+ require 'axlsx/stylesheet/cell_alignment.rb'
9
+ require 'axlsx/stylesheet/cell_style.rb'
10
+ require 'axlsx/stylesheet/color.rb'
11
+ require 'axlsx/stylesheet/fill.rb'
12
+ require 'axlsx/stylesheet/font.rb'
13
+ require 'axlsx/stylesheet/gradient_fill.rb'
14
+ require 'axlsx/stylesheet/gradient_stop.rb'
15
+ require 'axlsx/stylesheet/num_fmt.rb'
16
+ require 'axlsx/stylesheet/pattern_fill.rb'
17
+ require 'axlsx/stylesheet/styles.rb'
18
+ require 'axlsx/stylesheet/table_style.rb'
19
+ require 'axlsx/stylesheet/table_styles.rb'
20
+ require 'axlsx/stylesheet/table_style_element.rb'
21
+ require 'axlsx/stylesheet/xf.rb'
22
+ require 'axlsx/stylesheet/cell_protection.rb'
23
+
24
+ require 'axlsx/doc_props/app.rb'
25
+ require 'axlsx/doc_props/core.rb'
26
+
27
+ require 'axlsx/drawing/drawing.rb'
28
+ require 'axlsx/drawing/graphic_frame.rb'
29
+ require 'axlsx/drawing/marker.rb'
30
+ require 'axlsx/drawing/pie_3D_chart.rb'
31
+ require 'axlsx/drawing/series.rb'
32
+ require 'axlsx/drawing/two_cell_anchor.rb'
33
+ require 'axlsx/drawing/title.rb'
34
+
35
+ require 'axlsx/content_type/content_type.rb'
36
+ require 'axlsx/content_type/default.rb'
37
+ require 'axlsx/content_type/override.rb'
38
+
39
+
40
+ require 'axlsx/rels/relationship.rb'
41
+ require 'axlsx/rels/relationships.rb'
42
+
43
+ require 'axlsx/workbook/worksheet/row.rb'
44
+ require 'axlsx/workbook/worksheet/cell.rb'
45
+ require 'axlsx/workbook/workbook.rb'
46
+ require 'axlsx/workbook/worksheet/worksheet.rb'
47
+
48
+ require 'axlsx/package.rb'
49
+
50
+
51
+ module Axlsx
52
+
53
+ #required gems
54
+ require 'Nokogiri'
55
+ require 'active_support/core_ext/object/instance_variables'
56
+ require 'active_support/inflector'
57
+ require 'rmagick'
58
+ require 'zip/zip'
59
+
60
+ #core dependencies
61
+ require 'bigdecimal'
62
+ require 'time'
63
+ require 'CGI'
64
+
65
+
66
+
67
+ end
@@ -0,0 +1,20 @@
1
+ module Axlsx
2
+ # ContentTypes used in the package. This is automatcially managed by the package package.
3
+ class ContentType < SimpleTypedList
4
+
5
+ def initialize
6
+ super [Override, Default]
7
+ end
8
+
9
+ # Generates the xml document for [Content_Types].xml
10
+ # @return [String] The document as a string.
11
+ def to_xml()
12
+ builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
13
+ xml.Types(:xmlns => Axlsx::XML_NS_T) {
14
+ each { |type| type.to_xml(xml) }
15
+ }
16
+ end
17
+ builder.to_xml
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,32 @@
1
+ module Axlsx
2
+ # An default content part. These parts are automatically created by for you based on the content of your package.
3
+ class Default
4
+
5
+ # The extension of the content type.
6
+ # @return [String]
7
+ attr_accessor :Extension
8
+
9
+ # @return [String] ContentType The type of content. TABLE_CT, WORKBOOK_CT, APP_CT, RELS_CT, STYLES_CT, XML_CT, WORKSHEET_CT, SHARED_STRINGS_CT, CORE_CT, CHART_CT, DRAWING_CT are allowed
10
+ attr_accessor :ContentType
11
+
12
+ #Creates a new Default object
13
+ # @option options [String] Extension
14
+ # @option options [String] ContentType
15
+ # @raise [ArgumentError] An argument error is raised if both Extension and ContentType are not specified.
16
+ def initialize(options={})
17
+ raise ArugumentError, "Extension and ContentType are required" unless options[:Extension] && options[:ContentType]
18
+ options.each do |o|
19
+ self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
20
+ end
21
+ end
22
+ def Extension=(v) Axlsx::validate_string v; @Extension = v end
23
+ def ContentType=(v) Axlsx::validate_content_type v; @ContentType = v end
24
+
25
+ # Serializes the object to xml
26
+ # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
27
+ # @return [String]
28
+ def to_xml(xml)
29
+ xml.Default(self.instance_values)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,30 @@
1
+ module Axlsx
2
+ # An override content part. These parts are automatically created by for you based on the content of your package.
3
+ class Override
4
+
5
+ # @return [String] ContentType The type of content. TABLE_CT, WORKBOOK_CT, APP_CT, RELS_CT, STYLES_CT, XML_CT, WORKSHEET_CT, SHARED_STRINGS_CT, CORE_CT, CHART_CT, DRAWING_CT are allowed
6
+ attr_accessor :ContentType
7
+
8
+ # @return [String] PartName The name and location of the part.
9
+ attr_accessor :PartName
10
+
11
+ #Creates a new Override object
12
+ # @option options [String] PartName
13
+ # @option options [String] ContentType
14
+ # @raise [ArgumentError] An argument error is raised if both PartName and ContentType are not specified.
15
+ def initialize(options={})
16
+ raise ArugumentError, "PartName and ContentType are required" unless options[:PartName] && options[:ContentType]
17
+ options.each do |o|
18
+ self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
19
+ end
20
+ end
21
+ def PartName=(v) Axlsx::validate_string v; @PartName = v end
22
+ def ContentType=(v) Axlsx::validate_content_type v; @ContentType = v end
23
+
24
+ # Serializes the Override object to xml
25
+ # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
26
+ def to_xml(xml)
27
+ xml.Override(self.instance_values)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,127 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Axlsx
3
+
4
+
5
+ # App represents the app.xml document. The attributes for this object are primarily managed by the application the end user uses to edit the document. None of the attributes are required to serialize a valid xlsx object.
6
+ # @see shared-documentPropertiesExtended.xsd
7
+ # @note Support is not implemented for the following complex types:
8
+ #
9
+ # HeadingPairs (VectorVariant),
10
+ # TitlesOfParts (VectorLpstr),
11
+ # HLinks (VectorVariant),
12
+ # DigSig (DigSigBlob)
13
+ class App
14
+
15
+ # @return [String] The name of the document template.
16
+ attr_accessor :Template
17
+
18
+ # @return [String] The name of the manager for the document.
19
+ attr_accessor :Manager
20
+
21
+ # @return [String] The name of the company generating the document.
22
+ attr_accessor :Company
23
+
24
+ # @return [Integer] The number of pages in the document.
25
+ attr_accessor :Pages
26
+
27
+ # @return [Integer] The number of words in the document.
28
+ attr_accessor :Words
29
+
30
+ # @return [Integer] The number of characters in the document.
31
+ attr_accessor :Characters
32
+
33
+ # @return [String] The intended format of the presentation.
34
+ attr_accessor :PresentationFormat
35
+
36
+ # @return [Integer] The number of lines in the document.
37
+ attr_accessor :Lines
38
+
39
+ # @return [Integer] The number of paragraphs in the document
40
+ attr_accessor :Paragraphs
41
+
42
+ # @return [Intger] The number of slides in the document.
43
+ attr_accessor :Slides
44
+
45
+ # @return [Integer] The number of slides that have notes.
46
+ attr_accessor :Notes
47
+
48
+ # @return [Integer] The total amount of time spent editing.
49
+ attr_accessor :TotalTime
50
+
51
+ # @return [Integer] The number of hidden slides.
52
+ attr_accessor :HiddenSlides
53
+
54
+ # @return [Integer] The total number multimedia clips
55
+ attr_accessor :MMClips
56
+
57
+ # @return [Boolean] The display mode for the document thumbnail.
58
+ attr_accessor :ScaleCrop
59
+
60
+ # @return [Boolean] The links in the document are up to date.
61
+ attr_accessor :LinksUpToDate
62
+
63
+ # @return [Integer] The number of characters in the document including spaces.
64
+ attr_accessor :CharactersWithSpaces
65
+
66
+ # @return [Boolean] Indicates if the document is shared.
67
+ attr_accessor :ShareDoc
68
+
69
+ # @return [String] The base for hyper links in the document.
70
+ attr_accessor :HyperLinkBase
71
+
72
+ # @return [Boolean] Indicates that the hyper links in the document have been changed.
73
+ attr_accessor :HyperlinksChanged
74
+
75
+ # @return [String] The name of the application
76
+ attr_accessor :Application
77
+
78
+ # @return [String] The version of the application.
79
+ attr_accessor :AppVersion
80
+
81
+ # @return [Integer] Document security
82
+ attr_accessor :DocSecurity
83
+
84
+ def initalize(options={})
85
+ options.each do |o|
86
+ self.send("#{o[0]}=", o[1]) if self.respond_to? o[0]
87
+ end
88
+ end
89
+
90
+ def Template=(v) Axlsx::validate_string v; @Template = v; end
91
+ def Manager=(v) Axlsx::validate_string v; @Manager = v; end
92
+ def Company=(v) Axlsx::validate_string v; @Company = v; end
93
+ def Pages=(v) Axlsx::validate_int v; @Pages = v; end
94
+ def Words=(v) Axlsx::validate_int v; @Words = v; end
95
+ def Characters=(v) Axlsx::validate_int v; @Characters = v; end
96
+ def PresentationFormat=(v) Axlsx::validate_string v; @PresentationFormat = v; end
97
+ def Lines=(v) Axlsx::validate_int v; @Lines = v; end
98
+ def Paragraphs=(v) Axlsx::validate_int v; @Paragraphs = v; end
99
+ def Slides=(v) Axlsx::validate_int v; @Slides = v; end
100
+ def Notes=(v) Axlsx::validate_int v; @Notes = v; end
101
+ def TotalTime=(v) Axlsx::validate_int v; @TotalTime = v; end
102
+ def HiddenSlides=(v) Axlsx::validate_int v; @HiddenSlides = v; end
103
+ def MMClips=(v) Axlsx::validate_int v; @MMClips = v; end
104
+ def ScaleCrop=(v) Axlsx::validate_boolean v; @ScaleCrop = v; end
105
+ def LinksUpToDate=(v) Axlsx::validate_boolean v; @LinksUpToDate = v; end
106
+ def CharactersWithSpaces=(v) Axlsx::validate_int v; @CharactersWithSpaces = v; end
107
+ def ShareDoc=(v) Axlsx::validate_boolean v; @ShareDoc = v; end
108
+ def HyperLinkBase=(v) Axlsx::validate_string v; @HyperLinkBase = v; end
109
+ def HyperlinksChanged=(v) Axlsx::validate_boolean v; @HyperlinksChanged = v; end
110
+ def Application=(v) Axlsx::validate_string v; @Application = v; end
111
+ def AppVersion=(v) Axlsx::validate_string v; @AppVersion = v; end
112
+ def DocSecurity=(v) Axlsx::validate_int v; @DocSecurity = v; end
113
+
114
+ # Generate an app.xml document
115
+ # @return [String] The document as a string
116
+ def to_xml()
117
+ builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
118
+ xml.send(:Properties, :xmlns => APP_NS, :'xmlns:vt' => APP_NS_VT) {
119
+ self.instance_values.each do |name, value|
120
+ xml.send("ap:#{name}", value)
121
+ end
122
+ }
123
+ end
124
+ builder.to_xml
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,25 @@
1
+ module Axlsx
2
+
3
+ class Core
4
+ attr_accessor :creator
5
+ def initialize(options={})
6
+ @creator = options[:creator] || 'axlsx'
7
+
8
+ end
9
+ def to_xml()
10
+ builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
11
+ xml.send('cp:coreProperties',
12
+ :"xmlns:cp" => CORE_NS,
13
+ :'xmlns:dc' => CORE_NS_DC,
14
+ :'xmlns:dcmitype'=>CORE_NS_DCMIT,
15
+ :'xmlns:dcterms'=>CORE_NS_DCT,
16
+ :'xmlns:xsi'=>CORE_NS_XSI) {
17
+ xml['dc'].creator self.creator
18
+ xml['dcterms'].created Time.now.strftime('%Y-%m-%dT%H:%M:%S'), :'xsi:type'=>"dcterms:W3CDTF"
19
+ xml['cp'].revision 0
20
+ }
21
+ end
22
+ builder.to_xml
23
+ end
24
+ end
25
+ end
File without changes
@@ -0,0 +1,64 @@
1
+
2
+ # The Pie3DChart is a three dimentional piechart (who would have guessed?) that you can add to your worksheet.
3
+ # @example Creating a chart
4
+ # # This example creates two charts in a single sheet.
5
+ # # The first uses data directly fed to the sheet, while the second references cells withing the worksheet for data.
6
+ #
7
+ # require "rubygems" # if that is your preferred way to manage gems!
8
+ # require "axlsx"
9
+ #
10
+ # p = Axlsx::Package.new
11
+ # ws = p.workbook.add_worksheet
12
+ # ws.add_row :values => ["This is a chart with no data in the sheet"]
13
+ #
14
+ # chart = ws.add_chart(Axlsx::Pie3DChart, :start_at=> [0,1], :end_at=>[0,6], :title=>"Most Popular Pets")
15
+ # chart.add_series :data => [1, 9, 10], :labels => ["Slimy Reptiles", "Fuzzy Bunnies", "Rottweiler"]
16
+ #
17
+ # ws.add_row :values => ["This chart uses the data below"]
18
+ # title_row = ws.add_row :values => ["Least Popular Pets"]
19
+ # label_row = ws.add_row :values => ["", "Dry Skinned Reptiles", "Bald Cats", "Violent Parrots"]
20
+ # data_row = ws.add_row :values => ["Votes", 6, 4, 1]
21
+ #
22
+ # chart = ws.add_chart(Axlsx::Pie3DChart, :start_at => [0,11], :end_at =>[0,16], :title => title_row.cells.last)
23
+ # chart.add_series :data => data_row.cells[(1..-1)], :labels => label_row.cells
24
+ #
25
+ # f = File.open('example_pie_3d_chart.xlsx', 'w')
26
+ # p.serialize(f)
27
+ #
28
+ # @see Worksheet#add_chart
29
+ # @see Worksheet#add_row
30
+ # @see Chart#add_series
31
+ # @see Series
32
+ # @see Package#serialize
33
+ class Pie3DChart < Chart
34
+
35
+ # Serializes the pie chart
36
+ # @return [String]
37
+ def to_xml
38
+ builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
39
+ xml.send('c:chartSpace',:'xmlns:c' => XML_NS_C,
40
+ :'xmlns:a' => XML_NS_A) {
41
+ xml.send('c:chart') {
42
+ @title.to_xml(xml)
43
+ xml.send('c:view3D') {
44
+ xml.send('c:rotX', :val=>30)
45
+ xml.send('c:perspective', :val=>30)
46
+ }
47
+ xml.send('c:plotArea') {
48
+ xml.send('c:layout')
49
+ xml.send('c:pie3DChart') {
50
+ xml.send('c:varyColors', :val=>1)
51
+ @series.each { |ser| ser.to_xml(xml) }
52
+ }
53
+ }
54
+ xml.send('c:legend') {
55
+ xml.send('c:legendPos', :val => "r")
56
+ xml.send('c:layout')
57
+ }
58
+ }
59
+ }
60
+ end
61
+ builder.to_xml
62
+ end
63
+ end
64
+ end