caxlsx 3.3.0 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +24 -5
  4. data/Rakefile +0 -1
  5. data/lib/axlsx/content_type/abstract_content_type.rb +2 -5
  6. data/lib/axlsx/content_type/content_type.rb +0 -4
  7. data/lib/axlsx/content_type/default.rb +1 -5
  8. data/lib/axlsx/content_type/override.rb +0 -4
  9. data/lib/axlsx/doc_props/app.rb +1 -6
  10. data/lib/axlsx/doc_props/core.rb +1 -6
  11. data/lib/axlsx/drawing/area_chart.rb +3 -6
  12. data/lib/axlsx/drawing/area_series.rb +1 -4
  13. data/lib/axlsx/drawing/ax_data_source.rb +1 -6
  14. data/lib/axlsx/drawing/axes.rb +5 -6
  15. data/lib/axlsx/drawing/axis.rb +7 -12
  16. data/lib/axlsx/drawing/bar_3D_chart.rb +7 -10
  17. data/lib/axlsx/drawing/bar_chart.rb +6 -9
  18. data/lib/axlsx/drawing/bar_series.rb +2 -8
  19. data/lib/axlsx/drawing/bubble_chart.rb +2 -5
  20. data/lib/axlsx/drawing/bubble_series.rb +3 -6
  21. data/lib/axlsx/drawing/cat_axis.rb +2 -7
  22. data/lib/axlsx/drawing/chart.rb +7 -12
  23. data/lib/axlsx/drawing/d_lbls.rb +23 -22
  24. data/lib/axlsx/drawing/drawing.rb +4 -8
  25. data/lib/axlsx/drawing/graphic_frame.rb +0 -3
  26. data/lib/axlsx/drawing/hyperlink.rb +4 -7
  27. data/lib/axlsx/drawing/line_3D_chart.rb +10 -14
  28. data/lib/axlsx/drawing/line_chart.rb +3 -6
  29. data/lib/axlsx/drawing/line_series.rb +1 -4
  30. data/lib/axlsx/drawing/marker.rb +5 -9
  31. data/lib/axlsx/drawing/num_data.rb +4 -9
  32. data/lib/axlsx/drawing/num_data_source.rb +3 -7
  33. data/lib/axlsx/drawing/num_val.rb +2 -5
  34. data/lib/axlsx/drawing/one_cell_anchor.rb +4 -6
  35. data/lib/axlsx/drawing/pic.rb +46 -13
  36. data/lib/axlsx/drawing/picture_locking.rb +3 -6
  37. data/lib/axlsx/drawing/pie_3D_chart.rb +2 -7
  38. data/lib/axlsx/drawing/pie_series.rb +1 -6
  39. data/lib/axlsx/drawing/scaling.rb +2 -5
  40. data/lib/axlsx/drawing/scatter_chart.rb +2 -5
  41. data/lib/axlsx/drawing/scatter_series.rb +2 -5
  42. data/lib/axlsx/drawing/ser_axis.rb +2 -6
  43. data/lib/axlsx/drawing/series.rb +3 -5
  44. data/lib/axlsx/drawing/series_title.rb +0 -2
  45. data/lib/axlsx/drawing/str_data.rb +3 -8
  46. data/lib/axlsx/drawing/str_val.rb +2 -5
  47. data/lib/axlsx/drawing/title.rb +12 -15
  48. data/lib/axlsx/drawing/two_cell_anchor.rb +5 -7
  49. data/lib/axlsx/drawing/val_axis.rb +1 -4
  50. data/lib/axlsx/drawing/view_3D.rb +24 -24
  51. data/lib/axlsx/drawing/vml_drawing.rb +2 -5
  52. data/lib/axlsx/drawing/vml_shape.rb +4 -7
  53. data/lib/axlsx/package.rb +35 -36
  54. data/lib/axlsx/rels/relationship.rb +21 -24
  55. data/lib/axlsx/rels/relationships.rb +3 -6
  56. data/lib/axlsx/stylesheet/border.rb +1 -4
  57. data/lib/axlsx/stylesheet/border_pr.rb +3 -5
  58. data/lib/axlsx/stylesheet/cell_alignment.rb +2 -10
  59. data/lib/axlsx/stylesheet/cell_protection.rb +1 -4
  60. data/lib/axlsx/stylesheet/cell_style.rb +3 -7
  61. data/lib/axlsx/stylesheet/color.rb +6 -5
  62. data/lib/axlsx/stylesheet/dxf.rb +2 -6
  63. data/lib/axlsx/stylesheet/fill.rb +0 -4
  64. data/lib/axlsx/stylesheet/font.rb +7 -6
  65. data/lib/axlsx/stylesheet/gradient_fill.rb +4 -6
  66. data/lib/axlsx/stylesheet/gradient_stop.rb +2 -3
  67. data/lib/axlsx/stylesheet/num_fmt.rb +1 -4
  68. data/lib/axlsx/stylesheet/pattern_fill.rb +3 -5
  69. data/lib/axlsx/stylesheet/styles.rb +53 -45
  70. data/lib/axlsx/stylesheet/table_style.rb +5 -8
  71. data/lib/axlsx/stylesheet/table_style_element.rb +1 -4
  72. data/lib/axlsx/stylesheet/table_styles.rb +3 -7
  73. data/lib/axlsx/stylesheet/xf.rb +3 -6
  74. data/lib/axlsx/util/accessors.rb +2 -4
  75. data/lib/axlsx/util/constants.rb +3 -5
  76. data/lib/axlsx/util/mime_type_utils.rb +13 -0
  77. data/lib/axlsx/util/options_parser.rb +1 -2
  78. data/lib/axlsx/util/serialized_attributes.rb +4 -5
  79. data/lib/axlsx/util/simple_typed_list.rb +18 -17
  80. data/lib/axlsx/util/storage.rb +32 -36
  81. data/lib/axlsx/util/validators.rb +7 -4
  82. data/lib/axlsx/util/zip_command.rb +0 -2
  83. data/lib/axlsx/version.rb +1 -2
  84. data/lib/axlsx/workbook/defined_name.rb +6 -5
  85. data/lib/axlsx/workbook/defined_names.rb +1 -2
  86. data/lib/axlsx/workbook/shared_strings_table.rb +3 -6
  87. data/lib/axlsx/workbook/workbook.rb +96 -91
  88. data/lib/axlsx/workbook/workbook_view.rb +5 -10
  89. data/lib/axlsx/workbook/workbook_views.rb +1 -3
  90. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +9 -8
  91. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +6 -6
  92. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +13 -14
  93. data/lib/axlsx/workbook/worksheet/border_creator.rb +29 -26
  94. data/lib/axlsx/workbook/worksheet/break.rb +2 -5
  95. data/lib/axlsx/workbook/worksheet/cell.rb +46 -26
  96. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +11 -11
  97. data/lib/axlsx/workbook/worksheet/cfvo.rb +2 -2
  98. data/lib/axlsx/workbook/worksheet/cfvos.rb +3 -5
  99. data/lib/axlsx/workbook/worksheet/col.rb +4 -7
  100. data/lib/axlsx/workbook/worksheet/col_breaks.rb +4 -5
  101. data/lib/axlsx/workbook/worksheet/color_scale.rb +10 -12
  102. data/lib/axlsx/workbook/worksheet/cols.rb +6 -6
  103. data/lib/axlsx/workbook/worksheet/comment.rb +4 -5
  104. data/lib/axlsx/workbook/worksheet/comments.rb +6 -10
  105. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +4 -5
  106. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +2 -6
  107. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +2 -4
  108. data/lib/axlsx/workbook/worksheet/data_bar.rb +20 -22
  109. data/lib/axlsx/workbook/worksheet/data_validation.rb +4 -5
  110. data/lib/axlsx/workbook/worksheet/data_validations.rb +2 -5
  111. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +1 -3
  112. data/lib/axlsx/workbook/worksheet/dimension.rb +5 -4
  113. data/lib/axlsx/workbook/worksheet/header_footer.rb +0 -1
  114. data/lib/axlsx/workbook/worksheet/icon_set.rb +2 -3
  115. data/lib/axlsx/workbook/worksheet/merged_cells.rb +8 -8
  116. data/lib/axlsx/workbook/worksheet/outline_pr.rb +0 -1
  117. data/lib/axlsx/workbook/worksheet/page_margins.rb +2 -2
  118. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -3
  119. data/lib/axlsx/workbook/worksheet/page_setup.rb +117 -120
  120. data/lib/axlsx/workbook/worksheet/pane.rb +16 -17
  121. data/lib/axlsx/workbook/worksheet/pivot_table.rb +8 -11
  122. data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +8 -11
  123. data/lib/axlsx/workbook/worksheet/pivot_tables.rb +3 -4
  124. data/lib/axlsx/workbook/worksheet/print_options.rb +0 -1
  125. data/lib/axlsx/workbook/worksheet/protected_range.rb +4 -5
  126. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +9 -9
  127. data/lib/axlsx/workbook/worksheet/rich_text.rb +4 -6
  128. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +21 -5
  129. data/lib/axlsx/workbook/worksheet/row.rb +24 -15
  130. data/lib/axlsx/workbook/worksheet/row_breaks.rb +3 -4
  131. data/lib/axlsx/workbook/worksheet/selection.rb +7 -9
  132. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +5 -6
  133. data/lib/axlsx/workbook/worksheet/sheet_data.rb +4 -6
  134. data/lib/axlsx/workbook/worksheet/sheet_format_pr.rb +18 -18
  135. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +4 -4
  136. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +12 -13
  137. data/lib/axlsx/workbook/worksheet/sheet_view.rb +35 -42
  138. data/lib/axlsx/workbook/worksheet/table.rb +7 -9
  139. data/lib/axlsx/workbook/worksheet/table_style_info.rb +2 -3
  140. data/lib/axlsx/workbook/worksheet/tables.rb +4 -4
  141. data/lib/axlsx/workbook/worksheet/worksheet.rb +63 -35
  142. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +6 -6
  143. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +3 -2
  144. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +5 -6
  145. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +4 -4
  146. data/lib/axlsx.rb +23 -9
  147. data/lib/caxlsx.rb +0 -1
  148. metadata +3 -3
