caxlsx 4.0.0 → 4.1.0

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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/examples/generate.rb +3 -1
  4. data/lib/axlsx/content_type/abstract_content_type.rb +4 -1
  5. data/lib/axlsx/content_type/content_type.rb +1 -1
  6. data/lib/axlsx/content_type/default.rb +4 -1
  7. data/lib/axlsx/content_type/override.rb +4 -1
  8. data/lib/axlsx/doc_props/app.rb +91 -24
  9. data/lib/axlsx/drawing/area_series.rb +8 -2
  10. data/lib/axlsx/drawing/axis.rb +24 -6
  11. data/lib/axlsx/drawing/bar_series.rb +12 -3
  12. data/lib/axlsx/drawing/cat_axis.rb +20 -5
  13. data/lib/axlsx/drawing/chart.rb +32 -8
  14. data/lib/axlsx/drawing/d_lbls.rb +4 -4
  15. data/lib/axlsx/drawing/drawing.rb +1 -0
  16. data/lib/axlsx/drawing/hyperlink.rb +12 -3
  17. data/lib/axlsx/drawing/line_series.rb +8 -2
  18. data/lib/axlsx/drawing/marker.rb +19 -4
  19. data/lib/axlsx/drawing/one_cell_anchor.rb +8 -2
  20. data/lib/axlsx/drawing/pic.rb +13 -4
  21. data/lib/axlsx/drawing/pie_3D_chart.rb +1 -1
  22. data/lib/axlsx/drawing/pie_chart.rb +36 -0
  23. data/lib/axlsx/drawing/pie_series.rb +16 -4
  24. data/lib/axlsx/drawing/scaling.rb +18 -4
  25. data/lib/axlsx/drawing/ser_axis.rb +8 -2
  26. data/lib/axlsx/drawing/series.rb +8 -2
  27. data/lib/axlsx/drawing/view_3D.rb +8 -2
  28. data/lib/axlsx/package.rb +4 -1
  29. data/lib/axlsx/rels/relationship.rb +13 -3
  30. data/lib/axlsx/rels/relationships.rb +1 -1
  31. data/lib/axlsx/stylesheet/border.rb +12 -3
  32. data/lib/axlsx/stylesheet/border_pr.rb +14 -3
  33. data/lib/axlsx/stylesheet/cell_alignment.rb +38 -9
  34. data/lib/axlsx/stylesheet/cell_protection.rb +9 -2
  35. data/lib/axlsx/stylesheet/cell_style.rb +29 -6
  36. data/lib/axlsx/stylesheet/color.rb +8 -2
  37. data/lib/axlsx/stylesheet/dxf.rb +29 -6
  38. data/lib/axlsx/stylesheet/fill.rb +4 -1
  39. data/lib/axlsx/stylesheet/font.rb +58 -12
  40. data/lib/axlsx/stylesheet/gradient_fill.rb +8 -2
  41. data/lib/axlsx/stylesheet/gradient_stop.rb +9 -2
  42. data/lib/axlsx/stylesheet/num_fmt.rb +8 -2
  43. data/lib/axlsx/stylesheet/pattern_fill.rb +14 -3
  44. data/lib/axlsx/stylesheet/styles.rb +57 -13
  45. data/lib/axlsx/stylesheet/table_style.rb +15 -4
  46. data/lib/axlsx/stylesheet/table_style_element.rb +12 -3
  47. data/lib/axlsx/stylesheet/table_styles.rb +10 -3
  48. data/lib/axlsx/stylesheet/xf.rb +68 -15
  49. data/lib/axlsx/util/accessors.rb +8 -6
  50. data/lib/axlsx/util/storage.rb +1 -1
  51. data/lib/axlsx/version.rb +1 -1
  52. data/lib/axlsx/workbook/defined_names.rb +1 -1
  53. data/lib/axlsx/workbook/workbook.rb +19 -6
  54. data/lib/axlsx/workbook/workbook_views.rb +1 -1
  55. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +4 -2
  56. data/lib/axlsx/workbook/worksheet/cell.rb +30 -10
  57. data/lib/axlsx/workbook/worksheet/cfvo.rb +8 -2
  58. data/lib/axlsx/workbook/worksheet/col_breaks.rb +1 -1
  59. data/lib/axlsx/workbook/worksheet/cols.rb +1 -1
  60. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +8 -2
  61. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +69 -14
  62. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +1 -1
  63. data/lib/axlsx/workbook/worksheet/data_validation.rb +52 -13
  64. data/lib/axlsx/workbook/worksheet/data_validations.rb +1 -1
  65. data/lib/axlsx/workbook/worksheet/icon_set.rb +16 -4
  66. data/lib/axlsx/workbook/worksheet/merged_cells.rb +1 -1
  67. data/lib/axlsx/workbook/worksheet/page_margins.rb +30 -7
  68. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -2
  69. data/lib/axlsx/workbook/worksheet/page_setup.rb +30 -7
  70. data/lib/axlsx/workbook/worksheet/pane.rb +8 -2
  71. data/lib/axlsx/workbook/worksheet/pivot_tables.rb +1 -1
  72. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +1 -1
  73. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +30 -10
  74. data/lib/axlsx/workbook/worksheet/row.rb +5 -2
  75. data/lib/axlsx/workbook/worksheet/row_breaks.rb +1 -1
  76. data/lib/axlsx/workbook/worksheet/selection.rb +8 -2
  77. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -1
  78. data/lib/axlsx/workbook/worksheet/sheet_view.rb +30 -9
  79. data/lib/axlsx/workbook/worksheet/table_style_info.rb +1 -1
  80. data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
  81. data/lib/axlsx/workbook/worksheet/worksheet.rb +18 -2
  82. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +1 -1
  83. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +1 -1
  84. metadata +6 -44
