robust_excel_ole 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +13 -0
  3. data/README.rdoc +107 -73
  4. data/{README_excel.rdoc → docs/README_excel.rdoc} +2 -0
  5. data/{README_open.rdoc → docs/README_open.rdoc} +12 -16
  6. data/{README_ranges.rdoc → docs/README_ranges.rdoc} +1 -1
  7. data/{README_save_close.rdoc → docs/README_save_close.rdoc} +0 -0
  8. data/{README_sheet.rdoc → docs/README_sheet.rdoc} +0 -0
  9. data/examples/open_save_close/example_control_to_excel.rb +3 -3
  10. data/examples/open_save_close/example_default_excel.rb +2 -2
  11. data/examples/open_save_close/example_force_excel.rb +2 -2
  12. data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +2 -2
  13. data/examples/open_save_close/example_if_obstructed_forget.rb +2 -2
  14. data/examples/open_save_close/example_if_obstructed_save.rb +2 -2
  15. data/examples/open_save_close/example_if_unsaved_accept.rb +3 -3
  16. data/examples/open_save_close/example_if_unsaved_forget.rb +7 -3
  17. data/examples/open_save_close/example_if_unsaved_forget_more.rb +1 -1
  18. data/examples/open_save_close/example_read_only.rb +2 -2
  19. data/examples/open_save_close/example_rename_cells.rb +2 -2
  20. data/examples/open_save_close/example_reuse.rb +2 -2
  21. data/examples/open_save_close/example_simple.rb +1 -1
  22. data/examples/open_save_close/example_unobtrusively.rb +2 -2
  23. data/lib/robust_excel_ole/book.rb +75 -76
  24. data/lib/robust_excel_ole/bookstore.rb +9 -9
  25. data/lib/robust_excel_ole/excel.rb +5 -5
  26. data/lib/robust_excel_ole/general.rb +11 -4
  27. data/lib/robust_excel_ole/reo_common.rb +3 -0
  28. data/lib/robust_excel_ole/version.rb +1 -1
  29. data/robust_excel_ole.gemspec +2 -2
  30. data/spec/book_spec.rb +67 -63
  31. data/spec/book_specs/book_close_spec.rb +12 -10
  32. data/spec/book_specs/book_misc_spec.rb +279 -279
  33. data/spec/book_specs/book_open_spec.rb +258 -105
  34. data/spec/book_specs/book_save_spec.rb +28 -28
  35. data/spec/book_specs/book_unobtr_spec.rb +862 -164
  36. data/spec/bookstore_spec.rb +22 -22
  37. data/spec/data/another_workbook.xls +0 -0
  38. data/spec/data/different_workbook.xls +0 -0
  39. data/spec/data/workbook.xls +0 -0
  40. data/spec/excel_spec.rb +256 -254
  41. data/spec/general_spec.rb +7 -7
  42. data/spec/ruby1.8.6_rspec2.14/book_spec.rb +1421 -0
  43. data/spec/ruby1.8.6_rspec2.14/book_specs/book_all_spec.rb +22 -0
  44. data/spec/ruby1.8.6_rspec2.14/book_specs/book_close_spec.rb +252 -0
  45. data/spec/ruby1.8.6_rspec2.14/book_specs/book_misc_spec.rb +1070 -0
  46. data/spec/ruby1.8.6_rspec2.14/book_specs/book_open_spec.rb +1855 -0
  47. data/spec/ruby1.8.6_rspec2.14/book_specs/book_save_spec.rb +514 -0
  48. data/spec/ruby1.8.6_rspec2.14/book_specs/book_sheet_spec.rb +395 -0
  49. data/spec/ruby1.8.6_rspec2.14/book_specs/book_subclass_spec.rb +51 -0
  50. data/spec/ruby1.8.6_rspec2.14/book_specs/book_unobtr_spec.rb +1737 -0
  51. data/spec/ruby1.8.6_rspec2.14/bookstore_spec.rb +495 -0
  52. data/spec/ruby1.8.6_rspec2.14/cell_spec.rb +76 -0
  53. data/spec/ruby1.8.6_rspec2.14/cygwin_spec.rb +42 -0
  54. data/spec/ruby1.8.6_rspec2.14/excel_spec.rb +1820 -0
  55. data/spec/ruby1.8.6_rspec2.14/general_spec.rb +212 -0
  56. data/spec/ruby1.8.6_rspec2.14/range_spec.rb +131 -0
  57. data/spec/ruby1.8.6_rspec2.14/reo_common_spec.rb +130 -0
  58. data/spec/ruby1.8.6_rspec2.14/sheet_spec.rb +663 -0
  59. data/spec/ruby1.8.6_rspec2.14/spec_helper.rb +35 -0
  60. data/spec/sheet_spec.rb +2 -2
  61. metadata +28 -12
  62. data/README_detail.rdoc +0 -852
  63. data/README_development.rdoc +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c842707a42ecf41966021d1c4b46de412d598a5