@@ -1,14 +1,13 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
2
  # a Pic object represents an image in your worksheet
4
3
  # Worksheet#add_image is the recommended way to manage images in your sheets
5
4
  # @see Worksheet#add_image
6
5
  class Pic
7
-
8
6
  include Axlsx::OptionsParser
9
7
 
10
8
  # Creates a new Pic(ture) object
11
9
  # @param [Anchor] anchor the anchor that holds this image
10
+ # @option options [Boolean] :remote indicates if image_src is a remote URI
12
11
  # @option options [String] :name
13
12
  # @option options [String] :descr
14
13
  # @option options [String] :image_src
@@ -16,10 +15,11 @@ module Axlsx
16
15
  # @option options [Integer] :width
17
16
  # @option options [Integer] :height
18
17
  # @option options [Float] :opacity - set the picture opacity, accepts a value between 0.0 and 1.0
19
- def initialize(anchor, options={})
18
+ def initialize(anchor, options = {})
20
19
  @anchor = anchor
21
20
  @hyperlink = nil
22
21
  @anchor.drawing.worksheet.workbook.images << self
22
+ @remote = options[:remote]
23
23
  parse_options options
24
24
  start_at(*options[:start_at]) if options[:start_at]
25
25
  yield self if block_given?
@@ -56,10 +56,14 @@ module Axlsx
56
56
  # @return [Integer]
