axlsx 1.0.8 → 1.0.9

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.
Files changed (128) hide show
  1. data/CHANGELOG.md +14 -0
  2. data/README.md +22 -21
  3. data/Rakefile +1 -1
  4. data/axlsx.gemspec +36 -0
  5. data/doc/Axlsx.html +373 -559
  6. data/doc/Axlsx/App.html +257 -360
  7. data/doc/Axlsx/Axis.html +113 -144
  8. data/doc/Axlsx/Bar3DChart.html +122 -152
  9. data/doc/Axlsx/BarSeries.html +67 -81
  10. data/doc/Axlsx/Border.html +96 -119
  11. data/doc/Axlsx/BorderPr.html +89 -114
  12. data/doc/Axlsx/CatAxis.html +79 -104
  13. data/doc/Axlsx/CatAxisData.html +40 -54
  14. data/doc/Axlsx/Cell.html +193 -679
  15. data/doc/Axlsx/CellAlignment.html +116 -157
  16. data/doc/Axlsx/CellProtection.html +50 -68
  17. data/doc/Axlsx/CellStyle.html +78 -106
  18. data/doc/Axlsx/Chart.html +361 -432
  19. data/doc/Axlsx/Color.html +56 -78
  20. data/doc/Axlsx/ContentType.html +28 -41
  21. data/doc/Axlsx/Core.html +43 -55
  22. data/doc/Axlsx/DataTypeValidator.html +34 -43
  23. data/doc/Axlsx/Default.html +55 -81
  24. data/doc/Axlsx/Drawing.html +322 -412
  25. data/doc/Axlsx/Fill.html +34 -47
  26. data/doc/Axlsx/Font.html +157 -207
  27. data/doc/Axlsx/GradientFill.html +90 -122
  28. data/doc/Axlsx/GradientStop.html +36 -50
  29. data/doc/Axlsx/GraphicFrame.html +106 -130
  30. data/doc/Axlsx/Line3DChart.html +108 -134
  31. data/doc/Axlsx/LineSeries.html +58 -67
  32. data/doc/Axlsx/Marker.html +84 -111
  33. data/doc/Axlsx/NumFmt.html +83 -102
  34. data/doc/Axlsx/OneCellAnchor.html +158 -196
  35. data/doc/Axlsx/Override.html +60 -92
  36. data/doc/Axlsx/Package.html +190 -759
  37. data/doc/Axlsx/PatternFill.html +78 -99
  38. data/doc/Axlsx/Pic.html +451 -405
  39. data/doc/Axlsx/Pie3DChart.html +33 -42
  40. data/doc/Axlsx/PieSeries.html +68 -80
  41. data/doc/Axlsx/RegexValidator.html +15 -20
  42. data/doc/Axlsx/Relationship.html +49 -66
  43. data/doc/Axlsx/Relationships.html +28 -41
  44. data/doc/Axlsx/RestrictionValidator.html +23 -32
  45. data/doc/Axlsx/Row.html +132 -161
  46. data/doc/Axlsx/Scaling.html +71 -90
  47. data/doc/Axlsx/SerAxis.html +61 -79
  48. data/doc/Axlsx/Series.html +125 -201
  49. data/doc/Axlsx/SeriesTitle.html +26 -31
  50. data/doc/Axlsx/Styles.html +286 -355
  51. data/doc/Axlsx/TableStyle.html +62 -87
  52. data/doc/Axlsx/TableStyleElement.html +84 -104
  53. data/doc/Axlsx/TableStyles.html +59 -82
  54. data/doc/Axlsx/Title.html +58 -155
  55. data/doc/Axlsx/TwoCellAnchor.html +165 -204
  56. data/doc/Axlsx/ValAxis.html +39 -53
  57. data/doc/Axlsx/ValAxisData.html +29 -39
  58. data/doc/Axlsx/View3D.html +93 -122
  59. data/doc/Axlsx/Workbook.html +359 -362
  60. data/doc/Axlsx/Worksheet.html +471 -816
  61. data/doc/Axlsx/Xf.html +341 -296
  62. data/doc/_index.html +7 -11
  63. data/doc/class_list.html +1 -1
  64. data/doc/file.LICENSE.html +86 -0
  65. data/doc/file.README.html +105 -107
  66. data/doc/file_list.html +3 -0
  67. data/doc/frames.html +1 -1
  68. data/doc/index.html +105 -107
  69. data/doc/method_list.html +426 -602
  70. data/doc/top-level-namespace.html +3 -3
  71. data/examples/example.rb +20 -1
  72. data/lib/axlsx.rb +20 -15
  73. data/lib/axlsx/content_type/default.rb +8 -3
  74. data/lib/axlsx/content_type/override.rb +11 -4
  75. data/lib/axlsx/doc_props/app.rb +53 -23
  76. data/lib/axlsx/drawing/axis.rb +16 -5
  77. data/lib/axlsx/drawing/bar_3D_chart.rb +15 -7
  78. data/lib/axlsx/drawing/bar_series.rb +7 -5
  79. data/lib/axlsx/drawing/cat_axis.rb +10 -3
  80. data/lib/axlsx/drawing/chart.rb +21 -15
  81. data/lib/axlsx/drawing/drawing.rb +16 -30
  82. data/lib/axlsx/drawing/graphic_frame.rb +2 -4
  83. data/lib/axlsx/drawing/line_3D_chart.rb +5 -2
  84. data/lib/axlsx/drawing/line_series.rb +6 -5
  85. data/lib/axlsx/drawing/marker.rb +9 -5
  86. data/lib/axlsx/drawing/one_cell_anchor.rb +7 -7
  87. data/lib/axlsx/drawing/pic.rb +29 -37
  88. data/lib/axlsx/drawing/pie_series.rb +7 -5
  89. data/lib/axlsx/drawing/scaling.rb +11 -5
  90. data/lib/axlsx/drawing/ser_axis.rb +6 -2
  91. data/lib/axlsx/drawing/series.rb +11 -11
  92. data/lib/axlsx/drawing/series_title.rb +1 -1
  93. data/lib/axlsx/drawing/title.rb +5 -12
  94. data/lib/axlsx/drawing/two_cell_anchor.rb +2 -3
  95. data/lib/axlsx/drawing/val_axis.rb +2 -2
  96. data/lib/axlsx/drawing/view_3D.rb +16 -9
  97. data/lib/axlsx/package.rb +25 -27
  98. data/lib/axlsx/rels/relationship.rb +4 -2
  99. data/lib/axlsx/stylesheet/border.rb +9 -4
  100. data/lib/axlsx/stylesheet/border_pr.rb +7 -4
  101. data/lib/axlsx/stylesheet/cell_alignment.rb +18 -9
  102. data/lib/axlsx/stylesheet/cell_protection.rb +5 -2
  103. data/lib/axlsx/stylesheet/cell_style.rb +12 -7
  104. data/lib/axlsx/stylesheet/color.rb +8 -6
  105. data/lib/axlsx/stylesheet/fill.rb +2 -1
  106. data/lib/axlsx/stylesheet/font.rb +24 -13
  107. data/lib/axlsx/stylesheet/gradient_fill.rb +16 -10
  108. data/lib/axlsx/stylesheet/gradient_stop.rb +5 -3
  109. data/lib/axlsx/stylesheet/num_fmt.rb +4 -2
  110. data/lib/axlsx/stylesheet/pattern_fill.rb +6 -4
  111. data/lib/axlsx/stylesheet/styles.rb +12 -12
  112. data/lib/axlsx/stylesheet/table_style.rb +6 -3
  113. data/lib/axlsx/stylesheet/table_style_element.rb +9 -4
  114. data/lib/axlsx/stylesheet/table_styles.rb +4 -4
  115. data/lib/axlsx/stylesheet/xf.rb +52 -31
  116. data/lib/axlsx/util/validators.rb +3 -3
  117. data/lib/axlsx/version.rb +1 -1
  118. data/lib/axlsx/workbook/workbook.rb +8 -9
  119. data/lib/axlsx/workbook/worksheet/cell.rb +25 -16
  120. data/lib/axlsx/workbook/worksheet/row.rb +2 -4
  121. data/lib/axlsx/workbook/worksheet/worksheet.rb +23 -32
  122. data/test/drawing/tc_one_cell_anchor.rb +1 -1
  123. metadata +135 -165
  124. data/doc/Axlsx/SimpleTypedList.html +0 -1686
  125. data/lib/schema/dc.xsd~ +0 -118
  126. data/lib/schema/dcterms.xsd~ +0 -331
  127. data/lib/schema/opc-coreProperties.xsd~ +0 -50
  128. data/test/drawing/tc_line_series.tc~ +0 -34