4
- data.tar.gz: 2ac4026904e8fab21e087bdeaae0b123d14d41cc
3
+ metadata.gz: 94e2b8cc2f0306a63e377d70378a04063e6b5cf2
4
+ data.tar.gz: 6d4c94aa56956a25ba723746bf05e23320aa36bb
5
5
  SHA512:
6
- metadata.gz: 93acf54dc229f58aa5e1cb5b1ad59f0d28fa77e513af12adc52e1bf5daaeae2920d3206637a196cc7dd78d2b40c5feb2bbfb2599e88d70ac273396dd5545bf9e
7
- data.tar.gz: 468faa1ad3c10feeb8316fc9de2d827ba1be7444108af0c0f9cd0d7d89ba33538e87e9af5e9ae694a11ca25bef2b2ccafbd475880a753923417a011bc85baaa0
6
+ metadata.gz: f46997852585e4560db9ccb679a0dccc11a6128b59022b374d8393771531ae2aab2973fa10d0f342f882181dcaaca2cdf4af7151ed918446bdebdb5f57faf8dc
7
+ data.tar.gz: 99d74fe8c6c16ab52c40c6d5362cba29a07539acf695fbc546619b8fb18086b860258005ccd63429c19655aaf6212096c5d1d76924c4ff85be565cf7dc88e34a
data/Changelog CHANGED
@@ -1,9 +1,22 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [1.1.5] - 2018-10-7
5
+
6
+ ### Added
7
+ - Book#unobtrusively:
8
+ option :writable
9
+
10
+ ### Changed
11
+ - Book#unobtrusively:
12
+ option :rw_change_excel instead :readonly_excel
13
+
14
+ ### Added
15
+
4
16
  ## [1.1.4] - 2018-10-6
5
17
 
6
18
  ### Added
19
+ - Book#open: for the options: simplifiaction: :force can be left out
7
20
  - Excel#for_this_instance
8
21
  - Excel#for_all_workbooks
9
22
  - Book#for_this_workbooks
data/README.rdoc CHANGED
@@ -1,22 +1,26 @@
1
1
  = RobustExcelOle
2
2
 
3
- This ruby gem automates reading, modifying, and writing Excel files. It is designed to support several kinds of concurrency of both simultaneously running Excel instances and simultanously happening user interactions.
3
+ This library automates reading, modifying, and writing Excel workbooks. It is designed to support several kinds of concurrency of both simultaneously running Excel instances and simultanously happening user interactions.
4
4
  RobustExcelOle deals with various cases of Excel and user behaviour,
5
5
  and implements workarounds for some Excel bugs.
6
6
  The gem provides convenient methods for common tasks, and facilitates referenced libraries.
7
- It can be used for any recent Excel Office version, and is tested for Excel 2010.
8
7
 
9
- RobustExcelOle works by sending VBA methods via Win32OLE.
10
- It implements a management system and keeps track of Excel files and Excel instances.
8
+ RobustExcelOle works by sending VBA methods via Win32OLE. It keeps track of Excel workbooks and Excel instances.
11
9
 
12
10
  == Requirements
13
11
 
14
12
  * Ruby 1.8.6 or higher
15
13
 
16
- == Install
14
+ == Installation
15
+
16
+ You can install the gem by running the command
17
17
 
18
18
  gem install robust_excel_ole
19
19
 