57
57
  attr_reader :opacity
58
58
 
59
+ # Flag for remote picture (from URI)
60
+ # @return [Boolean]
61
+ attr_reader :remote
62
+
59
63
  # sets or updates a hyperlink for this image.
60
64
  # @param [String] v The href value for the hyper link
61
65
  # @option options @see Hyperlink#initialize All options available to the Hyperlink class apply - however href will be overridden with the v parameter value.
62
- def hyperlink=(v, options={})
66
+ def hyperlink=(v, options = {})
63
67
  options[:href] = v
64
68
  if hyperlink.is_a?(Hyperlink)
65
69
  options.each do |o|
@@ -73,8 +77,14 @@ module Axlsx
73
77
 
74
78
  def image_src=(v)
75
79
  Axlsx::validate_string(v)
76
- RestrictionValidator.validate 'Pic.image_src', ALLOWED_MIME_TYPES, MimeTypeUtils.get_mime_type(v)
77
- raise ArgumentError, "File does not exist" unless File.exist?(v)
80
+ if remote?
81
+ RegexValidator.validate('Pic.image_src', /\A#{URI::DEFAULT_PARSER.make_regexp}\z/, v)
82
+ RestrictionValidator.validate 'Pic.image_src', ALLOWED_MIME_TYPES, MimeTypeUtils.get_mime_type_from_uri(v)
83
+ else
84
+ RestrictionValidator.validate 'Pic.image_src', ALLOWED_MIME_TYPES, MimeTypeUtils.get_mime_type(v)
85
+ raise ArgumentError, "File does not exist" unless File.exist?(v)
86
+ end
87
+
78
88
  @image_src = v
79
89
  end
80
90
 
@@ -84,10 +94,17 @@ module Axlsx
84
94
  # @see descr
85
95
  def descr=(v) Axlsx::validate_string(v); @descr = v; end
86
96
 
97
+ # @see remote
98
+ def remote=(v) Axlsx::validate_boolean(v); @remote = v; end
99
+
100
+ def remote?
101
+ remote == 1 || remote.to_s == 'true'
102
+ end
103
+
87
104
  # The file name of image_src without any path information
88
105
  # @return [String]
89
106
  def file_name
90
- File.basename(image_src) unless image_src.nil?
107
+ File.basename(image_src) unless remote? || image_src.nil?
91
108
  end
92
109
 
93
110
  # returns the extension of image_src without the preceeding '.'
@@ -105,19 +122,24 @@ module Axlsx
105
122
  # The part name for this image used in serialization and relationship building
106
123
  # @return [String]
107
124
  def pn
108
- "#{IMAGE_PN % [(index+1), extname]}"
125
+ "#{IMAGE_PN % [(index + 1), extname]}"
109
126
  end
110
127
 
111
128
  # The relationship object for this pic.
112
129
  # @return [Relationship]
113
130
  def relationship
114
- Relationship.new(self, IMAGE_R, "../#{pn}")
131
+ if remote?
132
+ Relationship.new(self, IMAGE_R, "#{image_src}", target_mode: :External)
133
+ else
134
+ Relationship.new(self, IMAGE_R, "../#{pn}")
135
+ end
115
136
  end
116
137
 
117
138
  # providing access to the anchor's width attribute
118
139
  # @see OneCellAnchor.width
119
140
  def width
120
141
  return unless @anchor.is_a?(OneCellAnchor)
142
+
121
143
  @anchor.width
122
144
  end
123
145
 
@@ -147,7 +169,7 @@ module Axlsx
147
169
  # @param [Integer] x The column
148
170
  # @param [Integer] y The row
149
171
  # @return [Marker]
150
- def start_at(x, y=nil)
172
+ def start_at(x, y = nil)
151
173
  @anchor.start_at x, y
152
174
  @anchor.from
153
175
  end
@@ -156,7 +178,7 @@ module Axlsx
156
178
  # @param [Integer] x The column
157
179
  # @param [Integer] y The row
158
180
  # @return [Marker]
159
- def end_at(x, y=nil)
181
+ def end_at(x, y = nil)
160
182
  use_two_cell_anchor unless @anchor.is_a?(TwoCellAnchor)
161
183
  @anchor.end_at x, y
162
184
  @anchor.to
@@ -174,7 +196,7 @@ module Axlsx
174
196
  picture_locking.to_xml_string(str)
175
197
  str << '</xdr:cNvPicPr></xdr:nvPicPr>'
176
198
  str << '<xdr:blipFill>'
177
- str << ('<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">')
199
+ str << relationship_xml_portion
178
200
  if opacity
179
201
  str << "<a:alphaModFix amt=\"#{opacity}\"/>"
180
202
  end
@@ -186,16 +208,27 @@ module Axlsx
186
208
 
187
209
  private
188
210
 
211
+ # Return correct xml relationship string portion
212
+ def relationship_xml_portion
213
+ if remote?
214
+ ('<a:blip xmlns:r ="' << XML_NS_R << '" r:link="' << relationship.Id << '">')
215
+ else
216
+ ('<a:blip xmlns:r ="' << XML_NS_R << '" r:embed="' << relationship.Id << '">')
217
+ end
218
+ end
219
+
189
220
  # Changes the anchor to a one cell anchor.
190
221
  def use_one_cell_anchor
191
222
  return if @anchor.is_a?(OneCellAnchor)
223
+
192
224
  new_anchor = OneCellAnchor.new(@anchor.drawing, :start_at => [@anchor.from.col, @anchor.from.row])
193
225
  swap_anchor(new_anchor)
194
226
  end
195
227
 
196
- #changes the anchor type to a two cell anchor
228
+ # changes the anchor type to a two cell anchor
197
229
  def use_two_cell_anchor
198
230
  return if @anchor.is_a?(TwoCellAnchor)
231
+
199
232
  new_anchor = TwoCellAnchor.new(@anchor.drawing, :start_at => [@anchor.from.col, @anchor.from.row])
200
233
  swap_anchor(new_anchor)
201
234
  end
@@ -1,15 +1,13 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
2
  # The picture locking class defines the locking properties for pictures in your workbook.
4
3
  class PictureLocking
5
-
6
4
  include Axlsx::OptionsParser
7
5
  include Axlsx::SerializedAttributes
8
6
  include Axlsx::Accessors
9
7
 
10
8
  boolean_attr_accessor :noGrp, :noSelect, :noRot, :noChangeAspect,
11
- :noMove, :noResize, :noEditPoints, :noAdjustHandles,
12
- :noChangeArrowheads, :noChangeShapeType
9
+ :noMove, :noResize, :noEditPoints, :noAdjustHandles,
10
+ :noChangeArrowheads, :noChangeShapeType
13
11
 
14
12
  serializable_attributes :noGrp, :noSelect, :noRot, :noChangeAspect,
15
13
  :noMove, :noResize, :noEditPoints, :noAdjustHandles,
@@ -26,7 +24,7 @@ module Axlsx
26
24
  # @option options [Boolean] noAdjustHandles
27
25
  # @option options [Boolean] noChangeArrowheads
28
26
  # @option options [Boolean] noChangeShapeType
29
- def initialize(options={})
27
+ def initialize(options = {})
30
28
  @noChangeAspect = true
31
29
  parse_options options
32
30
  end
@@ -37,6 +35,5 @@ module Axlsx
37
35
  def to_xml_string(str = '')
38
36
  serialized_tag('a:picLocks', str)
39
37
  end
40
-
41
38
  end
42
39
  end
@@ -1,13 +1,9 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
-
4
-
5
2
  # The Pie3DChart is a three dimentional piechart (who would have guessed?) that you can add to your worksheet.
6
3
  # @see Worksheet#add_chart
7
4
  # @see Chart#add_series
8
5
  # @see README for an example
9
6
  class Pie3DChart < Chart
10
-
11
7
  # Creates a new pie chart object
12
8
  # @param [GraphicFrame] frame The workbook that owns this chart.
13
9
  # @option options [Cell, String] title
@@ -22,11 +18,11 @@ module Axlsx
22
18
  # @option options [Integer] perspective
23
19
  # @see Chart
24
20
  # @see View3D
25
- def initialize(frame, options={})
21
+ def initialize(frame, options = {})
26
22
  @vary_colors = true
27
23
  super(frame, options)
28
24
  @series_type = PieSeries
29
- @view_3D = View3D.new({:rot_x =>30, :perspective=>30}.merge(options))
25
+ @view_3D = View3D.new({ :rot_x => 30, :perspective => 30 }.merge(options))
30
26
  @d_lbls = nil
31
27
  end
32
28
 
@@ -42,6 +38,5 @@ module Axlsx
42
38
  str << '</c:pie3DChart>'
43
39
  end
44
40
  end
45
-
46
41
  end
47
42
  end
@@ -1,12 +1,9 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
-
4
2
  # A PieSeries defines the data and labels and explosion for pie charts series.
5
3
  # @note The recommended way to manage series is to use Chart#add_series
6
4
  # @see Worksheet#add_chart
7
5
  # @see Chart#add_series
8
6
  class PieSeries < Series
9
-
10
7
  # The data for this series.
11
8
  # @return [SimpleTypedList]
12
9
  attr_reader :data
@@ -28,7 +25,7 @@ module Axlsx
28
25
  # @option options [String] title
29
26
  # @option options [Integer] explosion
30
27
  # @param [Chart] chart
31
- def initialize(chart, options={})
28
+ def initialize(chart, options = {})
32
29
  @explosion = nil
33
30
  @colors = []
34
31
  super(chart, options)
@@ -68,7 +65,5 @@ module Axlsx
68
65
 
69
66
  # assigns the labels for this series
70
67
  def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end
71
-
72
68
  end
73
-
74
69
  end
@@ -1,8 +1,6 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
2
  # The Scaling class defines axis scaling
4
3
  class Scaling
5
-
6
4
  include Axlsx::OptionsParser
7
5
 
8
6
  # creates a new Scaling object
@@ -10,7 +8,7 @@ module Axlsx
10
8
  # @option options [Symbol] orientation
11
9
  # @option options [Float] max
12
10
  # @option options [Float] min
13
- def initialize(options={})
11
+ def initialize(options = {})
14
12
  @orientation = :minMax
15
13
  @logBase, @min, @max = nil, nil, nil
16
14
  parse_options options
@@ -35,7 +33,7 @@ module Axlsx
35
33
  attr_reader :min
36
34
 
37
35
  # @see logBase
38
- def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer], v, lambda { |arg| arg >= 2 && arg <= 1000}; @logBase = v; end
36
+ def logBase=(v) DataTypeValidator.validate "Scaling.logBase", [Integer], v, lambda { |arg| arg >= 2 && arg <= 1000 }; @logBase = v; end
39
37
  # @see orientation