@@ -15,7 +15,7 @@ module Axlsx
15
15
 
16
16
  # The explosion for this series
17
17
  # @return [Integert]
18
- attr_accessor :explosion
18
+ attr_reader :explosion
19
19
 
20
20
  # Creates a new series
21
21
  # @option options [Array, SimpleTypedList] data
@@ -24,21 +24,23 @@ module Axlsx
24
24
  # @option options [Integer] explosion
25
25
  # @param [Chart] chart
26
26
  def initialize(chart, options={})
27
+ @explosion = nil
27
28
  super(chart, options)
28
29
  self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil?
29
30
  self.data = ValAxisData.new(options[:data]) unless options[:data].nil?
30
31
  end
31
32
 
33
+ # @see explosion
32
34
  def explosion=(v) Axlsx::validate_unsigned_int(v); @explosion = v; end
33
35
 
34
36
  # Serializes the series
35
37
  # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
36
38
  # @return [String]
37
39
  def to_xml(xml)
38
- super(xml) do |xml|
39
- xml.send('c:explosion', :val=>@explosion) unless @explosion.nil?
40
- @labels.to_xml(xml) unless @labels.nil?
41
- @data.to_xml(xml) unless @data.nil?
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?
42
44
  end
43
45
  end
44
46
  private
@@ -5,20 +5,20 @@ module Axlsx
5
5
  # logarithmic base for a logarithmic axis.