@@ -61,10 +61,16 @@ module Axlsx
61
61
  attr_reader :numFmtId
62
62
 
63
63
  # @see numFmtId
64
- def numFmtId=(v) Axlsx.validate_unsigned_int v; @numFmtId = v end
64
+ def numFmtId=(v)
65
+ Axlsx.validate_unsigned_int v
66
+ @numFmtId = v
67
+ end
65
68
 
66
69
  # @see formatCode
67
- def formatCode=(v) Axlsx.validate_string v; @formatCode = v end
70
+ def formatCode=(v)
71
+ Axlsx.validate_string v
72
+ @formatCode = v
73
+ end
68
74
 
69
75
  # Serializes the object
70
76
  # @param [String] str
@@ -49,11 +49,22 @@ module Axlsx
49
49
  attr_reader :patternType
50
50
 
51
51
  # @see fgColor
52
- def fgColor=(v) DataTypeValidator.validate "PatternFill.fgColor", Color, v; @fgColor = v end
52
+ def fgColor=(v)
53
+ DataTypeValidator.validate "PatternFill.fgColor", Color, v
54
+ @fgColor = v
55
+ end
56
+
53
57
  # @see bgColor
54
- def bgColor=(v) DataTypeValidator.validate "PatternFill.bgColor", Color, v; @bgColor = v end
58
+ def bgColor=(v)
59
+ DataTypeValidator.validate "PatternFill.bgColor", Color, v
60
+ @bgColor = v
61
+ end
62
+
55
63
  # @see patternType
56
- def patternType=(v) Axlsx.validate_pattern_type v; @patternType = v end
64
+ def patternType=(v)
65
+ Axlsx.validate_pattern_type v
66
+ @patternType = v
67
+ end
57
68
 
58
69
  # Serializes the object
59
70
  # @param [String] str
@@ -336,16 +336,53 @@ module Axlsx
336
336
  end
337
337
 
338
338
  # parses add_style options for fills. If the options hash contains :type => :dxf we return a Fill object. If not, we return the index of the fill after being added to the fills collection.
339
- # @note noop if :bg_color is not specified in options
340
- # @option options [String] bg_color The rgb color to apply to the fill
339
+ # @note noop unless at least one of the documented attributes is specified in options
340
+ # @option options [String] bg_color The rgb color to apply to the fill. An alias for pattern_bg_color if you need only a solid background
341
+ # @option options [String] pattern_type The fill pattern to apply to the fill
342
+ # @option options [String] pattern_bg_color The rgb color to apply to the fill as the first color
343
+ # @option options [String] pattern_fg_color The rgb color to apply to the fill as the second color
341
344
  # @return [Fill|Integer]