40
38
  def orientation=(v) RestrictionValidator.validate "Scaling.orientation", [:minMax, :maxMin], v; @orientation = v; end
41
39
  # @see max
@@ -55,6 +53,5 @@ module Axlsx
55
53
  str << ('<c:max val="' << @max.to_s << '"/>') unless @max.nil?
56
54
  str << '</c:scaling>'
57
55
  end
58
-
59
56
  end
60
57
  end
@@ -1,12 +1,9 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
-
4
2
  # The ScatterChart allows you to insert a scatter chart into your worksheet
5
3
  # @see Worksheet#add_chart
6
4
  # @see Chart#add_series
7
5
  # @see README for an example
8
6
  class ScatterChart < Chart
9
-
10
7
  include Axlsx::OptionsParser
11
8
 
12
9
  # The Style for the scatter chart
@@ -30,11 +27,11 @@ module Axlsx
30
27
  alias :yValAxis :y_val_axis
31
28
 
32
29
  # Creates a new scatter chart
33
- def initialize(frame, options={})
30
+ def initialize(frame, options = {})
34
31
  @vary_colors = 0
35
32
  @scatter_style = :lineMarker
36
33
 
37
- super(frame, options)
34
+ super(frame, options)
38
35
  @series_type = ScatterSeries
39
36
  @d_lbls = nil
