caxlsx 4.0.0 → 4.2.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 (122) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -12
  3. data/README.md +1 -1
  4. data/examples/generate.rb +3 -1
  5. data/lib/axlsx/content_type/abstract_content_type.rb +6 -3
  6. data/lib/axlsx/content_type/content_type.rb +4 -4
  7. data/lib/axlsx/content_type/default.rb +4 -1
  8. data/lib/axlsx/content_type/override.rb +4 -1
  9. data/lib/axlsx/doc_props/app.rb +91 -24
  10. data/lib/axlsx/drawing/area_chart.rb +3 -3
  11. data/lib/axlsx/drawing/area_series.rb +10 -4
  12. data/lib/axlsx/drawing/ax_data_source.rb +1 -1
  13. data/lib/axlsx/drawing/axes.rb +1 -1
  14. data/lib/axlsx/drawing/axis.rb +25 -7
  15. data/lib/axlsx/drawing/bar_3D_chart.rb +3 -3
  16. data/lib/axlsx/drawing/bar_chart.rb +3 -3
  17. data/lib/axlsx/drawing/bar_series.rb +14 -5
  18. data/lib/axlsx/drawing/bubble_chart.rb +2 -2
  19. data/lib/axlsx/drawing/bubble_series.rb +2 -2
  20. data/lib/axlsx/drawing/cat_axis.rb +23 -8
  21. data/lib/axlsx/drawing/chart.rb +32 -8
  22. data/lib/axlsx/drawing/d_lbls.rb +8 -8
  23. data/lib/axlsx/drawing/drawing.rb +50 -49
  24. data/lib/axlsx/drawing/hyperlink.rb +13 -4
  25. data/lib/axlsx/drawing/line_3D_chart.rb +3 -3
  26. data/lib/axlsx/drawing/line_chart.rb +3 -3
  27. data/lib/axlsx/drawing/line_series.rb +10 -4
  28. data/lib/axlsx/drawing/marker.rb +19 -4
  29. data/lib/axlsx/drawing/num_val.rb +1 -1
  30. data/lib/axlsx/drawing/one_cell_anchor.rb +8 -2
  31. data/lib/axlsx/drawing/pic.rb +17 -8
  32. data/lib/axlsx/drawing/pie_3D_chart.rb +3 -3
  33. data/lib/axlsx/drawing/pie_chart.rb +36 -0
  34. data/lib/axlsx/drawing/pie_series.rb +18 -6
  35. data/lib/axlsx/drawing/scaling.rb +18 -4
  36. data/lib/axlsx/drawing/scatter_chart.rb +2 -2
  37. data/lib/axlsx/drawing/scatter_series.rb +2 -2
  38. data/lib/axlsx/drawing/ser_axis.rb +11 -5
  39. data/lib/axlsx/drawing/series.rb +8 -2
  40. data/lib/axlsx/drawing/two_cell_anchor.rb +1 -1
  41. data/lib/axlsx/drawing/val_axis.rb +2 -2
  42. data/lib/axlsx/drawing/view_3D.rb +8 -2
  43. data/lib/axlsx/package.rb +11 -11
  44. data/lib/axlsx/rels/relationship.rb +15 -5
  45. data/lib/axlsx/rels/relationships.rb +3 -3
  46. data/lib/axlsx/stylesheet/border.rb +12 -3
  47. data/lib/axlsx/stylesheet/border_pr.rb +15 -4
  48. data/lib/axlsx/stylesheet/cell_alignment.rb +39 -10
  49. data/lib/axlsx/stylesheet/cell_protection.rb +9 -2
  50. data/lib/axlsx/stylesheet/cell_style.rb +30 -7
  51. data/lib/axlsx/stylesheet/color.rb +10 -4
  52. data/lib/axlsx/stylesheet/dxf.rb +29 -6
  53. data/lib/axlsx/stylesheet/fill.rb +4 -1
  54. data/lib/axlsx/stylesheet/font.rb +59 -13
  55. data/lib/axlsx/stylesheet/gradient_fill.rb +9 -3
  56. data/lib/axlsx/stylesheet/gradient_stop.rb +9 -2
  57. data/lib/axlsx/stylesheet/num_fmt.rb +8 -2
  58. data/lib/axlsx/stylesheet/pattern_fill.rb +14 -3
  59. data/lib/axlsx/stylesheet/styles.rb +83 -43
  60. data/lib/axlsx/stylesheet/table_style.rb +15 -4
  61. data/lib/axlsx/stylesheet/table_style_element.rb +12 -3
  62. data/lib/axlsx/stylesheet/table_styles.rb +10 -3
  63. data/lib/axlsx/stylesheet/xf.rb +69 -16
  64. data/lib/axlsx/util/accessors.rb +9 -7
  65. data/lib/axlsx/util/constants.rb +2 -2
  66. data/lib/axlsx/util/serialized_attributes.rb +2 -2
  67. data/lib/axlsx/util/simple_typed_list.rb +25 -12
  68. data/lib/axlsx/util/storage.rb +4 -4
  69. data/lib/axlsx/util/validators.rb +1 -1
  70. data/lib/axlsx/version.rb +1 -1
  71. data/lib/axlsx/workbook/defined_name.rb +1 -1
  72. data/lib/axlsx/workbook/defined_names.rb +1 -1
  73. data/lib/axlsx/workbook/shared_strings_table.rb +3 -3
  74. data/lib/axlsx/workbook/workbook.rb +80 -67
  75. data/lib/axlsx/workbook/workbook_views.rb +1 -1
  76. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +4 -4
  77. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +5 -3
  78. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +3 -3
  79. data/lib/axlsx/workbook/worksheet/auto_filter/sort_condition.rb +1 -1
  80. data/lib/axlsx/workbook/worksheet/auto_filter/sort_state.rb +2 -2
  81. data/lib/axlsx/workbook/worksheet/border_creator.rb +4 -4
  82. data/lib/axlsx/workbook/worksheet/cell.rb +37 -17
  83. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +1 -1
  84. data/lib/axlsx/workbook/worksheet/cfvo.rb +8 -2
  85. data/lib/axlsx/workbook/worksheet/col.rb +22 -9
  86. data/lib/axlsx/workbook/worksheet/col_breaks.rb +1 -1
  87. data/lib/axlsx/workbook/worksheet/cols.rb +1 -1
  88. data/lib/axlsx/workbook/worksheet/comment.rb +2 -2
  89. data/lib/axlsx/workbook/worksheet/comments.rb +1 -1
  90. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +9 -3
  91. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +70 -15
  92. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +3 -3
  93. data/lib/axlsx/workbook/worksheet/data_validation.rb +53 -14
  94. data/lib/axlsx/workbook/worksheet/data_validations.rb +3 -3
  95. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +2 -2
  96. data/lib/axlsx/workbook/worksheet/dimension.rb +1 -1
  97. data/lib/axlsx/workbook/worksheet/icon_set.rb +17 -5
  98. data/lib/axlsx/workbook/worksheet/merged_cells.rb +1 -1
  99. data/lib/axlsx/workbook/worksheet/outline_pr.rb +1 -1
  100. data/lib/axlsx/workbook/worksheet/page_margins.rb +30 -7
  101. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -2
  102. data/lib/axlsx/workbook/worksheet/page_setup.rb +32 -9
  103. data/lib/axlsx/workbook/worksheet/pane.rb +8 -2
  104. data/lib/axlsx/workbook/worksheet/pivot_table.rb +29 -5
  105. data/lib/axlsx/workbook/worksheet/pivot_tables.rb +1 -1
  106. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +1 -1
  107. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +31 -11
  108. data/lib/axlsx/workbook/worksheet/row.rb +5 -2
  109. data/lib/axlsx/workbook/worksheet/row_breaks.rb +1 -1
  110. data/lib/axlsx/workbook/worksheet/selection.rb +8 -2
  111. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +1 -1
  112. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -1
  113. data/lib/axlsx/workbook/worksheet/sheet_view.rb +30 -9
  114. data/lib/axlsx/workbook/worksheet/table_style_info.rb +2 -2
  115. data/lib/axlsx/workbook/worksheet/tables.rb +1 -1
  116. data/lib/axlsx/workbook/worksheet/worksheet.rb +28 -14
  117. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +3 -3
  118. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +2 -2
  119. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +2 -2
  120. data/lib/axlsx.rb +44 -30
  121. data/lib/caxlsx.rb +1 -1
  122. metadata +10 -48