342
345
  def parse_fill_options(options = {})
343
- return unless options[:bg_color]
346
+ return unless options[:bg_color] || options[:pattern_type] || options[:pattern_bg_color] || options[:pattern_fg_color]
344
347
 
345
- color = Color.new(rgb: options[:bg_color])
348
+ pattern_type = options[:pattern_type] || :solid
346
349
  dxf = options[:type] == :dxf
347
- color_key = dxf ? :bgColor : :fgColor
348
- pattern = PatternFill.new(:patternType => :solid, color_key => color)
350
+
351
+ pattern_options = {
352
+ patternType: pattern_type
353
+ }
354
+
355
+ if options[:pattern_bg_color] && options[:bg_color]
356
+ warn 'Both `bg_color` and `pattern_bg_color` got defined. To get a solid background without defining it in `patter_type`, use only `bg_color`, otherwise use only `pattern_bg_color` to avoid confusion.'
357
+ end
358
+
359
+ bg_color = options[:pattern_bg_color] || options[:bg_color]
360
+ fg_color = options[:pattern_fg_color]
361
+
362
+ # Both bgColor and fgColor happens to configure the background of the cell.
363
+ # One of them sets the "background" of the cell, while the other one is
364
+ # responsibe for the "pattern" of the cell. When you pick "solid" pattern for
365
+ # a normal xf style, then it's a rectangle covering all bgColor with fgColor,
366
+ # which means we need to to set the given background color to fgColor as well.
367
+ # For some reason I wasn't able find, it works the opposite for dxf styles
368
+ # (differential formatting records), so to get the expected color, we need
369
+ # to put it into bgColor. We only need these cross-assignments when using
370
+ # "solid" pattern and the user provided only one color to get the least
371
+ # amount of surprise
372
+
373
+ if bg_color
374
+ pattern_options[:bgColor] = Color.new(rgb: bg_color)
375
+ elsif pattern_type == :solid && fg_color
376
+ pattern_options[:bgColor] = Color.new(rgb: fg_color)
377
+ end
378
+
379
+ if fg_color
380
+ pattern_options[:fgColor] = Color.new(rgb: fg_color)
381
+ elsif pattern_type == :solid && bg_color
382
+ pattern_options[:fgColor] = Color.new(rgb: bg_color)
383
+ end
384
+
385
+ pattern = PatternFill.new(pattern_options)
349
386
  fill = Fill.new(pattern)
350
387
  dxf ? fill : fills << fill
351
388
  end
@@ -364,7 +401,7 @@ module Axlsx
364
401
  # { :border => { :style => :thick, :color => "FFFF0000", :edges => [:top, :bottom] }
365
402
  # @return [Border|Integer]
366
403
  def parse_border_options(options = {})
367
- if options[:border].nil? && Border::EDGES.all? { |x| options["border_#{x}".to_sym].nil? }
404
+ if options[:border].nil? && Border::EDGES.all? { |x| options[:"border_#{x}"].nil? }
368
405
  return nil
369
406
  end
370
407
 
@@ -409,7 +446,7 @@ module Axlsx
409
446
  end
410
447
 
411
448
  Border::EDGES.each do |edge|
412
- val = options["border_#{edge}".to_sym]
449
+ val = options[:"border_#{edge}"]
413
450
 
414
451
  if val
415
452
  borders_array << val.merge(edges: [edge])
@@ -430,8 +467,8 @@ module Axlsx
430
467
  end
431
468
  end
432
469
 
433
- if options["border_#{edge}".to_sym]
434
- edge_b_opts = edge_b_opts.merge(options["border_#{edge}".to_sym])
470
+ if options[:"border_#{edge}"]
471
+ edge_b_opts = edge_b_opts.merge(options[:"border_#{edge}"])
435
472
  skip_edge = false
436
473
  end
437
474
 