40
37
  parse_options options
@@ -1,13 +1,10 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
-
4
2
  # A ScatterSeries defines the x and y position of data in the chart
5
3
  # @note The recommended way to manage series is to use Chart#add_series
6
4
  # @see Worksheet#add_chart
7
5
  # @see Chart#add_series
8
6
  # @see examples/example.rb
9
7
  class ScatterSeries < Series
10
-
11
8
  # The x data for this series.
12
9
  # @return [NamedAxisData]
13
10
  attr_reader :xData
@@ -37,7 +34,7 @@ module Axlsx
37
34
  attr_reader :marker_symbol
38
35
 
39
36
  # Creates a new ScatterSeries
40
- def initialize(chart, options={})
37
+ def initialize(chart, options = {})
41
38
  @xData, @yData = nil
42
39
  if options[:smooth].nil?
43
40
  # If caller hasn't specified smoothing or not, turn smoothing on or off based on scatter style
@@ -53,7 +50,7 @@ module Axlsx
53
50
 
54
51
  super(chart, options)
55
52
  @xData = AxDataSource.new(:tag_name => :xVal, :data => options[:xData]) unless options[:xData].nil?
56
- @yData = NumDataSource.new({:tag_name => :yVal, :data => options[:yData]}) unless options[:yData].nil?
53
+ @yData = NumDataSource.new({ :tag_name => :yVal, :data => options[:yData] }) unless options[:yData].nil?
57
54
  end