20
+ or by using bundler and putting the following line in your Gemfile.
21
+
22
+ gem 'robust_excel_ole'
23
+
20
24
  == Usage
21
25
 
22
26
  RobustExcelOle can be used either for scripts
@@ -30,79 +34,110 @@ or as a console
30
34
 
31
35
  The call of the console will include RobustExcelOle for you.
32
36
 
33
- The following examples can be used for both scripts and console. You can try them directly.
37
+ The following examples can be used for both scripts and console. If you are in the path of the gem and start the console, you can just put these examples.
34
38
 
35
39
  == Description
36
40
 
37
- RobustExcelOle enables opening and processing Excel files (or workbooks). In the following example, we want to open a workbook, modify a cell, save and close the workbook.
41
+ In the following example, we want to open a workbook, modify a cell, save and close the workbook.
38
42
 
39
- First we open a workbook.
43
+ Let's open a workbook.
40
44
 
41
45
  workbook = Workbook.open 'spec/data/workbook.xls'
42
46
 
43
- We can also open the workbook using a block, similar to, e.g., +File.open+.
47
+ Now we have a Workbook object that wraps a win32ole object. That is, you can send any win32ole (VBA) method to it. For example, you can determine the name and the saved-status of the workbook.
44
48
 
45
- Workbook.open('spec/data/workbook.xls') do |workbook|
46
- # do something
47
- end
49
+ workbook.Name
50
+ # => "workbook.xls"
51
+
52
+ workbook.Visible
53
+ # => false
48
54
 
49
- Now we have a Workbook object that wraps a win32ole object. That is, you can send any win32ole (VBA) method to it. For some common tasks and for considering various cases of Excel and user behaviour, more convenient methods are implemented.
55
+ For some common tasks and for considering various complex cases of Excel and user behaviour, more convenient methods are implemented. For example, RobustExcelOle provides methods for reading and writing the contents of ranges, for opening, saving, closing, reopening and unobtrusively opening workbooks, and for setting options.
50
56
 
51
- For example, we can make the workbook visible, using
57
+ First we want to make the workbook visible.
52
58
 
53
59
  workbook.visible = true
54
60
 
55
- or
61
+ This method makes both the Excel instance and the window of the Workbook-win32ole-object visible.
56
62
 
57
- workbook.for_this_workbook(:visible => true)
63
+ Let's read the value of a named cell.
58
64
 
59
- You can also open a workbook and make it visible in one step.
65
+ value = workbook['firstcell']
66
+ # => "foo"
60
67
 
61
- workbook = Workbook.open('spec/data/workbook.xls', :visible => true)
68
+ Now we want to write a new value into this cell.
62
69
 
63
- or
70
+ workbook['firstcell'] = "new"
64
71
 
65
- workbook = Workbook.open('spec/data/workbook.xls', :v => true)
72
+ Then we'll save the workbook.
66
73
 
67
- Then we read the value of a cell.
74
+ workbook.save
68
75
 
69
- value = workbook['firstcell']
70
- # => "foo"
76
+ Finally we want to close the workbook.
71
77
 
72
- Now we write a new value in this cell.
78
+ workbook.close
73
79
 
74
- workbook['firstcell'] = "new"
80
+ One special feature of RobustExcelOle is that it enables reopening workbooks.
75
81
 