@@ -62,7 +62,7 @@ module Axlsx
62
62
  # @return [Integer]
63
63
  attr_reader :xfId
64
64
 
65
- # indecates if text should be prefixed by a single quote in the cell
65
+ # indicates if text should be prefixed by a single quote in the cell
66
66
  # @return [Boolean]
67
67
  attr_reader :quotePrefix
68
68
 
@@ -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
@@ -23,7 +23,7 @@ module Axlsx
23
23
  validated_attr_accessor(symbols, :validate_string)
24
24
  end
25
25
 
26
- # Creates one or more usigned integer attr_accessors
26
+ # Creates one or more unsigned integer attr_accessors
27
27
  # @param [Array] symbols An array of symbols representing the
28
28
  # names of the attributes you will add to your class
29
29
  def unsigned_int_attr_accessor(*symbols)
@@ -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
@@ -259,7 +259,7 @@ module Axlsx
259
259
  # drawing validation schema
260
260
  DRAWING_XSD = "#{SCHEMA_BASE}dml-spreadsheetDrawing.xsd"
261
261
 
262
- # number format id for pecentage formatting using the default formatting id.
262
+ # number format id for percentage formatting using the default formatting id.
263
263
  NUM_FMT_PERCENT = 9
264
264
 
265
265
  # number format id for date format like 2011/11/13