58
55
 
59
56
  # @see color
@@ -1,8 +1,6 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
- #A SerAxis object defines a series axis
2
+ # A SerAxis object defines a series axis
4
3
  class SerAxis < Axis
5
-
6
4
  # The number of tick lables to skip between labels
7
5
  # @return [Integer]
8
6
  attr_reader :tick_lbl_skip
@@ -16,7 +14,7 @@ module Axlsx
16
14
  # Creates a new SerAxis object
17
15
  # @option options [Integer] tick_lbl_skip
18
16
  # @option options [Integer] tick_mark_skip
19
- def initialize(options={})
17
+ def initialize(options = {})
20
18
  @tick_lbl_skip, @tick_mark_skip = 1, 1
21
19
  super(options)
22
20
  end
@@ -40,6 +38,4 @@ module Axlsx
40
38
  str << '</c:serAx>'
41
39
  end
42
40
  end
43
-
44
-
45
41
  end
@@ -1,11 +1,9 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
2
  # A Series defines the common series attributes and is the super class for all concrete series types.
4
3
  # @note The recommended way to manage series is to use Chart#add_series
5
4
  # @see Worksheet#add_chart
6
5
  # @see Chart#add_series
7
6
  class Series
8
-
9
7
  include Axlsx::OptionsParser
10
8
 
11
9
  # The chart that owns this series
@@ -20,7 +18,7 @@ module Axlsx
20
18
  # @param [Chart] chart
21
19
  # @option options [Integer] order
22
20
  # @option options [String] title
23
- def initialize(chart, options={})
21
+ def initialize(chart, options = {})
24
22
  @order = nil
25
23
  self.chart = chart
