caxlsx 2.0.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +41 -33
  4. data/Rakefile +9 -11
  5. data/examples/auto_filter.rb +10 -1
  6. data/examples/conditional_formatting/example_conditional_formatting.rb +18 -3
  7. data/examples/data_validation.rb +57 -40
  8. data/examples/example.rb +115 -7
  9. data/examples/merge_cells.rb +17 -0
  10. data/examples/no_grid_with_borders.rb +18 -0
  11. data/examples/pivot_test.rb +63 -0
  12. data/examples/split.rb +16 -0
  13. data/lib/axlsx.rb +34 -15
  14. data/lib/axlsx/content_type/abstract_content_type.rb +1 -1
  15. data/lib/axlsx/content_type/content_type.rb +1 -1
  16. data/lib/axlsx/doc_props/app.rb +1 -1
  17. data/lib/axlsx/doc_props/core.rb +5 -5
  18. data/lib/axlsx/drawing/area_chart.rb +99 -0
  19. data/lib/axlsx/drawing/area_series.rb +110 -0
  20. data/lib/axlsx/drawing/axes.rb +1 -1
  21. data/lib/axlsx/drawing/axis.rb +12 -9
  22. data/lib/axlsx/drawing/bar_3D_chart.rb +13 -13
  23. data/lib/axlsx/drawing/bar_chart.rb +143 -0
  24. data/lib/axlsx/drawing/bar_series.rb +9 -9
  25. data/lib/axlsx/drawing/bubble_chart.rb +59 -0
  26. data/lib/axlsx/drawing/bubble_series.rb +63 -0
  27. data/lib/axlsx/drawing/cat_axis.rb +5 -5
  28. data/lib/axlsx/drawing/chart.rb +52 -8
  29. data/lib/axlsx/drawing/d_lbls.rb +3 -3
  30. data/lib/axlsx/drawing/drawing.rb +6 -1
  31. data/lib/axlsx/drawing/graphic_frame.rb +3 -3
  32. data/lib/axlsx/drawing/hyperlink.rb +1 -3
  33. data/lib/axlsx/drawing/line_3D_chart.rb +2 -2
  34. data/lib/axlsx/drawing/line_chart.rb +10 -10
  35. data/lib/axlsx/drawing/line_series.rb +32 -3
  36. data/lib/axlsx/drawing/marker.rb +1 -1
  37. data/lib/axlsx/drawing/num_data.rb +4 -4
  38. data/lib/axlsx/drawing/num_data_source.rb +6 -6
  39. data/lib/axlsx/drawing/num_val.rb +3 -1
  40. data/lib/axlsx/drawing/one_cell_anchor.rb +3 -2
  41. data/lib/axlsx/drawing/pic.rb +25 -19
  42. data/lib/axlsx/drawing/picture_locking.rb +1 -3
  43. data/lib/axlsx/drawing/pie_3D_chart.rb +5 -6
  44. data/lib/axlsx/drawing/pie_series.rb +6 -6
  45. data/lib/axlsx/drawing/scaling.rb +6 -6
  46. data/lib/axlsx/drawing/scatter_chart.rb +10 -10
  47. data/lib/axlsx/drawing/scatter_series.rb +40 -7
  48. data/lib/axlsx/drawing/ser_axis.rb +2 -2
  49. data/lib/axlsx/drawing/series.rb +3 -3
  50. data/lib/axlsx/drawing/series_title.rb +2 -2
  51. data/lib/axlsx/drawing/str_data.rb +3 -3
  52. data/lib/axlsx/drawing/str_val.rb +3 -1
  53. data/lib/axlsx/drawing/title.rb +22 -4
  54. data/lib/axlsx/drawing/two_cell_anchor.rb +6 -1
  55. data/lib/axlsx/drawing/val_axis.rb +1 -1
  56. data/lib/axlsx/drawing/view_3D.rb +2 -2
  57. data/lib/axlsx/drawing/vml_drawing.rb +1 -1
  58. data/lib/axlsx/package.rb +33 -31
  59. data/lib/axlsx/rels/relationship.rb +1 -1
  60. data/lib/axlsx/rels/relationships.rb +7 -4
  61. data/lib/axlsx/stylesheet/border_pr.rb +2 -2
  62. data/lib/axlsx/stylesheet/cell_alignment.rb +1 -3
  63. data/lib/axlsx/stylesheet/cell_protection.rb +1 -3
  64. data/lib/axlsx/stylesheet/cell_style.rb +1 -3
  65. data/lib/axlsx/stylesheet/color.rb +1 -3
  66. data/lib/axlsx/stylesheet/font.rb +1 -1
  67. data/lib/axlsx/stylesheet/gradient_stop.rb +1 -1
  68. data/lib/axlsx/stylesheet/num_fmt.rb +10 -3
  69. data/lib/axlsx/stylesheet/pattern_fill.rb +1 -1
  70. data/lib/axlsx/stylesheet/styles.rb +7 -7
  71. data/lib/axlsx/stylesheet/table_style_element.rb +1 -3
  72. data/lib/axlsx/util/accessors.rb +6 -6
  73. data/lib/axlsx/util/constants.rb +107 -99
  74. data/lib/axlsx/util/mime_type_utils.rb +11 -0
  75. data/lib/axlsx/util/options_parser.rb +2 -1
  76. data/lib/axlsx/util/parser.rb +4 -4
  77. data/lib/axlsx/util/serialized_attributes.rb +16 -6
  78. data/lib/axlsx/util/simple_typed_list.rb +28 -52
  79. data/lib/axlsx/util/storage.rb +4 -4
  80. data/lib/axlsx/util/validators.rb +29 -17
  81. data/lib/axlsx/version.rb +1 -1
  82. data/lib/axlsx/workbook/defined_name.rb +11 -12
  83. data/lib/axlsx/workbook/defined_names.rb +2 -2
  84. data/lib/axlsx/workbook/shared_strings_table.rb +5 -5
  85. data/lib/axlsx/workbook/workbook.rb +36 -11
  86. data/lib/axlsx/workbook/workbook_view.rb +80 -0
  87. data/lib/axlsx/workbook/workbook_views.rb +22 -0
  88. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +2 -2
  89. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +1 -3
  90. data/lib/axlsx/workbook/worksheet/break.rb +1 -3
  91. data/lib/axlsx/workbook/worksheet/cell.rb +136 -74
  92. data/lib/axlsx/workbook/worksheet/cell_serializer.rb +63 -43
  93. data/lib/axlsx/workbook/worksheet/cfvo.rb +1 -3
  94. data/lib/axlsx/workbook/worksheet/cfvos.rb +4 -1
  95. data/lib/axlsx/workbook/worksheet/col.rb +7 -10
  96. data/lib/axlsx/workbook/worksheet/col_breaks.rb +2 -2
  97. data/lib/axlsx/workbook/worksheet/cols.rb +5 -2
  98. data/lib/axlsx/workbook/worksheet/comment.rb +5 -6
  99. data/lib/axlsx/workbook/worksheet/comments.rb +9 -12
  100. data/lib/axlsx/workbook/worksheet/conditional_formatting.rb +1 -1
  101. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +1 -1
  102. data/lib/axlsx/workbook/worksheet/data_bar.rb +4 -6
  103. data/lib/axlsx/workbook/worksheet/data_validation.rb +6 -4
  104. data/lib/axlsx/workbook/worksheet/dimension.rb +2 -2
  105. data/lib/axlsx/workbook/worksheet/header_footer.rb +6 -8
  106. data/lib/axlsx/workbook/worksheet/icon_set.rb +3 -5
  107. data/lib/axlsx/workbook/worksheet/merged_cells.rb +4 -2
  108. data/lib/axlsx/workbook/worksheet/outline_pr.rb +33 -0
  109. data/lib/axlsx/workbook/worksheet/page_margins.rb +1 -3
  110. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +1 -1
  111. data/lib/axlsx/workbook/worksheet/page_setup.rb +21 -23
  112. data/lib/axlsx/workbook/worksheet/pane.rb +1 -3
  113. data/lib/axlsx/workbook/worksheet/pivot_table.rb +44 -28
  114. data/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +4 -4
  115. data/lib/axlsx/workbook/worksheet/print_options.rb +1 -3
  116. data/lib/axlsx/workbook/worksheet/protected_range.rb +1 -3
  117. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +5 -2
  118. data/lib/axlsx/workbook/worksheet/rich_text.rb +55 -0
  119. data/lib/axlsx/workbook/worksheet/rich_text_run.rb +250 -0
  120. data/lib/axlsx/workbook/worksheet/row.rb +40 -51
  121. data/lib/axlsx/workbook/worksheet/row_breaks.rb +2 -2
  122. data/lib/axlsx/workbook/worksheet/selection.rb +1 -3
  123. data/lib/axlsx/workbook/worksheet/sheet_data.rb +3 -1
  124. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +21 -3
  125. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +1 -3
  126. data/lib/axlsx/workbook/worksheet/table.rb +6 -6
  127. data/lib/axlsx/workbook/worksheet/table_style_info.rb +1 -3
  128. data/lib/axlsx/workbook/worksheet/tables.rb +4 -1
  129. data/lib/axlsx/workbook/worksheet/worksheet.rb +64 -78
  130. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +10 -10
  131. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +3 -3
  132. data/test/drawing/tc_area_chart.rb +39 -0
  133. data/test/drawing/tc_area_series.rb +71 -0
  134. data/test/drawing/tc_axis.rb +27 -0
  135. data/test/drawing/tc_bar_chart.rb +71 -0
  136. data/test/drawing/tc_bubble_chart.rb +44 -0
  137. data/test/drawing/tc_bubble_series.rb +21 -0
  138. data/test/drawing/tc_chart.rb +23 -10
  139. data/test/drawing/tc_data_source.rb +6 -0
  140. data/test/drawing/tc_drawing.rb +2 -2
  141. data/test/drawing/tc_line_chart.rb +5 -5
  142. data/test/drawing/tc_line_series.rb +47 -6
  143. data/test/drawing/tc_pic.rb +11 -15
  144. data/test/drawing/tc_scatter_series.rb +36 -1
  145. data/test/drawing/tc_str_val.rb +9 -0
  146. data/test/drawing/tc_title.rb +5 -0
  147. data/test/stylesheet/tc_styles.rb +2 -2
  148. data/test/tc_axlsx.rb +31 -0
  149. data/test/tc_helper.rb +2 -0
  150. data/test/tc_package.rb +19 -1
  151. data/test/util/tc_mime_type_utils.rb +13 -0
  152. data/test/util/tc_simple_typed_list.rb +2 -3
  153. data/test/util/tc_validators.rb +34 -10
  154. data/test/workbook/tc_defined_name.rb +12 -4
  155. data/test/workbook/tc_shared_strings_table.rb +16 -1
  156. data/test/workbook/tc_workbook.rb +38 -3
  157. data/test/workbook/tc_workbook_view.rb +50 -0
  158. data/test/workbook/worksheet/auto_filter/tc_filters.rb +1 -1
  159. data/test/workbook/worksheet/tc_break.rb +1 -1
  160. data/test/workbook/worksheet/tc_cell.rb +76 -8
  161. data/test/workbook/worksheet/tc_col.rb +2 -2
  162. data/test/workbook/worksheet/tc_conditional_formatting.rb +2 -2
  163. data/test/workbook/worksheet/tc_data_bar.rb +1 -1
  164. data/test/workbook/worksheet/tc_data_validation.rb +11 -11
  165. data/test/workbook/worksheet/tc_header_footer.rb +2 -2
  166. data/test/workbook/worksheet/tc_icon_set.rb +1 -1
  167. data/test/workbook/worksheet/tc_outline_pr.rb +19 -0
  168. data/test/workbook/worksheet/tc_page_setup.rb +3 -3
  169. data/test/workbook/worksheet/tc_pivot_table.rb +21 -6
  170. data/test/workbook/worksheet/tc_print_options.rb +1 -1
  171. data/test/workbook/worksheet/tc_rich_text.rb +44 -0
  172. data/test/workbook/worksheet/tc_rich_text_run.rb +172 -0
  173. data/test/workbook/worksheet/tc_row.rb +7 -2
  174. data/test/workbook/worksheet/tc_sheet_calc_pr.rb +1 -1
  175. data/test/workbook/worksheet/tc_sheet_format_pr.rb +4 -4
  176. data/test/workbook/worksheet/tc_sheet_pr.rb +26 -4
  177. data/test/workbook/worksheet/tc_sheet_protection.rb +5 -5
  178. data/test/workbook/worksheet/tc_sheet_view.rb +4 -4
  179. data/test/workbook/worksheet/tc_table.rb +2 -3
  180. data/test/workbook/worksheet/tc_worksheet.rb +99 -45
  181. metadata +89 -16