6
6
  # must be between 2 and 1000
7
7
  # @return [Integer]
8
- attr_accessor :logBase
8
+ attr_reader :logBase
9
9
 
10
10
  # the orientation of the axis
11
11
  # must be one of [:minMax, :maxMin]
12
12
  # @return [Symbol]
13
- attr_accessor :orientation
13
+ attr_reader :orientation
14
14
 
15
15
  # the maximum scaling
16
16
  # @return [Float]
17
- attr_accessor :max
17
+ attr_reader :max
18
18
 
19
19
  # the minimu scaling
20
20
  # @return [Float]
21
- attr_accessor :min
21
+ attr_reader :min
22
22
 
23
23
  # creates a new Scaling object
24
24
  # @option options [Integer, Fixnum] logBase
@@ -27,14 +27,20 @@ module Axlsx
27
27
  # @option options [Float] min
28
28
  def initialize(options={})
29
29
  @orientation = :minMax
30
+ @logBase, @min, @max = nil, nil, nil
30
31
  options.each do |o|
31
32
  self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
32
33
  end
33
34
  end
34
35
 
35
- def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer, Fixnum], v, lambda { |v| v >= 2 && v <= 1000}; @logBase = v; end
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
36
39
  def orientation=(v) RestrictionValidator.validate "Scaling.orientation", [:minMax, :maxMin], v; @orientation = v; end
40
+ # @see max
37
41
  def max=(v) DataTypeValidator.validate "Scaling.max", Float, v; @max = v; end
42
+
43
+ # @see min
38
44
  def min=(v) DataTypeValidator.validate "Scaling.min", Float, v; @min = v; end
39
45
 
40
46
  # Serializes the axId
@@ -4,11 +4,11 @@ module Axlsx
4
4
 
5
5
  # The number of tick lables to skip between labels
6
6
  # @return [Integer]
7
- attr_accessor :tickLblSkip
7
+ attr_reader :tickLblSkip
8
8
 
9
9
  # The number of tickmarks to be skipped before the next one is rendered.
10
10
  # @return [Boolean]
11
- attr_accessor :tickMarkSkip
11
+ attr_reader :tickMarkSkip
12
12
 
13
13
  # Creates a new SerAxis object
14
14
  # @param [Integer] axId the id of this axis. Inherited
