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
@@ -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
- attr_accessor :shape
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 |xml|
45
- @labels.to_xml(xml) unless @labels.nil?
46
- @data.to_xml(xml) unless @data.nil?
47
- xml.send('c:shape', :val=>@shape)
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
- attr_accessor :auto
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
- attr_accessor :lblAlgn
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
- attr_accessor :lblOffset
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
@@ -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
- #attr_accessor :dLabls
25
+ #attr_reader :dLabls
34
26
 
35
27
  # The title object for the chart.
36
28
  # @return [Title]
37
- attr_accessor :title
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
- attr_accessor :style
34
+ attr_reader :style
43
35
 
44
36
  # Show the legend in the chart
45
37
  # @return [Boolean]
46
- attr_accessor :show_legend
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 *options[:start_at] if options[:start_at]
63
- end_at *options[:end_at] if options[:start_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
- def style=(v) DataTypeValidator.validate "Chart.style", Integer, v, lambda { |v| v >= 1 && v <= 48 }; @style = v; end
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
- attr_accessor :gapDepth
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
- attr_accessor :grouping
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
- self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil?
23
- self.data = ValAxisData.new(options[:data]) unless options[:data].nil?
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 |xml|
31
- @labels.to_xml(xml) unless @labels.nil?
32
- @data.to_xml(xml) unless @data.nil?
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
 
@@ -6,19 +6,19 @@ module Axlsx
6
6
 
7
7
  # The column this marker anchors to
8
8
  # @return [Integer]
9
- attr_accessor :col
9
+ attr_reader :col
10
10
 
11
11
  # The offset distance from this marker's column
12
12
  # @return [Integer]
13
- attr_accessor :colOff
13
+ attr_reader :colOff
14
14
 
15
15
  # The row this marker anchors to
16
16
  # @return [Integer]
17
- attr_accessor :row
17
+ attr_reader :row
18
18
 
19
19
  # The offset distance from this marker's row
20
20
  # @return [Integer]
21
- attr_accessor :rowOff
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
- attr_accessor :width
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
- attr_accessor :height
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
@@ -10,50 +10,22 @@ module Axlsx
10
10
 
11
11
  # The name to use for this picture
12
12
  # @return [String]
13
- attr_accessor :name
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
- attr_accessor :descr
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
- attr_accessor :image_src
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 *options[:start_at] if options[: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
- def height=(v)
111
- @anchor.height = v
112
- end
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