@@ -472,7 +509,12 @@ module Axlsx
472
509
  # If this is a standard xf we pull from numFmts the highest current and increment for num_fmt
473
510
  options[:num_fmt] ||= (@numFmts.map(&:numFmtId).max + 1) if options[:type] != :dxf
474
511
  numFmt = NumFmt.new(numFmtId: options[:num_fmt] || 0, formatCode: options[:format_code].to_s)
475
- options[:type] == :dxf ? numFmt : (numFmts << numFmt; numFmt.numFmtId)
512
+ if options[:type] == :dxf
513
+ numFmt
514
+ else
515
+ numFmts << numFmt
516
+ numFmt.numFmtId
517
+ end
476
518
  else
477
519
  options[:num_fmt]
478
520
  end
@@ -534,8 +576,10 @@ module Axlsx
534
576
  @cellXfs << Xf.new(borderId: 0, xfId: 0, numFmtId: 14, fontId: 0, fillId: 0, applyNumberFormat: 1)
535
577
  @cellXfs.lock
536
578
 
537
- @dxfs = SimpleTypedList.new(Dxf, "dxfs"); @dxfs.lock
538
- @tableStyles = TableStyles.new(defaultTableStyle: "TableStyleMedium9", defaultPivotStyle: "PivotStyleLight16"); @tableStyles.lock
579
+ @dxfs = SimpleTypedList.new(Dxf, "dxfs")
580
+ @dxfs.lock
581
+ @tableStyles = TableStyles.new(defaultTableStyle: "TableStyleMedium9", defaultPivotStyle: "PivotStyleLight16")
582
+ @tableStyles.lock
539
583
  end
540
584
  end
541
585
  end
@@ -15,7 +15,7 @@ module Axlsx
15
15
  def initialize(name, options = {})
16
16
  self.name = name
17
17
  parse_options options
18
- super TableStyleElement
18
+ super(TableStyleElement)
19
19
  end
20
20
 
21
21
  serializable_attributes :name, :pivot, :table
@@ -33,11 +33,22 @@ module Axlsx
33
33
  attr_reader :table
34
34
 
35
35
  # @see name
36
- def name=(v) Axlsx.validate_string v; @name = v end
36
+ def name=(v)
37
+ Axlsx.validate_string v
38
+ @name = v
39
+ end
40
+
37
41
  # @see pivot
38
- def pivot=(v) Axlsx.validate_boolean v; @pivot = v end
42
+ def pivot=(v)
43
+ Axlsx.validate_boolean v
44
+ @pivot = v
45
+ end
46
+
39
47
  # @see table
40
- def table=(v) Axlsx.validate_boolean v; @table = v end
48
+ def table=(v)
49
+ Axlsx.validate_boolean v
50
+ @table = v
51
+ end
41
52
 
42
53
  # Serializes the object
43
54
  # @param [String] str
@@ -58,13 +58,22 @@ module Axlsx
58
58
  attr_reader :dxfId
59
59
 
60
60
  # @see type
61
- def type=(v) Axlsx.validate_table_element_type v; @type = v end
61
+ def type=(v)
62
+ Axlsx.validate_table_element_type v
63
+ @type = v
64
+ end
62
65
 
63
66
  # @see size
64
- def size=(v) Axlsx.validate_unsigned_int v; @size = v end
67
+ def size=(v)
68
+ Axlsx.validate_unsigned_int v
69
+ @size = v
70
+ end
65
71
 
66
72
  # @see dxfId
67
- def dxfId=(v) Axlsx.validate_unsigned_int v; @dxfId = v end
73
+ def dxfId=(v)
74
+ Axlsx.validate_unsigned_int v
75
+ @dxfId = v
76
+ end
68
77
 
69
78
  # Serializes the object
70
79
  # @param [String] str
@@ -12,7 +12,7 @@ module Axlsx
12
12
  def initialize(options = {})
13
13
  @defaultTableStyle = options[:defaultTableStyle] || "TableStyleMedium9"
14
14
  @defaultPivotStyle = options[:defaultPivotStyle] || "PivotStyleLight16"
15
- super TableStyle
15
+ super(TableStyle)
16
16
  end
17
17
 