@@ -404,7 +404,7 @@ module Axlsx
404
404
  CONTROL_CHARS = pattern.freeze
405
405
 
406
406
  # ISO 8601 date recognition
407
- ISO_8601_REGEX = /\A(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?\Z/.freeze
407
+ ISO_8601_REGEX = /\A(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?\Z/.freeze
408
408
 
409
409
  # FLOAT recognition
410
410
  SAFE_FLOAT_REGEX = /\A[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]{1,2})?\Z/.freeze
@@ -91,8 +91,8 @@ module Axlsx
91
91
 
92
92
  # serialized instance values at text nodes on a camelized element of the
93
93
  # attribute name. You may pass in a block for evaluation against non nil
94
- # values. We use an array for element attributes becuase misordering will
95
- # break the xml and 1.8.7 does not support ordered hashes.
94
+ # values. We use an array for element attributes because misordering will
95
+ # break the xml.
96
96
  # @param [String] str The string instance to which serialized data is appended
97
97
  # @param [Array] additional_attributes An array of additional attribute names.
98
98
  # @return [String] The serialized output.
@@ -21,7 +21,7 @@ module Axlsx
21
21
  alias :== :equal?
22
22
  alias :eql? :equal?
23
23
 
24
- # Creats a new typed list
24
+ # Creates a new typed list
25
25
  # @param [Array, Class] type An array of Class objects or a single Class object
26
26
  # @param [String] serialize_as The tag name to use in serialization
27
27
  # @raise [ArgumentError] if all members of type are not Class objects
@@ -57,7 +57,7 @@ module Axlsx
57
57
  # Transposes the list (without blowing up like ruby does)
58
58
  # any non populated cell in the matrix will be a nil value
59
59
  def transpose
60
- return clone if size.zero?
60
+ return clone if size == 0
61
61
 
62
62
  row_count = size
63
63
  max_column_count = map { |row| row.cells.size }.max
@@ -90,21 +90,24 @@ module Axlsx
90
90
  self
91
91
  end
92
92
 
93
- # join operator
94
- # @param [Array] other the array to join
93
+ # Appends the elements of +others+ to self.
94
+ # @param [Array<Array>] others one or more arrays to join
95
95
  # @raise [ArgumentError] if any of the values being joined are not
96
96
  # one of the allowed types
97
97
  # @return [SimpleTypedList]
98
- def +(other)
99
- other.each do |item|
100
- self << item
98
+ def concat(*others)
99
+ others.each do |other|
100
+ other.each do |item|
101
+ self << item
102
+ end
101
103
  end
102
- super
104
+ self
103
105
  end
104
106
 
105
- # Concat operator
107
+ # Pushes the given object on to the end of this array and returns the index
108
+ # of the item added.
106
109
  # @param [Any] v the data to be added
107
- # @raise [ArgumentError] if the value being added is not one fo the allowed types
110
+ # @raise [ArgumentError] if the value being added is not one of the allowed types
108
111
  # @return [Integer] returns the index of the item added.
109
112
  def <<(v)
110
113
  DataTypeValidator.validate :SimpleTypedList_push, @allowed_types, v
@@ -112,7 +115,17 @@ module Axlsx
112
115
  size - 1
113
116
  end
114
117
 
115
- alias :push :<<
118
+ # Pushes the given object(s) on to the end of this array. This expression
119
+ # returns the array itself, so several appends may be chained together.
120
+ # @param [Any] values the data to be added
121
+ # @raise [ArgumentError] if any of the values being joined are not
122
+ # @return [SimpleTypedList]
123
+ def push(*values)
124
+ values.each do |value|
125
+ self << value
126
+ end
127
+ self
128
+ end
116
129
 
117
130
  # delete the item from the list
118
131
  # @param [Any] v The item to be deleted.
@@ -147,7 +160,7 @@ module Axlsx
147
160
  super
148
161
  end
149
162
 
150
- # inserts an item at the index specfied
163
+ # inserts an item at the index specified
151
164
  # @param [Integer] index
152
165
  # @param [Any] v
153
166
  # @raise [ArgumentError] if the index is protected by locking
@@ -85,16 +85,16 @@ module Axlsx
85
85
  # @return [Integer] sector
86
86
  attr_accessor :sector
87
87
 
88
- # The 0 based index in the directoies chain for this the left sibling of this storage.
88
+ # The 0 based index in the directories chain for this the left sibling of this storage.
89
89
 
90
90
  # @return [Integer] left
91
91
  attr_accessor :left
92
92
 
93
- # The 0 based index in the directoies chain for this the right sibling of this storage.
93
+ # The 0 based index in the directories chain for this the right sibling of this storage.
94
94
  # @return [Integer] right
95
95
  attr_accessor :right
96
96
 
97
- # The 0 based index in the directoies chain for the child of this storage.
97
+ # The 0 based index in the directories chain for the child of this storage.
98
98
  # @return [Integer] child
99
99
  attr_accessor :child
100
100
 
@@ -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])
@@ -81,7 +81,7 @@ module Axlsx
81
81
  raise ArgumentError, format(ERR_ANGLE, v.inspect) unless v.to_i >= -5400000 && v.to_i <= 5400000