26
24
  @chart.series << self
@@ -40,7 +38,7 @@ module Axlsx
40
38
  end
41
39
 
42
40
  # @see order
43
- def order=(v) Axlsx::validate_unsigned_int(v); @order = v; end
41
+ def order=(v) Axlsx::validate_unsigned_int(v); @order = v; end
44
42
 
45
43
  # @see title
46
44
  def title=(v)
@@ -52,7 +50,7 @@ module Axlsx
52
50
  private
53
51
 
54
52
  # assigns the chart for this series
55
- def chart=(v) DataTypeValidator.validate "Series.chart", Chart, v; @chart = v; end
53
+ def chart=(v) DataTypeValidator.validate "Series.chart", Chart, v; @chart = v; end
56
54
 
57
55
  # Serializes the object
58
56
  # @param [String] str
@@ -1,8 +1,6 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
2
  # A series title is a Title with a slightly different serialization than chart titles.
4
3
  class SeriesTitle < Title
5
-
6
4
  # Serializes the object
7
5
  # @param [String] str
8
6
  # @return [String]
@@ -1,16 +1,13 @@
1
- # -*- coding: utf-8 -*-
2
1
  module Axlsx
3
-
4
- #This specifies the last string data used for a chart. (e.g. strLit and strCache)
2
+ # This specifies the last string data used for a chart. (e.g. strLit and strCache)
5
3
  # This class is extended for NumData to include the formatCode attribute required for numLit and numCache
6
4
  class StrData
7
-
8
5
  include Axlsx::OptionsParser
9
6
 
10
7
  # creates a new StrVal object
11
8
  # @option options [Array] :data
12
9
  # @option options [String] :tag_name
13
- def initialize(options={})
10
+ def initialize(options = {})
14
11
  @tag_prefix = :str
15
12
  @type = StrVal
16
13
  @pt = SimpleTypedList.new(@type)
@@ -19,7 +16,7 @@ module Axlsx
19
16
 
20
17
  # Creates the val objects for this data set. I am not overly confident this is going to play nicely with time and data types.
21
18
  # @param [Array] values An array of cells or values.
22
- def data=(values=[])
19
+ def data=(values = [])
23
20
  @tag_name = values.first.is_a?(Cell) ? :strCache : :strLit
24
21
  values.each do |value|
25
22
  v = value.is_a?(Cell) ? value.value : value
@@ -36,7 +33,5 @@ module Axlsx
36
33
  end
37
34
  str << ('</c:' << @tag_name.to_s << '>')
38
35
  end
39
-
40
36
  end
41
-
42
37
  end
@@ -1,14 +1,11 @@
1
- # -*- coding: utf-8 -*-
2
1
  module Axlsx
3
-
4
- #This class specifies data for a particular data point.
2
+ # This class specifies data for a particular data point.
5
3
  class StrVal
6
-
7
4
  include Axlsx::OptionsParser
8
5
 
9
6
  # creates a new StrVal object
10
7
  # @option options [String] v
11
- def initialize(options={})
8
+ def initialize(options = {})
12
9
  @v = ""
13
10
  @idx = 0
14
11
  parse_options options
@@ -1,8 +1,6 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
2
  # A Title stores information about the title of a chart
4
3
  class Title
5
-
6
4
  # The text to be shown. Setting this property directly with a string will remove the cell reference.
7
5
  # @return [String]
8
6
  attr_reader :text
@@ -17,7 +15,7 @@ module Axlsx
17
15
 
18
16
  # Creates a new Title object
19
17
  # @param [String, Cell] title The cell or string to be used for the chart's title
20
- def initialize(title="", title_size="")
18
+ def initialize(title = "", title_size = "")
21
19
  self.cell = title if title.is_a?(Cell)
22
20
  self.text = title.to_s unless title.is_a?(Cell)
23
21
  if title_size.to_s.empty?
@@ -62,9 +60,9 @@ module Axlsx
62
60
  end
63
61
 
64
62
  # Not implemented at this time.
65
- #def layout=(v) DataTypeValidator.validate 'Title.layout', Layout, v; @layout = v; end
66
- #def overlay=(v) Axlsx::validate_boolean v; @overlay=v; end
67
- #def spPr=(v) DataTypeValidator.validate 'Title.spPr', SpPr, v; @spPr = v; end
63
+ # def layout=(v) DataTypeValidator.validate 'Title.layout', Layout, v; @layout = v; end
64
+ # def overlay=(v) Axlsx::validate_boolean v; @overlay=v; end
65
+ # def spPr=(v) DataTypeValidator.validate 'Title.spPr', SpPr, v; @spPr = v; end
68
66
 
