axlsx 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -17,7 +17,7 @@ module Axlsx
|
|
17
17
|
# The shabe of the bars or columns
|
18
18
|
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
19
19
|
# @return [Symbol]
|
20
|
-
|
20
|
+
attr_reader :shape
|
21
21
|
|
22
22
|
# Creates a new series
|
23
23
|
# @option options [Array, SimpleTypedList] data
|
@@ -32,6 +32,8 @@ module Axlsx
|
|
32
32
|
self.data = ValAxisData.new(options[:data]) unless options[:data].nil?
|
33
33
|
end
|
34
34
|
|
35
|
+
# The shabe of the bars or columns
|
36
|
+
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
35
37
|
def shape=(v)
|
36
38
|
RestrictionValidator.validate "BarSeries.shape", [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax], v
|
37
39
|
@shape = v
|
@@ -41,10 +43,10 @@ module Axlsx
|
|
41
43
|
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
42
44
|
# @return [String]
|
43
45
|
def to_xml(xml)
|
44
|
-
super(xml) do |
|
45
|
-
@labels.to_xml(
|
46
|
-
@data.to_xml(
|
47
|
-
|
46
|
+
super(xml) do |xml_inner|
|
47
|
+
@labels.to_xml(xml_inner) unless @labels.nil?
|
48
|
+
@data.to_xml(xml_inner) unless @data.nil?
|
49
|
+
xml_inner.send('c:shape', :val=>@shape)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
@@ -4,17 +4,17 @@ module Axlsx
|
|
4
4
|
|
5
5
|
# From the docs: This element specifies that this axis is a date or text axis based on the data that is used for the axis labels, not a specific choice.
|
6
6
|
# @return [Boolean]
|
7
|
-
|
7
|
+
attr_reader :auto
|
8
8
|
|
9
9
|
# specifies how the perpendicular axis is crossed
|
10
10
|
# must be one of [:ctr, :l, :r]
|
11
11
|
# @return [Symbol]
|
12
|
-
|
12
|
+
attr_reader :lblAlgn
|
13
13
|
|
14
14
|
# The offset of the labels
|
15
15
|
# must be between a string between 0 and 1000
|
16
16
|
# @return [Integer]
|
17
|
-
|
17
|
+
attr_reader :lblOffset
|
18
18
|
|
19
19
|
# regex for validating label offset
|
20
20
|
LBL_OFFSET_REGEX = /0*(([0-9])|([1-9][0-9])|([1-9][0-9][0-9])|1000)%/
|
@@ -35,8 +35,15 @@ module Axlsx
|
|
35
35
|
super(axId, crossAx, options)
|
36
36
|
end
|
37
37
|
|
38
|
+
# From the docs: This element specifies that this axis is a date or text axis based on the data that is used for the axis labels, not a specific choice.
|
38
39
|
def auto=(v) Axlsx::validate_boolean(v); @auto = v; end
|
40
|
+
|
41
|
+
# specifies how the perpendicular axis is crossed
|
42
|
+
# must be one of [:ctr, :l, :r]
|
39
43
|
def lblAlgn=(v) RestrictionValidator.validate "#{self.class}.lblAlgn", [:ctr, :l, :r], v; @lblAlgn = v; end
|
44
|
+
|
45
|
+
# The offset of the labels
|
46
|
+
# must be between a string between 0 and 1000
|
40
47
|
def lblOffset=(v) RegexValidator.validate "#{self.class}.lblOffset", LBL_OFFSET_REGEX, v; @lblOffset = v; end
|
41
48
|
|
42
49
|
# Serializes the category axis
|
data/lib/axlsx/drawing/chart.rb
CHANGED
@@ -21,29 +21,21 @@ module Axlsx
|
|
21
21
|
# @return [Series]
|
22
22
|
attr_reader :series_type
|
23
23
|
|
24
|
-
# The index of this chart in the workbooks charts collection
|
25
|
-
# @return [Integer]
|
26
|
-
attr_reader :index
|
27
|
-
|
28
|
-
# The part name for this chart
|
29
|
-
# @return [String]
|
30
|
-
attr_reader :pn
|
31
|
-
|
32
24
|
#TODO data labels!
|
33
|
-
#
|
25
|
+
#attr_reader :dLabls
|
34
26
|
|
35
27
|
# The title object for the chart.
|
36
28
|
# @return [Title]
|
37
|
-
|
29
|
+
attr_reader :title
|
38
30
|
|
39
31
|
# The style for the chart.
|
40
32
|
# see ECMA Part 1 §21.2.2.196
|
41
33
|
# @return [Integer]
|
42
|
-
|
34
|
+
attr_reader :style
|
43
35
|
|
44
36
|
# Show the legend in the chart
|
45
37
|
# @return [Boolean]
|
46
|
-
|
38
|
+
attr_reader :show_legend
|
47
39
|
|
48
40
|
# Creates a new chart object
|
49
41
|
# @param [GraphicalFrame] frame The frame that holds this chart.
|
@@ -59,28 +51,42 @@ module Axlsx
|
|
59
51
|
options.each do |o|
|
60
52
|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
61
53
|
end
|
62
|
-
start_at
|
63
|
-
end_at
|
54
|
+
start_at(*options[:start_at]) if options[:start_at]
|
55
|
+
end_at(*options[:end_at]) if options[:start_at]
|
64
56
|
yield self if block_given?
|
65
57
|
end
|
66
58
|
|
59
|
+
# The index of this chart in the workbooks charts collection
|
60
|
+
# @return [Integer]
|
67
61
|
def index
|
68
62
|
@graphic_frame.anchor.drawing.worksheet.workbook.charts.index(self)
|
69
63
|
end
|
70
64
|
|
65
|
+
# The part name for this chart
|
66
|
+
# @return [String]
|
71
67
|
def pn
|
72
68
|
"#{CHART_PN % (index+1)}"
|
73
69
|
end
|
74
70
|
|
71
|
+
# The title object for the chart.
|
72
|
+
# @param [String, Cell] v
|
73
|
+
# @return [Title]
|
75
74
|
def title=(v)
|
76
75
|
v = Title.new(v) if v.is_a?(String) || v.is_a?(Cell)
|
77
76
|
DataTypeValidator.validate "#{self.class}.title", Title, v
|
78
77
|
@title = v
|
79
78
|
end
|
80
79
|
|
80
|
+
# Show the legend in the chart
|
81
|
+
# @param [Boolean] v
|
82
|
+
# @return [Boolean]
|
81
83
|
def show_legend=(v) Axlsx::validate_boolean(v); @show_legend = v; end
|
82
84
|
|
83
|
-
|
85
|
+
|
86
|
+
# The style for the chart.
|
87
|
+
# see ECMA Part 1 §21.2.2.196
|
88
|
+
# @param [Integer] v must be between 1 and 48
|
89
|
+
def style=(v) DataTypeValidator.validate "Chart.style", Integer, v, lambda { |arg| arg >= 1 && arg <= 48 }; @style = v; end
|
84
90
|
|
85
91
|
# backwards compatibility to allow chart.to and chart.from access to anchor markers
|
86
92
|
# @note This will be disconinued in version 2.0.0. Please use the end_at method
|
@@ -47,34 +47,6 @@ module Axlsx
|
|
47
47
|
# @return [SimpleTypedList]
|
48
48
|
attr_reader :anchors
|
49
49
|
|
50
|
-
# An array of charts that are associated with this drawing's anchors
|
51
|
-
# @return [Array]
|
52
|
-
attr_reader :charts
|
53
|
-
|
54
|
-
# An array of image objects that are associated with this drawing's anchors
|
55
|
-
# @return [Array]
|
56
|
-
attr_reader :images
|
57
|
-
|
58
|
-
# The index of this drawing in the owning workbooks's drawings collection.
|
59
|
-
# @return [Integer]
|
60
|
-
attr_reader :index
|
61
|
-
|
62
|
-
# The relation reference id for this drawing
|
63
|
-
# @return [String]
|
64
|
-
attr_reader :rId
|
65
|
-
|
66
|
-
# The part name for this drawing
|
67
|
-
# @return [String]
|
68
|
-
attr_reader :pn
|
69
|
-
|
70
|
-
# The relational part name for this drawing
|
71
|
-
# @return [String]
|
72
|
-
attr_reader :rels_pn
|
73
|
-
|
74
|
-
# The drawing's relationships.
|
75
|
-
# @return [Relationships]
|
76
|
-
attr_reader :relationships
|
77
|
-
|
78
50
|
# Creates a new Drawing object
|
79
51
|
# @param [Worksheet] worksheet The worksheet that owns this drawing
|
80
52
|
def initialize(worksheet)
|
@@ -99,33 +71,47 @@ module Axlsx
|
|
99
71
|
TwoCellAnchor.new(self, options)
|
100
72
|
@anchors.last.add_chart(chart_type, options)
|
101
73
|
end
|
102
|
-
|
74
|
+
|
75
|
+
# An array of charts that are associated with this drawing's anchors
|
76
|
+
# @return [Array]
|
103
77
|
def charts
|
104
78
|
charts = @anchors.select { |a| a.object.is_a?(GraphicFrame) }
|
105
79
|
charts.map { |a| a.object.chart }
|
106
80
|
end
|
107
81
|
|
82
|
+
# An array of image objects that are associated with this drawing's anchors
|
83
|
+
# @return [Array]
|
108
84
|
def images
|
109
85
|
images = @anchors.select { |a| a.object.is_a?(Pic) }
|
110
86
|
images.map { |a| a.object }
|
111
87
|
end
|
112
88
|
|
89
|
+
# The index of this drawing in the owning workbooks's drawings collection.
|
90
|
+
# @return [Integer]
|
113
91
|
def index
|
114
92
|
@worksheet.workbook.drawings.index(self)
|
115
93
|
end
|
116
94
|
|
95
|
+
# The relation reference id for this drawing
|
96
|
+
# @return [String]
|
117
97
|
def rId
|
118
98
|
"rId#{index+1}"
|
119
99
|
end
|
120
100
|
|
101
|
+
# The part name for this drawing
|
102
|
+
# @return [String]
|
121
103
|
def pn
|
122
104
|
"#{DRAWING_PN % (index+1)}"
|
123
105
|
end
|
124
|
-
|
106
|
+
|
107
|
+
# The relational part name for this drawing
|
108
|
+
# @return [String]
|
125
109
|
def rels_pn
|
126
110
|
"#{DRAWING_RELS_PN % (index+1)}"
|
127
111
|
end
|
128
112
|
|
113
|
+
# The drawing's relationships.
|
114
|
+
# @return [Relationships]
|
129
115
|
def relationships
|
130
116
|
r = Relationships.new
|
131
117
|
charts.each do |chart|
|
@@ -12,10 +12,6 @@ module Axlsx
|
|
12
12
|
# @return [TwoCellAnchor]
|
13
13
|
attr_reader :anchor
|
14
14
|
|
15
|
-
# The relationship id for this graphic
|
16
|
-
# @return [String]
|
17
|
-
attr_reader :rId
|
18
|
-
|
19
15
|
# Creates a new GraphicFrame object
|
20
16
|
# @param [TwoCellAnchor] anchor
|
21
17
|
# @param [Class] chart_type
|
@@ -25,6 +21,8 @@ module Axlsx
|
|
25
21
|
@chart = chart_type.new(self, options)
|
26
22
|
end
|
27
23
|
|
24
|
+
# The relationship id for this graphic
|
25
|
+
# @return [String]
|
28
26
|
def rId
|
29
27
|
"rId#{@anchor.index+1}"
|
30
28
|
end
|
@@ -34,12 +34,12 @@ module Axlsx
|
|
34
34
|
|
35
35
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
36
36
|
# @return [String]
|
37
|
-
|
37
|
+
attr_reader :gapDepth
|
38
38
|
|
39
39
|
#grouping for a column, line, or area chart.
|
40
40
|
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
41
41
|
# @return [Symbol]
|
42
|
-
|
42
|
+
attr_reader :grouping
|
43
43
|
|
44
44
|
# validation regex for gap amount percent
|
45
45
|
GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/
|
@@ -59,6 +59,7 @@ module Axlsx
|
|
59
59
|
# @see Chart
|
60
60
|
# @see View3D
|
61
61
|
def initialize(frame, options={})
|
62
|
+
@gapDepth = nil
|
62
63
|
@grouping = :standard
|
63
64
|
@catAxId = rand(8 ** 8)
|
64
65
|
@valAxId = rand(8 ** 8)
|
@@ -71,11 +72,13 @@ module Axlsx
|
|
71
72
|
@view3D = View3D.new({:perspective=>30}.merge(options))
|
72
73
|
end
|
73
74
|
|
75
|
+
# @see grouping
|
74
76
|
def grouping=(v)
|
75
77
|
RestrictionValidator.validate "Bar3DChart.grouping", [:percentStacked, :standard, :stacked], v
|
76
78
|
@grouping = v
|
77
79
|
end
|
78
80
|
|
81
|
+
# @see gapDepth
|
79
82
|
def gapDepth=(v)
|
80
83
|
RegexValidator.validate "Bar3DChart.gapWidth", GAP_AMOUNT_PERCENT, v
|
81
84
|
@gapDepth=(v)
|
@@ -18,18 +18,19 @@ module Axlsx
|
|
18
18
|
# @option options [Array, SimpleTypedList] labels
|
19
19
|
# @param [Chart] chart
|
20
20
|
def initialize(chart, options={})
|
21
|
+
@labels, @data = nil, nil
|
21
22
|
super(chart, options)
|
22
|
-
|
23
|
-
|
23
|
+
@labels = CatAxisData.new(options[:labels]) unless options[:labels].nil?
|
24
|
+
@data = ValAxisData.new(options[:data]) unless options[:data].nil?
|
24
25
|
end
|
25
26
|
|
26
27
|
# Serializes the series
|
27
28
|
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
|
28
29
|
# @return [String]
|
29
30
|
def to_xml(xml)
|
30
|
-
super(xml) do |
|
31
|
-
@labels.to_xml(
|
32
|
-
@data.to_xml(
|
31
|
+
super(xml) do |xml_inner|
|
32
|
+
@labels.to_xml(xml_inner) unless @labels.nil?
|
33
|
+
@data.to_xml(xml_inner) unless @data.nil?
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
data/lib/axlsx/drawing/marker.rb
CHANGED
@@ -6,19 +6,19 @@ module Axlsx
|
|
6
6
|
|
7
7
|
# The column this marker anchors to
|
8
8
|
# @return [Integer]
|
9
|
-
|
9
|
+
attr_reader :col
|
10
10
|
|
11
11
|
# The offset distance from this marker's column
|
12
12
|
# @return [Integer]
|
13
|
-
|
13
|
+
attr_reader :colOff
|
14
14
|
|
15
15
|
# The row this marker anchors to
|
16
16
|
# @return [Integer]
|
17
|
-
|
17
|
+
attr_reader :row
|
18
18
|
|
19
19
|
# The offset distance from this marker's row
|
20
20
|
# @return [Integer]
|
21
|
-
|
21
|
+
attr_reader :rowOff
|
22
22
|
|
23
23
|
# Creates a new Marker object
|
24
24
|
# @option options [Integer] col
|
@@ -32,11 +32,15 @@ module Axlsx
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
# @see col
|
35
36
|
def col=(v) Axlsx::validate_unsigned_int v; @col = v end
|
37
|
+
# @see colOff
|
36
38
|
def colOff=(v) Axlsx::validate_int v; @colOff = v end
|
39
|
+
# @see row
|
37
40
|
def row=(v) Axlsx::validate_unsigned_int v; @row = v end
|
41
|
+
# @see rowOff
|
38
42
|
def rowOff=(v) Axlsx::validate_int v; @rowOff = v end
|
39
|
-
|
43
|
+
|
40
44
|
# shortcut to set the column, row position for this marker
|
41
45
|
# @param col the column for the marker
|
42
46
|
# @param row the row of the marker
|
@@ -17,20 +17,15 @@ module Axlsx
|
|
17
17
|
# @return [Drawing]
|
18
18
|
attr_reader :drawing
|
19
19
|
|
20
|
-
# The index of this anchor in the drawing
|
21
|
-
# @return [Integer]
|
22
|
-
attr_reader :index
|
23
|
-
|
24
|
-
|
25
20
|
# the width of the graphic object in pixels.
|
26
21
|
# this is converted to EMU at a 92 ppi resolution
|
27
22
|
# @return [Integer]
|
28
|
-
|
23
|
+
attr_reader :width
|
29
24
|
|
30
25
|
# the height of the graphic object in pixels
|
31
26
|
# this is converted to EMU at a 92 ppi resolution
|
32
27
|
# @return [Integer]
|
33
|
-
|
28
|
+
attr_reader :height
|
34
29
|
|
35
30
|
|
36
31
|
# Creates a new OneCellAnchor object and an Pic associated with it.
|
@@ -53,9 +48,14 @@ module Axlsx
|
|
53
48
|
@object = Pic.new(self, options)
|
54
49
|
end
|
55
50
|
|
51
|
+
# @see height
|
56
52
|
def height=(v) Axlsx::validate_unsigned_int(v); @height = v; end
|
53
|
+
|
54
|
+
# @see width
|
57
55
|
def width=(v) Axlsx::validate_unsigned_int(v); @width = v; end
|
58
56
|
|
57
|
+
# The index of this anchor in the drawing
|
58
|
+
# @return [Integer]
|
59
59
|
def index
|
60
60
|
@drawing.anchors.index(self)
|
61
61
|
end
|
data/lib/axlsx/drawing/pic.rb
CHANGED
@@ -10,50 +10,22 @@ module Axlsx
|
|
10
10
|
|
11
11
|
# The name to use for this picture
|
12
12
|
# @return [String]
|
13
|
-
|
13
|
+
attr_reader :name
|
14
14
|
|
15
|
-
# providing access to the anchor's width attribute
|
16
|
-
# @param [Integer] v
|
17
|
-
# @see OneCellAnchor.width
|
18
|
-
attr_accessor :width
|
19
|
-
|
20
|
-
# providing access to update the anchor's height attribute
|
21
|
-
# @param [Integer] v
|
22
|
-
# @see OneCellAnchor.width
|
23
|
-
attr_accessor :height
|
24
15
|
|
25
16
|
# A description of the picture
|
26
17
|
# @return [String]
|
27
|
-
|
18
|
+
attr_reader :descr
|
28
19
|
|
29
20
|
# The path to the image you want to include
|
30
21
|
# Only local images are supported at this time and only jpg support
|
31
22
|
# @return [String]
|
32
|
-
|
23
|
+
attr_reader :image_src
|
33
24
|
|
34
25
|
# The anchor for this image
|
35
26
|
# @return [OneCellAnchor]
|
36
27
|
attr_reader :anchor
|
37
28
|
|
38
|
-
# returns the extension of image_src without the preceeding '.'
|
39
|
-
# @return [String]
|
40
|
-
attr_reader :extname
|
41
|
-
|
42
|
-
# The file name of image_src without any path information
|
43
|
-
# @return [String]
|
44
|
-
attr_reader :file_name
|
45
|
-
|
46
|
-
# The part name for this image used in serialization and relationship building
|
47
|
-
# @return [String]
|
48
|
-
attr_reader :pn
|
49
|
-
|
50
|
-
# The index of this image in the workbooks images collections
|
51
|
-
# @return [Index]
|
52
|
-
attr_reader :index
|
53
|
-
|
54
|
-
# The name of the image file, sans directory info
|
55
|
-
# @return [String]
|
56
|
-
attr_reader :file_name
|
57
29
|
|
58
30
|
# Creates a new Pic(ture) object
|
59
31
|
# @param [Anchor] anchor the anchor that holds this image
|
@@ -69,7 +41,7 @@ module Axlsx
|
|
69
41
|
options.each do |o|
|
70
42
|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
71
43
|
end
|
72
|
-
start_at
|
44
|
+
start_at(*options[:start_at]) if options[:start_at]
|
73
45
|
yield self if block_given?
|
74
46
|
end
|
75
47
|
|
@@ -80,41 +52,61 @@ module Axlsx
|
|
80
52
|
@image_src = v
|
81
53
|
end
|
82
54
|
|
55
|
+
# @see name
|
83
56
|
def name=(v) Axlsx::validate_string(v); @name = v; end
|
57
|
+
|
58
|
+
# @see descr
|
84
59
|
def descr=(v) Axlsx::validate_string(v); @descr = v; end
|
85
60
|
|
61
|
+
|
62
|
+
# The file name of image_src without any path information
|
63
|
+
# @return [String]
|
86
64
|
def file_name
|
87
65
|
File.basename(image_src) unless image_src.nil?
|
88
66
|
end
|
89
67
|
|
68
|
+
# returns the extension of image_src without the preceeding '.'
|
69
|
+
# @return [String]
|
90
70
|
def extname
|
91
71
|
File.extname(image_src).delete('.') unless image_src.nil?
|
92
72
|
end
|
93
73
|
|
74
|
+
# The index of this image in the workbooks images collections
|
75
|
+
# @return [Index]
|
94
76
|
def index
|
95
77
|
@anchor.drawing.worksheet.workbook.images.index(self)
|
96
78
|
end
|
97
|
-
|
79
|
+
|
80
|
+
# The part name for this image used in serialization and relationship building
|
81
|
+
# @return [String]
|
98
82
|
def pn
|
99
83
|
"#{IMAGE_PN % [(index+1), extname]}"
|
100
84
|
end
|
101
85
|
|
86
|
+
# providing access to the anchor's width attribute
|
87
|
+
# @param [Integer] v
|
88
|
+
# @see OneCellAnchor.width
|
102
89
|
def width
|
103
90
|
@anchor.width
|
104
91
|
end
|
105
92
|
|
93
|
+
# @see width
|
106
94
|
def width=(v)
|
107
95
|
@anchor.width = v
|
108
96
|
end
|
109
97
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
98
|
+
# providing access to update the anchor's height attribute
|
99
|
+
# @param [Integer] v
|
100
|
+
# @see OneCellAnchor.width
|
114
101
|
def height
|
115
102
|
@anchor.height
|
116
103
|
end
|
117
104
|
|
105
|
+
# @see height
|
106
|
+
def height=(v)
|
107
|
+
@anchor.height = v
|
108
|
+
end
|
109
|
+
|
118
110
|
# This is a short cut method to set the start anchor position
|
119
111
|
# If you need finer granularity in positioning use
|
120
112
|
# graphic_frame.anchor.from.colOff / rowOff
|