@@ -102,7 +102,7 @@ module Axlsx
102
102
  def to_xml_string(str = '')
103
103
  h = self.instance_values.reject{|k, _| k == "source_obj"}
104
104
  str << '<Relationship '
105
- str << h.map { |key, value| '' << key.to_s << '="' << Axlsx::coder.encode(value.to_s) << '"'}.join(' ')
105
+ str << (h.map { |key, value| '' << key.to_s << '="' << Axlsx::coder.encode(value.to_s) << '"'}.join(' '))
106
106
  str << '/>'
107
107
  end
108
108
 
@@ -10,17 +10,20 @@ require 'axlsx/rels/relationship.rb'
10
10
  def initialize
11
11
  super Relationship
12
12
  end
13
-
13
+
14
14
  # The relationship instance for the given source object, or nil if none exists.
15
15
  # @see Relationship#source_obj
16
16
  # @return [Relationship]
17
17
  def for(source_obj)
18
- @list.find{ |rel| rel.source_obj == source_obj }
18
+ find{ |rel| rel.source_obj == source_obj }
19
19
  end
20
-
20
+
21
+ # serialize relationships
22
+ # @param [String] str
23
+ # @return [String]
21
24
  def to_xml_string(str = '')
22
25
  str << '<?xml version="1.0" encoding="UTF-8"?>'