69
67
  # Serializes the object
70
68
  # @param [String] str
@@ -86,14 +84,14 @@ module Axlsx
86
84
  str << '</c:strRef>'
87
85
  else
88
86
  str << '<c:rich>'
89
- str << '<a:bodyPr/>'
90
- str << '<a:lstStyle/>'
91
- str << '<a:p>'
92
- str << '<a:r>'
93
- str << ('<a:rPr sz="' << @text_size.to_s << '"/>')
94
- str << ('<a:t>' << clean_value << '</a:t>')
95
- str << '</a:r>'
96
- str << '</a:p>'
87
+ str << '<a:bodyPr/>'
88
+ str << '<a:lstStyle/>'
89
+ str << '<a:p>'
90
+ str << '<a:r>'
91
+ str << ('<a:rPr sz="' << @text_size.to_s << '"/>')
92
+ str << ('<a:t>' << clean_value << '</a:t>')
93
+ str << '</a:r>'
94
+ str << '</a:p>'
97
95
  str << '</c:rich>'
98
96
  end
99
97
  str << '</c:tx>'
@@ -102,6 +100,5 @@ module Axlsx
102
100
  str << '<c:overlay val="0"/>'
103
101
  str << '</c:title>'
104
102
  end
105
-
106
103
  end
107
104
  end
@@ -1,10 +1,8 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
2
  # This class details the anchor points for drawings.
4
3
  # @note The recommended way to manage drawings and charts is Worksheet#add_chart. Anchors are specified by the :start_at and :end_at options to that method.
5
4
  # @see Worksheet#add_chart
6
5
  class TwoCellAnchor
7
-
8
6
  include Axlsx::OptionsParser
9
7
 
10
8
  # A marker that defines the from cell anchor. The default from column and row are 0 and 0 respectively
@@ -32,10 +30,10 @@ module Axlsx
32
30
  # @param [Drawing] drawing
33
31
  # @option options [Array] :start_at the col, row to start at THIS IS DOCUMENTED BUT NOT IMPLEMENTED HERE!
34
32
  # @option options [Array] :end_at the col, row to end at
35
- def initialize(drawing, options={})
33
+ def initialize(drawing, options = {})
36
34
  @drawing = drawing
37
35
  drawing.anchors << self
38
- @from, @to = Marker.new, Marker.new(:col => 5, :row=>10)
36
+ @from, @to = Marker.new, Marker.new(:col => 5, :row => 10)
39
37
  parse_options options
40
38
 
41
39
  # bit of a hack to work around the fact that the coords for start at and end at
@@ -48,7 +46,7 @@ module Axlsx
48
46
  # @note The recommended way to set the start position for graphical
49
47
  # objects is directly thru the object.
50
48
  # @see Chart#start_at
51
- def start_at(x, y=nil)
49
+ def start_at(x, y = nil)
52
50
  from.coord x, y
53
51
  end
54
52
 
@@ -56,7 +54,7 @@ module Axlsx
56
54
  # @note the recommended way to set the to position for graphical
57
55
  # objects is directly thru the object
58
56
  # @see Char#end_at
59
- def end_at(x, y=nil)
57
+ def end_at(x, y = nil)
60
58
  to.coord x, y
61
59
  end
62
60
 
@@ -68,7 +66,7 @@ module Axlsx
68
66
  end
69
67
 
70
68
  # Creates an image associated with this anchor.
71
- def add_pic(options={})
69
+ def add_pic(options = {})
72
70
  @object = Pic.new(self, options)
73
71
  end
74
72
 
@@ -1,8 +1,6 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
2
  # the ValAxis class defines a chart value axis.
4
3
  class ValAxis < Axis
5
-
6
4
  # This element specifies how the value axis crosses the category axis.
7
5
  # must be one of [:between, :midCat]
8
6
  # @return [Symbol]
@@ -11,7 +9,7 @@ module Axlsx
11
9
 
12
10
  # Creates a new ValAxis object
13
11
  # @option options [Symbol] crosses_between
14
- def initialize(options={})
12
+ def initialize(options = {})
15
13
  self.cross_between = :between
16
14
  super(options)
17
15
  end
@@ -32,6 +30,5 @@ module Axlsx
32
30
  str << ('<c:crossBetween val="' << @cross_between.to_s << '"/>')
33
31
  str << '</c:valAx>'
34
32
  end
35
-
36
33
  end
37
34
  end