18
18
  serializable_attributes :defaultTableStyle, :defaultPivotStyle
@@ -26,9 +26,16 @@ module Axlsx
26
26
  attr_reader :defaultPivotStyle
27
27
 
28
28
  # @see defaultTableStyle
29
- def defaultTableStyle=(v) Axlsx.validate_string(v); @defaultTableStyle = v; end
29
+ def defaultTableStyle=(v)
30
+ Axlsx.validate_string(v)
31
+ @defaultTableStyle = v
32
+ end
33
+
30
34
  # @see defaultPivotStyle
31
- def defaultPivotStyle=(v) Axlsx.validate_string(v); @defaultPivotStyle = v; end
35
+ def defaultPivotStyle=(v)
36
+ Axlsx.validate_string(v)
37
+ @defaultPivotStyle = v
38
+ end
32
39
 
33
40
  # Serializes the object
34
41
  # @param [String] str
@@ -95,41 +95,94 @@ module Axlsx
95
95
  attr_reader :applyProtection
96
96
 
97
97
  # @see Xf#alignment
98
- def alignment=(v) DataTypeValidator.validate "Xf.alignment", CellAlignment, v; @alignment = v end
98
+ def alignment=(v)
99
+ DataTypeValidator.validate "Xf.alignment", CellAlignment, v
100
+ @alignment = v
101
+ end
99
102
 
100
103
  # @see protection
101
- def protection=(v) DataTypeValidator.validate "Xf.protection", CellProtection, v; @protection = v end
104
+ def protection=(v)
105
+ DataTypeValidator.validate "Xf.protection", CellProtection, v
106
+ @protection = v
107
+ end
102
108
 
103
109
  # @see numFmtId
104
- def numFmtId=(v) Axlsx.validate_unsigned_int v; @numFmtId = v end
110
+ def numFmtId=(v)
111
+ Axlsx.validate_unsigned_int v
112
+ @numFmtId = v
113
+ end
105
114
 
106
115
  # @see fontId
107
- def fontId=(v) Axlsx.validate_unsigned_int v; @fontId = v end
116
+ def fontId=(v)
117
+ Axlsx.validate_unsigned_int v
118
+ @fontId = v
119
+ end
120
+
108
121
  # @see fillId
109
- def fillId=(v) Axlsx.validate_unsigned_int v; @fillId = v end
122
+ def fillId=(v)
123
+ Axlsx.validate_unsigned_int v
124
+ @fillId = v
125
+ end
126
+
110
127
  # @see borderId
111
- def borderId=(v) Axlsx.validate_unsigned_int v; @borderId = v end
128
+ def borderId=(v)
129
+ Axlsx.validate_unsigned_int v
130
+ @borderId = v
131
+ end
132
+
112
133
  # @see xfId
113
- def xfId=(v) Axlsx.validate_unsigned_int v; @xfId = v end
134
+ def xfId=(v)
135
+ Axlsx.validate_unsigned_int v
136
+ @xfId = v
137
+ end
138
+
114
139
  # @see quotePrefix
115
- def quotePrefix=(v) Axlsx.validate_boolean v; @quotePrefix = v end
140
+ def quotePrefix=(v)
141
+ Axlsx.validate_boolean v
142
+ @quotePrefix = v
143
+ end
144
+
116
145
  # @see pivotButton
117
- def pivotButton=(v) Axlsx.validate_boolean v; @pivotButton = v end
146
+ def pivotButton=(v)
147
+ Axlsx.validate_boolean v
148
+ @pivotButton = v
149
+ end
150
+
118
151
  # @see applyNumberFormat
119
- def applyNumberFormat=(v) Axlsx.validate_boolean v; @applyNumberFormat = v end
152
+ def applyNumberFormat=(v)
153
+ Axlsx.validate_boolean v
154
+ @applyNumberFormat = v
155
+ end
156
+
120
157
  # @see applyFont
121
- def applyFont=(v) Axlsx.validate_boolean v; @applyFont = v end
158
+ def applyFont=(v)
159
+ Axlsx.validate_boolean v
160
+ @applyFont = v
161
+ end
162
+
122
163
  # @see applyFill
