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.
- data/CHANGELOG.md +14 -0
- data/README.md +22 -21
- data/Rakefile +1 -1
- data/axlsx.gemspec +36 -0
- data/doc/Axlsx.html +373 -559
- data/doc/Axlsx/App.html +257 -360
- data/doc/Axlsx/Axis.html +113 -144
- data/doc/Axlsx/Bar3DChart.html +122 -152
- data/doc/Axlsx/BarSeries.html +67 -81
- data/doc/Axlsx/Border.html +96 -119
- data/doc/Axlsx/BorderPr.html +89 -114
- data/doc/Axlsx/CatAxis.html +79 -104
- data/doc/Axlsx/CatAxisData.html +40 -54
- data/doc/Axlsx/Cell.html +193 -679
- data/doc/Axlsx/CellAlignment.html +116 -157
- data/doc/Axlsx/CellProtection.html +50 -68
- data/doc/Axlsx/CellStyle.html +78 -106
- data/doc/Axlsx/Chart.html +361 -432
- data/doc/Axlsx/Color.html +56 -78
- data/doc/Axlsx/ContentType.html +28 -41
- data/doc/Axlsx/Core.html +43 -55
- data/doc/Axlsx/DataTypeValidator.html +34 -43
- data/doc/Axlsx/Default.html +55 -81
- data/doc/Axlsx/Drawing.html +322 -412
- data/doc/Axlsx/Fill.html +34 -47
- data/doc/Axlsx/Font.html +157 -207
- data/doc/Axlsx/GradientFill.html +90 -122
- data/doc/Axlsx/GradientStop.html +36 -50
- data/doc/Axlsx/GraphicFrame.html +106 -130
- data/doc/Axlsx/Line3DChart.html +108 -134
- data/doc/Axlsx/LineSeries.html +58 -67
- data/doc/Axlsx/Marker.html +84 -111
- data/doc/Axlsx/NumFmt.html +83 -102
- data/doc/Axlsx/OneCellAnchor.html +158 -196
- data/doc/Axlsx/Override.html +60 -92
- data/doc/Axlsx/Package.html +190 -759
- data/doc/Axlsx/PatternFill.html +78 -99
- data/doc/Axlsx/Pic.html +451 -405
- data/doc/Axlsx/Pie3DChart.html +33 -42
- data/doc/Axlsx/PieSeries.html +68 -80
- data/doc/Axlsx/RegexValidator.html +15 -20
- data/doc/Axlsx/Relationship.html +49 -66
- data/doc/Axlsx/Relationships.html +28 -41
- data/doc/Axlsx/RestrictionValidator.html +23 -32
- data/doc/Axlsx/Row.html +132 -161
- data/doc/Axlsx/Scaling.html +71 -90
- data/doc/Axlsx/SerAxis.html +61 -79
- data/doc/Axlsx/Series.html +125 -201
- data/doc/Axlsx/SeriesTitle.html +26 -31
- data/doc/Axlsx/Styles.html +286 -355
- data/doc/Axlsx/TableStyle.html +62 -87
- data/doc/Axlsx/TableStyleElement.html +84 -104
- data/doc/Axlsx/TableStyles.html +59 -82
- data/doc/Axlsx/Title.html +58 -155
- data/doc/Axlsx/TwoCellAnchor.html +165 -204
- data/doc/Axlsx/ValAxis.html +39 -53
- data/doc/Axlsx/ValAxisData.html +29 -39
- data/doc/Axlsx/View3D.html +93 -122
- data/doc/Axlsx/Workbook.html +359 -362
- data/doc/Axlsx/Worksheet.html +471 -816
- data/doc/Axlsx/Xf.html +341 -296
- data/doc/_index.html +7 -11
- data/doc/class_list.html +1 -1
- data/doc/file.LICENSE.html +86 -0
- data/doc/file.README.html +105 -107
- data/doc/file_list.html +3 -0
- data/doc/frames.html +1 -1
- data/doc/index.html +105 -107
- data/doc/method_list.html +426 -602
- data/doc/top-level-namespace.html +3 -3
- data/examples/example.rb +20 -1
- data/lib/axlsx.rb +20 -15
- data/lib/axlsx/content_type/default.rb +8 -3
- data/lib/axlsx/content_type/override.rb +11 -4
- data/lib/axlsx/doc_props/app.rb +53 -23
- data/lib/axlsx/drawing/axis.rb +16 -5
- data/lib/axlsx/drawing/bar_3D_chart.rb +15 -7
- data/lib/axlsx/drawing/bar_series.rb +7 -5
- data/lib/axlsx/drawing/cat_axis.rb +10 -3
- data/lib/axlsx/drawing/chart.rb +21 -15
- data/lib/axlsx/drawing/drawing.rb +16 -30
- data/lib/axlsx/drawing/graphic_frame.rb +2 -4
- data/lib/axlsx/drawing/line_3D_chart.rb +5 -2
- data/lib/axlsx/drawing/line_series.rb +6 -5
- data/lib/axlsx/drawing/marker.rb +9 -5
- data/lib/axlsx/drawing/one_cell_anchor.rb +7 -7
- data/lib/axlsx/drawing/pic.rb +29 -37
- data/lib/axlsx/drawing/pie_series.rb +7 -5
- data/lib/axlsx/drawing/scaling.rb +11 -5
- data/lib/axlsx/drawing/ser_axis.rb +6 -2
- data/lib/axlsx/drawing/series.rb +11 -11
- data/lib/axlsx/drawing/series_title.rb +1 -1
- data/lib/axlsx/drawing/title.rb +5 -12
- data/lib/axlsx/drawing/two_cell_anchor.rb +2 -3
- data/lib/axlsx/drawing/val_axis.rb +2 -2
- data/lib/axlsx/drawing/view_3D.rb +16 -9
- data/lib/axlsx/package.rb +25 -27
- data/lib/axlsx/rels/relationship.rb +4 -2
- data/lib/axlsx/stylesheet/border.rb +9 -4
- data/lib/axlsx/stylesheet/border_pr.rb +7 -4
- data/lib/axlsx/stylesheet/cell_alignment.rb +18 -9
- data/lib/axlsx/stylesheet/cell_protection.rb +5 -2
- data/lib/axlsx/stylesheet/cell_style.rb +12 -7
- data/lib/axlsx/stylesheet/color.rb +8 -6
- data/lib/axlsx/stylesheet/fill.rb +2 -1
- data/lib/axlsx/stylesheet/font.rb +24 -13
- data/lib/axlsx/stylesheet/gradient_fill.rb +16 -10
- data/lib/axlsx/stylesheet/gradient_stop.rb +5 -3
- data/lib/axlsx/stylesheet/num_fmt.rb +4 -2
- data/lib/axlsx/stylesheet/pattern_fill.rb +6 -4
- data/lib/axlsx/stylesheet/styles.rb +12 -12
- data/lib/axlsx/stylesheet/table_style.rb +6 -3
- data/lib/axlsx/stylesheet/table_style_element.rb +9 -4
- data/lib/axlsx/stylesheet/table_styles.rb +4 -4
- data/lib/axlsx/stylesheet/xf.rb +52 -31
- data/lib/axlsx/util/validators.rb +3 -3
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/workbook.rb +8 -9
- data/lib/axlsx/workbook/worksheet/cell.rb +25 -16
- data/lib/axlsx/workbook/worksheet/row.rb +2 -4
- data/lib/axlsx/workbook/worksheet/worksheet.rb +23 -32
- data/test/drawing/tc_one_cell_anchor.rb +1 -1
- metadata +135 -165
- data/doc/Axlsx/SimpleTypedList.html +0 -1686
- data/lib/schema/dc.xsd~ +0 -118
- data/lib/schema/dcterms.xsd~ +0 -331
- data/lib/schema/opc-coreProperties.xsd~ +0 -50
- 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
|
-
|
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 |
|
39
|
-
|
40
|
-
@labels.to_xml(
|
41
|
-
@data.to_xml(
|
40
|
+
super(xml) do |xml_inner|
|
41
|
+
xml_inner.send('c:explosion', :val=>@explosion) unless @explosion.nil?
|
42
|
+
@labels.to_xml(xml_inner) unless @labels.nil?
|
43
|
+
@data.to_xml(xml_inner) unless @data.nil?
|
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
|
-
|
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
|
-
|
13
|
+
attr_reader :orientation
|
14
14
|
|
15
15
|
# the maximum scaling
|
16
16
|
# @return [Float]
|
17
|
-
|
17
|
+
attr_reader :max
|
18
18
|
|
19
19
|
# the minimu scaling
|
20
20
|
# @return [Float]
|
21
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/axlsx/drawing/series.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/axlsx/drawing/title.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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',
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
29
|
+
attr_reader :depthPercent
|
30
30
|
|
31
31
|
# Chart axis are at right angles
|
32
32
|
# @return [Boolean]
|
33
|
-
|
33
|
+
attr_reader :rAngAx
|
34
34
|
|
35
35
|
# field of view angle
|
36
36
|
# @return [Integer]
|
37
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
data/lib/axlsx/package.rb
CHANGED
@@ -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
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|