76
- For more details about reading and writing contents of cells and ranges see {README_ranges}[https://github.com/Thomas008/robust_excel_ole/blob/master/README_ranges.rdoc]
82
+ workbook.reopen
77
83
 
78
- Then we save the workbook.
84
+ The workbook is now open again and ready for applying further operations, e.g.
79
85
 
86
+ workbook['firstcell'] = "another_value"
80
87
  workbook.save
88
+ workbook.close
81
89
 
82
- We can also save the workbook under a different name.
90
+ RobustExcelOle allows unobtrusively reading and modifying workbooks, i.e. accessing workbooks without changing their "status". The status comprises whether the workbook is open or closed, saved or unsaved, read-only or writable, visible or invisible, whether the calculation mode is manual or automatic, and checking compatibility is done or not done (the Workbook object remembers its properties).
83
91
 
84
- workbook.save_as('spec/data/new_workbook.xls')
92
+ Workbook.for_modifying('spec/data/workbook.xls') do |workbook|
93
+ # do something
94
+ end
85
95
 
86
- Finally we close the workbook.
96
+ Workbook.for_reading('spec/data/workbook.xls') do |workbook|
97
+ # do something
98
+ end
87
99
 
88
- workbook.close
100
+ === More features when opening, modifying, saving and closing workbooks
89
101
 
90
- We could also have saved and closed the workbook in one step.
102
+ We can open the workbook using a block, similar to, e.g., +File.open+.
91
103
 
92
- workbook.close(:if_unsaved => :save)
104
+ Workbook.open('spec/data/workbook.xls') do |workbook|
105
+ # do something
106
+ end
93
107
 
94
- For more details about saving and closing workbooks see
95
- {README_save_close}[https://github.com/Thomas008/robust_excel_ole/blob/master/README_save_close.rdoc]
108
+ Once we have a workbook, we can set some options, e.g.
96
109
 
97
- One special feature of RobustExcelOle is that it enables reopening workbooks.
110
+ workbook.for_this_workbook(:visible => true, :read_only => false)
98
111
 
99
- workbook.reopen
112
+ We can also open the workbook and provide the options in one step, e.g.
113
+
114
+ workbook = Workbook.open('spec/data/workbook.xls', :visible => true)
115
+
116
+ or, using abbreviations,
117
+
118
+ workbook = Workbook.open('spec/data/workbook.xls', :v => true)
119
+
120
+ For more details about opening workbooks see {README_open}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_open.rdoc]
121
+
122
+ We can do a simple save
123
+
124
+ workbook.save
125
+
126
+ or save the workbook under a different name.
127
+
128
+ workbook.save_as('spec/data/new_workbook.xls')
129
+
130
+ Finally we can save and close the workbook in one step.
131
+
132
+ workbook.close(:if_unsaved => :save)
133
+
134
+ For more details about saving and closing workbooks see
135
+ {README_save_close}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_save_close.rdoc]
100
136
 
101
- Technically, this feature is implemented in such way, that a Workbook object is a proxy of an Excel workbook. A Workbook object is defined by the full workbook name and the Excel instance in which it is opened. RobustExcelOle ensures identity transparency which means that the same Workbook objects refer to the same workbooks, and vice versa.
102
137
 
103
138
  === Using Excel instances
104
139
 
105
- You can start a new Excel instance with
140
+ We can start a new Excel instance with
106
141
 
107
142
  excel1 = Excel.create
108
143
 
@@ -110,7 +145,7 @@ or
110
145
 
111
146
  excel1 = Excel.new(:reuse => false)
112
147
 
113
- You can also have an Excel object by connecting to the already running Excel instance.
148
+ We can also obtain an Excel object by connecting to the already running Excel instance.
114
149
 
115
150
  excel2 = Excel.current
116
151
 
@@ -130,17 +165,17 @@ Closing all Excel instances is done by
130
165
 
131
166
  Excel.close_all(:if_unsaved => :forget)
132
167
 
133
- For hard terminating all Excel processes you can use
168
+ For hard terminating all Excel processes we can use
134
169
 
135
170
  Excel.kill_all
136
171
 
137
- For more details about creating Excel instances see README_excel[https://github.com/Thomas008/robust_excel_ole/blob/master/README_excel_rdoc]
172
+ For more details about creating Excel instances see README_excel[https://github.com/Thomas008/robust_excel_ole/blob/master/README/README_excel_rdoc]
138
173
 
139
174
  === Opening workbooks in several Excel instances
140
175
 
141
176
  RobustExcelOle enables opening and processing workbooks in several Excel instances. Using more than one Excel process allows, e.g., running a script that operates in one Excel instance, while a user (or another script) modifies workbooks in another Excel instance.
142
177
 
143
- For example, suppose you want to open a workbook.
178
+ For example, suppose we want to open a workbook.
144
179
 
145
180
  workbook1 = Workbook.open('spec/data/workbook.xls')
146
181
 
@@ -162,41 +197,31 @@ If this Excel instance is damaged or closed, then options control whether the wo
162
197
 
163
198
  workbook1 = Workbook.open('spec/data/workbook.xls', :default => {:excel => :new})
164
199
 
165
- Without the option +:default+, the workbook is forced to be opened in the current, new or given Excel instance, no matter if and where it was opened before, e.g.
200
+ 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.
166
201
 
167
202
  workbook2 = Workbook.open('spec/data/workbook.xls', :excel => excel1)
168
203
 
169
- As a further feature, RobustExcelOle allows processing workbooks, while still supporting user's interactions: The commands enable to open, close, reopen, read, modify, write and save Excel files, without the need of the user's interaction, and even without the user noticing. Thus, while running a script containing RobustExcelOle commands, the user can open and process Excel files in any Excel instances at any time. RobustExcelOle manages the complex cases of conflicts that might occur such that the user does not need to interfere and the script can continue.
204
+ As a further feature, RobustExcelOle allows processing workbooks, while still supporting user's interactions: The commands enable to open, close, reopen, read, modify, write and save Excel workbooks, without the need of the user's interaction, and even without the user noticing. Thus, while running a script containing RobustExcelOle commands, the user can open and process workbooks in any Excel instances at any time. RobustExcelOle manages the complex cases of conflicts that might occur such that the user does not need to interfere and the script can continue.
170
205
 
171
- For example, suppose you 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 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 before opening the workbook, e.g.
206
+ 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 before opening the workbook, e.g.
172
207
 
173
208
  workbook = Workbook.open('workbook.xls', :if_unsaved => :accept)
174
209
 
175
- Similarly, if the user has opened a workbook that has the same name but a different path, the conflict is solved via an option.
210
+ 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.
176
211
 
177
212
  workbook1 = Workbook.open('spec/data/workbook.xls')
178
213
  # do something
179
214
  workbook2 = Workbook.open('spec/data/more/workbook.xls', :if_obstructed => :forget)
180
215
 
181
- Finally, RobustExcelOle allows unobtrusively reading and modifying workbooks, i.e. accessing workbooks without changing their "status". The status comprises whether the workbook is open or closed, saved or unsaved, read-only or writable, visible or invisible, whether the calculation mode is manual or automatic, and checking compatibility is done or not done.
182
-
183
- Workbook.for_modifying('workbook.xls') do |book|
184
- # do something
185
- end
186
-
187
- Workbook.for_reading('workbook.xls') do |book|
188
- # do something
189
- end
190
-
191
- For more details about opening and closing workbooks in Excel instances see {README_open}[https://github.com/Thomas008/robust_excel_ole/blob/master/README_open.rdoc]
216
+ 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]
192
217
 
193
- === Processing worksheets
218
+ === Operating on worksheets
194
219
 
195
- Assime you have opened a workbook
220
+ Assume we have opened a workbook
196
221
 
197
222
  workbook = Workbook.open('spec/data/workbook.xls')
198
223
 
199
- You access the first worksheet by
224
+ We access the first worksheet by
200
225
 
201
226
  sheet = workbook.sheet(1)
202
227
 
@@ -208,14 +233,22 @@ or
208
233
 
209
234
  sheet = workbook.first_sheet
210
235
 
211
- You can read and change the worksheet name.
236
+ We can read and change the worksheet name.
212
237
 
213
238
  sheet.name
214
239
  # => "Sheet1"
215
240
 
216
241
  sheet.name = "new_sheet"
217
242
 
218
- You can read the first three cells of the first row
243
+ We can copy the first worksheet, name it and add it before the third worksheet.
244
+
245
+ workbook.add_or_copy_sheet(sheet, :as => "copied_name, :before => workbook.last_sheet)
246
+
247
+ For more details about processing worksheets see {README_sheet}[https://github.com/Thomas008/robust_excel_ole/blob/master/docs/README_sheet.rdoc]
248
+
249
+ === Reading and writing ranges in worksheets
250
+
251
+ We can read the first three cells of the first row
219
252
 
220
253
  sheet.row_range(1, 1..3).values # => ["foo","workbook","sheet1"]
221
254
 
@@ -223,7 +256,7 @@ and the third column
223
256
 
224
257
  sheet.col_range(3).values # => ["sheet1", 2.0, 4.0]
225
258
 
226
- You can read the first cell, using
259
+ We can read the first cell, using
227
260
 
228
261
  sheet[1,1].value # => "foo"
229
262
 
@@ -235,7 +268,7 @@ Then we modify it
235
268
 
236
269
  sheet[1,1] = "hello"
237
270
 
238
- You can get the value of a named range
271
+ We get the value of a named range
239
272
 
240
273
  sheet["firstcell"] # => "hello"
241
274
 
@@ -243,20 +276,21 @@ and set another value to that range.
243
276
 
244
277
  sheet["firstcell"] = "new_value"
245
278
 
246
- You can copy the first worksheet, name it and add it before the third worksheet.
279
+ 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]
247
280
 
248
- workbook.add_or_copy_sheet(sheet, :as => "copied_name, :before => workbook.last_sheet)
281
+ === Examples
282
+
283
+ You can run the examples included in the directory +examples+, e.g.
249
284
 
250
- For more details about processing worksheets see {README_sheet}[https://github.com/Thomas008/robust_excel_ole/blob/master/README_sheet.rdoc]
285
+ ruby examples\open_save_close\example_unobtrusively.rb
251
286
 
252
- === Development
287
+ == Development
253
288
 
254
- For some details about developing RobustExcelOle see
255
- {README_development}[https://github.com/Thomas008/robust_excel_ole/blob/master/README_development.rdoc]
289
+ This project RobustExcelOle is work in progress. We are happy to implement further features. So we invite you to send your pull requests. We then strive to realize them as soon as possible. If you have any feedback, or you find use cases that RobustExcelOle does not satisfy, please let us know.
256
290
 
257
- === Want to do more things
291
+ RobustExcelOle is being tested for Excel 2010. It can be used for any recent Excel Office version.
258
292
 
259
- If you want to do something that not provide a function, you can use win32ole methods.
293
+ The tests of RobustExcelOle are optimised with help of the rcov tool.
260
294
 
261
295
  == Support
262
296
 
@@ -76,6 +76,8 @@ You can turn off and off DisplayAlerts in a block.
76
76
  # do something
77
77
  end
78
78
 
79
+ Notice, that when the Excel instance is set to visible, its DisplayAlerts is set to true by default, if DisplayAlerts is not explicitely set to false.
80
+
79
81
  === Setting Calculation mode.
80
82
 
81
83
  You can set the calculation mode of an Excel instance to manual or automatic.
@@ -107,6 +107,7 @@ If you want to open the workbook and make its window visible, then use
107
107
 
108
108
  book = Workbook.open('workbook.xls', :visible => true)
109
109
 
110
+ Notice, that when the workbook is visible, the DisplayAlerts of the respective Excel instance is true, if not explicitely DisplayAlerts is set to false in this Excel instance.
110
111
  You can combine options, e.g.
111
112
 
112
113
  Workbook.open('workbook.xls', :excel => :new, :visible => true, :default => {:excel => excel1})
@@ -139,13 +140,7 @@ A special feature of RobustExcelOle is that it allows to reopen workbooks after
139
140
 
140
141
  The closed workbook is now alive again, i.e. is open and responds to Excel methods.
141
142
 
142
- This feature is a result of providing identity transparence and storing the file name.
143
-
144
- === The Workbook objects and transperence identity
145
-
146
- An Excel file (or workbook) is represented by a Workbook object. A Workbook object is defined by the full name of the workbook and the Excel instance in which it is opened. RobustExcelOle aims to ensure identity transperency.
147
- Identity transparence means that the same Workbook objects refer to the same Excel files, and vice versa.
148
- In other words, a Workbook objects is a proxy of an Excel file.
143
+ Technically, this feature is implemented in such way, that a Workbook object is a proxy of an Excel workbook. A Workbook object is defined by the full workbook name and the Excel instance in which it is opened. RobustExcelOle ensures identity transparency which means that the same Workbook objects refer to the same workbooks, and vice versa.
149
144
 
150
145
  === Promoting a workbook to a Workbook object
151
146
 
@@ -153,22 +148,23 @@ A Workbook object can be created when giving an Excel workbook.
153
148
 
154
149
  book = Workbook.new(win32ole_workbook)
155
150
 
156
-
157
151
  === Unobtrusively modifying a workbook
158
152
 
159
153
  The method +unobtrusively+ enables the user to read or modify a workbook, no matter if it is open in some Excel instance, if it is saved or unsaved, and if it is writable or not. When opening a workbook unobtrusively, its status remains unchanged. This status includes, whether the workbook is opened or closed, saved or unsaved, readonly or writable, visible or invisible, calculation mode is automatic or manual, and checking compatibility is turned on or off.
160
154
 
161
- One option chooses the Excel instance in which a closed workbook is opened. The option +:current+ (or +:active+, or +:reuse) (default) indicates that the closed workbook is opened in the Excel instance of the workbook, if it exists, or that another Excel instance is reused. Moreover, an Excel instance can be given directly where to open the closed workbook.
162
-
163
155
  Options are the following:
164
156
 
165
- +:current+ (or +:active, or +:reuse+:): (default) : open a closed workbook in the Excel instance where it was opened most recently, if such an Excel instance exists, otherwise open it in the current (first opened) Excel instance
157
+ +:if_closed+:: +:current+ (or +:active, or +:reuse+:): (default) : open a closed workbook in the Excel instance where it was opened most recently, if such an Excel instance exists, otherwise open it in the current (first opened) Excel instance
166
158
 
167
- +:read_only+:: Open the workbook unobtrusively for reading only (default: false)
168
- +:readonly_excel+:: if the workbook is opened only as ReadOnly and shall be modified, then
169
- true: close it and open it as writable in the excel instance where it was open so far
170
- false (default) open it as writable in another running excel instance, if it exists, otherwise open in a new excel instance
171
- +:keep_open+:: let the workbook open after unobtrusively opening (default: false)
159
+ +:read_only+:: Whether the workbook shall be forced to be open in ReadOnly mode (default: +false+)
160
+ +:writable+:: Whether changes in the workbook shall be saved (default: +true+)
161
+
162
+ +:rw_change_excel+:: Excel instance in which the workbook with the
163
+ changed read-write permissions shall be opened
164
+ :current (default), :new or an Excel instance
165
+
166
+ +:keep_open+:: Whether the workbook shall be open after unobtrusively opening (default: false)
167
+
172
168
 
173
169
  Workbook.unobtrusively('workbook.xls') do |book|
174
170
  # some modification
@@ -2,7 +2,7 @@
2
2
 
3
3
  == Reading and writing the contents of ranges and cells
4
4
 
5
- RobustExcelOle enables to read and write the contents of ranges and cells in Excel files. This can be done from a Sheet, a Book or an Excel object representing a Worksheet, Workbook, or Application object in VBA.
5
+ RobustExcelOle enables to read and write the contents of ranges and cells in workbooks. This can be done from a Sheet, a Book or an Excel object representing a Worksheet, Workbook, or Application object in VBA.
6
6
 
7
7
  === Reading and writing the contents of a named range in a workbook.
8
8
 
File without changes
@@ -7,7 +7,7 @@ require "fileutils"
7
7
 
8
8
  include RobustExcelOle
9
9
 
10
- Excel.close_all
10
+ Excel.kill_all
11
11
  begin
12
12
  dir = create_tmpdir
13
13
  file_name = dir + 'workbook.xls'
@@ -19,7 +19,7 @@ begin
19
19
  sleep 1
20
20
  begin
21
21
  new_book = Book.open(file_name, :if_unsaved => :alert) # open another book with the same file name
22
- rescue ExcelUserCanceled => msg # if the user chooses not open the book,
22
+ rescue WorkbookREOError => msg # if the user chooses not open the book,
23
23
  puts "#{msg.message}" # an exeptions is raised
24
24
  end
25
25
  puts "new book has opened" if new_book
@@ -39,6 +39,6 @@ begin
39
39
  new_book.close # close the new book, if the user chose to open it
40
40
  end
41
41
  ensure
42
- Excel.close_all # close ALL workbooks, quit Excel application
42
+ Excel.kill_all # close ALL workbooks, quit Excel application
43
43
  rm_tmp(dir)
44
44
  end