23
- str << '<Relationships xmlns="' << RELS_R << '">'
26
+ str << ('<Relationships xmlns="' << RELS_R << '">')
24
27
  each{ |rel| rel.to_xml_string(str) }
25
28
  str << '</Relationships>'
26
29
  end
@@ -62,9 +62,9 @@ module Axlsx
62
62
  # @param [String] str
63
63
  # @return [String]
64
64
  def to_xml_string(str = '')
65
- str << '<' << @name.to_s << ' style="' << @style.to_s << '">'
65
+ str << ('<' << @name.to_s << ' style="' << @style.to_s << '">')
66
66
  @color.to_xml_string(str) if @color.is_a?(Color)
67
- str << '</' << @name.to_s << '>'
67
+ str << ('</' << @name.to_s << '>')
68
68
  end
69
69
 
70
70
  end
@@ -125,9 +125,7 @@ module Axlsx
125
125
  # @param [String] str
126
126
  # @return [String]
127
127
  def to_xml_string(str = '')
128
- str << '<alignment '
129
- serialized_attributes str
130
- str << '/>'
128
+ serialized_tag('alignment', str)
131
129
  end
132
130
 
133
131
  end
@@ -34,9 +34,7 @@ module Axlsx
34
34
  # @param [String] str
35
35
  # @return [String]
36
36
  def to_xml_string(str = '')
37
- str << '<protection '
38
- serialized_attributes str
39
- str << '/>'
37
+ serialized_tag('protection', str)
40
38
  end
41
39
 
42
40
  end
@@ -64,9 +64,7 @@ module Axlsx
64
64
  # @param [String] str
65
65
  # @return [String]
66
66
  def to_xml_string(str = '')
67
- str << '<cellStyle '
68
- serialized_attributes str
69
- str << '/>'
67
+ serialized_tag('cellStyle', str)
70
68
  end
71
69
 
72
70
  end
@@ -70,9 +70,7 @@ module Axlsx
70
70
  # @param [String] str
71
71
  # @return [String]
72
72
  def to_xml_string(str = '', tag_name = 'color')
73
- str << "<" << tag_name << " "
74
- serialized_attributes str
75
- str << "/>"
73
+ serialized_tag('' + tag_name + '', str)
76
74
  end
77
75
  end
78
76
  end
@@ -140,7 +140,7 @@ module Axlsx
140
140
  def to_xml_string(str = '')
141
141
  str << '<font>'
142
142
  instance_values.each do |k, v|
143
- v.is_a?(Color) ? v.to_xml_string(str) : (str << '<' << k.to_s << ' val="' << v.to_s << '"/>')
143
+ v.is_a?(Color) ? v.to_xml_string(str) : (str << ('<' << k.to_s << ' val="' << Axlsx.booleanize(v).to_s << '"/>'))
144
144
  end
145
145
  str << '</font>'
146
146
  end
@@ -29,7 +29,7 @@ module Axlsx
29
29
  # @param [String] str
30
30
  # @return [String]
31
31
  def to_xml_string(str = '')
