robust_excel_ole 1.31 → 1.32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +20 -1
  3. data/README.rdoc +118 -18
  4. data/___dummy_workbook.xls +0 -0
  5. data/benchmarking/creek_example.rb +1 -1
  6. data/benchmarking/roo_example.rb +1 -1
  7. data/benchmarking/simple_xlsx_reader_example.rb +1 -1
  8. data/benchmarking/spreadsheet_example.rb +1 -1
  9. data/docs/README_excel.rdoc +16 -24
  10. data/docs/README_listobjects.rdoc +176 -0
  11. data/docs/README_open.rdoc +12 -12
  12. data/docs/README_ranges.rdoc +72 -55
  13. data/docs/README_save_close.rdoc +3 -3
  14. data/docs/README_sheet.rdoc +18 -13
  15. data/examples/example_ruby_library.rb +2 -2
  16. data/examples/introductory_examples/example_range.rb +2 -2
  17. data/examples/modifying_sheets/example_access_sheets_and_cells.rb +6 -6
  18. data/examples/modifying_sheets/example_add_names.rb +1 -1
  19. data/examples/modifying_sheets/example_concating.rb +1 -1
  20. data/examples/modifying_sheets/example_copying.rb +2 -2
  21. data/examples/modifying_sheets/example_listobjects.rb +86 -0
  22. data/examples/modifying_sheets/example_naming.rb +1 -1
  23. data/examples/modifying_sheets/example_ranges.rb +1 -1
  24. data/examples/open_save_close/example_control_to_excel.rb +1 -1
  25. data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +1 -1
  26. data/examples/open_save_close/example_if_obstructed_save.rb +3 -3
  27. data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
  28. data/examples/open_save_close/example_if_unsaved_forget.rb +3 -3
  29. data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -4
  30. data/examples/open_save_close/example_read_only.rb +1 -1
  31. data/examples/open_save_close/example_simple.rb +1 -1
  32. data/examples/open_save_close/example_unobtrusively.rb +3 -3
  33. data/lib/robust_excel_ole/address_tool.rb +54 -44
  34. data/lib/robust_excel_ole/base.rb +4 -6
  35. data/lib/robust_excel_ole/bookstore.rb +2 -16
  36. data/lib/robust_excel_ole/cell.rb +16 -21
  37. data/lib/robust_excel_ole/excel.rb +131 -186
  38. data/lib/robust_excel_ole/general.rb +82 -55
  39. data/lib/robust_excel_ole/list_object.rb +182 -109
  40. data/lib/robust_excel_ole/list_row.rb +65 -38
  41. data/lib/robust_excel_ole/range.rb +125 -93
  42. data/lib/robust_excel_ole/range_owners.rb +52 -66
  43. data/lib/robust_excel_ole/version.rb +1 -1
  44. data/lib/robust_excel_ole/workbook.rb +168 -176
  45. data/lib/robust_excel_ole/worksheet.rb +177 -141
  46. data/robust_excel_ole.gemspec +4 -3
  47. data/spec/bookstore_spec.rb +2 -3
  48. data/spec/cell_spec.rb +9 -9
  49. data/spec/data/more_data/workbook.xls +0 -0
  50. data/spec/excel_spec.rb +132 -85
  51. data/spec/general_spec.rb +47 -15
  52. data/spec/list_object_spec.rb +258 -145
  53. data/spec/list_row_spec.rb +218 -0
  54. data/spec/range_spec.rb +76 -29
  55. data/spec/spec_helper.rb +15 -1
  56. data/spec/workbook_spec.rb +75 -34
  57. data/spec/workbook_specs/workbook_all_spec.rb +2 -1
  58. data/spec/workbook_specs/workbook_misc_spec.rb +20 -13
  59. data/spec/workbook_specs/workbook_open_spec.rb +47 -45
  60. data/spec/workbook_specs/workbook_save_spec.rb +21 -22
  61. data/spec/workbook_specs/workbook_sheet_spec.rb +3 -3
  62. data/spec/workbook_specs/workbook_unobtr_spec.rb +303 -303
  63. data/spec/worksheet_spec.rb +522 -318
  64. metadata +37 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 304ee26bf15359eec5e54ac846203b60f3d7419e54779ced816182f76f6e9b46
4
- data.tar.gz: 0ea8a4d763d10b286cd29610261b815ca51308cb364483935c5c396fa31e2c67
3
+ metadata.gz: f56e6aaeeeec6c073cc4f871ea99185428523959c420e1165d199792979074c5
4
+ data.tar.gz: 79dd7f6ea160e0045592a3dd8ae31a5b8a162c71b6986dcbcef157eba54c93b4
5
5
  SHA512:
6
- metadata.gz: ae94a7357c87e0069e15e279a0eb420df939840192fc2e674f8e3c1890bebdaa7c49d37e0d8a888939f8009109fc7fabf0105e7b76f6b75f168431cb58d2e0e1
7
- data.tar.gz: 450ebbad0840bd557c652cc2fa9027dee4a45114a6d3b8ea0065fd5120e9b916ad26ad63a1f97088bb148f1dc07cff7fd9cdf8c9b956e6a0ee2295be4434dec2
6
+ metadata.gz: 894959ff3e8c48c8413bbb137013cf8ad7612bb991292f1461b1df9b3371d15c16132ecf0df0dbf78403171381064cfb43d9400604bc2155214f8aa2a514ea7c
7
+ data.tar.gz: 508b37f27ef7c0e554b565f21263386e1b180cb5269f6a843b2da927eaa3f6eebe5a111a362d5dc96de4726a1c3648673b062b02589739eb7e5ff2a0bb7f59cc
data/Changelog CHANGED
@@ -1,6 +1,25 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [1.32] 2021-23-04
5
+
6
+ ### Added
7
+ - Excel#each
8
+ - ListObject#each, value, rows_number, position, ==
9
+ - ListObject#[] extended with options
10
+ - ListRow#to_h, to_a, values=, keys_values, ==
11
+ - RangeOwners#names
12
+ - Worksheet#each_cell
13
+
14
+ ### Changed
15
+ - Worksheet#[]: returning range values given address or defined name (instead of returning a cell when giving address)
16
+ - Worksheet#each traversing row values instead of cells
17
+ - Excel#excels_number renamed to #instance_count
18
+ - Excel#known_excels_number renamed to #known_instance_count
19
+ - Excel#known_excel_instance renamed to #known_running_instance
20
+ - Excel#known_excel_instances renamed to #known_running_instances
21
+ - RangeOwners#rename_range renamed to #rename_name
22
+
4
23
  ## [1.31] 2021-14-01
5
24
 
6
25
  ### Added
@@ -192,7 +211,7 @@ All notable changes to this project will be documented in this file.
192
211
  ## [1.1.4] - 2018-10-6
193
212
 
194
213
  ### Added
195
- - Book#open: for the options: simplifiaction: :force can be left out
214
+ - Book#open: for the options: simplifiction: :force can be left out
196
215
  - Excel#for_this_instance
197
216
  - Excel#for_all_workbooks
198
217
  - Book#for_this_workbooks
data/README.rdoc CHANGED
@@ -1,3 +1,29 @@
1
+ = News
2
+
3
+ == New Interface of #[]
4
+
5
+ Worksheet#[] now returns a value instead of a range, e.g.
6
+
7
+ worksheet[1,1]
8
+ # => "foo"
9
+
10
+ Transformation: To yield the range, write range() instead of (). For example,
11
+
12
+ worksheet.range(1,1)
13
+
14
+ or
15
+
16
+ worksheet.range([1,1])
17
+
18
+ This returns the range of cell with address 1,1.
19
+
20
+ With this new interface, we want to be compatible with the standard syntax of other known Excel libraries, e.g. +spreadsheet+ or +axlsx+.
21
+
22
+ == Using own WIN32OLE objects
23
+
24
+ If you use WIN32OLE objects and define your own methods, please use upper-case method names.
25
+ The reason is that we extend the class WIN32OLE such that RobustExcelOle methods can be applied to WIN32OLE objects, such the RobustExcelOle objects and their wrapped WIN32OLE objects are interchangeable. We want to develop a refinement such that the name space is not being desturbed.
26
+
1
27
  = RobustExcelOle
2
28
 
3
29
  RobustExcelOle helps controlling Excel.
@@ -123,7 +149,7 @@ RobustExcelOle allows unobtrusively reading and modifying workbooks, i.e. access
123
149
 
124
150
  We can also create a new, empty workbook.
125
151
 
126
- Workbook.create('spec/data/new_workbook.xls', :visible => true)
152
+ Workbook.create('spec/data/new_workbook.xls', visible: true)
127
153
 
128
154
  Moreover, we can open the workbook using a block, similar to, e.g., +File.open+.
129
155
 
@@ -133,15 +159,15 @@ Moreover, we can open the workbook using a block, similar to, e.g., +File.open+.
133
159
 
134
160
  Once we have a workbook, we can set some options, e.g.
135
161
 
136
- workbook.for_this_workbook(:visible => true, :read_only => false)
162
+ workbook.for_this_workbook(visible: true, read_only: false)
137
163
 
138
164
  We can also open the workbook and provide the options in one step, e.g.
139
165
 
140
- workbook = Workbook.open('spec/data/workbook.xls', :visible => true)
166
+ workbook = Workbook.open('spec/data/workbook.xls', visible: true)
141
167
 
142
168
  or, using abbreviations,
143
169
 
144
- workbook = Workbook.open('spec/data/workbook.xls', :v => true)
170
+ workbook = Workbook.open('spec/data/workbook.xls', v: true)
145
171
 
146
172
  Note that +Workbook.open+ can also connect to workbooks which were not opened via RobustExcelOle (but had been opened before by some user).
147
173
 
@@ -161,7 +187,7 @@ Finally we can close the workbook
161
187
 
162
188
  or save and close the workbook in one step.
163
189
 
164
- workbook.close(:if_unsaved => :save)
190
+ workbook.close(if_unsaved: :save)
165
191
 
166
192
  For more details about saving and closing workbooks see
167
193
  {README_save_close}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_save_close.rdoc]
@@ -175,7 +201,7 @@ We can start a new Excel instance with
175
201
 
176
202
  or
177
203
 
178
- excel1 = Excel.new(:reuse => false)
204
+ excel1 = Excel.new(reuse: false)
179
205
 
180
206
  We can also obtain an Excel object by connecting to the already running Excel instance.
181
207
 
@@ -183,7 +209,7 @@ We can also obtain an Excel object by connecting to the already running Excel in
183
209
 
184
210
  or
185
211
 
186
- excel2 = Excel.new(:reuse => true)
212
+ excel2 = Excel.new(reuse: true)
187
213
 
188
214
  We close the Excel instance using
189
215
 
@@ -191,11 +217,11 @@ We close the Excel instance using
191
217
 
192
218
  Closed Excel instances can be reopened.
193
219
 
194
- excel1.recreate(:reopen_workbooks => true, :visible => true)
220
+ excel1.recreate(reopen_workbooks: true, visible: true)
195
221
 
196
222
  Closing all Excel instances is done by
197
223
 
198
- Excel.close_all(:if_unsaved => :forget)
224
+ Excel.close_all(if_unsaved: :forget)
199
225
 
200
226
  For hard terminating all Excel processes we can use
201
227
 
@@ -214,12 +240,12 @@ For example, suppose we want to open a workbook.
214
240
 
215
241
  Now we want to open another workbook in a different Excel instance.
216
242
 
217
- workbook2 = Workbook.open('spec/data/different_workbook.xls', :excel => :new)
243
+ workbook2 = Workbook.open('spec/data/different_workbook.xls', excel: :new)
218
244
 
219
245
  We can also create a third Excel instance and open another workbook in this instance.
220
246
 
221
247
  excel1 = Excel.create
222
- workbook3 = Workbook.open('spec/data/another_workbook.xls', :excel => excel1)
248
+ workbook3 = Workbook.open('spec/data/another_workbook.xls', excel: excel1)
223
249
 
224
250
  A workbook is opened by default in the Excel instance where it was open before most recently.
225
251
 
@@ -228,11 +254,11 @@ A workbook is opened by default in the Excel instance where it was open before m
228
254
 
229
255
  If this Excel instance is damaged or closed, then options control whether the workbook shall be opened in the current (active), a new or a given Excel instance.
230
256
 
231
- workbook1 = Workbook.open('spec/data/workbook.xls', :default => {:excel => :new})
257
+ workbook1 = Workbook.open('spec/data/workbook.xls', default: {excel: new})
232
258
 
233
259
  Without the option +:default+, the workbook can be forced to be opened in the current, new or given Excel instance, no matter if and where it was opened before, e.g.
234
260
 
235
- workbook2 = Workbook.open('spec/data/workbook.xls', :excel => excel1)
261
+ workbook2 = Workbook.open('spec/data/workbook.xls', excel: excel1)
236
262
 
237
263
  === Managing conflicts with unsaved and blocking workbooks
238
264
 
@@ -240,13 +266,13 @@ RobustExcelOle enables processing workbooks, while still supporting user's inter
240
266
 
241
267
  For example, suppose we want to process a list of workbooks. RobustExcelOle allows to rapidly open, manipulate, close and save these workbooks. Now assume, the workbook "workbook.xls" is being processed, while the user has already opened this workbook, has modified but not saved it yet. Excel would prompt a message and ask the user what to do. RobustExcelOle solves this conflict by using an option that states whether the changes of the user should be saved (accepted) or discarded (forgotten) before opening the workbook, e.g.
242
268
 
243
- workbook = Workbook.open('workbook.xls', :if_unsaved => :accept)
269
+ workbook = Workbook.open('workbook.xls', if_unsaved: :accept)
244
270
 
245
271
  Similarly, if the user has opened a workbook that has the same name but a different path, the conflict can be solved via an option.
246
272
 
247
273
  workbook1 = Workbook.open('spec/data/workbook.xls')
248
274
  # do something
249
- workbook2 = Workbook.open('spec/data/more/workbook.xls', :if_blocked => :forget)
275
+ workbook2 = Workbook.open('spec/data/more/workbook.xls', if_blocked: :forget)
250
276
 
251
277
  For more details about opening and closing workbooks in Excel instances see {README_open}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_open.rdoc]
252
278
 
@@ -277,7 +303,7 @@ We can read and change the worksheet name.
277
303
 
278
304
  We can copy the first worksheet, name it and add it before the third worksheet.
279
305
 
280
- workbook.add_or_copy_sheet(sheet, :as => "copied_name, :before => workbook.last_sheet)
306
+ workbook.add_or_copy_sheet(sheet, as: "copied_name, before: workbook.last_sheet)
281
307
 
282
308
  For more details about processing worksheets see {README_sheet}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_sheet.rdoc]
283
309
 
@@ -297,7 +323,7 @@ and the third column
297
323
 
298
324
  We can read the first cell, using
299
325
 
300
- worksheet[1,1].value # => "foo"
326
+ worksheet[1,1]. # => "foo"
301
327
 
302
328
  or
303
329
 
@@ -318,6 +344,76 @@ and set another value to that range.
318
344
  For more details about reading and writing contents of cells and ranges see {README_ranges}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_ranges.rdoc]
319
345
 
320
346
 
347
+ === List Objects (Tables)
348
+
349
+ We can define a list object (or table) from scratch
350
+
351
+ table = ListObject.new(worksheet, "table 1", [1,1], 3, ["Person","AmountSales"])
352
+
353
+ or get a given list object in a worksheet given its table number or name.
354
+
355
+ table = worksheet.table(1)
356
+
357
+ or
358
+
359
+ table = worksheet.table("table1")
360
+
361
+ A list row can be accessed by providing either the row number or a key, i.e. hash of column name - value pairs, e.g.
362
+
363
+ row1 = table[1]
364
+
365
+ row1 = table[{"Number": 1, "Person": "John"}]
366
+
367
+ You can get all or a maximal number of list rows matching the key.
368
+
369
+ rows = table[{"Number": 1}, limit: 2]
370
+ rows = table[{"Number": 1}, limit: nil]
371
+
372
+ Now we can set value of a cell of the table with help of methods that are equal to or are underscored variants of the column names, e.g.
373
+
374
+ row1.person = "John"
375
+
376
+ or
377
+
378
+ row1["Person"] = "John"
379
+
380
+ Similarly you can get the values. We can also read all values in a row.
381
+
382
+ table[1].to_a
383
+ # => ["John", 40]
384
+
385
+ table[1].to_h
386
+ # => {"Person": "John", "AmountSales": 40}
387
+
388
+ We can set the values in a whole row.
389
+
390
+ table[1].values = ["Herber", 80]
391
+
392
+ Similarly, we can read and set the values in a whole column, e.g.
393
+
394
+ table.column_values("Person")
395
+ # => ["John", "Peter"]
396
+
397
+ and
398
+
399
+ table.set_column_values(1, ["Herbert","Paul"])
400
+
401
+ We can add and delete rows and columns, supplying optionally their name, the position and contents.
402
+
403
+ table.add_column("column_name", 3, ["John", "Paul"])
404
+ table.add_row(3, ["John", 40, 2, 2004])
405
+
406
+ table.delete_column_values("column_name")
407
+ table[2].delete_values
408
+
409
+ Finally we can delete empty rows and columns.
410
+
411
+ table.delete_empty_rows
412
+ table.delete_empty_columns
413
+
414
+ For more details about using and processing list objects see {README_listobjects}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_listobjects.rdoc]
415
+
416
+
321
417
  === More features
322
418
 
323
419
  1. The method +General.change_current_binding+ allows to change the value of self within the current binding, while preserving the local variables, without starting another repl. Assume, +object+ shall be the self, then you would put
@@ -335,7 +431,7 @@ or
335
431
  However, this command also starts another pry repl (with another binding). Moreover, local variables in the previous binding are forgotten.
336
432
 
337
433
 
338
- 2. The class Win32Ole is being extended such that RobustExcelOle methods can be applied to Win32Ole objects. As mentioned above, the RobustExcelOle objects are wrapper of corresponding WIN32OLE objects. So the RobustExcelOle objects and their wrapped Win32Ole objects are interchangeable. One example would be
434
+ 2. The class Win32Ole is being extended such that RobustExcelOle methods can be applied to WIN32OLE objects. As mentioned above, the RobustExcelOle objects are wrapper of corresponding WIN32OLE objects. So the RobustExcelOle objects and their wrapped WIN32OLE objects are interchangeable. One example would be
339
435
 
340
436
  range.ole_range.copy([4,3])
341
437
 
@@ -345,6 +441,10 @@ Likewise it is possible to convert ("type-lift") Win32Ole objects into the corre
345
441
 
346
442
  range = sheet.Names.Item("firstcell").to_reo
347
443
 
444
+ === Design issues
445
+
446
+ We don't consider active worksheets or workbooks in our implementation, because this has been proven to be very error-prone.
447
+
348
448
  === Examples
349
449
 
350
450
  You can run the examples included in the directory +examples+, e.g.
Binary file
@@ -10,7 +10,7 @@ start_time = Time.now
10
10
  workbook = Creek::Book.new './sample_excel_files/xlsx_500_rows.xlsx'
11
11
 
12
12
  worksheets = workbook.sheets
13
- puts "Found #{worksheets.count} worksheets"
13
+ puts "Found #{worksheets.size} worksheets"
14
14
 
15
15
  worksheets.each do |worksheet|
16
16
  puts "Reading: #{worksheet.name}"
@@ -9,7 +9,7 @@ start_time = Time.now
9
9
  workbook = Roo::Spreadsheet.open './sample_excel_files/xlsx_500_rows.xlsx'
10
10
 
11
11
  worksheets = workbook.sheets
12
- puts "Found #{worksheets.count} worksheets"
12
+ puts "Found #{worksheets.size} worksheets"
13
13
 
14
14
  worksheets.each do |worksheet|
15
15
  puts "Reading: #{worksheet}"
@@ -10,7 +10,7 @@ start_time = Time.now
10
10
  workbook = SimpleXlsxReader.open './sample_excel_files/xlsx_500_rows.xlsx'
11
11
 
12
12
  worksheets = workbook.sheets
13
- puts "Found #{worksheets.count} worksheets"
13
+ puts "Found #{worksheets.size} worksheets"
14
14
 
15
15
  worksheets.each do |worksheet|
16
16
  puts "Reading: #{worksheet.name}"
@@ -11,7 +11,7 @@ start_time = Time.now
11
11
  workbook = Spreadsheet.open './sample_excel_files/xls_25000_rows.xls'
12
12
 
13
13
  worksheets = workbook.worksheets
14
- puts "Found #{worksheets.count} worksheets"
14
+ puts "Found #{worksheets.size} worksheets"
15
15
 
16
16
 
17
17
  worksheets.each do |worksheet|
@@ -12,7 +12,7 @@ You can create a new Excel instance by
12
12
 
13
13
  or
14
14
 
15
- excel1 = Excel.new(:reuse => false)
15
+ excel1 = Excel.new(reuse: false)
16
16
 
17
17
  In case you want to reuse an already running Excel instance, write
18
18
 
@@ -20,7 +20,7 @@ In case you want to reuse an already running Excel instance, write
20
20
 
21
21
  or
22
22
 
23
- excel2 = Excel.new(:reuse => true)
23
+ excel2 = Excel.new(reuse: true)
24
24
 
25
25
  Options of the methods +create+ and +new+ are +:reuse+ (+true+, +false+), +:visible+ (+true+, +false+), +:displayalerts+ (+true+, +false+, +:if_visible+), +:calculation+ (+:manual+, +:automatic+, +nil+) and +:screenupdating+ (+true+, +false+).
26
26
 
@@ -28,7 +28,7 @@ The option +:calculation+ specifies, whether the calculation mode is being force
28
28
 
29
29
  You can also type-lift an Excel instance represented as WIN32OLE object to an Excel object.
30
30
 
31
- excel = Excel.new(win32ole_object, :visible => true)
31
+ excel = Excel.new(win32ole_object, visible: true)
32
32
 
33
33
  Once you have got an Excel object, you can apply all VBA methods that you would apply to a VBA Application object
34
34
  (see https://docs.microsoft.com/en-us/office/vba/api/excel.application(object)#methods).
@@ -40,17 +40,17 @@ You can set all options in a given Excel instance
40
40
 
41
41
  excel = Excel.current
42
42
 
43
- excel.for_this_instance(:visible => true, :displayalerts => true, :calculation => :manual)
43
+ excel.set_options(visible: true, displayalerts: true, calculation: :manual)
44
44
 
45
45
  === Making an Excel visible or invisible
46
46
 
47
47
  You can create a new Excel instance and make it visible.
48
48
 
49
- excel1 = Excel.create(:visible => true)
49
+ excel1 = Excel.create(visible: true)
50
50
 
51
51
  or
52
52
 
53
- excel1 = Excel.new(:reuse => false, :visible => true)
53
+ excel1 = Excel.new(reuse: false, visible: true)
54
54
 
55
55
  or
56
56
 
@@ -62,7 +62,7 @@ or
62
62
 
63
63
  You can enable DisplayAlerts with, e.g.
64
64
 
65
- excel1 = Excel.new(:reuse => true, :displayalerts => true)
65
+ excel1 = Excel.new(reuse: true, displayalerts: true)
66
66
 
67
67
  or
68
68
 
@@ -99,30 +99,22 @@ You can do it in a block:
99
99
 
100
100
  You can set options for all workbooks of an Excel instance.
101
101
 
102
- excel.for_all_workooks(:visible => true, :read_only => true)
102
+ excel.each_workook(visible: true, read_only: true)
103
103
 
104
104
 
105
- === Showing and traversing through all workbooks
105
+ === Showing and traversing all workbooks
106
106
 
107
- You can yield an array of all Workbook objects of an Excel instance.
107
+ The method +each+ provides an enumerator traversing all workbook objects. You can yield an array of all Workbook objects of an Excel instance, by applying +to_a+ or
108
108
 
109
109
  excel.workbooks
110
110
 
111
- You can access all Workbook objects by using the methods Excel#each_workbook and Excel#each_workbook_with_index. Here are some examples:
111
+ You can access all Workbook objects supplying options by using the methods Excel#each_workbook and Excel#each_workbook_with_index. Here are some examples:
112
112
 
113
- excel.each_workbook {|w| puts w.filename}
113
+ excel.each_workbook(displayalerts: true) {|w| puts w.filename}
114
114
 
115
115
  and
116
116
 
117
- excel.each_workbook.with_index {|w,i| puts w,i }
118
-
119
- With help of these methods you can also supply options, e.g. without a block,
120
-
121
- excel.each_workbook(:visible => true)
122
-
123
- or, with a block,
124
-
125
- excel.each_workbook(:visible => true) {|w| puts w}
117
+ excel.each_workbook.with_index(displayalerts: true) {|w,i| puts w,i }
126
118
 
127
119
  === Accessing the active workbook
128
120
 
@@ -143,7 +135,7 @@ The method +close has the option +:if_unsaved+ with the values +:raise+, +:save+
143
135
 
144
136
  For example, if you want to close an Excel instance and save unsaved workbooks, use
145
137
 
146
- excel.close(:if_unsaved => :save)
138
+ excel.close(if_unsaved: :save)
147
139
 
148
140
  === Recreating an Excel instance
149
141
 
@@ -154,7 +146,7 @@ Closed Excel instances can also be reopened. This includes reopening all workboo
154
146
 
155
147
  The options are +:reopen_workbooks+, +:visible+ and +:displayalerts+.
156
148
 
157
- excel.recreate(:reopen_workbooks => true, :visible => true, :displayalerts => true)
149
+ excel.recreate(reopen_workbooks: true, visible: true, displayalerts: true)
158
150
 
159
151
  === Providing Excel instances
160
152
 
@@ -168,7 +160,7 @@ Providing all Excel instances (opened via RobustExcelOle) as objects of the clas
168
160
 
169
161
  This method has the option +:if_unsaved+ as described above. For example, if you want to close all Excel instances containing saved workbooks and raise an error for Excel instances with unsaved workbooks, use
170
162
 
171
- Excel.close_all(:if_unsaved => :raise)
163
+ Excel.close_all(if_unsaved: :raise)
172
164
 
173
165
  === Terminating all Excel processes
174
166