123
- def applyFill=(v) Axlsx.validate_boolean v; @applyFill = v end
164
+ def applyFill=(v)
165
+ Axlsx.validate_boolean v
166
+ @applyFill = v
167
+ end
124
168
 
125
169
  # @see applyBorder
126
- def applyBorder=(v) Axlsx.validate_boolean v; @applyBorder = v end
170
+ def applyBorder=(v)
171
+ Axlsx.validate_boolean v
172
+ @applyBorder = v
173
+ end
127
174
 
128
175
  # @see applyAlignment
129
- def applyAlignment=(v) Axlsx.validate_boolean v; @applyAlignment = v end
176
+ def applyAlignment=(v)
177
+ Axlsx.validate_boolean v
178
+ @applyAlignment = v
179
+ end
130
180
 
131
181
  # @see applyProtection
132
- def applyProtection=(v) Axlsx.validate_boolean v; @applyProtection = v end
182
+ def applyProtection=(v)
183
+ Axlsx.validate_boolean v
184
+ @applyProtection = v
185
+ end
133
186
 
134
187
  # Serializes the object
135
188
  # @param [String] str
@@ -44,19 +44,21 @@ module Axlsx
44
44
  validated_attr_accessor(symbols, :validate_boolean)
45
45
  end
46
46
 
47
- # Template for defining validated write accessors
48
- SETTER = "def %s=(value) Axlsx::%s(value); @%s = value; end"
49
-
50
47
  # Creates the reader and writer access methods
51
- # @param [Array] symbols The names of the attributes to create
52
- # @param [String] validator The axlsx validation method to use when
48
+ # @param [Array<Symbol, String>] symbols The names of the attributes to create
49
+ # @param [Symbol|String] validator The axlsx validation method to use when
53
50
  # validating assignation.
54
51
  # @see lib/axlsx/util/validators.rb
55
52
  def validated_attr_accessor(symbols, validator)
56
53
  symbols.each do |symbol|
57
54
  attr_reader symbol
58
55
 
59
- module_eval(format(SETTER, symbol, validator, symbol), __FILE__, __LINE__)
56
+ module_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
57
+ def #{symbol}=(value) # def name=(value)
58
+ Axlsx.#{validator} value # Axlsx.validate_string value
59
+ @#{symbol} = value # @name = value
60
+ end # end
61
+ RUBY_EVAL
60
62
  end
61
63
  end
62
64
  end
@@ -133,7 +133,7 @@ module Axlsx
133
133
  @left = @right = @child = -1
134
134
  @sector = @size = @created = @modified = 0
135
135
  options.each do |o|
136
- send("#{o[0]}=", o[1]) if respond_to? "#{o[0]}="
136
+ send(:"#{o[0]}=", o[1]) if respond_to? :"#{o[0]}="
137
137
  end
138
138
  @color ||= COLORS[:black]
139
139
  @type ||= (data.nil? ? TYPES[:storage] : TYPES[:stream])
data/lib/axlsx/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Axlsx
4
4
  # The current version
5
- VERSION = "4.0.0"
5
+ VERSION = "4.1.0"
6
6
  end
@@ -5,7 +5,7 @@ module Axlsx
5
5
  class DefinedNames < SimpleTypedList
6
6
  # creates the DefinedNames object
7
7
  def initialize
8
- super DefinedName
8
+ super(DefinedName)
9
9
  end
10
10
 
11
11
  # Serialize to xml
@@ -249,18 +249,28 @@ module Axlsx
249
249
 
250
250
  # Instance level access to the class variable 1904
251
251
  # @return [Boolean]
252
- def date1904() @@date1904; end
252
+ def date1904
253
+ @@date1904
254
+ end
253
255
 
254
256
  # see @date1904
255
- def date1904=(v) Axlsx.validate_boolean v; @@date1904 = v; end
257
+ def date1904=(v)
258
+ Axlsx.validate_boolean v
259
+ @@date1904 = v
260
+ end
256
261
 
257
262
  # Sets the date1904 attribute to the provided boolean
258
263
  # @return [Boolean]