32
- str << '<stop position="' << position.to_s << '">'
32
+ str << ('<stop position="' << position.to_s << '">')
33
33
  self.color.to_xml_string(str)
34
34
  str << '</stop>'
35
35
  end
@@ -70,9 +70,16 @@ module Axlsx
70
70
  # @param [String] str
71
71
  # @return [String]
72
72
  def to_xml_string(str = '')
73
- str << '<numFmt '
74
- serialized_attributes str
75
- str << '/>'
73
+ serialized_tag('numFmt', str)
74
+ end
75
+
76
+ # Override to avoid removing underscores
77
+ def serialized_attributes(str = '', additional_attributes = {})
78
+ attributes = declared_attributes.merge! additional_attributes
79
+ attributes.each do |key, value|
80
+ str << "#{Axlsx.camel(key, false)}=\"#{Axlsx.booleanize(value)}\" "
81
+ end
82
+ str
76
83
  end
77
84
 
78
85
  end
@@ -59,7 +59,7 @@ module Axlsx
59
59
  # @param [String] str
60
60
  # @return [String]
61
61
  def to_xml_string(str = '')
62
- str << '<patternFill patternType="' << patternType.to_s << '">'
62
+ str << ('<patternFill patternType="' << patternType.to_s << '">')
63
63
  if fgColor.is_a?(Color)
64
64
  fgColor.to_xml_string str, "fgColor"
65
65
  end
@@ -128,7 +128,7 @@ module Axlsx
128
128
  # @option options [Boolean] i Indicates if the text should be italicised
129
129
  # @option options [Boolean] u Indicates if the text should be underlined
130
130
  # @option options [Boolean] strike Indicates if the text should be rendered with a strikethrough
131
- # @option options [Boolean] strike Indicates if the text should be rendered with a shadow
131
+ # @option options [Boolean] shadow Indicates if the text should be rendered with a shadow
132
132
  # @option options [Integer] charset The character set to use.
133
133
  # @option options [Integer] family The font family to use.
134
134
  # @option options [String] font_name The name of the font to use
@@ -151,7 +151,7 @@ module Axlsx
151
151
  # ws = p.workbook.add_worksheet
152
152
  #
153
153
  # # black text on a white background at 14pt with thin borders!
154
- # title = ws.style.add_style(:bg_color => "FFFF0000", :fg_color=>"#FF000000", :sz=>14, :border=> {:style => :thin, :color => "FFFF0000"}
154
+ # title = ws.styles.add_style(:bg_color => "FFFF0000", :fg_color=>"#FF000000", :sz=>14, :border=> {:style => :thin, :color => "FFFF0000"}
155
155
  #
156
156
  # ws.add_row ["Least Popular Pets"]
157
157
  # ws.add_row ["", "Dry Skinned Reptiles", "Bald Cats", "Violent Parrots"], :style=>title
@@ -168,18 +168,18 @@ module Axlsx
168
168
  # ws = p.workbook.add_worksheet
169
169
  #
170
170
  # # define your styles
171
- # title = ws.style.add_style(:bg_color => "FFFF0000",
171
+ # title = ws.styles.add_style(:bg_color => "FFFF0000",
172
172
  # :fg_color=>"#FF000000",
173
173
  # :border=>Axlsx::STYLE_THIN_BORDER,
174
174
  # :alignment=>{:horizontal => :center})
175
175
  #
176
- # date_time = ws.style.add_style(:num_fmt => Axlsx::NUM_FMT_YYYYMMDDHHMMSS,
176
+ # date_time = ws.styles.add_style(:num_fmt => Axlsx::NUM_FMT_YYYYMMDDHHMMSS,
177
177
  # :border=>Axlsx::STYLE_THIN_BORDER)
178
178
  #
179
- # percent = ws.style.add_style(:num_fmt => Axlsx::NUM_FMT_PERCENT,
179
+ # percent = ws.styles.add_style(:num_fmt => Axlsx::NUM_FMT_PERCENT,
180
180
  # :border=>Axlsx::STYLE_THIN_BORDER)
181
181
  #
182
- # currency = ws.style.add_style(:format_code=>"¥#,##0;[Red]¥-#,##0",
182
+ # currency = ws.styles.add_style(:format_code=>"¥#,##0;[Red]¥-#,##0",
183
183
  # :border=>Axlsx::STYLE_THIN_BORDER)
184
184
  #
185
185
  # # build your rows
@@ -362,7 +362,7 @@ module Axlsx
362
362
  # @param [String] str
363
363
  # @return [String]
364
364
  def to_xml_string(str = '')
365
- str << '<styleSheet xmlns="' << XML_NS << '">'
365
+ str << ('<styleSheet xmlns="' << XML_NS << '">')
366
366
  [:numFmts, :fonts, :fills, :borders, :cellStyleXfs, :cellXfs, :cellStyles, :dxfs, :tableStyles].each do |key|
367
367
  self.instance_values[key.to_s].to_xml_string(str) unless self.instance_values[key.to_s].nil?
368
368
  end
@@ -70,9 +70,7 @@ module Axlsx
70
70
  # @param [String] str
71
71
  # @return [String]
72
72
  def to_xml_string(str = '')
73
- str << '<tableStyleElement '
74
- serialized_attributes str
75
- str << '/>'
73
+ serialized_tag('tableStyleElement', str)
76
74
  end
77
75
 
78
76
  end
@@ -19,7 +19,7 @@ module Axlsx
19
19
  # @param [Array] symbols An array of symbols representing the
20
20
  # names of the attributes you will add to your class.
21
21
  def string_attr_accessor(*symbols)
22
- validated_attr_accessor(symbols, 'validate_string')
22
+ validated_attr_accessor(symbols, :validate_string)
23
23
  end
24
24
 
25
25
 
@@ -27,25 +27,25 @@ module Axlsx
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)
30
- validated_attr_accessor(symbols, 'validate_unsigned_int')
30
+ validated_attr_accessor(symbols, :validate_unsigned_int)
31
31
  end
32
32
 
33
33
  # Creates one or more float (double?) attr_accessors
34
34
  # @param [Array] symbols An array of symbols representing the
35
35
  # names of the attributes you will add to your class
36
36
  def float_attr_accessor(*symbols)
37
- validated_attr_accessor(symbols, 'validate_float')
37
+ validated_attr_accessor(symbols, :validate_float)
38
38
  end
39
39
 
40
40
  # Creates on or more boolean validated attr_accessors
41
41
  # @param [Array] symbols An array of symbols representing the
42
42
  # names of the attributes you will add to your class.
43
43
  def boolean_attr_accessor(*symbols)
44
- validated_attr_accessor(symbols, 'validate_boolean')
44
+ validated_attr_accessor(symbols, :validate_boolean)
45
45
  end
46
46
 
47
47
  # Template for defining validated write accessors
48
- SETTER = "def %s=(value) Axlsx::%s(value); @%s = value; end"
48
+ SETTER = "def %s=(value) Axlsx::%s(value); @%s = value; end".freeze
49
49
 
50
50
  # Creates the reader and writer access methods
51
51
  # @param [Array] symbols The names of the attributes to create
@@ -55,7 +55,7 @@ module Axlsx
55
55
  def validated_attr_accessor(symbols, validator)
56
56
  symbols.each do |symbol|
57
57
  attr_reader symbol
58
- module_eval(SETTER % [symbol.to_s, validator, symbol.to_s], __FILE__, __LINE__)
58
+ module_eval(SETTER % [symbol, validator, symbol], __FILE__, __LINE__)
59
59
  end
60
60
  end
61
61
  end
@@ -1,263 +1,263 @@
1
1
  module Axlsx
2
2
 
3
3
  # XML Encoding
4
- ENCODING = "UTF-8"
4
+ ENCODING = "UTF-8".freeze
5
5
 
6
6
  # spreadsheetML namespace
7
- XML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main"
7
+ XML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main".freeze
8
8
 
9
9
  # content-types namespace
10
- XML_NS_T = "http://schemas.openxmlformats.org/package/2006/content-types"
10
+ XML_NS_T = "http://schemas.openxmlformats.org/package/2006/content-types".freeze
11
11
 
12
12
  # extended-properties namespace
13
- APP_NS = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
13
+ APP_NS = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties".freeze
14
14
 
15
15
  # doc props namespace
16
- APP_NS_VT = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"
16
+ APP_NS_VT = "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes".freeze
17
17
 
18
18
  # core properties namespace
19
- CORE_NS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"
19
+ CORE_NS = "http://schemas.openxmlformats.org/package/2006/metadata/core-properties".freeze
20
20
 
21
21
  # dc elements (core) namespace
22
- CORE_NS_DC = "http://purl.org/dc/elements/1.1/"
22
+ CORE_NS_DC = "http://purl.org/dc/elements/1.1/".freeze
23
23
 
24
24
  # dcmit (core) namespcace
25
- CORE_NS_DCMIT = "http://purl.org/dc/dcmitype/"
25
+ CORE_NS_DCMIT = "http://purl.org/dc/dcmitype/".freeze
26
26
 
27
27
  # dc terms namespace
28
- CORE_NS_DCT = "http://purl.org/dc/terms/"
28
+ CORE_NS_DCT = "http://purl.org/dc/terms/".freeze
29
29
 
30
30
  # xml schema namespace
31
- CORE_NS_XSI = "http://www.w3.org/2001/XMLSchema-instance"
31
+ CORE_NS_XSI = "http://www.w3.org/2001/XMLSchema-instance".freeze
32
32
 
33
33
  # Digital signature namespace
34
- DIGITAL_SIGNATURE_NS = "http://schemas.openxmlformats.org/package/2006/digital-signature"
34
+ DIGITAL_SIGNATURE_NS = "http://schemas.openxmlformats.org/package/2006/digital-signature".freeze
35
35
 
36
36
  # spreadsheet drawing namespace
37
- XML_NS_XDR = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
37
+ XML_NS_XDR = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing".freeze
38
38
 
39
39
  # drawing namespace
40
- XML_NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main"
40
+ XML_NS_A = "http://schemas.openxmlformats.org/drawingml/2006/main".freeze
41
41
 
42
42
  # chart namespace
43
- XML_NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart"
43
+ XML_NS_C = "http://schemas.openxmlformats.org/drawingml/2006/chart".freeze
44
44
 
45
45
  # relationships namespace
46
- XML_NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
46
+ XML_NS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships".freeze
47
47
 
48
48
  # relationships name space
49
- RELS_R = "http://schemas.openxmlformats.org/package/2006/relationships"
49
+ RELS_R = "http://schemas.openxmlformats.org/package/2006/relationships".freeze
50
50
 
51
51
  # table rels namespace
52
- TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"
52
+ TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table".freeze
53
53
 
54
54
  # pivot table rels namespace
55
- PIVOT_TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"
55
+ PIVOT_TABLE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable".freeze
56
56
 
57
57
  # pivot table cache definition namespace
58
- PIVOT_TABLE_CACHE_DEFINITION_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"
58
+ PIVOT_TABLE_CACHE_DEFINITION_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition".freeze
59
59
 
60
60
  # workbook rels namespace
61
- WORKBOOK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
61
+ WORKBOOK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument".freeze
62
62
 
63
63
  # worksheet rels namespace
64
- WORKSHEET_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"
64
+ WORKSHEET_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet".freeze
65
65
 
66
66
  # app rels namespace
67
- APP_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
67
+ APP_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties".freeze
68
68
 
69
69
  # core rels namespace
70
- CORE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/metadata/core-properties"
70
+ CORE_R = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties".freeze
71
71
 
72
72
  # digital signature rels namespace
73
- DIGITAL_SIGNATURE_R = "http://schemas.openxmlformats.org/package/2006/relationships/digital- signature/signature"
73
+ DIGITAL_SIGNATURE_R = "http://schemas.openxmlformats.org/package/2006/relationships/digital- signature/signature".freeze
74
74
 
75
75
  # styles rels namespace
76
- STYLES_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
76
+ STYLES_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles".freeze
77
77
 
78
78
  # shared strings namespace
79
- SHARED_STRINGS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"
79
+ SHARED_STRINGS_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings".freeze
80
80
 
81
81
  # drawing rels namespace
82
- DRAWING_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"
82
+ DRAWING_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing".freeze
83
83
 
84
84
  # chart rels namespace
85
- CHART_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"
85
+ CHART_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart".freeze
86
86
 
87
87
  # image rels namespace
88
- IMAGE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
88
+ IMAGE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image".freeze
89
89
 
90
90
  # hyperlink rels namespace
91
- HYPERLINK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
91
+ HYPERLINK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink".freeze
92
92
 
93
93
  # comment rels namespace
94
- COMMENT_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
94
+ COMMENT_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments".freeze
95
95
 
96
96
  # comment relation for nil target
97
- COMMENT_R_NULL = "http://purl.oclc.org/ooxml/officeDocument/relationships/comments"
97
+ COMMENT_R_NULL = "http://purl.oclc.org/ooxml/officeDocument/relationships/comments".freeze
98
98
 
99
99
  #vml drawing relation namespace
100
100
  VML_DRAWING_R = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing'
101
101
 
102
102
  # VML Drawing content type
103
- VML_DRAWING_CT = "application/vnd.openxmlformats-officedocument.vmlDrawing"
103
+ VML_DRAWING_CT = "application/vnd.openxmlformats-officedocument.vmlDrawing".freeze
104
104
 
105
105
  # table content type
106
- TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"
106
+ TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml".freeze
107
107
 
108
108
  # pivot table content type
109
- PIVOT_TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"
109
+ PIVOT_TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml".freeze
110
110
 
111
111
  # pivot table cache definition content type
112
- PIVOT_TABLE_CACHE_DEFINITION_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"
112
+ PIVOT_TABLE_CACHE_DEFINITION_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml".freeze
113
113
 
114
114
  # workbook content type
115
- WORKBOOK_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"
115
+ WORKBOOK_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml".freeze
116
116
 
117
117
  # app content type
118
- APP_CT = "application/vnd.openxmlformats-officedocument.extended-properties+xml"
118
+ APP_CT = "application/vnd.openxmlformats-officedocument.extended-properties+xml".freeze
119
119
 
120
120
  # rels content type
121
- RELS_CT = "application/vnd.openxmlformats-package.relationships+xml"
121
+ RELS_CT = "application/vnd.openxmlformats-package.relationships+xml".freeze
122
122
 
123
123
  # styles content type
124
- STYLES_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"
124
+ STYLES_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml".freeze
125
125
 
126
126
  # xml content type
127
- XML_CT = "application/xml"
127
+ XML_CT = "application/xml".freeze
128
128
 
129
129
  # worksheet content type
130
- WORKSHEET_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"
130
+ WORKSHEET_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml".freeze
131
131
 
132
132
  # shared strings content type
133
- SHARED_STRINGS_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"
133
+ SHARED_STRINGS_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml".freeze
134
134
 
135
135
  # core content type
136
- CORE_CT = "application/vnd.openxmlformats-package.core-properties+xml"
136
+ CORE_CT = "application/vnd.openxmlformats-package.core-properties+xml".freeze
137
137
 
138
138
  # digital signature xml content type
139
- DIGITAL_SIGNATURE_XML_CT = "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml"
139
+ DIGITAL_SIGNATURE_XML_CT = "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml".freeze
140
140
 
141
141
  # digital signature origin content type
142
- DIGITAL_SIGNATURE_ORIGIN_CT = "application/vnd.openxmlformats-package.digital-signature-origin"
142
+ DIGITAL_SIGNATURE_ORIGIN_CT = "application/vnd.openxmlformats-package.digital-signature-origin".freeze
143
143
 
144
144
  # digital signature certificate content type
145
- DIGITAL_SIGNATURE_CERTIFICATE_CT = "application/vnd.openxmlformats-package.digital-signature-certificate"
145
+ DIGITAL_SIGNATURE_CERTIFICATE_CT = "application/vnd.openxmlformats-package.digital-signature-certificate".freeze
146
146
 
147
147
  # chart content type
148
- CHART_CT = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
148
+ CHART_CT = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml".freeze
149
149
 
150
150
  # comments content type
151
- COMMENT_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
151
+ COMMENT_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml".freeze
152
152
 
153
153
  # jpeg content type
154
- JPEG_CT = "image/jpeg"
154
+ JPEG_CT = "image/jpeg".freeze
155
155
 
156
156
  # gif content type
157
- GIF_CT = "image/gif"
157
+ GIF_CT = "image/gif".freeze
158
158
 
159
159
  # png content type
160
- PNG_CT = "image/png"
160
+ PNG_CT = "image/png".freeze
161
161
 
162
162
  #drawing content type
163
- DRAWING_CT = "application/vnd.openxmlformats-officedocument.drawing+xml"
163
+ DRAWING_CT = "application/vnd.openxmlformats-officedocument.drawing+xml".freeze
164
164
 
165
165
 
166
166
  # xml content type extensions
167
- XML_EX = "xml"
167
+ XML_EX = "xml".freeze
168
168
 
169
169
  # jpeg extension
170
- JPEG_EX = "jpeg"
170
+ JPEG_EX = "jpeg".freeze
171
171
 
172
172
  # gif extension
173
- GIF_EX = "gif"
173
+ GIF_EX = "gif".freeze
174
174
 
175
175
  # png extension
176
- PNG_EX = "png"
176
+ PNG_EX = "png".freeze
177
177
 
178
178
  # rels content type extension
179
- RELS_EX = "rels"
179
+ RELS_EX = "rels".freeze
180
180
 
181
181
  # workbook part
182
- WORKBOOK_PN = "xl/workbook.xml"
182
+ WORKBOOK_PN = "xl/workbook.xml".freeze
183
183
 
184
184
  # styles part
185
- STYLES_PN = "styles.xml"
185
+ STYLES_PN = "styles.xml".freeze
186
186
 
187
187
  # shared_strings part
188
- SHARED_STRINGS_PN = "sharedStrings.xml"
188
+ SHARED_STRINGS_PN = "sharedStrings.xml".freeze
189
189
 
190
190
  # app part
191
- APP_PN = "docProps/app.xml"
191
+ APP_PN = "docProps/app.xml".freeze
192
192
 
193
193
  # core part
194
- CORE_PN = "docProps/core.xml"
194
+ CORE_PN = "docProps/core.xml".freeze
195
195
 
196
196
  # content types part
197
- CONTENT_TYPES_PN = "[Content_Types].xml"
197
+ CONTENT_TYPES_PN = "[Content_Types].xml".freeze
198
198
 
199
199
  # rels part
200
- RELS_PN = "_rels/.rels"
200
+ RELS_PN = "_rels/.rels".freeze
201
201
 
202
202
  # workbook rels part
203
- WORKBOOK_RELS_PN = "xl/_rels/workbook.xml.rels"
203
+ WORKBOOK_RELS_PN = "xl/_rels/workbook.xml.rels".freeze
204
204
 
205
205
  # worksheet part
206
- WORKSHEET_PN = "worksheets/sheet%d.xml"
206
+ WORKSHEET_PN = "worksheets/sheet%d.xml".freeze
207
207
 
208
208
  # worksheet rels part
209
- WORKSHEET_RELS_PN = "worksheets/_rels/sheet%d.xml.rels"
209
+ WORKSHEET_RELS_PN = "worksheets/_rels/sheet%d.xml.rels".freeze
210
210
 
211
211
  # drawing part
212
- DRAWING_PN = "drawings/drawing%d.xml"
212
+ DRAWING_PN = "drawings/drawing%d.xml".freeze
213
213
 
214
214
  # drawing rels part
215
- DRAWING_RELS_PN = "drawings/_rels/drawing%d.xml.rels"
215
+ DRAWING_RELS_PN = "drawings/_rels/drawing%d.xml.rels".freeze
216
216
 
217
217
  # vml drawing part
218
- VML_DRAWING_PN = "drawings/vmlDrawing%d.vml"
218
+ VML_DRAWING_PN = "drawings/vmlDrawing%d.vml".freeze
219
219
 
220
220
  # drawing part
221
- TABLE_PN = "tables/table%d.xml"
221
+ TABLE_PN = "tables/table%d.xml".freeze
222
222
 
223
223
  # pivot table parts
224
- PIVOT_TABLE_PN = "pivotTables/pivotTable%d.xml"
224
+ PIVOT_TABLE_PN = "pivotTables/pivotTable%d.xml".freeze
225
225
 
226
226
  # pivot table cache definition part name
227
- PIVOT_TABLE_CACHE_DEFINITION_PN = "pivotCache/pivotCacheDefinition%d.xml"
227
+ PIVOT_TABLE_CACHE_DEFINITION_PN = "pivotCache/pivotCacheDefinition%d.xml".freeze
228
228
 
229
229
  # pivot table rels parts
230
- PIVOT_TABLE_RELS_PN = "pivotTables/_rels/pivotTable%d.xml.rels"
230
+ PIVOT_TABLE_RELS_PN = "pivotTables/_rels/pivotTable%d.xml.rels".freeze
231
231
 
232
232
  # chart part
233
- CHART_PN = "charts/chart%d.xml"
233
+ CHART_PN = "charts/chart%d.xml".freeze
234
234
 
235
235
  # chart part
236
- IMAGE_PN = "media/image%d.%s"
236
+ IMAGE_PN = "media/image%d.%s".freeze
237
237
 
238
238
  # comment part
239
- COMMENT_PN = "comments%d.xml"
239
+ COMMENT_PN = "comments%d.xml".freeze
240
240
 
241
241
  # location of schema files for validation
242
- SCHEMA_BASE = File.dirname(__FILE__)+'/../../schema/'
242
+ SCHEMA_BASE = (File.dirname(__FILE__)+'/../../schema/').freeze
243
243
 
244
244
  # App validation schema
245
- APP_XSD = SCHEMA_BASE + "shared-documentPropertiesExtended.xsd"
245
+ APP_XSD = (SCHEMA_BASE + "shared-documentPropertiesExtended.xsd").freeze
246
246
 
247
247
  # core validation schema
248
- CORE_XSD = SCHEMA_BASE + "opc-coreProperties.xsd"
248
+ CORE_XSD = (SCHEMA_BASE + "opc-coreProperties.xsd").freeze
249
249
 
250
250
  # content types validation schema
251
- CONTENT_TYPES_XSD = SCHEMA_BASE + "opc-contentTypes.xsd"
251
+ CONTENT_TYPES_XSD = (SCHEMA_BASE + "opc-contentTypes.xsd").freeze
252
252
 
253
253
  # rels validation schema
254
- RELS_XSD = SCHEMA_BASE + "opc-relationships.xsd"
254
+ RELS_XSD = (SCHEMA_BASE + "opc-relationships.xsd").freeze
255
255
 
256
256
  # spreadsheetML validation schema
257
- SML_XSD = SCHEMA_BASE + "sml.xsd"
257
+ SML_XSD = (SCHEMA_BASE + "sml.xsd").freeze
258
258
 
259
259
  # drawing validation schema
260
- DRAWING_XSD = SCHEMA_BASE + "dml-spreadsheetDrawing.xsd"
260
+ DRAWING_XSD = (SCHEMA_BASE + "dml-spreadsheetDrawing.xsd").freeze
261
261
 
262
262
  # number format id for pecentage formatting using the default formatting id.
263
263
  NUM_FMT_PERCENT = 9
@@ -275,37 +275,37 @@ module Axlsx
275
275
  STYLE_DATE = 2
276
276
 
277
277
  # error messages RestrictionValidor
278
- ERR_RESTRICTION = "Invalid Data: %s. %s must be one of %s."
278
+ ERR_RESTRICTION = "Invalid Data: %s. %s must be one of %s.".freeze
279
279
 
280
280
  # error message DataTypeValidator
281
- ERR_TYPE = "Invalid Data %s for %s. must be %s."
281
+ ERR_TYPE = "Invalid Data %s for %s. must be %s.".freeze
282
282
 
283
283
  # error message for RegexValidator
284
- ERR_REGEX = "Invalid Data. %s does not match %s."
284
+ ERR_REGEX = "Invalid Data. %s does not match %s.".freeze
285
285
 
286
286
  # error message for RangeValidator
287
- ERR_RANGE = "Invalid Data. %s must be between %s and %s, (inclusive:%s) you gave: %s"
287
+ ERR_RANGE = "Invalid Data. %s must be between %s and %s, (inclusive:%s) you gave: %s".freeze
288
288
 
289
289
  # error message for sheets that use a name which is longer than 31 bytes
290
- ERR_SHEET_NAME_TOO_LONG = "Your worksheet name '%s' is too long. Worksheet names must be 31 characters (bytes) or less"
290
+ ERR_SHEET_NAME_TOO_LONG = "Your worksheet name '%s' is too long. Worksheet names must be 31 characters (bytes) or less".freeze
291
291
 
292
292
  # error message for sheets that use a name which include invalid characters
293
- ERR_SHEET_NAME_CHARACTER_FORBIDDEN = "Your worksheet name '%s' contains a character which is not allowed by MS Excel and will cause repair warnings. Please change the name of your sheet."
293
+ ERR_SHEET_NAME_CHARACTER_FORBIDDEN = "Your worksheet name '%s' contains a character which is not allowed by MS Excel and will cause repair warnings. Please change the name of your sheet.".freeze
294
294
 
295
295
  # error message for duplicate sheet names
296
- ERR_DUPLICATE_SHEET_NAME = "There is already a worksheet in this workbook named '%s'. Please use a unique name"
296
+ ERR_DUPLICATE_SHEET_NAME = "There is already a worksheet in this workbook named '%s'. Please use a unique name".freeze
297
297
 
298
298
  # error message when user does not provide color and or style options for border in Style#add_sytle
299
- ERR_INVALID_BORDER_OPTIONS = "border hash must include both style and color. e.g. :border => { :color => 'FF000000', :style => :thin }. You provided: %s"
299
+ ERR_INVALID_BORDER_OPTIONS = "border hash must include both style and color. e.g. :border => { :color => 'FF000000', :style => :thin }. You provided: %s".freeze
300
300
 
301
301
  # error message for invalid border id reference
302
- ERR_INVALID_BORDER_ID = "The border id you specified (%s) does not exist. Please add a border with Style#add_style before referencing its index."
302
+ ERR_INVALID_BORDER_ID = "The border id you specified (%s) does not exist. Please add a border with Style#add_style before referencing its index.".freeze
303
303
 
304
304
  # error message for invalid angles
305
- ERR_ANGLE = "Angles must be a value between -90 and 90. You provided: %s"
305
+ ERR_ANGLE = "Angles must be a value between -90 and 90. You provided: %s".freeze
306
306
 
307
307
  # error message for non 'integerish' value
308
- ERR_INTEGERISH = "You value must be, or be castable via to_i, an Integer. You provided %s"
308
+ ERR_INTEGERISH = "You value must be, or be castable via to_i, an Integer. You provided %s".freeze
309
309
 
310
310
  # Regex to match forbidden control characters
311
311
  # The following will be automatically stripped from worksheets.
@@ -383,10 +383,18 @@ module Axlsx
383
383
  # x0D Carriage Return (Cr)
384
384
  # x09 Character Tabulation
385
385
  # @see http://www.codetable.net/asciikeycodes
386
- pattern = "[\x0-\x08\x0B\x0C\x0E-\x1F]"
387
- pattern= pattern.respond_to?(:encode) ? pattern.encode('UTF-8') : pattern
386
+ pattern = "\x0-\x08\x0B\x0C\x0E-\x1F"
387
+ pattern = pattern.respond_to?(:encode) ? pattern.encode('UTF-8') : pattern
388
388
 
389
389
  # The regular expression used to remove control characters from worksheets
390
- CONTROL_CHAR_REGEX = Regexp.new(pattern, 'n')
390
+ CONTROL_CHARS = pattern.freeze
391
391
 
392
+ # ISO 8601 date recognition
393
+ 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
394
+
395
+ # FLOAT recognition
396
+ FLOAT_REGEX = /\A[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\Z/.freeze
397
+
398
+ # Numeric recognition
399
+ NUMERIC_REGEX = /\A[+-]?\d+?\Z/.freeze
392
400
  end