robust_excel_ole 1.28 → 1.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog +35 -1
- data/README.rdoc +116 -19
- data/___dummy_workbook.xls +0 -0
- data/benchmarking/creek_example.rb +1 -1
- data/benchmarking/reo_example.rb +1 -1
- data/benchmarking/reo_example1.rb +1 -1
- data/benchmarking/reo_example2.rb +1 -1
- data/benchmarking/roo_example.rb +1 -1
- data/benchmarking/simple_xlsx_reader_example.rb +1 -1
- data/benchmarking/spreadsheet_example.rb +1 -1
- data/bin/reo +2 -2
- data/docs/README_excel.rdoc +16 -24
- data/docs/README_listobjects.rdoc +176 -0
- data/docs/README_open.rdoc +20 -16
- data/docs/README_ranges.rdoc +72 -55
- data/docs/README_save_close.rdoc +3 -3
- data/docs/README_sheet.rdoc +19 -20
- data/examples/example_ruby_library.rb +2 -2
- data/examples/introductory_examples/example_open.rb +11 -0
- data/examples/introductory_examples/example_range.rb +2 -2
- data/examples/modifying_sheets/example_access_sheets_and_cells.rb +6 -6
- data/examples/modifying_sheets/example_add_names.rb +1 -1
- data/examples/modifying_sheets/example_concating.rb +1 -1
- data/examples/modifying_sheets/example_copying.rb +2 -2
- data/examples/modifying_sheets/example_listobjects.rb +86 -0
- data/examples/modifying_sheets/example_naming.rb +1 -1
- data/examples/modifying_sheets/example_ranges.rb +1 -1
- data/examples/open_save_close/example_control_to_excel.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_save.rb +3 -3
- data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
- data/examples/open_save_close/example_if_unsaved_forget.rb +3 -3
- data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -4
- data/examples/open_save_close/example_read_only.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 +18 -14
- data/lib/robust_excel_ole/address_tool.rb +57 -46
- data/lib/robust_excel_ole/base.rb +4 -6
- data/lib/robust_excel_ole/bookstore.rb +3 -17
- data/lib/robust_excel_ole/cell.rb +17 -22
- data/lib/robust_excel_ole/cygwin.rb +2 -0
- data/lib/robust_excel_ole/excel.rb +136 -201
- data/lib/robust_excel_ole/general.rb +266 -204
- data/lib/robust_excel_ole/list_object.rb +186 -210
- data/lib/robust_excel_ole/list_row.rb +160 -0
- data/lib/robust_excel_ole/range.rb +136 -95
- data/lib/robust_excel_ole/range_owners.rb +54 -135
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/workbook.rb +236 -197
- data/lib/robust_excel_ole/worksheet.rb +262 -133
- data/lib/spec_helper.rb +1 -1
- data/robust_excel_ole.gemspec +4 -3
- data/spec/address_tool_spec.rb +2 -2
- data/spec/base_spec.rb +19 -17
- data/spec/bookstore_spec.rb +10 -16
- data/spec/cell_spec.rb +10 -10
- data/spec/cygwin_spec.rb +1 -1
- data/spec/data/more_data/workbook.xls +0 -0
- data/spec/excel_spec.rb +133 -86
- data/spec/general_spec.rb +141 -43
- data/spec/list_object_spec.rb +259 -81
- data/spec/list_row_spec.rb +220 -0
- data/spec/range_spec.rb +75 -41
- data/spec/spec_helper.rb +16 -2
- data/spec/workbook_spec.rb +87 -46
- data/spec/workbook_specs/workbook_all_spec.rb +8 -28
- data/spec/workbook_specs/workbook_close_spec.rb +1 -1
- data/spec/workbook_specs/workbook_misc_spec.rb +52 -45
- data/spec/workbook_specs/workbook_open_spec.rb +103 -50
- data/spec/workbook_specs/workbook_save_spec.rb +22 -23
- data/spec/workbook_specs/workbook_sheet_spec.rb +4 -4
- data/spec/workbook_specs/workbook_subclass_spec.rb +1 -1
- data/spec/workbook_specs/workbook_unobtr_spec.rb +553 -395
- data/spec/worksheet_spec.rb +544 -308
- metadata +42 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1c1d70d522034dc16bc609e2578e02b556396051ec7fdd14e2f11bd5aea85cd
|
4
|
+
data.tar.gz: e14ac932aae718dd25d3a3ddc9ab487d63dc934c6e1d136a1adb069b0c57c81e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77e8abbfee1226d86e58d75aa4e1625b3a7d385333974c4cb9e854527d1c6e2cfdcb827a55749343e34dfae0867bc843ac609ebb1541f71960dd08ffbdf7d1fd
|
7
|
+
data.tar.gz: f3b02fa7307c8d7031fdf65d246d3e22a800d39f476a24f227abba0dc2eb058b119dc29c249285392013a8d0de73735c176030d39fd8f97f7ea9150b7a8d0b61
|
data/Changelog
CHANGED
@@ -1,6 +1,40 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [1.33] 2021-01-06
|
5
|
+
|
6
|
+
## [1.32] 2021-23-04
|
7
|
+
|
8
|
+
### Added
|
9
|
+
- Excel#each
|
10
|
+
- ListObject#each, value, rows_number, position, ==
|
11
|
+
- ListObject#[] extended with options
|
12
|
+
- ListRow#to_h, to_a, values=, keys_values, ==
|
13
|
+
- RangeOwners#names
|
14
|
+
- Worksheet#each_cell
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- Worksheet#[]: returning range values given address or defined name (instead of returning a cell when giving address)
|
18
|
+
- Worksheet#each traversing row values instead of cells
|
19
|
+
- Excel#excels_number renamed to #instance_count
|
20
|
+
- Excel#known_excels_number renamed to #known_instance_count
|
21
|
+
- Excel#known_excel_instance renamed to #known_running_instance
|
22
|
+
- Excel#known_excel_instances renamed to #known_running_instances
|
23
|
+
- RangeOwners#rename_range renamed to #rename_name
|
24
|
+
|
25
|
+
## [1.31] 2021-14-01
|
26
|
+
|
27
|
+
### Added
|
28
|
+
- Worksheet#table
|
29
|
+
|
30
|
+
## [1.30] 2020-18-11
|
31
|
+
|
32
|
+
## [1.29] 2020-05-11
|
33
|
+
|
34
|
+
### Added
|
35
|
+
- Workbook.open can also take a Pathname object
|
36
|
+
- General#init_reo_for_win32ole
|
37
|
+
|
4
38
|
## [1.28] 2020-23-10
|
5
39
|
|
6
40
|
## [1.27] 2020-16-10
|
@@ -179,7 +213,7 @@ All notable changes to this project will be documented in this file.
|
|
179
213
|
## [1.1.4] - 2018-10-6
|
180
214
|
|
181
215
|
### Added
|
182
|
-
- Book#open: for the options:
|
216
|
+
- Book#open: for the options: simplifiction: :force can be left out
|
183
217
|
- Excel#for_this_instance
|
184
218
|
- Excel#for_all_workbooks
|
185
219
|
- Book#for_this_workbooks
|
data/README.rdoc
CHANGED
@@ -1,3 +1,24 @@
|
|
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
|
+
|
1
22
|
= RobustExcelOle
|
2
23
|
|
3
24
|
RobustExcelOle helps controlling Excel.
|
@@ -123,7 +144,7 @@ RobustExcelOle allows unobtrusively reading and modifying workbooks, i.e. access
|
|
123
144
|
|
124
145
|
We can also create a new, empty workbook.
|
125
146
|
|
126
|
-
Workbook.create('spec/data/new_workbook.xls', :
|
147
|
+
Workbook.create('spec/data/new_workbook.xls', visible: true)
|
127
148
|
|
128
149
|
Moreover, we can open the workbook using a block, similar to, e.g., +File.open+.
|
129
150
|
|
@@ -133,15 +154,15 @@ Moreover, we can open the workbook using a block, similar to, e.g., +File.open+.
|
|
133
154
|
|
134
155
|
Once we have a workbook, we can set some options, e.g.
|
135
156
|
|
136
|
-
workbook.for_this_workbook(:
|
157
|
+
workbook.for_this_workbook(visible: true, read_only: false)
|
137
158
|
|
138
159
|
We can also open the workbook and provide the options in one step, e.g.
|
139
160
|
|
140
|
-
workbook = Workbook.open('spec/data/workbook.xls', :
|
161
|
+
workbook = Workbook.open('spec/data/workbook.xls', visible: true)
|
141
162
|
|
142
163
|
or, using abbreviations,
|
143
164
|
|
144
|
-
workbook = Workbook.open('spec/data/workbook.xls', :
|
165
|
+
workbook = Workbook.open('spec/data/workbook.xls', v: true)
|
145
166
|
|
146
167
|
Note that +Workbook.open+ can also connect to workbooks which were not opened via RobustExcelOle (but had been opened before by some user).
|
147
168
|
|
@@ -161,7 +182,7 @@ Finally we can close the workbook
|
|
161
182
|
|
162
183
|
or save and close the workbook in one step.
|
163
184
|
|
164
|
-
workbook.close(:
|
185
|
+
workbook.close(if_unsaved: :save)
|
165
186
|
|
166
187
|
For more details about saving and closing workbooks see
|
167
188
|
{README_save_close}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_save_close.rdoc]
|
@@ -175,7 +196,7 @@ We can start a new Excel instance with
|
|
175
196
|
|
176
197
|
or
|
177
198
|
|
178
|
-
excel1 = Excel.new(:
|
199
|
+
excel1 = Excel.new(reuse: false)
|
179
200
|
|
180
201
|
We can also obtain an Excel object by connecting to the already running Excel instance.
|
181
202
|
|
@@ -183,7 +204,7 @@ We can also obtain an Excel object by connecting to the already running Excel in
|
|
183
204
|
|
184
205
|
or
|
185
206
|
|
186
|
-
excel2 = Excel.new(:
|
207
|
+
excel2 = Excel.new(reuse: true)
|
187
208
|
|
188
209
|
We close the Excel instance using
|
189
210
|
|
@@ -191,11 +212,11 @@ We close the Excel instance using
|
|
191
212
|
|
192
213
|
Closed Excel instances can be reopened.
|
193
214
|
|
194
|
-
excel1.recreate(:
|
215
|
+
excel1.recreate(reopen_workbooks: true, visible: true)
|
195
216
|
|
196
217
|
Closing all Excel instances is done by
|
197
218
|
|
198
|
-
Excel.close_all(:
|
219
|
+
Excel.close_all(if_unsaved: :forget)
|
199
220
|
|
200
221
|
For hard terminating all Excel processes we can use
|
201
222
|
|
@@ -214,12 +235,12 @@ For example, suppose we want to open a workbook.
|
|
214
235
|
|
215
236
|
Now we want to open another workbook in a different Excel instance.
|
216
237
|
|
217
|
-
workbook2 = Workbook.open('spec/data/different_workbook.xls', :
|
238
|
+
workbook2 = Workbook.open('spec/data/different_workbook.xls', excel: :new)
|
218
239
|
|
219
240
|
We can also create a third Excel instance and open another workbook in this instance.
|
220
241
|
|
221
242
|
excel1 = Excel.create
|
222
|
-
workbook3 = Workbook.open('spec/data/another_workbook.xls', :
|
243
|
+
workbook3 = Workbook.open('spec/data/another_workbook.xls', excel: excel1)
|
223
244
|
|
224
245
|
A workbook is opened by default in the Excel instance where it was open before most recently.
|
225
246
|
|
@@ -228,11 +249,11 @@ A workbook is opened by default in the Excel instance where it was open before m
|
|
228
249
|
|
229
250
|
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
251
|
|
231
|
-
workbook1 = Workbook.open('spec/data/workbook.xls', :
|
252
|
+
workbook1 = Workbook.open('spec/data/workbook.xls', default: {excel: new})
|
232
253
|
|
233
254
|
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
255
|
|
235
|
-
workbook2 = Workbook.open('spec/data/workbook.xls', :
|
256
|
+
workbook2 = Workbook.open('spec/data/workbook.xls', excel: excel1)
|
236
257
|
|
237
258
|
=== Managing conflicts with unsaved and blocking workbooks
|
238
259
|
|
@@ -240,13 +261,13 @@ RobustExcelOle enables processing workbooks, while still supporting user's inter
|
|
240
261
|
|
241
262
|
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
263
|
|
243
|
-
workbook = Workbook.open('workbook.xls', :
|
264
|
+
workbook = Workbook.open('workbook.xls', if_unsaved: :accept)
|
244
265
|
|
245
266
|
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
267
|
|
247
268
|
workbook1 = Workbook.open('spec/data/workbook.xls')
|
248
269
|
# do something
|
249
|
-
workbook2 = Workbook.open('spec/data/more/workbook.xls', :
|
270
|
+
workbook2 = Workbook.open('spec/data/more/workbook.xls', if_blocked: :forget)
|
250
271
|
|
251
272
|
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
273
|
|
@@ -277,7 +298,7 @@ We can read and change the worksheet name.
|
|
277
298
|
|
278
299
|
We can copy the first worksheet, name it and add it before the third worksheet.
|
279
300
|
|
280
|
-
workbook.add_or_copy_sheet(sheet, :
|
301
|
+
workbook.add_or_copy_sheet(sheet, as: "copied_name, before: workbook.last_sheet)
|
281
302
|
|
282
303
|
For more details about processing worksheets see {README_sheet}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_sheet.rdoc]
|
283
304
|
|
@@ -297,7 +318,7 @@ and the third column
|
|
297
318
|
|
298
319
|
We can read the first cell, using
|
299
320
|
|
300
|
-
worksheet[1,1].
|
321
|
+
worksheet[1,1]. # => "foo"
|
301
322
|
|
302
323
|
or
|
303
324
|
|
@@ -318,6 +339,76 @@ and set another value to that range.
|
|
318
339
|
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
340
|
|
320
341
|
|
342
|
+
=== List Objects (Tables)
|
343
|
+
|
344
|
+
We can define a list object (or table) from scratch
|
345
|
+
|
346
|
+
table = ListObject.new(worksheet, "table 1", [1,1], 3, ["Person","AmountSales"])
|
347
|
+
|
348
|
+
or get a given list object in a worksheet given its table number or name.
|
349
|
+
|
350
|
+
table = worksheet.table(1)
|
351
|
+
|
352
|
+
or
|
353
|
+
|
354
|
+
table = worksheet.table("table1")
|
355
|
+
|
356
|
+
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.
|
357
|
+
|
358
|
+
row1 = table[1]
|
359
|
+
|
360
|
+
row1 = table[{"Number": 1, "Person": "John"}]
|
361
|
+
|
362
|
+
You can get all or a maximal number of list rows matching the key.
|
363
|
+
|
364
|
+
rows = table[{"Number": 1}, limit: 2]
|
365
|
+
rows = table[{"Number": 1}, limit: nil]
|
366
|
+
|
367
|
+
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.
|
368
|
+
|
369
|
+
row1.person = "John"
|
370
|
+
|
371
|
+
or
|
372
|
+
|
373
|
+
row1["Person"] = "John"
|
374
|
+
|
375
|
+
Similarly you can get the values. We can also read all values in a row.
|
376
|
+
|
377
|
+
table[1].to_a
|
378
|
+
# => ["John", 40]
|
379
|
+
|
380
|
+
table[1].to_h
|
381
|
+
# => {"Person": "John", "AmountSales": 40}
|
382
|
+
|
383
|
+
We can set the values in a whole row.
|
384
|
+
|
385
|
+
table[1].values = ["Herber", 80]
|
386
|
+
|
387
|
+
Similarly, we can read and set the values in a whole column, e.g.
|
388
|
+
|
389
|
+
table.column_values("Person")
|
390
|
+
# => ["John", "Peter"]
|
391
|
+
|
392
|
+
and
|
393
|
+
|
394
|
+
table.set_column_values(1, ["Herbert","Paul"])
|
395
|
+
|
396
|
+
We can add and delete rows and columns, supplying optionally their name, the position and contents.
|
397
|
+
|
398
|
+
table.add_column("column_name", 3, ["John", "Paul"])
|
399
|
+
table.add_row(3, ["John", 40, 2, 2004])
|
400
|
+
|
401
|
+
table.delete_column_values("column_name")
|
402
|
+
table[2].delete_values
|
403
|
+
|
404
|
+
Finally we can delete empty rows and columns.
|
405
|
+
|
406
|
+
table.delete_empty_rows
|
407
|
+
table.delete_empty_columns
|
408
|
+
|
409
|
+
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]
|
410
|
+
|
411
|
+
|
321
412
|
=== More features
|
322
413
|
|
323
414
|
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,14 +426,20 @@ or
|
|
335
426
|
However, this command also starts another pry repl (with another binding). Moreover, local variables in the previous binding are forgotten.
|
336
427
|
|
337
428
|
|
338
|
-
2. The class Win32Ole is being extended such that RobustExcelOle methods can be applied to
|
429
|
+
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
430
|
|
340
431
|
range.ole_range.copy([4,3])
|
341
432
|
|
342
|
-
Likewise it is possible to convert ("type-lift") Win32Ole objects into the corresponding RobustExcelOle object, using
|
433
|
+
Likewise it is possible to convert ("type-lift") Win32Ole objects into the corresponding RobustExcelOle object, using the method +to_reo+. It is a refinement of the class WIN32OLE. So you can write
|
434
|
+
|
435
|
+
using ToReoRefinement
|
343
436
|
|
344
437
|
range = sheet.Names.Item("firstcell").to_reo
|
345
438
|
|
439
|
+
=== Design issues
|
440
|
+
|
441
|
+
We don't consider active worksheets or workbooks in our implementation, because this has been proven to be very error-prone.
|
442
|
+
|
346
443
|
=== Examples
|
347
444
|
|
348
445
|
You can run the examples included in the directory +examples+, e.g.
|
data/___dummy_workbook.xls
CHANGED
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.
|
13
|
+
puts "Found #{worksheets.size} worksheets"
|
14
14
|
|
15
15
|
worksheets.each do |worksheet|
|
16
16
|
puts "Reading: #{worksheet.name}"
|
data/benchmarking/reo_example.rb
CHANGED
data/benchmarking/roo_example.rb
CHANGED
@@ -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.
|
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.
|
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.
|
14
|
+
puts "Found #{worksheets.size} worksheets"
|
15
15
|
|
16
16
|
|
17
17
|
worksheets.each do |worksheet|
|
data/bin/reo
CHANGED
@@ -16,11 +16,11 @@ Pry.config.prompt_name = "REO "
|
|
16
16
|
#Pry.editor = 'notepad' # 'subl', 'vi'
|
17
17
|
|
18
18
|
prompt_proc1 = proc { |target_self, nest_level, pry|
|
19
|
-
|
19
|
+
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}> "
|
20
20
|
}
|
21
21
|
|
22
22
|
prompt_proc2 = proc { |target_self, nest_level, pry|
|
23
|
-
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self
|
23
|
+
"[#{pry.input_ring.count}] #{pry.config.prompt_name}(#{Pry.view_clip(target_self)})#{":#{nest_level}" unless nest_level.zero?}* "
|
24
24
|
}
|
25
25
|
|
26
26
|
Pry.config.prompt = if RUBY_PLATFORM =~ /java/
|
data/docs/README_excel.rdoc
CHANGED
@@ -12,7 +12,7 @@ You can create a new Excel instance by
|
|
12
12
|
|
13
13
|
or
|
14
14
|
|
15
|
-
excel1 = Excel.new(:
|
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(:
|
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, :
|
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.
|
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(:
|
49
|
+
excel1 = Excel.create(visible: true)
|
50
50
|
|
51
51
|
or
|
52
52
|
|
53
|
-
excel1 = Excel.new(:
|
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(:
|
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.
|
102
|
+
excel.each_workook(visible: true, read_only: true)
|
103
103
|
|
104
104
|
|
105
|
-
=== Showing and traversing
|
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(:
|
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(:
|
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(:
|
163
|
+
Excel.close_all(if_unsaved: :raise)
|
172
164
|
|
173
165
|
=== Terminating all Excel processes
|
174
166
|
|