259
- def self.date1904=(v) Axlsx.validate_boolean v; @@date1904 = v; end
264
+ def self.date1904=(v)
265
+ Axlsx.validate_boolean v
266
+ @@date1904 = v
267
+ end
260
268
 
261
269
  # retrieves the date1904 attribute
262
270
  # @return [Boolean]
263
- def self.date1904() @@date1904; end
271
+ def self.date1904
272
+ @@date1904
273
+ end
264
274
 
265
275
  # Whether to treat values starting with an equals sign as formulas or as literal strings.
266
276
  # Allowing user-generated data to be interpreted as formulas is a security risk.
@@ -280,10 +290,13 @@ module Axlsx
280
290
  # calculation. Thus the performance benefits of turning this off are
281
291
  # marginal unless you are creating a very large sheet.
282
292
  # @return [Boolean]
283
- def use_autowidth() @use_autowidth; end
293
+ attr_reader :use_autowidth
284
294
 
285
295
  # see @use_autowidth
286
- def use_autowidth=(v = true) Axlsx.validate_boolean v; @use_autowidth = v; end
296
+ def use_autowidth=(v = true)
297
+ Axlsx.validate_boolean v
298
+ @use_autowidth = v
299
+ end
287
300
 
288
301
  # Font size of bold fonts is multiplied with this
289
302
  # Used for automatic calculation of cell widths with bold text
@@ -5,7 +5,7 @@ module Axlsx
5
5
  class WorkbookViews < SimpleTypedList
6
6
  # creates the book views object
7
7
  def initialize
8
- super WorkbookView
8
+ super(WorkbookView)
9
9
  end
10
10
 
11
11
  # Serialize to xml
@@ -43,7 +43,9 @@ module Axlsx
43
43
  # the filter button can be hidden, and not drawn.
44
44
  # @return [Boolean]
45
45
  def show_button
46
- @show_button ||= true
46
+ return @show_button if defined?(@show_button)
47
+
48
+ true
47
49
  end
48
50
 
49
51
  # Flag indicating whether the AutoFilter button for this column is hidden.
@@ -83,7 +85,7 @@ module Axlsx
83
85
  # @return [Boolean]
84
86
  def show_button=(show)
85
87
  Axlsx.validate_boolean show
86
- @show_botton = show
88
+ @show_button = show
87
89
  end
88
90
 
89
91
  # Serialize the object to xml
@@ -189,7 +189,9 @@ module Axlsx
189
189
  attr_reader :font_name
190
190
 
191
191
  # @see font_name
192
- def font_name=(v) set_run_style :validate_string, :font_name, v; end
192
+ def font_name=(v)
193
+ set_run_style :validate_string, :font_name, v
194
+ end
193
195
 
194
196
  # The inline charset property for the cell
195
197
  # As far as I can tell, this is pretty much ignored. However, based on the spec it should be one of the following:
@@ -216,7 +218,9 @@ module Axlsx
216
218
  attr_reader :charset
217
219
 
218
220
  # @see charset
219
- def charset=(v) set_run_style :validate_unsigned_int, :charset, v; end
221
+ def charset=(v)
222
+ set_run_style :validate_unsigned_int, :charset, v
223
+ end
220
224
 
221
225
  # The inline family property for the cell
222
226
  # @return [Integer]
@@ -237,49 +241,63 @@ module Axlsx
237
241
  attr_reader :b
238
242
 
239
243
  # @see b
240
- def b=(v) set_run_style :validate_boolean, :b, v; end
244
+ def b=(v)
245
+ set_run_style :validate_boolean, :b, v
246
+ end
241
247
 
242
248
  # The inline italic property for the cell
243
249
  # @return [Boolean]
244
250
  attr_reader :i
245
251
 
246
252
  # @see i
247
- def i=(v) set_run_style :validate_boolean, :i, v; end
253
+ def i=(v)
254
+ set_run_style :validate_boolean, :i, v
255
+ end
248
256
 
249
257
  # The inline strike property for the cell
250
258
  # @return [Boolean]
251
259
  attr_reader :strike
252
260
 
253
261
  # @see strike