82
82
  end
83
83
 
84
- # Validates an unsigned intger
84
+ # Validates an unsigned integer
85
85
  UINT_VALIDATOR = ->(arg) { arg.respond_to?(:>=) && arg >= 0 }
86
86
 
87
87
  # Requires that the value is a Integer and is greater or equal to 0
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.2.0"
6
6
  end
@@ -22,7 +22,7 @@
22
22
  # <xsd:attribute name="shortcutKey" type="s:ST_Xstring" use="optional"/>
23
23
  # <xsd:attribute name="publishToServer" type="xsd:boolean" use="optional" default="false"/>
24
24
  # <xsd:attribute name="workbookParameter" type="xsd:boolean" use="optional" default="false"/>
25
- # </xsd:extenstion>
25
+ # </xsd:extension>
26
26
  # </xsd:simpleContent>
27
27
 
28
28
  module Axlsx
@@ -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
@@ -7,7 +7,7 @@ module Axlsx
7
7
  # As a developer, you should never need to directly work against this class. Simply set 'use_shared_strings'
8
8
  # on the package or workbook to generate a package that uses the shared strings table instead of inline strings.
9
9
  # @note Serialization performance is affected by using this serialization method so if you do not need interoperability
10
- # it is recomended that you use the default inline string method of serialization.
10
+ # it is recommended that you use the default inline string method of serialization.
11
11
  class SharedStringsTable
12
12
  # The total number of strings in the workbook including duplicates
13
13
  # Empty cells are treated as blank strings
@@ -29,7 +29,7 @@ module Axlsx
29
29
  # @see Workbook#xml_space
30
30
  attr_reader :xml_space
31
31
 
32
- # Creates a new Shared Strings Table agains an array of cells
32
+ # Creates a new Shared Strings Table against an array of cells
33
33
  # @param [Array] cells This is an array of all of the cells in the workbook
34
34
  # @param [Symbol] xml_space The xml:space behavior for the shared string table.
35
35
  def initialize(cells, xml_space = :preserve)
@@ -54,7 +54,7 @@ module Axlsx
54
54
 
55
55
  private
56
56
 
57
- # Interate over all of the cells in the array.
57
+ # Iterate over all of the cells in the array.
58
58
  # if our unique cells array does not contain a sharable cell,
59
59
  # add the cell to our unique cells array and set the ssti attribute on the index of this cell in the shared strings table
60
60
  # if a sharable cell already exists in our unique_cells array, set the ssti attribute of the cell and move on.
@@ -1,67 +1,67 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Axlsx
4
- require 'axlsx/workbook/worksheet/sheet_calc_pr'
5
- require 'axlsx/workbook/worksheet/auto_filter/auto_filter'
6
- require 'axlsx/workbook/worksheet/date_time_converter'
7
- require 'axlsx/workbook/worksheet/protected_range'
8
- require 'axlsx/workbook/worksheet/protected_ranges'
9
- require 'axlsx/workbook/worksheet/rich_text_run'
10
- require 'axlsx/workbook/worksheet/rich_text'
11
- require 'axlsx/workbook/worksheet/cell_serializer'
12
- require 'axlsx/workbook/worksheet/cell'
13
- require 'axlsx/workbook/worksheet/page_margins'
14
- require 'axlsx/workbook/worksheet/page_set_up_pr'
15
- require 'axlsx/workbook/worksheet/outline_pr'
16
- require 'axlsx/workbook/worksheet/page_setup'
17
- require 'axlsx/workbook/worksheet/header_footer'
18
- require 'axlsx/workbook/worksheet/print_options'
19
- require 'axlsx/workbook/worksheet/cfvo'
20
- require 'axlsx/workbook/worksheet/cfvos'
21
- require 'axlsx/workbook/worksheet/color_scale'
22
- require 'axlsx/workbook/worksheet/data_bar'
23
- require 'axlsx/workbook/worksheet/icon_set'
24
- require 'axlsx/workbook/worksheet/conditional_formatting'
25
- require 'axlsx/workbook/worksheet/conditional_formatting_rule'
26
- require 'axlsx/workbook/worksheet/conditional_formattings'
27
- require 'axlsx/workbook/worksheet/row'
28
- require 'axlsx/workbook/worksheet/col'
29
- require 'axlsx/workbook/worksheet/cols'
30
- require 'axlsx/workbook/worksheet/comments'
31
- require 'axlsx/workbook/worksheet/comment'
32
- require 'axlsx/workbook/worksheet/merged_cells'
33
- require 'axlsx/workbook/worksheet/sheet_protection'
34
- require 'axlsx/workbook/worksheet/sheet_pr'
35
- require 'axlsx/workbook/worksheet/dimension'
36
- require 'axlsx/workbook/worksheet/sheet_data'
37
- require 'axlsx/workbook/worksheet/worksheet_drawing'
38
- require 'axlsx/workbook/worksheet/worksheet_comments'
39
- require 'axlsx/workbook/worksheet/worksheet_hyperlink'
40
- require 'axlsx/workbook/worksheet/worksheet_hyperlinks'
41
- require 'axlsx/workbook/worksheet/break'
42
- require 'axlsx/workbook/worksheet/row_breaks'
43
- require 'axlsx/workbook/worksheet/col_breaks'
44
- require 'axlsx/workbook/workbook_view'
45
- require 'axlsx/workbook/workbook_views'
46
- require 'axlsx/workbook/worksheet/worksheet'
47
- require 'axlsx/workbook/shared_strings_table'
48
- require 'axlsx/workbook/defined_name'
49
- require 'axlsx/workbook/defined_names'
50
- require 'axlsx/workbook/worksheet/table_style_info'
51
- require 'axlsx/workbook/worksheet/table'
52
- require 'axlsx/workbook/worksheet/tables'
53
- require 'axlsx/workbook/worksheet/pivot_table_cache_definition'
54
- require 'axlsx/workbook/worksheet/pivot_table'
55
- require 'axlsx/workbook/worksheet/pivot_tables'
56
- require 'axlsx/workbook/worksheet/data_validation'
57
- require 'axlsx/workbook/worksheet/data_validations'
58
- require 'axlsx/workbook/worksheet/sheet_view'
59
- require 'axlsx/workbook/worksheet/sheet_format_pr'
60
- require 'axlsx/workbook/worksheet/pane'
61
- require 'axlsx/workbook/worksheet/selection'
4
+ require_relative 'worksheet/sheet_calc_pr'
5
+ require_relative 'worksheet/auto_filter/auto_filter'
6
+ require_relative 'worksheet/date_time_converter'
7
+ require_relative 'worksheet/protected_range'
8
+ require_relative 'worksheet/protected_ranges'
9
+ require_relative 'worksheet/rich_text_run'
10
+ require_relative 'worksheet/rich_text'
11
+ require_relative 'worksheet/cell_serializer'
12
+ require_relative 'worksheet/cell'
13
+ require_relative 'worksheet/page_margins'
14
+ require_relative 'worksheet/page_set_up_pr'
15
+ require_relative 'worksheet/outline_pr'
16
+ require_relative 'worksheet/page_setup'
17
+ require_relative 'worksheet/header_footer'
18
+ require_relative 'worksheet/print_options'
19
+ require_relative 'worksheet/cfvo'
20
+ require_relative 'worksheet/cfvos'
21
+ require_relative 'worksheet/color_scale'
22
+ require_relative 'worksheet/data_bar'
23
+ require_relative 'worksheet/icon_set'
24
+ require_relative 'worksheet/conditional_formatting'
25
+ require_relative 'worksheet/conditional_formatting_rule'
26
+ require_relative 'worksheet/conditional_formattings'
27
+ require_relative 'worksheet/row'
28
+ require_relative 'worksheet/col'
29
+ require_relative 'worksheet/cols'
30
+ require_relative 'worksheet/comments'
31
+ require_relative 'worksheet/comment'
32
+ require_relative 'worksheet/merged_cells'
33
+ require_relative 'worksheet/sheet_protection'
34
+ require_relative 'worksheet/sheet_pr'
35
+ require_relative 'worksheet/dimension'
36
+ require_relative 'worksheet/sheet_data'
37
+ require_relative 'worksheet/worksheet_drawing'
38
+ require_relative 'worksheet/worksheet_comments'
39
+ require_relative 'worksheet/worksheet_hyperlink'
40
+ require_relative 'worksheet/worksheet_hyperlinks'
41
+ require_relative 'worksheet/break'
42
+ require_relative 'worksheet/row_breaks'
43
+ require_relative 'worksheet/col_breaks'
44
+ require_relative 'workbook_view'
45
+ require_relative 'workbook_views'
46
+ require_relative 'worksheet/worksheet'
47
+ require_relative 'shared_strings_table'
48
+ require_relative 'defined_name'
49
+ require_relative 'defined_names'
50
+ require_relative 'worksheet/table_style_info'
51
+ require_relative 'worksheet/table'
52
+ require_relative 'worksheet/tables'
53
+ require_relative 'worksheet/pivot_table_cache_definition'
54
+ require_relative 'worksheet/pivot_table'
55
+ require_relative 'worksheet/pivot_tables'
56
+ require_relative 'worksheet/data_validation'
57
+ require_relative 'worksheet/data_validations'
58
+ require_relative 'worksheet/sheet_view'
59
+ require_relative 'worksheet/sheet_format_pr'
60
+ require_relative 'worksheet/pane'
61
+ require_relative 'worksheet/selection'
62
62
 
63
63
  # The Workbook class is an xlsx workbook that manages worksheets, charts, drawings and styles.
64
- # The following parts of the Office Open XML spreadsheet specification are not implimented in this version.
64
+ # The following parts of the Office Open XML spreadsheet specification are not implemented in this version.
65
65
  #
66
66
  # bookViews
67
67
  # calcPr
@@ -217,7 +217,7 @@ module Axlsx
217
217
  # Indicates if the epoc date for serialization should be 1904. If false, 1900 is used.
218
218
  @@date1904 = false
219
219
 
220
- # A quick helper to retrive a worksheet by name
220
+ # A quick helper to retrieve a worksheet by name
221
221
  # @param [String] name The name of the sheet you are looking for
222
222
  # @return [Worksheet] The sheet found, or nil
223
223
  def sheet_by_name(name)
@@ -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
@@ -373,7 +386,7 @@ module Axlsx
373
386
  end
374
387
 
375
388
  # The xml:space attribute for the worksheet.
376
- # This determines how whitespace is handled withing the document.
389
+ # This determines how whitespace is handled within the document.
377
390
  # The most relevant part being whitespace in the cell text.
378
391
  # allowed values are :preserve and :default. Axlsx uses :preserve unless
379
392
  # you explicily set this to :default.
@@ -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
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'axlsx/workbook/worksheet/auto_filter/filter_column'
4
- require 'axlsx/workbook/worksheet/auto_filter/filters'
5
- require 'axlsx/workbook/worksheet/auto_filter/sort_state'
3
+ require_relative 'filter_column'
4
+ require_relative 'filters'
5
+ require_relative 'sort_state'
6
6
 
