robust_excel_ole 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Changelog +15 -0
- data/README.rdoc +128 -63
- data/README_detail.rdoc +130 -60
- data/examples/edit_sheets/example_access_sheets_and_cells.rb +1 -1
- data/examples/edit_sheets/example_adding_sheets.rb +2 -2
- data/examples/edit_sheets/example_copying.rb +1 -1
- data/examples/edit_sheets/example_expanding.rb +1 -1
- data/examples/edit_sheets/example_ranges.rb +1 -1
- data/examples/edit_sheets/example_saving.rb +2 -2
- data/examples/open_save_close/example_control_to_excel.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +2 -2
- data/examples/open_save_close/example_if_obstructed_save.rb +2 -2
- data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
- data/examples/open_save_close/example_if_unsaved_forget.rb +2 -2
- data/examples/open_save_close/example_if_unsaved_forget_more.rb +3 -3
- data/examples/open_save_close/example_read_only.rb +1 -1
- data/examples/open_save_close/example_rename_cells.rb +1 -1
- data/examples/open_save_close/example_simple.rb +1 -1
- data/examples/open_save_close/example_unobtrusively.rb +3 -3
- data/lib/robust_excel_ole.rb +1 -0
- data/lib/robust_excel_ole/book.rb +249 -193
- data/lib/robust_excel_ole/bookstore.rb +1 -1
- data/lib/robust_excel_ole/cell.rb +1 -1
- data/lib/robust_excel_ole/excel.rb +125 -4
- data/lib/robust_excel_ole/general.rb +1 -92
- data/lib/robust_excel_ole/range.rb +1 -1
- data/lib/robust_excel_ole/reo_common.rb +37 -0
- data/lib/robust_excel_ole/sheet.rb +77 -24
- data/lib/robust_excel_ole/version.rb +1 -1
- data/spec/book_spec.rb +112 -82
- data/spec/book_specs/book_close_spec.rb +44 -1
- data/spec/book_specs/book_misc_spec.rb +97 -92
- data/spec/book_specs/book_open_spec.rb +40 -8
- data/spec/book_specs/book_save_spec.rb +77 -7
- data/spec/book_specs/book_sheet_spec.rb +290 -66
- data/spec/book_specs/book_unobtr_spec.rb +99 -73
- data/spec/bookstore_spec.rb +1 -1
- data/spec/cell_spec.rb +2 -2
- data/spec/data/another_workbook.xls +0 -0
- data/spec/data/workbook.xls +0 -0
- data/spec/excel_spec.rb +174 -23
- data/spec/general_spec.rb +3 -18
- data/spec/range_spec.rb +3 -3
- data/spec/reo_common_spec.rb +104 -0
- data/spec/sheet_spec.rb +101 -60
- metadata +6 -4
data/.gitignore
CHANGED
data/Changelog
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [0.5.0] - 2016-31-05
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- Book: sheet, add_empty_sheet, copy_sheet
|
8
|
+
rangeval, set_rangeval, nameval, set_nameval
|
9
|
+
open: option check_compatibility
|
10
|
+
- Sheet: last_sheet, first_sheet, rangeval, nameval
|
11
|
+
- Excel: with_calculaiton, rangeval, set_rangeval, nameval, set_nameval, [], []=
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
- Book: book.sheet(<sheet_name>) replaces book[<sheet-name>]
|
15
|
+
add_or_copy_sheet replaces add_sheet
|
16
|
+
name_val, set_name_val replaces n_value, set_n_value
|
17
|
+
|
18
|
+
|
4
19
|
## [0.4] - 2016-03-16
|
5
20
|
|
6
21
|
### Added
|
data/README.rdoc
CHANGED
@@ -41,7 +41,7 @@ The semantics is similar to, e.g., +File.open+.
|
|
41
41
|
Options are
|
42
42
|
|
43
43
|
+:default_excel+, +:force_excel+, +:if_absent+, +:if_unsaved+, +:if_obstructed+,
|
44
|
-
+:read_only+, +:visible+, +:displayalerts+.
|
44
|
+
+:read_only+, +:check_compatibility, +:visible+, +:displayalerts+.
|
45
45
|
|
46
46
|
Valid values for +:default_excel+ are +:reuse+, +:new+ or some Excel instance, for +:force_excel+ : +:new+ or some Excel instance, for +:if_unsaved+ : +:raise+, +:accept+, +:forget+, +:alert+ and +:new_excel+, for +:if_obstructed+ : +:raise+, +:save+, +:close_if_saved+, +:forget+, +:alert+ and +:new_excel+ , for +:if_absent+ : +:raise+ and +:create+.
|
47
47
|
|
@@ -125,7 +125,7 @@ The method +unobtrusively+ enables the user to read or modify a workbook, no mat
|
|
125
125
|
|
126
126
|
Some options determine the Excel instance in which a closed workbook is opened. The options +:reuse (default) indicates that the closed workbook is opened in the Excel instance where the workbooks is opened, if such an Excel instance exists, otherwise that another Excel instance is reused. The option +:hidden+ provokes that the closed workbook is opened in a separate Excel instance that is not visible and has no DisplayAlerts. Any following closed workbook would be opened in this Excel instance as well when using this option. Moreover, an Excel instance can be given directly where to open the closed workbook.
|
127
127
|
|
128
|
-
Further options are +:read_only+, +:readonly_excel+, and +:keep_open. The option +:readonly_excel+ chooses whether a book that is opened in read only mode. If the workbook is opened as read only, then the option +:readonly_excel+ determines whether to close the workbook and open it as writable in the Excel instance where it was open so far, or to open it as writable in another running Excel instance, if such an instance exists, or to open it in a new Excel instance. Moreover, there are the options +:visible+ and +:
|
128
|
+
Further options are +:read_only+, +:readonly_excel+, and +:keep_open. The option +:readonly_excel+ chooses whether a book that is opened in read only mode. If the workbook is opened as read only, then the option +:readonly_excel+ determines whether to close the workbook and open it as writable in the Excel instance where it was open so far, or to open it as writable in another running Excel instance, if such an instance exists, or to open it in a new Excel instance. Moreover, there are the options +:visible+, +:displayalerts+ and +:check_compatiblity.
|
129
129
|
|
130
130
|
Book.unobtrusively('workbook.xls', :reuse, :read_only => false, :keep_open => false) do |book|
|
131
131
|
# some modification
|
@@ -147,25 +147,25 @@ This method finds out whether the Excel workbook that is referenced by the Book
|
|
147
147
|
|
148
148
|
if book.alive? then sheet = book[0] end
|
149
149
|
|
150
|
-
===
|
150
|
+
=== Getting and setting the contents of a range in a workbook.
|
151
151
|
|
152
|
-
|
152
|
+
Getting the contents of a range.
|
153
153
|
|
154
|
-
book["name"]
|
154
|
+
book["name"]
|
155
|
+
=> "value"
|
155
156
|
|
156
157
|
or
|
157
158
|
|
158
|
-
book.
|
159
|
+
book.nameval("name")
|
160
|
+
=> "value"
|
159
161
|
|
160
|
-
|
162
|
+
Setting the contents of a range.
|
161
163
|
|
162
|
-
book["name"]
|
163
|
-
=> "value"
|
164
|
+
book["name"] = "value"
|
164
165
|
|
165
166
|
or
|
166
167
|
|
167
|
-
book.
|
168
|
-
=> "value"
|
168
|
+
book.set_nameval("name") = "value"
|
169
169
|
|
170
170
|
=== Activating a workbook.
|
171
171
|
|
@@ -201,13 +201,21 @@ Enable DisplayAlerts.
|
|
201
201
|
|
202
202
|
=== Accessing a sheet.
|
203
203
|
|
204
|
-
|
204
|
+
Accessing the first sheet.
|
205
205
|
|
206
|
-
sheet = book
|
206
|
+
sheet = book.sheet(1)
|
207
|
+
|
208
|
+
or
|
207
209
|
|
208
|
-
|
210
|
+
sheet = book.first_sheet
|
209
211
|
|
210
|
-
|
212
|
+
Accessing the last sheet.
|
213
|
+
|
214
|
+
sheet = book.last_sheet
|
215
|
+
|
216
|
+
Accessing a sheet with the sheet name.
|
217
|
+
|
218
|
+
sheet = book.sheet('Sheet1')
|
211
219
|
|
212
220
|
Accessing sheet objects using the methods Book#each.
|
213
221
|
|
@@ -240,8 +248,8 @@ Reading a cell from a sheet object.
|
|
240
248
|
|
241
249
|
Reading a cell from a range object.
|
242
250
|
|
243
|
-
row_range[
|
244
|
-
column_range[
|
251
|
+
row_range[1] => first cell in row_range
|
252
|
+
column_range[2] => second cell in column_range
|
245
253
|
|
246
254
|
Methods to a cell are just delegated. Example:
|
247
255
|
|
@@ -270,49 +278,63 @@ Accessing a range of a column.
|
|
270
278
|
|
271
279
|
Naming or renaming a cell range given its address.
|
272
280
|
|
273
|
-
book.
|
281
|
+
book.set_name(1,1,"name")
|
282
|
+
|
283
|
+
=== Getting and setting the contents of a named range in a worksheet
|
284
|
+
|
285
|
+
Getting the value of a range.
|
286
|
+
|
287
|
+
sheet[name]
|
288
|
+
|
289
|
+
or
|
290
|
+
|
291
|
+
sheet.nameval(name)
|
292
|
+
|
293
|
+
Setting the value of a range.
|
274
294
|
|
275
|
-
|
295
|
+
book[name] = value
|
276
296
|
|
277
|
-
|
297
|
+
or
|
278
298
|
|
279
|
-
book.
|
299
|
+
book.set_nameval(name,value)
|
280
300
|
|
281
|
-
|
301
|
+
=== Getting and setting the contents of a named range in a Worksheet directly
|
282
302
|
|
283
|
-
|
303
|
+
Getting the value of a range.
|
284
304
|
|
285
|
-
|
305
|
+
sheet.rangeval(name)
|
286
306
|
|
287
|
-
|
307
|
+
Setting the value of a range.
|
288
308
|
|
289
|
-
|
309
|
+
book.set_rangeval(name,value)
|
290
310
|
|
291
|
-
|
311
|
+
=== Copying or Adding an sheet.
|
292
312
|
|
293
|
-
|
313
|
+
Adding (appending) an empty sheet.
|
294
314
|
|
295
|
-
|
315
|
+
book.add_empty_sheet
|
296
316
|
|
297
|
-
|
317
|
+
Adding an empty sheet and naming it.
|
298
318
|
|
299
|
-
|
319
|
+
book.add_empty_sheet(:as => 'sheet_name')
|
300
320
|
|
301
|
-
|
321
|
+
Adding an empty sheet with a name before another sheet.
|
302
322
|
|
303
|
-
|
323
|
+
book.add_empty_sheet(:as => 'new_name', :before => another_sheet)
|
304
324
|
|
305
|
-
|
325
|
+
Copying a sheet and adding (appending) it.
|
306
326
|
|
307
|
-
|
327
|
+
book.copy_sheet sheet
|
308
328
|
|
309
|
-
|
329
|
+
Copying a sheet after a another sheet and naming it.
|
310
330
|
|
311
|
-
|
331
|
+
book.copy_sheet(sheet, :as => 'new_name', :after => another_sheet)
|
312
332
|
|
313
|
-
|
333
|
+
Copying a sheet, if a sheet is given, adding an empty sheet, if no sheet is given.
|
314
334
|
|
315
|
-
|
335
|
+
book.add_or_copy_sheet
|
336
|
+
|
337
|
+
book.add_or_copy_sheet(sheet, :as => 'new_name', :after => another_sheet)
|
316
338
|
|
317
339
|
=== Creating and reusing an Excel instance.
|
318
340
|
|
@@ -332,6 +354,48 @@ Promoting an Excel instance represented as WIN32OLE object to an Excel object
|
|
332
354
|
|
333
355
|
excel = Excel.new(:reuse => win32ole_object)
|
334
356
|
|
357
|
+
=== Closing an Excel
|
358
|
+
|
359
|
+
excel = Excel.current
|
360
|
+
excel.close
|
361
|
+
|
362
|
+
The options are +:if_unsaved+ and +:hard+ . Example:
|
363
|
+
|
364
|
+
Closing the Excel instance, saving unsaved wrkbooks and terminating the Excel process
|
365
|
+
|
366
|
+
excel.close(:if_unsaved => :save, :hard => true)
|
367
|
+
|
368
|
+
=== Closing all Excel instances.
|
369
|
+
|
370
|
+
Excel.close_all
|
371
|
+
|
372
|
+
The options are +:if_unsaved+ and +:hard+ . Values for :if_unsaved+ are +raise+, +save+, and +forget+. Example:
|
373
|
+
|
374
|
+
Closing all Excel instances, not saving unsaved workbooks and terminating the Excel processes
|
375
|
+
|
376
|
+
Excel.close_all(:if_unsaved => :forget, :hard => :true)
|
377
|
+
|
378
|
+
=== Terminating all Excel processes
|
379
|
+
|
380
|
+
Excel.kill_all
|
381
|
+
|
382
|
+
=== Recreating an Excel instance
|
383
|
+
|
384
|
+
Reopening the closed Excel instance. This includes reopening all workbooks that were open in that Excel instance.
|
385
|
+
|
386
|
+
excel.close
|
387
|
+
excel.recreate
|
388
|
+
|
389
|
+
The options are :reopen_workbooks, :visible and :displayalerts.
|
390
|
+
|
391
|
+
excel.recreate(:reopen_workbooks => true, :visible => true, :displayalerts => true)
|
392
|
+
|
393
|
+
=== Providing Excel instances
|
394
|
+
|
395
|
+
Providing all Excel instances (opened via RobustExcelOle) as objects of the class Excel
|
396
|
+
|
397
|
+
Excel.excel_objects
|
398
|
+
|
335
399
|
=== Making Excel visible or invisible
|
336
400
|
|
337
401
|
Making Excel visible.
|
@@ -361,47 +425,48 @@ Turning on and off in a block.
|
|
361
425
|
book = Book.open('workbook.xls')
|
362
426
|
end
|
363
427
|
|
364
|
-
===
|
365
|
-
|
366
|
-
excel = Excel.current
|
367
|
-
excel.close
|
368
|
-
|
369
|
-
The options are +:if_unsaved+ and +:hard+ . Example:
|
428
|
+
=== Setting Calculation mode.
|
370
429
|
|
371
|
-
|
430
|
+
Setting calculation mode to manual. Options are +:manual+ and +:automatic+
|
431
|
+
The calculation mode is not reset after the block.
|
372
432
|
|
373
|
-
excel
|
433
|
+
excel = Excel.create
|
434
|
+
book = Book.open('workbook.xls')
|
435
|
+
excel.with_calculation(:manual) do
|
436
|
+
# do something
|
437
|
+
end
|
374
438
|
|
375
|
-
===
|
439
|
+
=== Getting and setting the contents of a named range in an Excel application
|
376
440
|
|
377
|
-
Excel.
|
441
|
+
excel = Excel.create
|
442
|
+
book = Book.open('another_workbook.xls')
|
378
443
|
|
379
|
-
|
444
|
+
Getting the value of a range.
|
380
445
|
|
381
|
-
|
446
|
+
excel[name]
|
447
|
+
|
448
|
+
or
|
382
449
|
|
383
|
-
|
450
|
+
excel.nameval(name)
|
384
451
|
|
385
|
-
|
452
|
+
Setting the value of a range.
|
386
453
|
|
387
|
-
|
454
|
+
excel[name] = value
|
388
455
|
|
389
|
-
|
456
|
+
or
|
390
457
|
|
391
|
-
|
458
|
+
excel.set_nameval(name,value)
|
392
459
|
|
393
|
-
|
394
|
-
excel.recreate
|
460
|
+
=== Getting and setting the contents of a named range in an Excel application directly
|
395
461
|
|
396
|
-
|
462
|
+
Getting the value of a range.
|
397
463
|
|
398
|
-
excel.
|
464
|
+
excel.rangeval(name)
|
399
465
|
|
400
|
-
|
466
|
+
Setting the value of a range.
|
401
467
|
|
402
|
-
|
468
|
+
excel.set_rangeval(name,value)
|
403
469
|
|
404
|
-
Excel.excel_objects
|
405
470
|
|
406
471
|
=== Examples
|
407
472
|
|
data/README_detail.rdoc
CHANGED
@@ -47,6 +47,7 @@ Options are the following:
|
|
47
47
|
+:if_unsaved+:: specify behaviour if the workbook was unsaved (default: +new_excel+)
|
48
48
|
+:if_obstructed+:: specidy behaviour if the workbook is blocked by another book (default: +new_excel+)
|
49
49
|
+:read_only+:: open in read-only mode (default: +false+)
|
50
|
+
+:check_compatibility:: check compatibility when saving
|
50
51
|
+:displayalerts+:: allow display alerts in Excel (default: +false+)
|
51
52
|
+:visible+:: make visibe in Excel (default: +false+)
|
52
53
|
|
@@ -188,9 +189,10 @@ Options are the following:
|
|
188
189
|
true: close it and open it as writable in the excel instance where it was open so far
|
189
190
|
false (default) open it as writable in another running excel instance, if it exists,
|
190
191
|
otherwise open in a new excel instance
|
191
|
-
+:keep_open+::
|
192
|
-
+:visible+::
|
193
|
-
+:displayalerts+::
|
192
|
+
+:keep_open+:: let the workbook open after unobtrusively opening (default: false)
|
193
|
+
+:visible+:: change the Excel into visible or invisible
|
194
|
+
+:displayalerts+:: change the Excel into enable or disable displayalerts
|
195
|
+
+:check_compatibility+:: checks compatibility when saving
|
194
196
|
|
195
197
|
Book.unobtrusively('workbook.xls') do |book|
|
196
198
|
# some modification
|
@@ -211,25 +213,26 @@ The methods +for_reading+ and +for_modifying+ indicate unobtrusively reading or
|
|
211
213
|
|
212
214
|
book.alive?
|
213
215
|
|
214
|
-
===
|
216
|
+
=== Getting and setting the contents of a range.
|
215
217
|
|
216
|
-
Setting:
|
217
218
|
|
218
|
-
|
219
|
+
Getting the contents of a range.
|
220
|
+
|
221
|
+
book["name"]
|
222
|
+
=> "value"
|
219
223
|
|
220
224
|
or
|
221
225
|
|
222
|
-
book.
|
226
|
+
book.nameval("name")
|
227
|
+
=> "value"
|
223
228
|
|
224
|
-
|
229
|
+
Setting the contents of a range.
|
225
230
|
|
226
|
-
book["name"]
|
227
|
-
=> "value"
|
231
|
+
book["name"] = "value"
|
228
232
|
|
229
233
|
or
|
230
234
|
|
231
|
-
book.
|
232
|
-
=> "value"
|
235
|
+
book.set_nameval("name") = "value"
|
233
236
|
|
234
237
|
=== Activating a workbook.
|
235
238
|
|
@@ -266,13 +269,21 @@ Options: +true+ -> enable DisplayAlerts , +false+ -> Disable DisplayAlerts
|
|
266
269
|
|
267
270
|
=== Accessing a sheet.
|
268
271
|
|
269
|
-
|
272
|
+
Accessing the first sheet.
|
270
273
|
|
271
|
-
sheet = book
|
274
|
+
sheet = book.sheet(1)
|
272
275
|
|
273
|
-
|
276
|
+
or
|
274
277
|
|
275
|
-
sheet = book
|
278
|
+
sheet = book.first_sheet
|
279
|
+
|
280
|
+
Accessing the last sheet.
|
281
|
+
|
282
|
+
sheet = book.last_sheet
|
283
|
+
|
284
|
+
Accessing a sheet with the sheet name.
|
285
|
+
|
286
|
+
sheet = book.sheet('Sheet1')
|
276
287
|
|
277
288
|
Accessing sheet objects using the methods Book#each.
|
278
289
|
|
@@ -280,6 +291,7 @@ Accessing sheet objects using the methods Book#each.
|
|
280
291
|
# do something with sheet
|
281
292
|
end
|
282
293
|
|
294
|
+
|
283
295
|
=== Accessing a row or a column.
|
284
296
|
|
285
297
|
A sheet object is enumerable. Use the methods Sheet#each_column, Sheet#each_row or Sheet#each.
|
@@ -305,7 +317,7 @@ Reading a cell from a sheet object.
|
|
305
317
|
|
306
318
|
Reading a cell from a range object.
|
307
319
|
|
308
|
-
row_range[
|
320
|
+
row_range[1] => first cell in row_range
|
309
321
|
column_range[1] => second cell in column_range
|
310
322
|
|
311
323
|
Methods to cell are just delegated as VBA methods. Example:
|
@@ -336,49 +348,63 @@ Accessing a range of a column.
|
|
336
348
|
|
337
349
|
Naming or renaming a cell range given its address.
|
338
350
|
|
339
|
-
book.
|
351
|
+
book.set_name(1,1,"name")
|
352
|
+
|
353
|
+
=== Getting and setting the contents of a named range
|
340
354
|
|
341
|
-
|
355
|
+
Getting the value of a range.
|
342
356
|
|
343
|
-
|
357
|
+
sheet[name]
|
358
|
+
|
359
|
+
or
|
360
|
+
|
361
|
+
sheet.nameval(name)
|
344
362
|
|
345
|
-
|
363
|
+
Setting the value of a range.
|
346
364
|
|
347
|
-
|
365
|
+
book[name] = value
|
348
366
|
|
349
|
-
|
367
|
+
or
|
350
368
|
|
351
|
-
|
369
|
+
book.set_nameval(name,value)
|
352
370
|
|
353
|
-
|
371
|
+
=== Getting and setting the contents of a named range directly
|
354
372
|
|
355
|
-
|
373
|
+
Getting the value of a range.
|
356
374
|
|
357
|
-
|
375
|
+
sheet.rangeval(name)
|
358
376
|
|
359
|
-
|
377
|
+
Setting the value of a range.
|
360
378
|
|
361
|
-
|
379
|
+
book.set_rangeval(name,value)
|
362
380
|
|
363
|
-
|
381
|
+
=== Copying or Adding an sheet.
|
364
382
|
|
365
|
-
Adding
|
383
|
+
Adding (appending) an empty sheet.
|
366
384
|
|
367
|
-
book.
|
385
|
+
book.add_empty_sheet
|
368
386
|
|
369
|
-
Adding
|
387
|
+
Adding an empty sheet and naming it.
|
370
388
|
|
371
|
-
book.
|
389
|
+
book.add_empty_sheet(:as => 'sheet_name')
|
372
390
|
|
373
|
-
Adding
|
391
|
+
Adding an empty sheet with a name before another sheet.
|
374
392
|
|
375
|
-
book.
|
393
|
+
book.add_empty_sheet(:as => 'new_name', :before => another_sheet)
|
376
394
|
|
377
|
-
|
395
|
+
Copying a sheet and adding (appending) it.
|
378
396
|
|
379
|
-
|
397
|
+
book.copy_sheet sheet
|
380
398
|
|
381
|
-
|
399
|
+
Copying a sheet after a another sheet and naming it.
|
400
|
+
|
401
|
+
book.copy_sheet(sheet, :as => 'new_name', :after => another_sheet)
|
402
|
+
|
403
|
+
Copying a sheet, if a sheet is given, adding an empty sheet, if no sheet is given.
|
404
|
+
|
405
|
+
book.add_or_copy_sheet
|
406
|
+
|
407
|
+
book.add_or_copy_sheet(sheet, :as => 'new_name', :after => another_sheet)
|
382
408
|
|
383
409
|
=== Creating and reusing an Excel instance.
|
384
410
|
|
@@ -398,6 +424,46 @@ Promoting an Excel instance represented as WIN32OLE object to an Excel object
|
|
398
424
|
|
399
425
|
excel = Excel.new(:reuse => win32ole_object)
|
400
426
|
|
427
|
+
|
428
|
+
=== Closing an Excel
|
429
|
+
|
430
|
+
excel = Excel.current
|
431
|
+
excel.close
|
432
|
+
|
433
|
+
Closing the Excel instance and terminating the Excel process
|
434
|
+
|
435
|
+
excel.close(:hard => true)
|
436
|
+
|
437
|
+
=== Closing all Excel instances.
|
438
|
+
|
439
|
+
Excel.close_all
|
440
|
+
|
441
|
+
Closing the Excel instances and terminating the Excel processes
|
442
|
+
|
443
|
+
Excel.close_all(:hard => true)
|
444
|
+
|
445
|
+
=== Terminating all Excel processes
|
446
|
+
|
447
|
+
Excel.kill_all
|
448
|
+
|
449
|
+
=== Recreating an Excel instance
|
450
|
+
|
451
|
+
Reopening the closed Excel instance. This includes reopening all workbooks that were open in that Excel instance.
|
452
|
+
|
453
|
+
excel.close
|
454
|
+
excel.recreate
|
455
|
+
|
456
|
+
Options are :visible and :displayalerts
|
457
|
+
|
458
|
+
excel.recreate(:visible => true, :displayalerts => true)
|
459
|
+
|
460
|
+
=== Providing Excel instances
|
461
|
+
|
462
|
+
Providing all Excel instances (opened via RobustExcelOle) as objects of the class Excel
|
463
|
+
|
464
|
+
Excel.excel_objects
|
465
|
+
|
466
|
+
|
401
467
|
=== Making Excel visible or invisible
|
402
468
|
|
403
469
|
Making Excel visible.
|
@@ -427,43 +493,47 @@ Turning on and off in a block.
|
|
427
493
|
book = Book.open('workbook.xls')
|
428
494
|
end
|
429
495
|
|
430
|
-
===
|
431
|
-
|
432
|
-
excel = Excel.current
|
433
|
-
excel.close
|
496
|
+
=== Setting Calculation mode.
|
434
497
|
|
435
|
-
|
498
|
+
Setting calculation mode to manual. Options are +:manual+ and +:automatic+
|
499
|
+
The calculation mode is not reset after the block.
|
436
500
|
|
437
|
-
excel
|
501
|
+
excel = Excel.create
|
502
|
+
book = Book.open('workbook.xls')
|
503
|
+
excel.with_calculation(:manual) do
|
504
|
+
# do something
|
505
|
+
end
|
438
506
|
|
439
|
-
===
|
507
|
+
=== Getting and setting the contents of a named range in an Excel application
|
440
508
|
|
441
|
-
Excel.
|
509
|
+
excel = Excel.create
|
510
|
+
book = Book.open('another_workbook.xls')
|
442
511
|
|
443
|
-
|
512
|
+
Getting the value of a range.
|
444
513
|
|
445
|
-
|
514
|
+
excel[name]
|
515
|
+
|
516
|
+
or
|
446
517
|
|
447
|
-
|
518
|
+
excel.nameval(name)
|
448
519
|
|
449
|
-
|
520
|
+
Setting the value of a range.
|
450
521
|
|
451
|
-
|
522
|
+
excel[name] = value
|
452
523
|
|
453
|
-
|
524
|
+
or
|
454
525
|
|
455
|
-
excel.
|
456
|
-
excel.recreate
|
526
|
+
excel.set_nameval(name,value)
|
457
527
|
|
458
|
-
|
528
|
+
=== Getting and setting the contents of a named range in an Excel application directly
|
459
529
|
|
460
|
-
|
530
|
+
Getting the value of a range.
|
461
531
|
|
462
|
-
|
532
|
+
excel.rangeval(name)
|
463
533
|
|
464
|
-
|
534
|
+
Setting the value of a range.
|
465
535
|
|
466
|
-
|
536
|
+
excel.set_rangeval(name,value)
|
467
537
|
|
468
538
|
|
469
539
|
=== Examples
|