254
- def strike=(v) set_run_style :validate_boolean, :strike, v; end
262
+ def strike=(v)
263
+ set_run_style :validate_boolean, :strike, v
264
+ end
255
265
 
256
266
  # The inline outline property for the cell
257
267
  # @return [Boolean]
258
268
  attr_reader :outline
259
269
 
260
270
  # @see outline
261
- def outline=(v) set_run_style :validate_boolean, :outline, v; end
271
+ def outline=(v)
272
+ set_run_style :validate_boolean, :outline, v
273
+ end
262
274
 
263
275
  # The inline shadow property for the cell
264
276
  # @return [Boolean]
265
277
  attr_reader :shadow
266
278
 
267
279
  # @see shadow
268
- def shadow=(v) set_run_style :validate_boolean, :shadow, v; end
280
+ def shadow=(v)
281
+ set_run_style :validate_boolean, :shadow, v
282
+ end
269
283
 
270
284
  # The inline condense property for the cell
271
285
  # @return [Boolean]
272
286
  attr_reader :condense
273
287
 
274
288
  # @see condense
275
- def condense=(v) set_run_style :validate_boolean, :condense, v; end
289
+ def condense=(v)
290
+ set_run_style :validate_boolean, :condense, v
291
+ end
276
292
 
277
293
  # The inline extend property for the cell
278
294
  # @return [Boolean]
279
295
  attr_reader :extend
280
296
 
281
297
  # @see extend
282
- def extend=(v) set_run_style :validate_boolean, :extend, v; end
298
+ def extend=(v)
299
+ set_run_style :validate_boolean, :extend, v
300
+ end
283
301
 
284
302
  # The inline underline property for the cell.
285
303
  # It must be one of :none, :single, :double, :singleAccounting, :doubleAccounting
@@ -307,7 +325,9 @@ module Axlsx
307
325
  attr_reader :sz
308
326
 
309
327
  # @see sz
310
- def sz=(v) set_run_style :validate_unsigned_int, :sz, v; end
328
+ def sz=(v)
329
+ set_run_style :validate_unsigned_int, :sz, v
330
+ end
311
331
 
312
332
  # The inline vertical alignment property for the cell
313
333
  # this must be one of [:baseline, :subscript, :superscript]
@@ -40,10 +40,16 @@ module Axlsx
40
40
  attr_reader :val
41
41
 
42
42
  # @see type
43
- def type=(v); Axlsx.validate_conditional_formatting_value_object_type(v); @type = v end
43
+ def type=(v)
44
+ Axlsx.validate_conditional_formatting_value_object_type(v)
45
+ @type = v
46
+ end
44
47
 
45
48
  # @see gte
46
- def gte=(v); Axlsx.validate_boolean(v); @gte = v end
49
+ def gte=(v)
50
+ Axlsx.validate_boolean(v)
51
+ @gte = v
52
+ end
47
53
 
48
54
  # @see val
49
55
  def val=(v)
@@ -7,7 +7,7 @@ module Axlsx
7
7
  class ColBreaks < SimpleTypedList
8
8
  # Instantiates a new list restricted to Break types
9
9
  def initialize
10
- super Break
10
+ super(Break)
11
11
  end
12
12
 
13
13
  # A column break specific helper for adding a break.
@@ -7,7 +7,7 @@ module Axlsx
7
7
  def initialize(worksheet)
8
8
  raise ArgumentError, "you must provide a worksheet" unless worksheet.is_a?(Worksheet)
9
9
 
10
- super Col
10
+ super(Col)
11
11
  @worksheet = worksheet
12
12
  end
13
13
 
@@ -61,9 +61,15 @@ module Axlsx
61
61
  end
62
62
 
63
63
  # @see rules
64
- def rules=(v); @rules = v end
64
+ def rules=(v)
65
+ @rules = v
66
+ end
67
+
65
68
  # @see sqref
66
- def sqref=(v); Axlsx.validate_string(v); @sqref = v end
69
+ def sqref=(v)
70
+ Axlsx.validate_string(v)
71
+ @sqref = v
72
+ end
67
73
 
68
74
  # Serializes the conditional formatting element
69
75
  # @example Conditional Formatting XML looks like: