axlsx 1.1.4 → 1.3.1

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 (242) hide show
  1. data/.yardopts +6 -2
  2. data/CHANGELOG.md +72 -0
  3. data/README.md +114 -31
  4. data/Rakefile +11 -3
  5. data/examples/auto_filter.rb +16 -0
  6. data/examples/auto_filter.xlsx +0 -0
  7. data/examples/basic_charts.rb +58 -0
  8. data/examples/chart_colors.rb +17 -2
  9. data/examples/data_validation.rb +50 -0
  10. data/examples/example.rb +171 -60
  11. data/examples/example.xlsx +0 -0
  12. data/examples/example_streamed.xlsx +0 -0
  13. data/examples/extractive.pdf +0 -0
  14. data/examples/extractive.rb +3 -0
  15. data/examples/extractive.xlsx +0 -0
  16. data/examples/hyperlinks.rb +23 -0
  17. data/examples/hyperlinks.xlsx +0 -0
  18. data/examples/no-use_autowidth.xlsx +0 -0
  19. data/examples/page_setup.rb +11 -0
  20. data/examples/page_setup.xlsx +0 -0
  21. data/examples/scraping_html.rb +91 -0
  22. data/examples/shared_strings_example.xlsx +0 -0
  23. data/examples/sheet_protection.rb +10 -0
  24. data/examples/sheet_view.rb +34 -0
  25. data/examples/skydrive/axlsx.csv +1 -0
  26. data/examples/skydrive/axlsx.xlsx +0 -0
  27. data/examples/skydrive/real_example.rb +8 -8
  28. data/examples/sprk2012/Screen Shot 2012-09-11 at 10.42.06 PM.png +0 -0
  29. data/examples/sprk2012/Screen Shot 2012-09-11 at 11.07.48 PM.png +0 -0
  30. data/examples/sprk2012/Screen Shot 2012-09-11 at 8.31.50 PM.png +0 -0
  31. data/examples/sprk2012/Screen Shot 2012-09-11 at 9.23.27 PM.png +0 -0
  32. data/examples/sprk2012/Screen Shot 2012-09-11 at 9.32.06 PM.png +0 -0
  33. data/examples/sprk2012/Screen Shot 2012-09-11 at 9.33.35 PM.png +0 -0
  34. data/examples/sprk2012/Screen Shot 2012-09-11 at 9.46.44 PM.png +0 -0
  35. data/examples/sprk2012/Screen Shot 2012-09-12 at 5.07.23 PM.png +0 -0
  36. data/examples/sprk2012/basics.rb +11 -0
  37. data/examples/sprk2012/basics.xlsx +0 -0
  38. data/examples/sprk2012/gravatar.jpeg +0 -0
  39. data/examples/sprk2012/hair_club.jpg +0 -0
  40. data/examples/sprk2012/images.rb +9 -0
  41. data/examples/sprk2012/images.xlsx +0 -0
  42. data/examples/sprk2012/line_chart.rb +56 -0
  43. data/examples/sprk2012/line_chart.xlsx +0 -0
  44. data/examples/sprk2012/sprk2012.key +0 -0
  45. data/examples/sprk2012/styles.rb +20 -0
  46. data/examples/sprk2012/styles.xlsx +0 -0
  47. data/examples/styles.rb +62 -0
  48. data/examples/styles.xlsx +0 -0
  49. data/examples/two_cell_anchor_image.rb +11 -0
  50. data/lib/axlsx/content_type/content_type.rb +2 -0
  51. data/lib/axlsx/content_type/default.rb +30 -15
  52. data/lib/axlsx/content_type/override.rb +29 -14
  53. data/lib/axlsx/doc_props/app.rb +161 -104
  54. data/lib/axlsx/doc_props/core.rb +9 -5
  55. data/lib/axlsx/drawing/ax_data_source.rb +7 -6
  56. data/lib/axlsx/drawing/axis.rb +82 -36
  57. data/lib/axlsx/drawing/bar_3D_chart.rb +49 -45
  58. data/lib/axlsx/drawing/bar_series.rb +2 -1
  59. data/lib/axlsx/drawing/cat_axis.rb +43 -39
  60. data/lib/axlsx/drawing/chart.rb +65 -54
  61. data/lib/axlsx/drawing/d_lbls.rb +100 -0
  62. data/lib/axlsx/drawing/drawing.rb +20 -8
  63. data/lib/axlsx/drawing/graphic_frame.rb +2 -1
  64. data/lib/axlsx/drawing/line_3D_chart.rb +3 -10
  65. data/lib/axlsx/drawing/num_data.rb +2 -2
  66. data/lib/axlsx/drawing/num_data_source.rb +4 -1
  67. data/lib/axlsx/drawing/pic.rb +44 -4
  68. data/lib/axlsx/drawing/pie_3D_chart.rb +10 -7
  69. data/lib/axlsx/drawing/scatter_chart.rb +2 -8
  70. data/lib/axlsx/drawing/title.rb +21 -9
  71. data/lib/axlsx/drawing/two_cell_anchor.rb +46 -9
  72. data/lib/axlsx/drawing/view_3D.rb +42 -32
  73. data/lib/axlsx/drawing/vml_drawing.rb +42 -0
  74. data/lib/axlsx/drawing/vml_shape.rb +125 -0
  75. data/lib/axlsx/package.rb +43 -16
  76. data/lib/axlsx/rels/relationship.rb +3 -3
  77. data/lib/axlsx/rels/relationships.rb +1 -11
  78. data/lib/axlsx/stylesheet/gradient_fill.rb +1 -1
  79. data/lib/axlsx/stylesheet/styles.rb +11 -2
  80. data/lib/axlsx/stylesheet/table_style.rb +3 -3
  81. data/lib/axlsx/util/constants.rb +131 -2
  82. data/lib/axlsx/util/simple_typed_list.rb +18 -22
  83. data/lib/axlsx/util/validators.rb +100 -9
  84. data/lib/axlsx/version.rb +2 -7
  85. data/lib/axlsx/workbook/defined_name.rb +174 -0
  86. data/lib/axlsx/workbook/defined_names.rb +21 -0
  87. data/lib/axlsx/workbook/workbook.rb +70 -13
  88. data/lib/axlsx/workbook/worksheet/auto_filter/auto_filter.rb +77 -0
  89. data/lib/axlsx/workbook/worksheet/auto_filter/filter_column.rb +102 -0
  90. data/lib/axlsx/workbook/worksheet/auto_filter/filters.rb +253 -0
  91. data/lib/axlsx/workbook/worksheet/cell.rb +41 -8
  92. data/lib/axlsx/workbook/worksheet/col.rb +15 -0
  93. data/lib/axlsx/workbook/worksheet/cols.rb +20 -0
  94. data/lib/axlsx/workbook/worksheet/comment.rb +101 -0
  95. data/lib/axlsx/workbook/worksheet/comments.rb +85 -0
  96. data/lib/axlsx/workbook/worksheet/conditional_formattings.rb +25 -0
  97. data/lib/axlsx/workbook/worksheet/data_bar.rb +1 -1
  98. data/lib/axlsx/workbook/worksheet/data_validation.rb +245 -0
  99. data/lib/axlsx/workbook/worksheet/data_validations.rb +28 -0
  100. data/lib/axlsx/workbook/worksheet/date_time_converter.rb +1 -1
  101. data/lib/axlsx/workbook/worksheet/dimension.rb +65 -0
  102. data/lib/axlsx/workbook/worksheet/merged_cells.rb +35 -0
  103. data/lib/axlsx/workbook/worksheet/page_set_up_pr.rb +47 -0
  104. data/lib/axlsx/workbook/worksheet/page_setup.rb +241 -0
  105. data/lib/axlsx/workbook/worksheet/pane.rb +144 -0
  106. data/lib/axlsx/workbook/worksheet/print_options.rb +63 -0
  107. data/lib/axlsx/workbook/worksheet/protected_range.rb +46 -0
  108. data/lib/axlsx/workbook/worksheet/protected_ranges.rb +34 -0
  109. data/lib/axlsx/workbook/worksheet/row.rb +36 -20
  110. data/lib/axlsx/workbook/worksheet/selection.rb +111 -0
  111. data/lib/axlsx/workbook/worksheet/sheet_calc_pr.rb +49 -0
  112. data/lib/axlsx/workbook/worksheet/sheet_data.rb +25 -0
  113. data/lib/axlsx/workbook/worksheet/sheet_pr.rb +107 -0
  114. data/lib/axlsx/workbook/worksheet/sheet_protection.rb +224 -0
  115. data/lib/axlsx/workbook/worksheet/sheet_view.rb +379 -0
  116. data/lib/axlsx/workbook/worksheet/table.rb +10 -3
  117. data/lib/axlsx/workbook/worksheet/table_style_info.rb +68 -0
  118. data/lib/axlsx/workbook/worksheet/tables.rb +31 -0
  119. data/lib/axlsx/workbook/worksheet/worksheet.rb +414 -254
  120. data/lib/axlsx/workbook/worksheet/worksheet_comments.rb +57 -0
  121. data/lib/axlsx/workbook/worksheet/worksheet_drawing.rb +64 -0
  122. data/lib/axlsx/workbook/worksheet/worksheet_hyperlink.rb +101 -0
  123. data/lib/axlsx/workbook/worksheet/worksheet_hyperlinks.rb +38 -0
  124. data/lib/axlsx.rb +38 -16
  125. data/test/content_type/tc_content_type.rb +1 -6
  126. data/test/doc_props/tc_app.rb +31 -1
  127. data/test/doc_props/tc_core.rb +3 -1
  128. data/test/drawing/tc_axis.rb +38 -3
  129. data/test/drawing/tc_bar_3D_chart.rb +12 -12
  130. data/test/drawing/tc_bar_series.rb +1 -2
  131. data/test/drawing/tc_cat_axis.rb +3 -3
  132. data/test/drawing/tc_chart.rb +29 -9
  133. data/test/drawing/tc_d_lbls.rb +47 -0
  134. data/test/drawing/tc_drawing.rb +11 -5
  135. data/test/drawing/tc_hyperlink.rb +4 -5
  136. data/test/drawing/tc_line_series.rb +7 -3
  137. data/test/drawing/tc_num_data.rb +5 -1
  138. data/test/drawing/tc_pic.rb +22 -2
  139. data/test/drawing/tc_pie_3D_chart.rb +4 -8
  140. data/test/drawing/tc_pie_series.rb +7 -2
  141. data/test/drawing/tc_scatter_chart.rb +6 -1
  142. data/test/drawing/tc_scatter_series.rb +1 -1
  143. data/test/drawing/tc_series.rb +1 -1
  144. data/test/drawing/tc_title.rb +16 -0
  145. data/test/drawing/tc_two_cell_anchor.rb +1 -2
  146. data/test/drawing/tc_view_3D.rb +18 -18
  147. data/test/drawing/tc_vml_drawing.rb +25 -0
  148. data/test/drawing/tc_vml_shape.rb +100 -0
  149. data/test/rels/tc_relationship.rb +1 -0
  150. data/test/stylesheet/tc_gradient_fill.rb +8 -0
  151. data/test/stylesheet/tc_pattern_fill.rb +7 -1
  152. data/test/stylesheet/tc_styles.rb +16 -4
  153. data/test/stylesheet/tc_table_style.rb +8 -0
  154. data/test/stylesheet/tc_table_style_element.rb +10 -1
  155. data/test/tc_helper.rb +1 -0
  156. data/test/tc_package.rb +94 -17
  157. data/test/util/tc_simple_typed_list.rb +13 -0
  158. data/test/util/tc_validators.rb +101 -8
  159. data/test/workbook/tc_defined_name.rb +41 -0
  160. data/test/workbook/tc_workbook.rb +5 -3
  161. data/test/workbook/worksheet/auto_filter/tc_auto_filter.rb +38 -0
  162. data/test/workbook/worksheet/auto_filter/tc_filter_column.rb +76 -0
  163. data/test/workbook/worksheet/auto_filter/tc_filters.rb +50 -0
  164. data/test/workbook/worksheet/tc_cell.rb +53 -7
  165. data/test/workbook/worksheet/tc_col.rb +9 -0
  166. data/test/workbook/worksheet/tc_comment.rb +57 -0
  167. data/test/workbook/worksheet/tc_comments.rb +57 -0
  168. data/test/workbook/worksheet/tc_conditional_formatting.rb +44 -0
  169. data/test/workbook/worksheet/tc_data_bar.rb +1 -1
  170. data/test/workbook/worksheet/tc_data_validation.rb +265 -0
  171. data/test/workbook/worksheet/tc_page_set_up_pr.rb +15 -0
  172. data/test/workbook/worksheet/tc_page_setup.rb +143 -0
  173. data/test/workbook/worksheet/tc_pane.rb +94 -0
  174. data/test/workbook/worksheet/tc_print_options.rb +72 -0
  175. data/test/workbook/worksheet/tc_protected_range.rb +17 -0
  176. data/test/workbook/worksheet/tc_row.rb +32 -14
  177. data/test/workbook/worksheet/tc_selection.rb +94 -0
  178. data/test/workbook/worksheet/tc_sheet_calc_pr.rb +18 -0
  179. data/test/workbook/worksheet/tc_sheet_pr.rb +27 -0
  180. data/test/workbook/worksheet/tc_sheet_protection.rb +117 -0
  181. data/test/workbook/worksheet/tc_sheet_view.rb +214 -0
  182. data/test/workbook/worksheet/{table/tc_table.rb → tc_table.rb} +9 -12
  183. data/test/workbook/worksheet/tc_table_style_info.rb +53 -0
  184. data/test/workbook/worksheet/tc_worksheet.rb +155 -51
  185. data/test/workbook/worksheet/tc_worksheet_hyperlink.rb +64 -0
  186. metadata +194 -81
  187. data/examples/#extractive.csv# +0 -0
  188. data/examples/#extractive.rb# +0 -45
  189. data/examples/chart_colors.rb~ +0 -0
  190. data/examples/chart_colors.xlsx +0 -0
  191. data/examples/colored_series_data.xlsx +0 -0
  192. data/examples/conditional_formatting/getting_barred.xlsx +0 -0
  193. data/examples/example.csv +0 -1000
  194. data/examples/extractive.csv +0 -1
  195. data/examples/extractive.csv~ +0 -1
  196. data/examples/extractive.rb~ +0 -3
  197. data/examples/stack.rb +0 -21
  198. data/examples/stack.rb~ +0 -27
  199. data/examples/stack.xlsx +0 -0
  200. data/examples/~$chart_colors.xlsx +0 -0
  201. data/examples/~$extractive.xlsx +0 -0
  202. data/lib/axlsx/drawing/ax_data_source.rb~ +0 -55
  203. data/lib/axlsx/drawing/data_source.rb~ +0 -51
  204. data/lib/axlsx/drawing/hlink_click.rb~ +0 -0
  205. data/lib/axlsx/drawing/hyperlink.rb~ +0 -64
  206. data/lib/axlsx/drawing/num_data.rb~ +0 -51
  207. data/lib/axlsx/drawing/num_data_source.rb~ +0 -54
  208. data/lib/axlsx/drawing/num_val.rb~ +0 -40
  209. data/lib/axlsx/drawing/picture_locking.rb~ +0 -36
  210. data/lib/axlsx/drawing/ref.rb~ +0 -41
  211. data/lib/axlsx/drawing/str_data.rb~ +0 -58
  212. data/lib/axlsx/drawing/str_val.rb~ +0 -35
  213. data/lib/axlsx/util/cbf.rb +0 -333
  214. data/lib/axlsx/util/cfb.rb~ +0 -201
  215. data/lib/axlsx/util/font_tables.rb~ +0 -0
  216. data/lib/axlsx/util/ms_off_crypto.rb +0 -189
  217. data/lib/axlsx/util/ms_off_crypto.rb~ +0 -3
  218. data/lib/axlsx/util/ms_offcrypto.rb~ +0 -0
  219. data/lib/axlsx/util/parser.rb~ +0 -6
  220. data/lib/axlsx/util/storage.rb~ +0 -0
  221. data/lib/axlsx/workbook/shared_strings_table.rb~ +0 -69
  222. data/lib/axlsx/workbook/worksheet/cfvo.rb~ +0 -0
  223. data/lib/axlsx/workbook/worksheet/col.rb~ +0 -0
  224. data/lib/axlsx/workbook/worksheet/color_scale.rb~ +0 -46
  225. data/lib/axlsx/workbook/worksheet/data_bar.rb~ +0 -0
  226. data/lib/axlsx/workbook/worksheet/icon_set.rb~ +0 -95
  227. data/lib/axlsx/workbook/worksheet/shared_strings_table.rb~ +0 -0
  228. data/lib/axlsx/workbook/worksheet/table.rb~ +0 -97
  229. data/lib/schema/dc.xsd~ +0 -118
  230. data/lib/schema/dcterms.xsd~ +0 -331
  231. data/lib/schema/opc-coreProperties.xsd~ +0 -50
  232. data/test/drawing/tc_data_source.rb~ +0 -30
  233. data/test/drawing/tc_num_data.rb~ +0 -35
  234. data/test/drawing/tc_num_val.rb~ +0 -29
  235. data/test/drawing/tc_str_data.rb~ +0 -30
  236. data/test/drawing/tc_str_val.rb~ +0 -26
  237. data/test/workbook/worksheet/table/tc_table.rb~ +0 -72
  238. data/test/workbook/worksheet/tc_cfvo.rb~ +0 -20
  239. data/test/workbook/worksheet/tc_col.rb~ +0 -10
  240. data/test/workbook/worksheet/tc_color_scale.rb~ +0 -0
  241. data/test/workbook/worksheet/tc_data_bar.rb~ +0 -0
  242. data/test/workbook/worksheet/tc_icon_set.rb~ +0 -0
data/lib/axlsx/package.rb CHANGED
@@ -80,9 +80,8 @@ module Axlsx
80
80
 
81
81
  # Serialize your workbook to disk as an xlsx document.
82
82
  #
83
- # @param [File] output The file you want to serialize your package to
83
+ # @param [String] output The name of the file you want to serialize your package to
84
84
  # @param [Boolean] confirm_valid Validate the package prior to serialization.
85
- # @option options stream indicates if we should be writing to a stream or a file. True for stream, nil for file
86
85
  # @return [Boolean] False if confirm_valid and validation errors exist. True if the package was serialized
87
86
  # @note A tremendous amount of effort has gone into ensuring that you cannot create invalid xlsx documents.
88
87
  # confirm_valid should be used in the rare case that you cannot open the serialized file.
@@ -90,10 +89,15 @@ module Axlsx
90
89
  # @example
91
90
  # # This is how easy it is to create a valid xlsx file. Of course you might want to add a sheet or two, and maybe some data, styles and charts.
92
91
  # # Take a look at the README for an example of how to do it!
93
- # f = File.open('test.xlsx', 'w')
94
- # Package.new.serialize(f)
95
92
  #
96
- # # You will find a file called test.xlsx
93
+ # #serialize to a file
94
+ # p = Axlsx::Package.new
95
+ # # ......add cool stuff to your workbook......
96
+ # p.serialize("example.xlsx")
97
+ #
98
+ # # Serialize to a stream
99
+ # s = p.to_stream()
100
+ # File.open('example_streamed.xlsx', 'w') { |f| f.write(s.read) }
97
101
  def serialize(output, confirm_valid=false)
98
102
  return false unless !confirm_valid || self.validate.empty?
99
103
  Zip::ZipOutputStream.open(output) do |zip|
@@ -152,18 +156,18 @@ module Axlsx
152
156
  # @return [Zip::ZipOutputStream]
153
157
  def write_parts(zip)
154
158
  p = parts
155
- p.each do |part|
156
- unless part[:doc].nil?
157
- zip.put_next_entry(part[:entry]);
158
- entry = ['1.9.2', '1.9.3'].include?(RUBY_VERSION) ? part[:doc].force_encoding('BINARY') : part[:doc]
159
- zip.puts(entry)
160
- end
161
- unless part[:path].nil?
162
- zip.put_next_entry(part[:entry]);
163
- # binread for 1.9.3
164
- zip.write IO.respond_to?(:binread) ? IO.binread(part[:path]) : IO.read(part[:path])
165
- end
159
+ p.each do |part|
160
+ unless part[:doc].nil?
161
+ zip.put_next_entry(part[:entry])
162
+ entry = ['1.9.2', '1.9.3'].include?(RUBY_VERSION) ? part[:doc].force_encoding('BINARY') : part[:doc]
163
+ zip.puts(entry)
164
+ end
165
+ unless part[:path].nil?
166
+ zip.put_next_entry(part[:entry]);
167
+ # binread for 1.9.3
168
+ zip.write IO.respond_to?(:binread) ? IO.binread(part[:path]) : IO.read(part[:path])
166
169
  end
170
+ end
167
171
  zip
168
172
  end
169
173
 
@@ -180,15 +184,24 @@ module Axlsx
180
184
  {:entry => CONTENT_TYPES_PN, :doc => content_types.to_xml_string, :schema => CONTENT_TYPES_XSD},
181
185
  {:entry => WORKBOOK_PN, :doc => workbook.to_xml_string, :schema => SML_XSD}
182
186
  ]
187
+
183
188
  workbook.drawings.each do |drawing|
184
189
  @parts << {:entry => "xl/#{drawing.rels_pn}", :doc => drawing.relationships.to_xml_string, :schema => RELS_XSD}
185
190
  @parts << {:entry => "xl/#{drawing.pn}", :doc => drawing.to_xml_string, :schema => DRAWING_XSD}
186
191
  end
187
192
 
193
+
188
194
  workbook.tables.each do |table|
189
195
  @parts << {:entry => "xl/#{table.pn}", :doc => table.to_xml_string, :schema => SML_XSD}
190
196
  end
191
197
 
198
+ workbook.comments.each do|comment|
199
+ if comment.size > 0
200
+ @parts << { :entry => "xl/#{comment.pn}", :doc => comment.to_xml_string, :schema => SML_XSD }
201
+ @parts << { :entry => "xl/#{comment.vml_drawing.pn}", :doc => comment.vml_drawing.to_xml_string, :schema => nil }
202
+ end
203
+ end
204
+
192
205
  workbook.charts.each do |chart|
193
206
  @parts << {:entry => "xl/#{chart.pn}", :doc => chart.to_xml_string, :schema => DRAWING_XSD}
194
207
  end
@@ -233,14 +246,28 @@ module Axlsx
233
246
  c_types << Axlsx::Override.new(:PartName => "/xl/#{drawing.pn}",
234
247
  :ContentType => DRAWING_CT)
235
248
  end
249
+
236
250
  workbook.charts.each do |chart|
237
251
  c_types << Axlsx::Override.new(:PartName => "/xl/#{chart.pn}",
238
252
  :ContentType => CHART_CT)
239
253
  end
254
+
240
255
  workbook.tables.each do |table|
241
256
  c_types << Axlsx::Override.new(:PartName => "/xl/#{table.pn}",
242
257
  :ContentType => TABLE_CT)
243
258
  end
259
+
260
+ workbook.comments.each do |comment|
261
+ if comment.size > 0
262
+ c_types << Axlsx::Override.new(:PartName => "/xl/#{comment.pn}",
263
+ :ContentType => COMMENT_CT)
264
+ end
265
+ end
266
+
267
+ if workbook.comments.size > 0
268
+ c_types << Axlsx::Default.new(:Extension => "vml", :ContentType => VML_DRAWING_CT)
269
+ end
270
+
244
271
  workbook.worksheets.each do |sheet|
245
272
  c_types << Axlsx::Override.new(:PartName => "/xl/#{sheet.pn}",
246
273
  :ContentType => WORKSHEET_CT)
@@ -30,9 +30,9 @@ module Axlsx
30
30
  attr_reader :TargetMode
31
31
 
32
32
  # creates a new relationship
33
- # @param [String] Type The type of the relationship
34
- # @param [String] Target The target for the relationship
35
- # @option [Symbol] target_mode only accepts :external.
33
+ # @param [String] type The type of the relationship
34
+ # @param [String] target The target for the relationship
35
+ # @option [Symbol] :target_mode only accepts :external.
36
36
  def initialize(type, target, options={})
37
37
  self.Target=target
38
38
  self.Type=type
@@ -10,23 +10,13 @@ require 'axlsx/rels/relationship.rb'
10
10
  def initialize
11
11
  super Relationship
12
12
  end
13
-
13
+
14
14
  def to_xml_string(str = '')
15
15
  str << '<?xml version="1.0" encoding="UTF-8"?>'
16
16
  str << '<Relationships xmlns="' << RELS_R << '">'
17
17
  each_with_index { |rel, index| rel.to_xml_string(index+1, str) }
18
18
  str << '</Relationships>'
19
19
  end
20
- # Serializes the relationships document.
21
- # @return [String]
22
- def to_xml()
23
- builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
24
- xml.Relationships(:xmlns => Axlsx::RELS_R) {
25
- each_with_index { |rel, index| rel.to_xml(xml, "rId#{index+1}") }
26
- }
27
- end
28
- builder.to_xml(:save_with => 0)
29
- end
30
20
 
31
21
  end
32
22
  end
@@ -68,7 +68,7 @@ module Axlsx
68
68
  # @param [String] str
69
69
  # @return [String]
70
70
  def to_xml_string(str = '')
71
- str << '<gradientFill'
71
+ str << '<gradientFill '
72
72
  h = self.instance_values.reject { |k,v| k.to_sym == :stop }
73
73
  str << h.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
74
74
  str << '>'
@@ -133,8 +133,9 @@ module Axlsx
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
135
135
  # @option options [Integer] num_fmt The number format to apply
136
- # @option options [String] format_code The formatting to apply. If this is specified, num_fmt is ignored.
136
+ # @option options [String] format_code The formatting to apply.
137
137
  # @option options [Integer|Hash] border The border style to use.
138
+ # borders support style, color and edges options @see parse_border_options
138
139
  # @option options [String] bg_color The background color to apply to the cell
139
140
  # @option options [Boolean] hidden Indicates if the cell should be hidden
140
141
  # @option options [Boolean] locked Indicates if the cell should be locked
@@ -278,6 +279,10 @@ module Axlsx
278
279
  # @return [Font|Integer]
279
280
  def parse_font_options(options={})
280
281
  return if (options.keys & [:fg_color, :sz, :b, :i, :u, :strike, :outline, :shadow, :charset, :family, :font_name]).empty?
282
+ fonts.first.instance_values.each do |key, value|
283
+ # Thanks for that 1.8.7 - cant do a simple merge...
284
+ options[key.to_sym] = value unless options.keys.include?(key.to_sym)
285
+ end
281
286
  font = Font.new(options)
282
287
  font.color = Color.new(:rgb => options[:fg_color]) if options[:fg_color]
283
288
  font.name = options[:font_name] if options[:font_name]
@@ -298,7 +303,11 @@ module Axlsx
298
303
 
299
304
  # parses Style#add_style options for borders.
300
305
  # @note noop if :border is not specified in options
301
- # @option options [Hash|Integer] A border style definition hash or the index of an existing border. Border style definition hashes must include :style and color: key-value entries and may include an :edges entry that references an array of symbols identifying which border edges you wish to apply the style or any other valid Border initializer options. If the :edges entity is not provided the style is applied to all edges of cells that reference this style.
306
+ # @option options [Hash|Integer] A border style definition hash or the index of an existing border.
307
+ # Border style definition hashes must include :style and :color key-value entries and
308
+ # may include an :edges entry that references an array of symbols identifying which border edges
309
+ # you wish to apply the style or any other valid Border initializer options.
310
+ # If the :edges entity is not provided the style is applied to all edges of cells that reference this style.
302
311
  # @example
303
312
  # #apply a thick red border to the top and bottom
304
313
  # { :border => { :style => :thick, :color => "FFFF0000", :edges => [:top, :bottom] }
@@ -40,10 +40,10 @@ module Axlsx
40
40
  # @param [String] str
41
41
  # @return [String]
42
42
  def to_xml_string(str = '')
43
- attr = self.instance_values.select { |k, v| [:name, :pivot, :table].include? k }
44
- attr[:count] = self.size
43
+ attrs = instance_values.reject { |k, v| ![:name, :pivot, :table].include?(k) }
44
+ attrs[:count] = self.size
45
45
  str << '<tableStyle '
46
- str << attr.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
46
+ str << attrs.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
47
47
  str << '>'
48
48
  each { |table_style_el| table_style_el.to_xml_string(str) }
49
49
  str << '</tableStyle>'
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  module Axlsx
3
2
 
4
3
  # XML Encoding
@@ -31,6 +30,9 @@ module Axlsx
31
30
  # xml schema namespace
32
31
  CORE_NS_XSI = "http://www.w3.org/2001/XMLSchema-instance"
33
32
 
33
+ # Digital signature namespace
34
+ DIGITAL_SIGNATURE_NS = "http://schemas.openxmlformats.org/package/2006/digital-signature"
35
+
34
36
  # spreadsheet drawing namespace
35
37
  XML_NS_XDR = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"
36
38
 
@@ -61,6 +63,9 @@ module Axlsx
61
63
  # core rels namespace
62
64
  CORE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/metadata/core-properties"
63
65
 
66
+ # digital signature rels namespace
67
+ DIGITAL_SIGNATURE_R = "http://schemas.openxmlformats.org/package/2006/relationships/digital- signature/signature"
68
+
64
69
  # styles rels namespace
65
70
  STYLES_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
66
71
 
@@ -76,9 +81,21 @@ module Axlsx
76
81
  # image rels namespace
77
82
  IMAGE_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
78
83
 
79
- # image rels namespace
84
+ # hyperlink rels namespace
80
85
  HYPERLINK_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
81
86
 
87
+ # comment rels namespace
88
+ COMMENT_R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
89
+
90
+ # comment relation for nil target
91
+ COMMENT_R_NULL = "http://purl.oclc.org/ooxml/officeDocument/relationships/comments"
92
+
93
+ #vml drawing relation namespace
94
+ VML_DRAWING_R = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing'
95
+
96
+ # VML Drawing content type
97
+ VML_DRAWING_CT = "application/vnd.openxmlformats-officedocument.vmlDrawing"
98
+
82
99
  # table content type
83
100
  TABLE_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"
84
101
 
@@ -106,9 +123,21 @@ module Axlsx
106
123
  # core content type
107
124
  CORE_CT = "application/vnd.openxmlformats-package.core-properties+xml"
108
125
 
126
+ # digital signature xml content type
127
+ DIGITAL_SIGNATURE_XML_CT = "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml"
128
+
129
+ # digital signature origin content type
130
+ DIGITAL_SIGNATURE_ORIGIN_CT = "application/vnd.openxmlformats-package.digital-signature-origin"
131
+
132
+ # digital signature certificate content type
133
+ DIGITAL_SIGNATURE_CERTIFICATE_CT = "application/vnd.openxmlformats-package.digital-signature-certificate"
134
+
109
135
  # chart content type
110
136
  CHART_CT = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
111
137
 
138
+ # comments content type
139
+ COMMENT_CT = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
140
+
112
141
  # jpeg content type
113
142
  JPEG_CT = "image/jpeg"
114
143
 
@@ -121,6 +150,7 @@ module Axlsx
121
150
  #drawing content type
122
151
  DRAWING_CT = "application/vnd.openxmlformats-officedocument.drawing+xml"
123
152
 
153
+
124
154
  # xml content type extensions
125
155
  XML_EX = "xml"
126
156
 
@@ -172,6 +202,9 @@ module Axlsx
172
202
  # drawing rels part
173
203
  DRAWING_RELS_PN = "drawings/_rels/drawing%d.xml.rels"
174
204
 
205
+ # vml drawing part
206
+ VML_DRAWING_PN = "drawings/vmlDrawing%d.vml"
207
+
175
208
  # drawing part
176
209
  TABLE_PN = "tables/table%d.xml"
177
210
 
@@ -181,6 +214,9 @@ module Axlsx
181
214
  # chart part
182
215
  IMAGE_PN = "media/image%d.%s"
183
216
 
217
+ # comment part
218
+ COMMENT_PN = "comments%d.xml"
219
+
184
220
  # location of schema files for validation
185
221
  SCHEMA_BASE = File.dirname(__FILE__)+'/../../schema/'
186
222
 
@@ -226,9 +262,16 @@ module Axlsx
226
262
  # error message for RegexValidator
227
263
  ERR_REGEX = "Invalid Data. %s does not match %s."
228
264
 
265
+ # error message for RangeValidator
266
+ ERR_RANGE = "Invalid Data. %s must be between %s and %s, (inclusive:%s) you gave: %s"
267
+
229
268
  # error message for sheets that use a name which is longer than 31 bytes
230
269
  ERR_SHEET_NAME_TOO_LONG = "Your worksheet name '%s' is too long. Worksheet names must be 31 characters (bytes) or less"
231
270
 
271
+ # error message for sheets that use a name which includes a colon
272
+
273
+ ERR_SHEET_NAME_COLON_FORBIDDEN = "Your worksheet name '%s' contains a colon, which is not allowed by MS Excel and will cause repair warnings. Please change the name of your sheet."
274
+
232
275
  # error message for duplicate sheet names
233
276
  ERR_DUPLICATE_SHEET_NAME = "There is already a worksheet in this workbook named '%s'. Please use a unique name"
234
277
 
@@ -240,4 +283,90 @@ module Axlsx
240
283
 
241
284
  # error message for invalid angles
242
285
  ERR_ANGLE = "Angles must be a value between -90 and 90. You provided: %s"
286
+
287
+ # error message for non 'integerish' value
288
+ ERR_INTEGERISH = "You value must be, or be castable via to_i, an Integer. You provided %s"
289
+
290
+ # Regex to match forbidden control characters
291
+ # The following will be automatically stripped from worksheets.
292
+ #
293
+ # x00 Null
294
+ # x01 Start Of Heading
295
+ # x02 Start Of Text
296
+ # x03End Of Text
297
+ # x04 End Of Transmission
298
+ # x05 Enquiry
299
+ # x06 Acknowledge
300
+ # x07 Bell
301
+ # x08 Backspace
302
+ # x0B Line Tabulation
303
+ # x0C Form Feed
304
+ # x0E Shift Out
305
+ # x0F Shift In
306
+ # x10 Data Link Escape
307
+ # x11 Device Control One
308
+ # x12 Device Control Two
309
+ # x13 Device Control Three
310
+ # x14 Device Control Four
311
+ # x15 Negative Acknowledge
312
+ # x16 Synchronous Idle
313
+ # x17 End Of Transmission Block
314
+ # x18 Cancel
315
+ # x19 End Of Medium
316
+ # x1A Substitute
317
+ # x1B Escape
318
+ # x1C Information Separator Four
319
+ # x1D Information Separator Three
320
+ # x1E Information Separator Two
321
+ # x1F Information Separator One
322
+ #
323
+ # The following are not dealt with.
324
+ # If you have this in your data, expect excel to blow up!
325
+ #
326
+ # x7F Delete
327
+ # x80 Control 0080
328
+ # x81 Control 0081
329
+ # x82 Break Permitted Here
330
+ # x83 No Break Here
331
+ # x84 Control 0084
332
+ # x85 Next Line (Nel)
333
+ # x86 Start Of Selected Area
334
+ # x87 End Of Selected Area
335
+ # x88 Character Tabulation Set
336
+ # x89 Character Tabulation With Justification
337
+ # x8A Line Tabulation Set
338
+ # x8B Partial Line Forward
339
+ # x8C Partial Line Backward
340
+ # x8D Reverse Line Feed
341
+ # x8E Single Shift Two
342
+ # x8F Single Shift Three
343
+ # x90 Device Control String
344
+ # x91 Private Use One
345
+ # x92 Private Use Two
346
+ # x93 Set Transmit State
347
+ # x94 Cancel Character
348
+ # x95 Message Waiting
349
+ # x96 Start Of Guarded Area
350
+ # x97 End Of Guarded Area
351
+ # x98 Start Of String
352
+ # x99 Control 0099
353
+ # x9A Single Character Introducer
354
+ # x9B Control Sequence Introducer
355
+ # x9C String Terminator
356
+ # x9D Operating System Command
357
+ # x9E Privacy Message
358
+ # x9F Application Program Command
359
+ #
360
+ # The following are allowed:
361
+ #
362
+ # x0A Line Feed (Lf)
363
+ # x0D Carriage Return (Cr)
364
+ # x09 Character Tabulation
365
+ # @see http://www.codetable.net/asciikeycodes
366
+ pattern = "[\x0-\x08\x0B\x0C\x0E-\x1F]"
367
+ pattern= pattern.respond_to?(:encode) ? pattern.encode('UTF-8') : pattern
368
+
369
+ # The regular expression used to remove control characters from worksheets
370
+ CONTROL_CHAR_REGEX = Regexp.new(pattern, 'n')
371
+
243
372
  end
@@ -18,7 +18,7 @@ module Axlsx
18
18
 
19
19
  # Creats a new typed list
20
20
  # @param [Array, Class] type An array of Class objects or a single Class object
21
- # @param [String] serialize The tag name to use in serialization
21
+ # @param [String] serialize_as The tag name to use in serialization
22
22
  # @raise [ArgumentError] if all members of type are not Class objects
23
23
  def initialize type, serialize_as=nil
24
24
  if type.is_a? Array
@@ -43,13 +43,27 @@ module Axlsx
43
43
  def to_ary
44
44
  @list
45
45
  end
46
-
46
+
47
+ alias :to_a :to_ary
48
+
47
49
  # Unlock the list
48
50
  # @return [self]
49
51
  def unlock
50
52
  @locked_at = nil
51
53
  self
52
54
  end
55
+
56
+ # join operator
57
+ # @param [Array] v the array to join
58
+ # @raise [ArgumentError] if any of the values being joined are not
59
+ # one of the allowed types
60
+ # @return [SimpleTypedList]
61
+ def +(v)
62
+ v.each do |item|
63
+ DataTypeValidator.validate "SimpleTypedList.+", @allowed_types, item
64
+ @list << item
65
+ end
66
+ end
53
67
 
54
68
  # Concat operator
55
69
  # @param [Any] v the data to be added
@@ -60,12 +74,7 @@ module Axlsx
60
74
  @list << v
61
75
  @list.size - 1
62
76
  end
63
-
64
- # alternate of << method
65
- # @see <<
66
- def push(v)
67
- self.<< v
68
- end
77
+ alias :push :<<
69
78
 
70
79
  # delete the item from the list
71
80
  # @param [Any] v The item to be deleted.
@@ -149,25 +158,12 @@ module Axlsx
149
158
 
150
159
  def to_xml_string(str = '')
151
160
  classname = @allowed_types[0].name.split('::').last
152
- el_name = serialize_as || (classname[0,1].downcase + classname[1..-1])
161
+ el_name = serialize_as.to_s || (classname[0,1].downcase + classname[1..-1])
153
162
  str << '<' << el_name << ' count="' << @list.size.to_s << '">'
154
163
  @list.each { |item| item.to_xml_string(str) }
155
164
  str << '</' << el_name << '>'
156
165
  end
157
166
 
158
- # Serializes the list
159
- # If the serialize_as property is set, it is used as the parent node name.
160
- # If the serialize_as property is nil, the first item in the list of allowed_types will be used, having the first letter of the class changed to lower case.
161
- # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
162
- # @return [String]
163
- def to_xml(xml)
164
- classname = @allowed_types[0].name.split('::').last
165
- el_name = serialize_as || (classname[0,1].downcase + classname[1..-1])
166
- xml.send(el_name, :count=>@list.size) {
167
- @list.each { |item| item.to_xml(xml) }
168
- }
169
- end
170
-
171
167
  end
172
168
 
173
169
 
@@ -14,6 +14,24 @@ module Axlsx
14
14
  end
15
15
  end
16
16
 
17
+ # Validate that the value provided is between a specific range
18
+ # Note that no data conversions will be done for you!
19
+ # Comparisons will be made using < and > or <= and <= when the inclusive parameter is true
20
+ class RangeValidator
21
+ # @param [String] name The name of what is being validated
22
+ # @param [Any] min The minimum allowed value
23
+ # @param [Any] max The maximum allowed value
24
+ # @param [Any] value The value to be validated
25
+ # @param [Boolean] inclusive Flag indicating if the comparison should be inclusive.
26
+ def self.validate(name, min, max, value, inclusive = true)
27
+ passes = if inclusive
28
+ min <= value && value <= max
29
+ else
30
+ min < value && value < max
31
+ end
32
+ raise ArgumentError, (ERR_RANGE % [value.inspect, min.to_s, max.to_s, inclusive]) unless passes
33
+ end
34
+ end
17
35
  # Validates the value against the regular expression provided.
18
36
  class RegexValidator
19
37
  # @param [String] name The name of what is being validated. This is included in the output when the value is invalid
@@ -45,8 +63,20 @@ module Axlsx
45
63
  true
46
64
  end
47
65
 
66
+
67
+ # Requires that the value can be converted to an integer
68
+ # @para, [Any] v the value to validate
69
+ # @raise [ArgumentError] raised if the value cannot be converted to an integer
70
+ def self.validate_integerish(v)
71
+ raise ArgumentError, (ERR_INTEGERISH % v.inspect) unless (v.respond_to?(:to_i) && v.to_i.is_a?(Integer))
72
+ end
73
+
74
+ # Requires that the value is between -54000000 and 54000000
75
+ # @param [Any] v The value validated
76
+ # @raise [ArgumentError] raised if the value cannot be converted to an integer between the allowed angle values for chart label rotation.
77
+ # @return [Boolean] true if the data is valid
48
78
  def self.validate_angle(v)
49
- raise ArgumentError, (ERR_ANGLE % v.inspect) unless (v >= -5400000 && v <= 5400000)
79
+ raise ArgumentError, (ERR_ANGLE % v.inspect) unless (v.to_i >= -5400000 && v.to_i <= 5400000)
50
80
  end
51
81
  # Requires that the value is a Fixnum or Integer and is greater or equal to 0
52
82
  # @param [Any] v The value validated
@@ -61,7 +91,7 @@ module Axlsx
61
91
  # @raise [ArgumentError] raised if the value is not a Fixnun, Integer, Float value greater or equal to 0
62
92
  # @return [Boolean] true if the data is valid
63
93
  def self.validate_unsigned_numeric(v)
64
- DataTypeValidator.validate("Invalid column width", [Fixnum, Integer, Float], v, lambda { |arg| arg.respond_to?(:>=) && arg >= 0 })
94
+ DataTypeValidator.validate("Invalid column width", [Fixnum, Integer, Float], v, lambda { |arg| arg.respond_to?(:>=) && arg.to_i >= 0 })
65
95
  end
66
96
 
67
97
  # Requires that the value is a Fixnum or Integer
@@ -90,13 +120,34 @@ module Axlsx
90
120
  DataTypeValidator.validate :float, Float, v
91
121
  end
92
122
 
123
+ # Requires that the value is a string containing a positive decimal number followed by one of the following units:
124
+ # "mm", "cm", "in", "pt", "pc", "pi"
125
+ def self.validate_number_with_unit(v)
126
+ RegexValidator.validate "number_with_unit", /\A[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)\Z/, v
127
+ end
128
+
129
+ # Requires that the value is an integer ranging from 10 to 400.
130
+ def self.validate_scale_10_400(v)
131
+ DataTypeValidator.validate "page_scale", [Fixnum, Integer], v, lambda { |arg| arg >= 10 && arg <= 400 }
132
+ end
133
+
134
+ # Requires that the value is an integer ranging from 10 to 400 or 0.
135
+ def self.validate_scale_0_10_400(v)
136
+ DataTypeValidator.validate "page_scale", [Fixnum, Integer], v, lambda { |arg| arg == 0 || (arg >= 10 && arg <= 400) }
137
+ end
138
+
139
+ # Requires that the value is one of :default, :landscape, or :portrait.
140
+ def self.validate_page_orientation(v)
141
+ RestrictionValidator.validate "page_orientation", [:default, :landscape, :portrait], v
142
+ end
143
+
93
144
  # Requires that the value is valid pattern type.
94
145
  # valid pattern types must be one of :none, :solid, :mediumGray, :darkGray, :lightGray, :darkHorizontal, :darkVertical, :darkDown,
95
146
  # :darkUp, :darkGrid, :darkTrellis, :lightHorizontal, :lightVertical, :lightDown, :lightUp, :lightGrid, :lightTrellis, :gray125, or :gray0625.
96
147
  # @param [Any] v The value validated
97
148
  def self.validate_pattern_type(v)
98
149
  RestrictionValidator.validate :pattern_type, [:none, :solid, :mediumGray, :darkGray, :lightGray, :darkHorizontal, :darkVertical, :darkDown, :darkUp, :darkGrid,
99
- :darkTrellis, :lightHorizontal, :lightVertical, :lightDown, :lightUp, :lightGrid, :lightTrellis, :gray125, :gray0625], v
150
+ :darkTrellis, :lightHorizontal, :lightVertical, :lightDown, :lightUp, :lightGrid, :lightTrellis, :gray125, :gray0625], v
100
151
  end
101
152
 
102
153
  # Requires that the value is one of the ST_TimePeriod types
@@ -104,8 +155,6 @@ module Axlsx
104
155
  # thisMonth, lastMonth, nextMonth, thisWeek, lastWeek, nextWeek
105
156
  def self.validate_time_period_type(v)
106
157
  RestrictionValidator.validate :time_period_type, [:today, :yesterday, :tomorrow, :last7Days, :thisMonth, :lastMonth, :nextMonth, :thisWeek, :lastWeek, :nextWeek], v
107
-
108
-
109
158
  end
110
159
 
111
160
  # Requires that the value is one of the valid ST_IconSet types
@@ -150,7 +199,7 @@ module Axlsx
150
199
  # Requires that the value is a valid scatterStyle
151
200
  # must be one of :none | :line | :lineMarker | :marker | :smooth | :smoothMarker
152
201
  # must be one of "none" | "line" | "lineMarker" | "marker" | "smooth" | "smoothMarker"
153
- # @param [Symbol|String] the value to validate
202
+ # @param [Symbol|String] v the value to validate
154
203
  def self.validate_scatter_style(v)
155
204
  Axlsx::RestrictionValidator.validate "ScatterChart.scatterStyle", [:none, :line, :lineMarker, :marker, :smooth, :smoothMarker], v.to_sym
156
205
  end
@@ -169,17 +218,17 @@ module Axlsx
169
218
  end
170
219
 
171
220
  # Requires that the value is a valid content_type
172
- # TABLE_CT, WORKBOOK_CT, APP_CT, RELS_CT, STYLES_CT, XML_CT, WORKSHEET_CT, SHARED_STRINGS_CT, CORE_CT, CHART_CT, DRAWING_CT are allowed
221
+ # TABLE_CT, WORKBOOK_CT, APP_CT, RELS_CT, STYLES_CT, XML_CT, WORKSHEET_CT, SHARED_STRINGS_CT, CORE_CT, CHART_CT, DRAWING_CT, COMMENT_CT are allowed
173
222
  # @param [Any] v The value validated
174
223
  def self.validate_content_type(v)
175
- RestrictionValidator.validate :content_type, [TABLE_CT, WORKBOOK_CT, APP_CT, RELS_CT, STYLES_CT, XML_CT, WORKSHEET_CT, SHARED_STRINGS_CT, CORE_CT, CHART_CT, JPEG_CT, GIF_CT, PNG_CT, DRAWING_CT], v
224
+ RestrictionValidator.validate :content_type, [TABLE_CT, WORKBOOK_CT, APP_CT, RELS_CT, STYLES_CT, XML_CT, WORKSHEET_CT, SHARED_STRINGS_CT, CORE_CT, CHART_CT, JPEG_CT, GIF_CT, PNG_CT, DRAWING_CT, COMMENT_CT, VML_DRAWING_CT], v
176
225
  end
177
226
 
178
227
  # Requires that the value is a valid relationship_type
179
228
  # XML_NS_R, TABLE_R, WORKBOOK_R, WORKSHEET_R, APP_R, RELS_R, CORE_R, STYLES_R, CHART_R, DRAWING_R, IMAGE_R, HYPERLINK_R, SHARED_STRINGS_R are allowed
180
229
  # @param [Any] v The value validated
181
230
  def self.validate_relationship_type(v)
182
- RestrictionValidator.validate :relationship_type, [XML_NS_R, TABLE_R, WORKBOOK_R, WORKSHEET_R, APP_R, RELS_R, CORE_R, STYLES_R, CHART_R, DRAWING_R, IMAGE_R, HYPERLINK_R, SHARED_STRINGS_R], v
231
+ RestrictionValidator.validate :relationship_type, [XML_NS_R, TABLE_R, WORKBOOK_R, WORKSHEET_R, APP_R, RELS_R, CORE_R, STYLES_R, CHART_R, DRAWING_R, IMAGE_R, HYPERLINK_R, SHARED_STRINGS_R, COMMENT_R, VML_DRAWING_R, COMMENT_R_NULL], v
183
232
  end
184
233
 
185
234
  # Requires that the value is a valid table element type
@@ -189,4 +238,46 @@ module Axlsx
189
238
  RestrictionValidator.validate :table_element_type, [:wholeTable, :headerRow, :totalRow, :firstColumn, :lastColumn, :firstRowStripe, :secondRowStripe, :firstColumnStripe, :secondColumnStripe, :firstHeaderCell, :lastHeaderCell, :firstTotalCell, :lastTotalCell, :firstSubtotalColumn, :secondSubtotalColumn, :thirdSubtotalColumn, :firstSubtotalRow, :secondSubtotalRow, :thirdSubtotalRow, :blankRow, :firstColumnSubheading, :secondColumnSubheading, :thirdColumnSubheading, :firstRowSubheading, :secondRowSubheading, :thirdRowSubheading, :pageFieldLabels, :pageFieldValues], v
190
239
  end
191
240
 
241
+ # Requires that the value is a valid data_validation_error_style
242
+ # :information, :stop, :warning
243
+ # @param [Any] v The value validated
244
+ def self.validate_data_validation_error_style(v)
245
+ RestrictionValidator.validate :validate_data_validation_error_style, [:information, :stop, :warning], v
246
+ end
247
+
248
+ # Requires that the value is valid data validation operator.
249
+ # valid operators must be one of lessThan, lessThanOrEqual, equal,
250
+ # notEqual, greaterThanOrEqual, greaterThan, between, notBetween
251
+ # @param [Any] v The value validated
252
+ def self.validate_data_validation_operator(v)
253
+ RestrictionValidator.validate :data_validation_operator, [:lessThan, :lessThanOrEqual, :equal, :notEqual, :greaterThanOrEqual, :greaterThan, :between, :notBetween], v
254
+ end
255
+
256
+ # Requires that the value is valid data validation type.
257
+ # valid types must be one of custom, data, decimal, list, none, textLength, time, whole
258
+ # @param [Any] v The value validated
259
+ def self.validate_data_validation_type(v)
260
+ RestrictionValidator.validate :data_validation_type, [:custom, :data, :decimal, :list, :none, :textLength, :time, :whole], v
261
+ end
262
+
263
+ # Requires that the value is a valid sheet view type.
264
+ # valid types must be one of normal, page_break_preview, page_layout
265
+ # @param [Any] v The value validated
266
+ def self.validate_sheet_view_type(v)
267
+ RestrictionValidator.validate :sheet_view_type, [:normal, :page_break_preview, :page_layout], v
268
+ end
269
+
270
+ # Requires that the value is a valid active pane type.
271
+ # valid types must be one of bottom_left, bottom_right, top_left, top_right
272
+ # @param [Any] v The value validated
273
+ def self.validate_pane_type(v)
274
+ RestrictionValidator.validate :active_pane_type, [:bottom_left, :bottom_right, :top_left, :top_right], v
275
+ end
276
+
277
+ # Requires that the value is a valid split state type.
278
+ # valid types must be one of frozen, frozen_split, split
279
+ # @param [Any] v The value validated
280
+ def self.validate_split_state_type(v)
281
+ RestrictionValidator.validate :split_state_type, [:frozen, :frozen_split, :split], v
282
+ end
192
283
  end