@@ -19,10 +19,14 @@ module Axlsx
19
19
  # @option options [Integer] tickLblSkip
20
20
  # @option options [Integer] tickMarkSkip
21
21
  def initialize(axId, crossAx, options={})
22
+ @tickLblSkip, @tickMarkSkip = nil, nil
22
23
  super(axId, crossAx, options)
23
24
  end
24
25
 
26
+ # @see tickLblSkip
25
27
  def tickLblSkip=(v) Axlsx::validate_unsigned_int(v); @tickLblSkip = v; end
28
+
29
+ # @see tickMarkSkip
26
30
  def tickMarkSkip=(v) Axlsx::validate_unsigned_int(v); @tickMarkSkip = v; end
27
31
 
28
32
  # Serializes the series axis
@@ -9,40 +9,40 @@ module Axlsx
9
9
  # @return [Chart]
10
10
  attr_reader :chart
11
11
 
12
- # The index of this series in the chart's series.
13
- # @return [Integer]
14
- attr_reader :index
15
-
16
- # The order of this series in the chart's series. By default the order is the index of the series.
17
- # @return [Integer]
18
- attr_accessor :order
19
-
20
12
  # The title of the series
21
13
  # @return [SeriesTitle]
22
- attr_accessor :title
14
+ attr_reader :title
23
15
 
24
16
  # Creates a new series
25
17
  # @param [Chart] chart
26
18
  # @option options [Integer] order
27
19
  # @option options [String] title
28
20
  def initialize(chart, options={})
21
+ @order = nil
29
22
  self.chart = chart
30
23
  @chart.series << self
31
24
  options.each do |o|
32
25
  self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
33
26
  end
34
27
  end
35
-
28
+
29
+ # The index of this series in the chart's series.
30
+ # @return [Integer]
36
31
  def index
37
32
  @chart.series.index(self)
38
33
  end
39
34
 
40
- def order=(v) Axlsx::validate_unsigned_int(v); @order = v; end
41
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]
42
38
  def order
43
39
  @order || index
44
40
  end
45
41
 
42
+ # @see order
43
+ def order=(v) Axlsx::validate_unsigned_int(v); @order = v; end
44
+
45
+ # @see title
46
46
  def title=(v)
47
47
  v = SeriesTitle.new(v) if v.is_a?(String) || v.is_a?(Cell)
48
48
  DataTypeValidator.validate "#{self.class}.title", SeriesTitle, v
@@ -8,7 +8,7 @@ module Axlsx
8
8
  def to_xml(xml)
9
9
  xml.send('c:tx') {
10
10
  xml.send('c:strRef') {
11
- xml.send('c:f', range)
11
+ xml.send('c:f', Axlsx::cell_range([@cell]))
12
12
  xml.send('c:strCache') {
13
13
  xml.send('c:ptCount', :val=>1)
14
14
  xml.send('c:pt', :idx=>0) {
@@ -4,11 +4,11 @@ module Axlsx
4
4
 
5
5
  # The text to be shown. Setting this property directly with a string will remove the cell reference.
6
6
  # @return [String]
7
- attr_accessor :text
7
+ attr_reader :text
8
8
 
9
9
  # The cell that holds the text for the title. Setting this property will automatically update the text attribute.
10
10
  # @return [Cell]
11
- attr_accessor :cell
11
+ attr_reader :cell
12
12
 
13
13
  # Creates a new Title object
14
14
  # @param [String, Cell] title The cell or string to be used for the chart's title
@@ -17,6 +17,7 @@ module Axlsx
17
17
  self.text = title.to_s unless title.is_a?(Cell)
18
18
  end
19
19
 
20
+ # @see text
20
21
  def text=(v)
21
22
  DataTypeValidator.validate 'Title.text', String, v
22
23
  @text = v
@@ -24,6 +25,7 @@ module Axlsx
24
25
  v
25
26
  end
26
27
 
28
+ # @see cell
27
29
  def cell=(v)
28
30
  DataTypeValidator.validate 'Title.text', Cell, v
29
31
  @cell = v
@@ -43,7 +45,7 @@ module Axlsx
43
45
  xml.send('c:title') {
44
46
  xml.send('c:tx') {
45
47
  xml.send('c:strRef') {
46
- xml.send('c:f', range)
48
+ xml.send('c:f', Axlsx::cell_range([@cell]))
47
49
  xml.send('c:strCache') {
48
50
  xml.send('c:ptCount', :val=>1)
49
51
  xml.send('c:pt', :idx=>0) {
@@ -55,14 +57,5 @@ module Axlsx
55
57
  }
56
58
  end
57
59
 
58
- private
59
-
60
- # returns the excel style abslute reference for the title when title is a Cell object
61
- # @return [String]
62
- def range
63
- return "" unless @data.is_a?(Cell)
64
- "#{@data.row.worksheet.name}!#{data.row.r_abs}"
65
- end
66
-
67
60
  end
68
61
  end
@@ -24,9 +24,6 @@ module Axlsx
24
24
  # @return [Drawing]
25
25
  attr_reader :drawing
26
26
 
27
- # The index of this anchor in the drawing
28
- # @return [Integer]
29
- attr_reader :index
30
27
 
31
28
  # Creates a new TwoCellAnchor object and sets up a reference to the from and to markers in the
32
29
  # graphic_frame's chart. That means that you can do stuff like
@@ -51,6 +48,8 @@ module Axlsx
51
48
  @object.chart
52
49
  end
53
50
 
51
+ # The index of this anchor in the drawing
52
+ # @return [Integer]
54
53
  def index
55
54
  @drawing.anchors.index(self)
56
55
  end
@@ -5,7 +5,7 @@ module Axlsx
5
5
  # This element specifies how the value axis crosses the category axis.
6
6
  # must be one of [:between, :midCat]
7
7
  # @return [Symbol]
8
- attr_accessor :crossBetween
8
+ attr_reader :crossBetween
9
9
 
10
10
  # Creates a new ValAxis object
11
11
  # @param [Integer] axId the id of this axis
@@ -18,7 +18,7 @@ module Axlsx
18
18
  self.crossBetween = :between
19
19
  super(axId, crossAx, options)
20
20
  end
21
-
21
+ # @see crossBetween
22
22
  def crossBetween=(v) RestrictionValidator.validate "ValAxis.crossBetween", [:between, :midCat], v; @crossBetween = v; end
23
23
 
24
24
  # Serializes the value axis
@@ -11,30 +11,30 @@ module Axlsx
11
11
  # x rotation for the chart
12
12
  # must be between -90 and 90
13
13
  # @return [Integer]
14
- attr_accessor :rotX
14
+ attr_reader :rotX
15
15
 
16
16
  # height of chart as % of chart
17
17
  # must be between 5% and 500%
18
18
  # @return [String]
19
- attr_accessor :hPercent
19
+ attr_reader :hPercent
20
20
 
21
21
  # y rotation for the chart
22
22
  # must be between 0 and 360
23
23
  # @return [Integer]
24
- attr_accessor :rotY
24
+ attr_reader :rotY
25
25
 
26
26
  # depth or chart as % of chart width
27
27
  # must be between 20% and 2000%
28
28
  # @return [String]
29
- attr_accessor :depthPercent
29
+ attr_reader :depthPercent
30
30
 
31
31
  # Chart axis are at right angles
32
32
  # @return [Boolean]
33
- attr_accessor :rAngAx
33
+ attr_reader :rAngAx
34
34
 
35
35
  # field of view angle
36
36
  # @return [Integer]
37
- attr_accessor :perspective
37
+ attr_reader :perspective
38
38
 
39
39
  # Creates a new View3D for charts
40
40
  # @option options [Integer] rotX
@@ -44,22 +44,29 @@ module Axlsx
44
44
  # @option options [Boolean] rAngAx
45
45
  # @option options [Integer] perspective
46
46
  def initialize(options={})
47
+ @rotX, @hPercent, @rotY, @depthPercent, @rAngAx, @perspective = nil, nil, nil, nil, nil, nil
47
48
  options.each do |o|
48
49
  self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
49
50
  end
50
51
  end
51
52
 
52
- def rotX=(v) DataTypeValidator.validate "#{self.class}.rotX", [Integer, Fixnum], v, lambda {|v| v >= -90 && v <= 90 }; @rotX = v; end
53
+ # @see rotX
54
+ def rotX=(v) DataTypeValidator.validate "#{self.class}.rotX", [Integer, Fixnum], v, lambda {|arg| arg >= -90 && arg <= 90 }; @rotX = v; end
53
55
 
56
+ # @see hPercent
54
57
  def hPercent=(v) RegexValidator.validate "#{self.class}.rotX", H_PERCENT_REGEX, v; @hPercent = v; end
55
58
 
56
- def rotY=(v) DataTypeValidator.validate "#{self.class}.rotY", [Integer, Fixnum], v, lambda {|v| v >= 0 && v <= 360 }; @rotY = v; end
59
+ # @see rotY
60
+ def rotY=(v) DataTypeValidator.validate "#{self.class}.rotY", [Integer, Fixnum], v, lambda {|arg| arg >= 0 && arg <= 360 }; @rotY = v; end
57
61
 
62
+ # @see depthPercent
58
63
  def depthPercent=(v) RegexValidator.validate "#{self.class}.depthPercent", DEPTH_PERCENT_REGEX, v; @depthPercent = v; end
59
64
 
65
+ # @see rAngAx
60
66
  def rAngAx=(v) Axlsx::validate_boolean(v); @rAngAx = v; end
61
67
 
62
- def perspective=(v) DataTypeValidator.validate "#{self.class}.perspective", [Integer, Fixnum], v, lambda {|v| v >= 0 && v <= 240 }; @perspective = v; end
68
+ # @see perspective
69
+ def perspective=(v) DataTypeValidator.validate "#{self.class}.perspective", [Integer, Fixnum], v, lambda {|arg| arg >= 0 && arg <= 240 }; @perspective = v; end
63
70
 
64
71
  # Serializes the view3D properties
65
72
  # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
@@ -1,12 +1,23 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Create Office Open XML Spreadsheets (xlsx) with safe and full control over cell styles, automatically resized column widths and 3D pie charts.
3
2
  module Axlsx
4
3
  # Package is responsible for managing all the bits and peices that Open Office XML requires to make a valid
5
4
  # xlsx document including valdation and serialization.
6
5
  class Package
7
6
 
7
+ # Initializes your package
8
+ #
9
+ # @param [Hash] options A hash that you can use to specify the author and workbook for this package.
10
+ # @option options [String] :author The author of the document
11
+ # @example Package.new :author => 'you!', :workbook => Workbook.new
12
+ def initialize(options={})
13
+ @workbook = nil
14
+ @core, @app = Core.new, App.new
15
+ @core.creator = options[:author] || @core.creator
16
+ yield self if block_given?
17
+ end
18
+
19
+
8
20
  # The workbook this package will serialize or validate.
9
- # @attribute
10
21
  # @return [Workbook] If no workbook instance has been assigned with this package a new Workbook instance is returned.
11
22
  # @raise ArgumentError if workbook parameter is not a Workbook instance.
12
23
  # @note As there are multiple ways to instantiate a workbook for the package,
@@ -18,25 +29,13 @@ module Axlsx
18
29
  # wb = Pacakge.new().workbook
19
30
  # # # set the workbook after creating the package
20
31
  # wb = Package.new().workbook = Workbook.new
21
- attr_accessor :workbook
22
-
23
- # Initializes your package
24
- #
25
- # @param [Hash] options A hash that you can use to specify the author and workbook for this package.
26
- # @option options [String] :author The author of the document
27
- # @example Package.new :author => 'you!', :workbook => Workbook.new
28
- def initialize(options={})
29
- @core, @app = Core.new, App.new
30
- @core.creator = options[:author] || @core.creator
31
- yield self if block_given?
32
- end
33
-
34
- def workbook=(workbook) DataTypeValidator.validate "Package.workbook", Workbook, workbook; @workbook = workbook; end
35
-
36
32
  def workbook
37
33
  @workbook || @workbook = Workbook.new
38
34
  end
39
35
 
36
+ # @see workbook
37
+ def workbook=(workbook) DataTypeValidator.validate "Package.workbook", Workbook, workbook; @workbook = workbook; end
38
+
40
39
  # Serialize your workbook to disk as an xlsx document.
41
40
  #
42
41
  # @param [File] output The file you want to serialize your package to
@@ -57,18 +56,17 @@ module Axlsx
57
56
  p = parts
58
57
  Zip::ZipOutputStream.open(output) do |zip|
59
58
  p.each do |part|
60
- zip.put_next_entry(part[:entry]); zip.puts(part[:doc]) unless part[:doc].nil?
61
- end
62
- end
63
- Zip::ZipFile.open(output) do |zip|
64
- p.each do |part|
65
- if part[:path]
66
- zip.add(part[:entry], part[:path], &proc{ true })
59
+ unless part[:doc].nil?
60
+ zip.put_next_entry(part[:entry]);
61
+ zip.puts(part[:doc])
67
62
  end
68
- end
63
+ unless part[:path].nil?
64
+ zip.put_next_entry(part[:entry]);
65
+ # binread for 1.9.3
66
+ zip.write IO.respond_to?(:binread) ? IO.binread(part[:path]) : IO.read(part[:path])
67
+ end
68
+ end
69
69
  end
70
-
71
-
72
70
  true
73
71
  end
74
72
 
@@ -5,7 +5,7 @@ module Axlsx
5
5
 
6
6
  # The location of the relationship target
7
7
  # @return [String]
8
- attr_accessor :Target
8
+ attr_reader :Target
9
9
 
10
10
  # The type of relationship
11
11
  # @note Supported types are defined as constants in Axlsx:
@@ -20,13 +20,15 @@ module Axlsx
20
20
  # @see CHART_R
21
21
  # @see DRAWING_R
22
22
  # @return [String]
23
- attr_accessor :Type
23
+ attr_reader :Type
24
24
  def initialize(type, target)
25
25
  self.Target=target
26
26
  self.Type=type
27
27
  end
28
28
 
29
+ # @see Target
29
30
  def Target=(v) Axlsx::validate_string v; @Target = v end
31
+ # @see Type
30
32
  def Type=(v) Axlsx::validate_relationship_type v; @Type = v end
31
33
 
32
34
  # Serializes the relationship
@@ -3,13 +3,13 @@ module Axlsx
3
3
  class Border
4
4
 
5
5
  # @return [Boolean] The diagonal up property for the border that indicates if the border should include a diagonal line from the bottom left to the top right of the cell.
6
- attr_accessor :diagonalUp
6
+ attr_reader :diagonalUp
7
7
 
8
8
  # @return [Boolean] The diagonal down property for the border that indicates if the border should include a diagonal line from the top left to the top right of the cell.
9
- attr_accessor :diagonalDown
9
+ attr_reader :diagonalDown
10
10
 
11
11
  # @return [Boolean] The outline property for the border indicating that top, left, right and bottom borders should only be applied to the outside border of a range of cells.
12
- attr_accessor :outline
12
+ attr_reader :outline
13
13
 
14
14
  # @return [SimpleTypedList] A list of BorderPr objects for this border.
15
15
  attr_reader :prs
@@ -35,8 +35,11 @@ module Axlsx
35
35
  end
36
36
  end
37
37
 
38
+ # @see diagonalUp
38
39
  def diagonalUp=(v) Axlsx::validate_boolean v; @diagonalUp = v end
40
+ # @see diagonalDown
39
41
  def diagonalDown=(v) Axlsx::validate_boolean v; @diagonalDown = v end
42
+ # @see outline
40
43
  def outline=(v) Axlsx::validate_boolean v; @outline = v end
41
44
 
42
45
  # Serializes the border element
@@ -44,7 +47,9 @@ module Axlsx
44
47
  def to_xml(xml)
45
48
  xml.border(self.instance_values.select{ |k,v| [:diagonalUp, :diagonalDown, :outline].include? k }) {
46
49
  [:start, :end, :left, :right, :top, :bottom, :diagonal, :vertical, :horizontal].each do |k|
47
- @prs.select { |pr| pr.name == k }.each { |pr| pr.to_xml(xml) }
50
+ @prs.select { |pr| pr.name == k }.each do |part|
51
+ part.to_xml(xml)
52
+ end
48
53
  end
49
54
  }
50
55
  end