7
7
  module Axlsx
8
8
  # This class represents an auto filter range in a worksheet
@@ -80,7 +80,7 @@ module Axlsx
80
80
  condition.order == :asc ? index1 <=> index2 : index2 <=> index1
81
81
  end
82
82
 
83
- break unless comparison.zero?
83
+ break unless comparison == 0
84
84
  end
85
85
 
86
86
  comparison
@@ -10,7 +10,7 @@ module Axlsx
10
10
  include Axlsx::SerializedAttributes
11
11
 
12
12
  # Creates a new FilterColumn object
13
- # @note This class yeilds its filter object as that is where the vast majority of processing will be done
13
+ # @note This class yields its filter object as that is where the vast majority of processing will be done
14
14
  # @param [Integer|Cell] col_id The zero based index for the column to which this filter will be applied
15
15
  # @param [Symbol] filter_type The symbolized class name of the filter to apply to this column.
16
16
  # @param [Hash] options options for this object and the filter
@@ -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
@@ -13,7 +13,7 @@ module Axlsx
13
13
  # @option [Boolean] blank @see blank
14
14
  # @option [String] calendar_type @see calendar_type
15
15
  # @option [Array] filter_items An array of values that will be used to create filter objects.
16
- # @option [Array] date_group_items An array of hases defining date group item filters to apply.
16
+ # @option [Array] date_group_items An array of hashes defining date group item filters to apply.
17
17
  # @note The recommended way to interact with filter objects is via AutoFilter#add_column
18
18
  # @example
19
19
  # ws.auto_filter.add_column(0, :filters, :blank => true, :calendar_type => 'japan', :filter_items => [100, 'a'])
@@ -36,7 +36,7 @@ module Axlsx
36
36
  # even when those dates are not using the same calendar system / date formatting.
37
37
  attr_reader :calendar_type
38
38
 
39
- # Tells us if the row of the cell provided should be filterd as it
39
+ # Tells us if the row of the cell provided should be filtered as it
40
40
  # does not meet any of the specified filter_items or
41
41
  # date_group_items restrictions.
42
42
  # @param [Cell] cell The cell to test against items
@@ -138,7 +138,7 @@ module Axlsx
138
138
 
139
139
  # Creates a new DateGroupItem
140
140
  # @param [Hash] options A hash of options to use when
141
- # instanciating the object
141
+ # instantiating the object
142
142
  # @option [String] date_time_grouping the part of the date this
143
143
  # filter should apply for grouping
144
144
  # @option [Integer|String] year @see year
@@ -6,7 +6,7 @@ module Axlsx
6
6
  # Creates a new SortCondition object
7
7
  # @param [Integer] column_index Zero-based index indicating the AutoFilter column to which the sorting should be applied to
8
8
  # @param [Symbol] order The order the column should be sorted on, can only be :asc or :desc
9
- # @param [Array] custom_list An array containg a custom sorting list in order.
9
+ # @param [Array] custom_list An array containing a custom sorting list in order.
10
10
  def initialize(column_index:, order:, custom_list:)
11
11
  Axlsx.validate_int column_index
12
12
  @column_index = column_index