robust_excel_ole 1.14 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog +34 -1
- data/README.rdoc +20 -6
- data/___dummy_workbook.xls +0 -0
- data/docs/README_excel.rdoc +7 -1
- data/docs/README_open.rdoc +45 -20
- data/docs/README_ranges.rdoc +11 -2
- data/examples/example_ruby_library.rb +27 -0
- data/extconf.rb +13 -0
- data/lib/robust_excel_ole.rb +4 -3
- data/lib/robust_excel_ole/{address.rb → address_tool.rb} +23 -22
- data/lib/robust_excel_ole/{reo_common.rb → base.rb} +2 -90
- data/lib/robust_excel_ole/bookstore.rb +14 -77
- data/lib/robust_excel_ole/cell.rb +30 -18
- data/lib/robust_excel_ole/excel.rb +105 -64
- data/lib/robust_excel_ole/general.rb +40 -15
- data/lib/robust_excel_ole/range.rb +42 -19
- data/lib/robust_excel_ole/range_owners.rb +40 -25
- data/lib/robust_excel_ole/vba_objects.rb +30 -0
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/workbook.rb +310 -336
- data/lib/robust_excel_ole/worksheet.rb +51 -25
- data/robust_excel_ole.gemspec +1 -0
- data/spec/address_tool_spec.rb +175 -0
- data/spec/{reo_common_spec.rb → base_spec.rb} +19 -34
- data/spec/bookstore_spec.rb +3 -3
- data/spec/cell_spec.rb +67 -25
- data/spec/data/more_data/workbook.xls +0 -0
- data/spec/excel_spec.rb +137 -369
- data/spec/general_spec.rb +21 -27
- data/spec/range_spec.rb +57 -3
- data/spec/workbook_spec.rb +11 -79
- data/spec/workbook_specs/workbook_misc_spec.rb +29 -40
- data/spec/workbook_specs/workbook_open_spec.rb +570 -30
- data/spec/workbook_specs/workbook_unobtr_spec.rb +440 -136
- data/spec/worksheet_spec.rb +36 -4
- metadata +11 -7
- data/spec/address_spec.rb +0 -174
@@ -35,8 +35,239 @@ describe Workbook do
|
|
35
35
|
rm_tmp(@dir)
|
36
36
|
end
|
37
37
|
|
38
|
+
describe "Workbook#for_reading, #for_modifying" do
|
39
|
+
|
40
|
+
context "with standard" do
|
41
|
+
|
42
|
+
before do
|
43
|
+
@book = Workbook.open(@simple_file1)
|
44
|
+
@old_value = @book.sheet(1)[1,1].Value
|
45
|
+
end
|
46
|
+
|
47
|
+
after do
|
48
|
+
@book.close(:if_unsaved => :forget) if @book && @book.alive?
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should not change the value" do
|
52
|
+
@book.for_reading do |book|
|
53
|
+
book.should be_a Workbook
|
54
|
+
book.should be_alive
|
55
|
+
book.Saved.should be true
|
56
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
57
|
+
book.Saved.should be false
|
58
|
+
end
|
59
|
+
@book.close(:if_unsaved => :forget)
|
60
|
+
new_book = Workbook.open(@simple_file1)
|
61
|
+
new_book.sheet(1)[1,1].Value.should == @old_value
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should change the value" do
|
65
|
+
@book.for_modifying do |book|
|
66
|
+
book.should be_a Workbook
|
67
|
+
book.should be_alive
|
68
|
+
book.Saved.should be true
|
69
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
70
|
+
book.Saved.should be false
|
71
|
+
end
|
72
|
+
@book.close(:if_unsaved => :forget)
|
73
|
+
new_book = Workbook.open(@simple_file1)
|
74
|
+
new_book.sheet(1)[1,1].Value.should_not == @old_value
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should not change the value and make visible" do
|
78
|
+
@book.for_reading(:visible => true) do |book|
|
79
|
+
book.should be_a Workbook
|
80
|
+
book.should be_alive
|
81
|
+
book.visible.should be true
|
82
|
+
book.Saved.should be true
|
83
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
84
|
+
book.Saved.should be false
|
85
|
+
end
|
86
|
+
@book.close(:if_unsaved => :forget)
|
87
|
+
new_book = Workbook.open(@simple_file1)
|
88
|
+
new_book.sheet(1)[1,1].Value.should == @old_value
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should change the value and make visible" do
|
92
|
+
@book.for_modifying(:visible => true) do |book|
|
93
|
+
book.should be_a Workbook
|
94
|
+
book.should be_alive
|
95
|
+
book.visible.should be true
|
96
|
+
book.Saved.should be true
|
97
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
98
|
+
book.Saved.should be false
|
99
|
+
end
|
100
|
+
@book.close(:if_unsaved => :forget)
|
101
|
+
new_book = Workbook.open(@simple_file1)
|
102
|
+
new_book.sheet(1)[1,1].Value.should_not == @old_value
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "Workbook#unobtrusively" do
|
110
|
+
|
111
|
+
context "with a writable saved workbook" do
|
112
|
+
|
113
|
+
before do
|
114
|
+
@book = Workbook.open(@simple_file1, :visible => true)
|
115
|
+
@old_value = @book.sheet(1)[1,1].Value
|
116
|
+
end
|
117
|
+
|
118
|
+
after do
|
119
|
+
@book.close(:if_unsaved => :forget) if @book && @book.alive?
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should unobtrusively open, modify, and retain the status" do
|
123
|
+
@book.unobtrusively do |book|
|
124
|
+
book.saved.should be true
|
125
|
+
book.visible.should be true
|
126
|
+
book.writable.should be true
|
127
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
128
|
+
end
|
129
|
+
@book.saved.should be true
|
130
|
+
@book.visible.should be true
|
131
|
+
@book.writable.should be true
|
132
|
+
@book.sheet(1)[1,1].Value.should_not == @old_value
|
133
|
+
@book.close
|
134
|
+
new_book = Workbook.open(@simple_file1)
|
135
|
+
new_book.sheet(1)[1,1].Value.should_not == @old_value
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should unobtrusively open, modify, and not save the changes" do
|
139
|
+
@book.unobtrusively(:writable => false) do |book|
|
140
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
141
|
+
end
|
142
|
+
@book.saved.should be true
|
143
|
+
@book.visible.should be true
|
144
|
+
@book.writable.should be true
|
145
|
+
@book.sheet(1)[1,1].Value.should_not == @old_value
|
146
|
+
@book.close
|
147
|
+
new_book = Workbook.open(@simple_file1)
|
148
|
+
new_book.sheet(1)[1,1].Value.should == @old_value
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should unobtrusively open, modify, and save the changes" do
|
152
|
+
@book.unobtrusively(:writable => true) do |book|
|
153
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
154
|
+
end
|
155
|
+
@book.saved.should be true
|
156
|
+
@book.visible.should be true
|
157
|
+
@book.writable.should be true
|
158
|
+
@book.sheet(1)[1,1].Value.should_not == @old_value
|
159
|
+
@book.close
|
160
|
+
new_book = Workbook.open(@simple_file1)
|
161
|
+
new_book.sheet(1)[1,1].Value.should_not == @old_value
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
context "with an writable unsaved workbook" do
|
167
|
+
|
168
|
+
before do
|
169
|
+
@book = Workbook.open(@simple_file1, :visible => true)
|
170
|
+
@old_value = @book.sheet(1)[1,1].Value
|
171
|
+
sheet = @book.sheet(1)
|
172
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
173
|
+
end
|
174
|
+
|
175
|
+
after do
|
176
|
+
@book.close(:if_unsaved => :forget) if @book && @book.alive?
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should unobtrusively open, modify, and retain the status" do
|
180
|
+
@book.unobtrusively do |book|
|
181
|
+
book.saved.should be false
|
182
|
+
book.visible.should be true
|
183
|
+
book.writable.should be true
|
184
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
185
|
+
end
|
186
|
+
@book.saved.should be false
|
187
|
+
@book.visible.should be true
|
188
|
+
@book.writable.should be true
|
189
|
+
@book.sheet(1)[1,1].Value.should == @old_value
|
190
|
+
@book.close(:if_unsaved => :forget)
|
191
|
+
@book = Workbook.open(@simple_file1)
|
192
|
+
@book.sheet(1)[1,1].Value.should == @old_value
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should unobtrusively open, modify, and not save the changes" do
|
196
|
+
@book.unobtrusively(:writable => false) do |book|
|
197
|
+
book.sheet(1)[1,1] = "bla"
|
198
|
+
end
|
199
|
+
@book.saved.should be false
|
200
|
+
@book.visible.should be true
|
201
|
+
@book.writable.should be true
|
202
|
+
@book.sheet(1)[1,1].Value.should == "bla"
|
203
|
+
@book.close(:if_unsaved => :forget)
|
204
|
+
new_book = Workbook.open(@simple_file1)
|
205
|
+
new_book.sheet(1)[1,1].Value.should == @old_value
|
206
|
+
end
|
207
|
+
|
208
|
+
it "should unobtrusively open, modify, and save the changes" do
|
209
|
+
@book.unobtrusively(:writable => true) do |book|
|
210
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
211
|
+
end
|
212
|
+
@book.saved.should be false
|
213
|
+
@book.visible.should be true
|
214
|
+
@book.writable.should be true
|
215
|
+
@book.sheet(1)[1,1].Value.should == @old_value
|
216
|
+
@book.close(:if_unsaved => :forget)
|
217
|
+
new_book = Workbook.open(@simple_file1)
|
218
|
+
new_book.sheet(1)[1,1].Value.should == @old_value
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
context "with a closed workbook" do
|
224
|
+
|
225
|
+
before do
|
226
|
+
@book = Workbook.open(@simple_file1, :visible => true)
|
227
|
+
@old_value = @book.sheet(1)[1,1].Value
|
228
|
+
@book.close
|
229
|
+
end
|
230
|
+
|
231
|
+
after do
|
232
|
+
@book.close(:if_unsaved => :forget) if @book && @book.alive?
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should unobtrusively open and close the workbook" do
|
236
|
+
@book.unobtrusively do |book|
|
237
|
+
book.should be_alive
|
238
|
+
book.saved.should be true
|
239
|
+
book.visible.should be true
|
240
|
+
book.writable.should be true
|
241
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
242
|
+
end
|
243
|
+
@book.should_not be_alive
|
244
|
+
new_book = Workbook.open(@simple_file1)
|
245
|
+
new_book.sheet(1)[1,1].Value.should_not == @old_value
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should unobtrusively open and and not close the workbook" do
|
249
|
+
@book.unobtrusively(:visible => true, :keep_open => true) do |book|
|
250
|
+
book.should be_alive
|
251
|
+
book.saved.should be true
|
252
|
+
book.visible.should be true
|
253
|
+
book.writable.should be true
|
254
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
255
|
+
end
|
256
|
+
@book.should be_alive
|
257
|
+
@book.saved.should be true
|
258
|
+
@book.visible.should be true
|
259
|
+
@book.writable.should be true
|
260
|
+
@book.sheet(1)[1,1].Value.should_not == @old_value
|
261
|
+
@book.close
|
262
|
+
new_book = Workbook.open(@simple_file1)
|
263
|
+
new_book.sheet(1)[1,1].Value.should_not == @old_value
|
264
|
+
end
|
265
|
+
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
38
269
|
|
39
|
-
describe "unobtrusively" do
|
270
|
+
describe "Workbook.unobtrusively" do
|
40
271
|
|
41
272
|
# @private
|
42
273
|
def unobtrusively_ok?
|
@@ -88,13 +319,13 @@ describe Workbook do
|
|
88
319
|
@ole_e1 = WIN32OLE.new('Excel.Application')
|
89
320
|
ws = @ole_e1.Workbooks
|
90
321
|
@abs_filename = General.absolute_path(@simple_file1)
|
91
|
-
@ole_wb = ws.Open(abs_filename)
|
322
|
+
@ole_wb = ws.Open(@abs_filename)
|
92
323
|
@old_value = @ole_wb.Worksheets.Item(1).Cells.Item(1,1).Value
|
93
324
|
end
|
94
325
|
|
95
326
|
it "should connect" do
|
96
|
-
|
97
|
-
book.excel.
|
327
|
+
Workbook.unobtrusively(@simple_file1) do |book|
|
328
|
+
book.excel.Workbooks.Count.should == 1
|
98
329
|
Excel.excels_number.should == 1
|
99
330
|
book.FullName.should == General.absolute_path(@simple_file1)
|
100
331
|
book.saved.should be true
|
@@ -108,22 +339,24 @@ describe Workbook do
|
|
108
339
|
end
|
109
340
|
|
110
341
|
it "should set visible => true and remain invisiblity" do
|
111
|
-
|
342
|
+
Workbook.unobtrusively(@simple_file1, :visible => true) do |book|
|
112
343
|
book.saved.should be true
|
113
344
|
book.visible.should be true
|
114
345
|
book.writable.should be true
|
115
346
|
end
|
116
347
|
ole_wb = WIN32OLE.connect(@abs_filename)
|
117
348
|
ole_wb.Saved.should be true
|
118
|
-
@ole_e1.Visible.should be
|
349
|
+
@ole_e1.Visible.should be true
|
350
|
+
ole_wb.Windows(ole_wb.Name).Visible.should be false
|
119
351
|
ole_wb.ReadOnly.should be false
|
120
352
|
end
|
121
353
|
|
122
354
|
it "should set read_only => true and remain writability" do
|
123
|
-
|
355
|
+
Workbook.unobtrusively(@simple_file1, :read_only => true) do |book|
|
124
356
|
book.saved.should be true
|
125
357
|
book.visible.should be false
|
126
|
-
book.
|
358
|
+
book.ReadOnly.should be true
|
359
|
+
book.writable.should be false
|
127
360
|
end
|
128
361
|
ole_wb = WIN32OLE.connect(@abs_filename)
|
129
362
|
ole_wb.Saved.should be true
|
@@ -132,24 +365,26 @@ describe Workbook do
|
|
132
365
|
end
|
133
366
|
|
134
367
|
it "should set visible => true, read_only => true" do
|
135
|
-
|
368
|
+
Workbook.unobtrusively(@simple_file1, :visible => true, :read_only => true) do |book|
|
136
369
|
book.saved.should be true
|
137
370
|
book.visible.should be true
|
371
|
+
book.ReadOnly.should be true
|
138
372
|
book.writable.should be false
|
139
373
|
end
|
140
374
|
ole_wb = WIN32OLE.connect(@abs_filename)
|
141
375
|
ole_wb.Saved.should be true
|
142
|
-
@ole_e1.Visible.should be
|
376
|
+
@ole_e1.Visible.should be true
|
377
|
+
ole_wb.Windows(ole_wb.Name).Visible.should be false
|
143
378
|
ole_wb.ReadOnly.should be false
|
144
379
|
end
|
145
380
|
|
146
381
|
it "should modify and remain saved-status" do
|
147
|
-
|
382
|
+
Workbook.unobtrusively(@simple_file1) do |book|
|
148
383
|
book.saved.should be true
|
149
384
|
book.visible.should be false
|
150
385
|
book.writable.should be true
|
151
386
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
152
|
-
@new_value = book.sheet(1)[1,1].
|
387
|
+
@new_value = book.sheet(1)[1,1].Value
|
153
388
|
book.Saved.should be false
|
154
389
|
end
|
155
390
|
ole_wb = WIN32OLE.connect(@abs_filename)
|
@@ -158,17 +393,17 @@ describe Workbook do
|
|
158
393
|
ole_wb.ReadOnly.should be false
|
159
394
|
ole_wb.Close
|
160
395
|
book2 = Workbook.open(@simple_file1)
|
161
|
-
book2.sheet(1)[1,1].
|
162
|
-
book2.sheet(1)[1,1].
|
396
|
+
book2.sheet(1)[1,1].Value.should_not == @old_value
|
397
|
+
book2.sheet(1)[1,1].Value.should == @new_value
|
163
398
|
end
|
164
399
|
|
165
400
|
it "should modify and remain saved-status and not save the new value when writable => false" do
|
166
|
-
|
401
|
+
Workbook.unobtrusively(@simple_file1, :writable => false) do |book|
|
167
402
|
book.saved.should be true
|
168
403
|
book.visible.should be false
|
169
404
|
book.writable.should be true
|
170
405
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
171
|
-
@new_value = book.sheet(1)[1,1].
|
406
|
+
@new_value = book.sheet(1)[1,1].Value
|
172
407
|
book.Saved.should be false
|
173
408
|
end
|
174
409
|
ole_wb = WIN32OLE.connect(@abs_filename)
|
@@ -177,8 +412,8 @@ describe Workbook do
|
|
177
412
|
ole_wb.ReadOnly.should be false
|
178
413
|
ole_wb.Close
|
179
414
|
book2 = Workbook.open(@simple_file1)
|
180
|
-
book2.sheet(1)[1,1].
|
181
|
-
book2.sheet(1)[1,1].
|
415
|
+
book2.sheet(1)[1,1].Value.should == @old_value
|
416
|
+
book2.sheet(1)[1,1].Value.should_not == @new_value
|
182
417
|
end
|
183
418
|
|
184
419
|
end
|
@@ -189,13 +424,13 @@ describe Workbook do
|
|
189
424
|
@ole_e1 = WIN32OLE.new('Excel.Application')
|
190
425
|
ws = @ole_e1.Workbooks
|
191
426
|
@abs_filename = General.absolute_path(@simple_file1)
|
192
|
-
@ole_wb = ws.Open(abs_filename)
|
427
|
+
@ole_wb = ws.Open(@abs_filename)
|
193
428
|
@ole_e1.Visible = true
|
194
429
|
@ole_wb.Windows(@ole_wb.Name).Visible = true
|
195
430
|
end
|
196
431
|
|
197
432
|
it "should remain visibility" do
|
198
|
-
|
433
|
+
Workbook.unobtrusively(@simple_file1) do |book|
|
199
434
|
book.saved.should be true
|
200
435
|
book.visible.should be true
|
201
436
|
book.writable.should be true
|
@@ -207,7 +442,7 @@ describe Workbook do
|
|
207
442
|
end
|
208
443
|
|
209
444
|
it "should set visible => false and remain visibility" do
|
210
|
-
|
445
|
+
Workbook.unobtrusively(@simple_file1, :visible => false) do |book|
|
211
446
|
book.saved.should be true
|
212
447
|
book.visible.should be false
|
213
448
|
book.writable.should be true
|
@@ -226,17 +461,17 @@ describe Workbook do
|
|
226
461
|
@ole_e1 = WIN32OLE.new('Excel.Application')
|
227
462
|
ws = @ole_e1.Workbooks
|
228
463
|
@abs_filename = General.absolute_path(@simple_file1)
|
229
|
-
@ole_wb = ws.Open(abs_filename)
|
464
|
+
@ole_wb = ws.Open(@abs_filename)
|
230
465
|
@ole_e1.Visible = true
|
231
466
|
@ole_wb.Windows(@ole_wb.Name).Visible = true
|
232
467
|
@old_value = @ole_wb.Worksheets.Item(1).Cells.Item(1,1).Value
|
233
|
-
@ole_wb.Worksheets.Item(
|
468
|
+
@ole_wb.Worksheets.Item(1).Cells.Item(1,1).Value = @old_value = "foo" #== "foo" ? "bar" : "foo"
|
234
469
|
@new_value = @ole_wb.Worksheets.Item(1).Cells.Item(1,1).Value
|
235
470
|
@ole_wb.Saved.should be false
|
236
471
|
end
|
237
472
|
|
238
473
|
it "should connect and remain unsaved" do
|
239
|
-
|
474
|
+
Workbook.unobtrusively(@simple_file1) do |book|
|
240
475
|
book.saved.should be false
|
241
476
|
book.visible.should be true
|
242
477
|
book.writable.should be true
|
@@ -247,9 +482,19 @@ describe Workbook do
|
|
247
482
|
ole_wb.ReadOnly.should be false
|
248
483
|
end
|
249
484
|
|
485
|
+
it "should raise error" do
|
486
|
+
expect{
|
487
|
+
Workbook.unobtrusively(@simple_file1, :read_only => true) do |book|
|
488
|
+
book.saved.should be false
|
489
|
+
book.visible.should be true
|
490
|
+
book.writable.should be false
|
491
|
+
end
|
492
|
+
}.to raise_error(WorkbookNotSaved)
|
493
|
+
end
|
494
|
+
|
250
495
|
it "should remain writable" do
|
251
|
-
|
252
|
-
book.saved.should be
|
496
|
+
Workbook.unobtrusively(@simple_file1, :read_only => true, :if_unsaved => :save) do |book|
|
497
|
+
book.saved.should be true
|
253
498
|
book.visible.should be true
|
254
499
|
book.writable.should be false
|
255
500
|
end
|
@@ -260,8 +505,8 @@ describe Workbook do
|
|
260
505
|
end
|
261
506
|
|
262
507
|
it "should remain unsaved when modifying" do
|
263
|
-
|
264
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
508
|
+
Workbook.unobtrusively(@simple_file1) do |book|
|
509
|
+
book.sheet(1)[1,1] = "bar" #book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
265
510
|
@new_value = book.sheet(1)[1,1].Value
|
266
511
|
book.saved.should be false
|
267
512
|
book.visible.should be true
|
@@ -271,15 +516,18 @@ describe Workbook do
|
|
271
516
|
ole_wb.Saved.should be false
|
272
517
|
@ole_e1.Visible.should be true
|
273
518
|
ole_wb.ReadOnly.should be false
|
274
|
-
|
519
|
+
Excel.kill_all
|
275
520
|
book2 = Workbook.open(@simple_file1)
|
276
|
-
book2.sheet(1)[1,1].
|
277
|
-
book2.sheet(1)[1,1].
|
521
|
+
book2.sheet(1)[1,1].Value.should_not == @old_value
|
522
|
+
book2.sheet(1)[1,1].Value.should == @new_value
|
278
523
|
end
|
279
524
|
|
280
525
|
it "should not write with :writable => false" do
|
281
|
-
|
282
|
-
|
526
|
+
@ole_wb.Worksheets.Item(1).Cells.Item(1,1).Value = @old_value = "foo"
|
527
|
+
@ole_wb.Save
|
528
|
+
@ole_wb.Worksheets.Item(1).Cells.Item(1,1).Value = @old_value = "foo"
|
529
|
+
Workbook.unobtrusively(@simple_file1, :writable => false) do |book|
|
530
|
+
book.sheet(1)[1,1] = "bar" #book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
283
531
|
@new_value = book.sheet(1)[1,1].Value
|
284
532
|
book.saved.should be false
|
285
533
|
book.visible.should be true
|
@@ -289,10 +537,10 @@ describe Workbook do
|
|
289
537
|
ole_wb.Saved.should be false
|
290
538
|
@ole_e1.Visible.should be true
|
291
539
|
ole_wb.ReadOnly.should be false
|
292
|
-
|
540
|
+
Excel.kill_all
|
293
541
|
book2 = Workbook.open(@simple_file1)
|
294
|
-
book2.sheet(1)[1,1].
|
295
|
-
book2.sheet(1)[1,1].
|
542
|
+
book2.sheet(1)[1,1].Value.should == @old_value
|
543
|
+
book2.sheet(1)[1,1].Value.should_not == @new_value
|
296
544
|
end
|
297
545
|
|
298
546
|
end
|
@@ -303,14 +551,15 @@ describe Workbook do
|
|
303
551
|
@ole_e1 = WIN32OLE.new('Excel.Application')
|
304
552
|
ws = @ole_e1.Workbooks
|
305
553
|
@abs_filename = General.absolute_path(@simple_file1)
|
306
|
-
@ole_wb = ws.Open(abs_filename, RobustExcelOle::XlUpdateLinksNever, true)
|
554
|
+
@ole_wb = ws.Open(@abs_filename, RobustExcelOle::XlUpdateLinksNever, true)
|
555
|
+
@old_value = @ole_wb.Worksheets.Item(1).Cells.Item(1,1).Value
|
307
556
|
@ole_e1.Visible = true
|
308
557
|
@ole_wb.Windows(@ole_wb.Name).Visible = true
|
309
558
|
@ole_wb.ReadOnly.should be true
|
310
559
|
end
|
311
560
|
|
312
561
|
it "should connect and remain read-only" do
|
313
|
-
|
562
|
+
Workbook.unobtrusively(@simple_file1) do |book|
|
314
563
|
book.saved.should be true
|
315
564
|
book.visible.should be true
|
316
565
|
book.writable.should be false
|
@@ -322,8 +571,8 @@ describe Workbook do
|
|
322
571
|
end
|
323
572
|
|
324
573
|
it "should remain read-only" do
|
325
|
-
|
326
|
-
book.saved.should be
|
574
|
+
Workbook.unobtrusively(@simple_file1, :read_only => false) do |book|
|
575
|
+
book.saved.should be true
|
327
576
|
book.visible.should be true
|
328
577
|
book.writable.should be true
|
329
578
|
end
|
@@ -334,7 +583,25 @@ describe Workbook do
|
|
334
583
|
end
|
335
584
|
|
336
585
|
it "should remain read-only when modifying" do
|
337
|
-
|
586
|
+
Workbook.unobtrusively(@simple_file1) do |book|
|
587
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
588
|
+
@new_value = book.sheet(1)[1,1].Value
|
589
|
+
book.saved.should be false
|
590
|
+
book.visible.should be true
|
591
|
+
book.writable.should be false
|
592
|
+
end
|
593
|
+
ole_wb = WIN32OLE.connect(@abs_filename)
|
594
|
+
ole_wb.Saved.should be true
|
595
|
+
@ole_e1.Visible.should be true
|
596
|
+
ole_wb.ReadOnly.should be true
|
597
|
+
ole_wb.Close
|
598
|
+
book2 = Workbook.open(@simple_file1)
|
599
|
+
book2.sheet(1)[1,1].Value.should == @old_value
|
600
|
+
book2.sheet(1)[1,1].Value.should_not == @new_value
|
601
|
+
end
|
602
|
+
|
603
|
+
it "should remain read-only when modifying" do
|
604
|
+
Workbook.unobtrusively(@simple_file1, :read_only => false) do |book|
|
338
605
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
339
606
|
@new_value = book.sheet(1)[1,1].Value
|
340
607
|
book.saved.should be false
|
@@ -347,12 +614,12 @@ describe Workbook do
|
|
347
614
|
ole_wb.ReadOnly.should be true
|
348
615
|
ole_wb.Close
|
349
616
|
book2 = Workbook.open(@simple_file1)
|
350
|
-
book2.sheet(1)[1,1].
|
351
|
-
book2.sheet(1)[1,1].
|
617
|
+
book2.sheet(1)[1,1].Value.should_not == @old_value
|
618
|
+
book2.sheet(1)[1,1].Value.should == @new_value
|
352
619
|
end
|
353
620
|
|
354
621
|
it "should remain read-only when modifying" do
|
355
|
-
|
622
|
+
Workbook.unobtrusively(@simple_file1, :read_only => false, :writable => true) do |book|
|
356
623
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
357
624
|
@new_value = book.sheet(1)[1,1].Value
|
358
625
|
book.saved.should be false
|
@@ -365,12 +632,30 @@ describe Workbook do
|
|
365
632
|
ole_wb.ReadOnly.should be true
|
366
633
|
ole_wb.Close
|
367
634
|
book2 = Workbook.open(@simple_file1)
|
368
|
-
book2.sheet(1)[1,1].
|
369
|
-
book2.sheet(1)[1,1].
|
635
|
+
book2.sheet(1)[1,1].Value.should_not == @old_value
|
636
|
+
book2.sheet(1)[1,1].Value.should == @new_value
|
637
|
+
end
|
638
|
+
|
639
|
+
it "should remain read-only when modifying and not save changes, when :writable => false" do
|
640
|
+
Workbook.unobtrusively(@simple_file1, :writable => false, :read_only => false) do |book|
|
641
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
642
|
+
@new_value = book.sheet(1)[1,1].Value
|
643
|
+
book.saved.should be false
|
644
|
+
book.visible.should be true
|
645
|
+
book.writable.should be true
|
646
|
+
end
|
647
|
+
ole_wb = WIN32OLE.connect(@abs_filename)
|
648
|
+
ole_wb.Saved.should be true
|
649
|
+
@ole_e1.Visible.should be true
|
650
|
+
ole_wb.ReadOnly.should be true
|
651
|
+
ole_wb.Close
|
652
|
+
book2 = Workbook.open(@simple_file1)
|
653
|
+
book2.sheet(1)[1,1].Value.should == @old_value
|
654
|
+
book2.sheet(1)[1,1].Value.should_not == @new_value
|
370
655
|
end
|
371
656
|
|
372
657
|
it "should remain read-only when modifying and not save changes, when :writable => false" do
|
373
|
-
|
658
|
+
Workbook.unobtrusively(@simple_file1, :read_only => false, :writable => false) do |book|
|
374
659
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
375
660
|
@new_value = book.sheet(1)[1,1].Value
|
376
661
|
book.saved.should be false
|
@@ -383,12 +668,13 @@ describe Workbook do
|
|
383
668
|
ole_wb.ReadOnly.should be true
|
384
669
|
ole_wb.Close
|
385
670
|
book2 = Workbook.open(@simple_file1)
|
386
|
-
book2.sheet(1)[1,1].
|
387
|
-
book2.sheet(1)[1,1].
|
671
|
+
book2.sheet(1)[1,1].Value.should == @old_value
|
672
|
+
book2.sheet(1)[1,1].Value.should_not == @new_value
|
388
673
|
end
|
389
674
|
|
675
|
+
|
390
676
|
it "should remain read-only when modifying and not save changes, when :writable => false" do
|
391
|
-
|
677
|
+
Workbook.unobtrusively(@simple_file1, :writable => false, :read_only => false) do |book|
|
392
678
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
393
679
|
@new_value = book.sheet(1)[1,1].Value
|
394
680
|
book.saved.should be false
|
@@ -401,10 +687,47 @@ describe Workbook do
|
|
401
687
|
ole_wb.ReadOnly.should be true
|
402
688
|
ole_wb.Close
|
403
689
|
book2 = Workbook.open(@simple_file1)
|
404
|
-
book2.sheet(1)[1,1].
|
405
|
-
book2.sheet(1)[1,1].
|
690
|
+
book2.sheet(1)[1,1].Value.should == @old_value
|
691
|
+
book2.sheet(1)[1,1].Value.should_not == @new_value
|
406
692
|
end
|
407
693
|
|
694
|
+
it "should remain read-only when modifying and not save changes, even if :writable => true" do
|
695
|
+
Workbook.unobtrusively(@simple_file1, :writable => true) do |book|
|
696
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
697
|
+
@new_value = book.sheet(1)[1,1].Value
|
698
|
+
book.saved.should be false
|
699
|
+
book.visible.should be true
|
700
|
+
book.writable.should be false
|
701
|
+
end
|
702
|
+
ole_wb = WIN32OLE.connect(@abs_filename)
|
703
|
+
ole_wb.Saved.should be true
|
704
|
+
@ole_e1.Visible.should be true
|
705
|
+
ole_wb.ReadOnly.should be true
|
706
|
+
ole_wb.Close
|
707
|
+
book2 = Workbook.open(@simple_file1)
|
708
|
+
book2.sheet(1)[1,1].Value.should == @old_value
|
709
|
+
book2.sheet(1)[1,1].Value.should_not == @new_value
|
710
|
+
end
|
711
|
+
|
712
|
+
it "should remain read-only when modifying and not save changes, when :writable => false" do
|
713
|
+
Workbook.unobtrusively(@simple_file1, :writable => false) do |book|
|
714
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
715
|
+
@new_value = book.sheet(1)[1,1].Value
|
716
|
+
book.saved.should be false
|
717
|
+
book.visible.should be true
|
718
|
+
book.writable.should be false
|
719
|
+
end
|
720
|
+
ole_wb = WIN32OLE.connect(@abs_filename)
|
721
|
+
ole_wb.Saved.should be true
|
722
|
+
@ole_e1.Visible.should be true
|
723
|
+
ole_wb.ReadOnly.should be true
|
724
|
+
Excel.kill_all
|
725
|
+
book2 = Workbook.open(@simple_file1)
|
726
|
+
book2.sheet(1)[1,1].Value.should == @old_value
|
727
|
+
book2.sheet(1)[1,1].Value.should_not == @new_value
|
728
|
+
end
|
729
|
+
|
730
|
+
|
408
731
|
end
|
409
732
|
|
410
733
|
end
|
@@ -464,7 +787,7 @@ describe Workbook do
|
|
464
787
|
end
|
465
788
|
Excel.current.Workbooks.Count.should == 0
|
466
789
|
b1 = Workbook.open(@simple_file1)
|
467
|
-
b1.sheet(1)[1,1].Value.
|
790
|
+
b1.sheet(1)[1,1].Value.should == @old_value
|
468
791
|
end
|
469
792
|
|
470
793
|
it "should open as read-write" do
|
@@ -495,8 +818,8 @@ describe Workbook do
|
|
495
818
|
Workbook.unobtrusively(@simple_file, :read_only => true) do |book|
|
496
819
|
book.ReadOnly.should be true
|
497
820
|
@old_value = book.sheet(1)[1,1].Value
|
498
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
499
|
-
book.Saved.should be false
|
821
|
+
#book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
822
|
+
#book.Saved.should be false
|
500
823
|
end
|
501
824
|
Excel.current.Workbooks.Count.should == 0
|
502
825
|
b1 = Workbook.open(@simple_file1)
|
@@ -577,7 +900,7 @@ describe Workbook do
|
|
577
900
|
end
|
578
901
|
@book.close
|
579
902
|
book2 = Workbook.open(@simple_file1)
|
580
|
-
book2.sheet(1)[1,1].Value.
|
903
|
+
book2.sheet(1)[1,1].Value.should == @old_value
|
581
904
|
end
|
582
905
|
|
583
906
|
it "should open as read-write" do
|
@@ -607,18 +930,20 @@ describe Workbook do
|
|
607
930
|
end
|
608
931
|
|
609
932
|
it "should force to read-only" do
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
book2.sheet(1)[1,1].Value.should == @old_value
|
933
|
+
expect{
|
934
|
+
Workbook.unobtrusively(@simple_file1, :if_unsaved => :forget, :read_only => true) do |book|
|
935
|
+
book.ReadOnly.should be true
|
936
|
+
book.should == @book
|
937
|
+
book.filename.should == @book.filename
|
938
|
+
book.excel.should_not == @book.excel
|
939
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
940
|
+
end
|
941
|
+
}.to raise_error(WorkbookReadOnly)
|
620
942
|
end
|
621
943
|
|
944
|
+
|
945
|
+
|
946
|
+
|
622
947
|
it "should force to read-only" do
|
623
948
|
Workbook.unobtrusively(@simple_file1, :read_only => true, :writable => false) do |book|
|
624
949
|
book.ReadOnly.should be true
|
@@ -685,15 +1010,15 @@ describe Workbook do
|
|
685
1010
|
|
686
1011
|
it "should open as read-write" do
|
687
1012
|
Workbook.unobtrusively(@simple_file1, :read_only => false) do |book|
|
688
|
-
book.Readonly.should be
|
1013
|
+
book.Readonly.should be false
|
689
1014
|
book.should == @book
|
690
1015
|
book.filename.should == @book.filename
|
691
|
-
book.excel.
|
1016
|
+
book.excel.should_not == @book.excel
|
692
1017
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
693
1018
|
end
|
694
1019
|
@book.close
|
695
1020
|
book2 = Workbook.open(@simple_file1)
|
696
|
-
book2.sheet(1)[1,1].Value.
|
1021
|
+
book2.sheet(1)[1,1].Value.should_not == @old_value
|
697
1022
|
end
|
698
1023
|
|
699
1024
|
it "should open as read-write" do
|
@@ -701,7 +1026,7 @@ describe Workbook do
|
|
701
1026
|
book.Readonly.should be false
|
702
1027
|
book.should == @book
|
703
1028
|
book.filename.should == @book.filename
|
704
|
-
book.excel.
|
1029
|
+
book.excel.should_not == @book.excel
|
705
1030
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
706
1031
|
end
|
707
1032
|
@book.close
|
@@ -709,9 +1034,9 @@ describe Workbook do
|
|
709
1034
|
book2.sheet(1)[1,1].Value.should == @old_value
|
710
1035
|
end
|
711
1036
|
|
712
|
-
it "should
|
1037
|
+
it "should remain read-only even if writeble => true" do
|
713
1038
|
Workbook.unobtrusively(@simple_file1, :writable => true) do |book|
|
714
|
-
book.ReadOnly.should be
|
1039
|
+
book.ReadOnly.should be true
|
715
1040
|
book.should == @book
|
716
1041
|
book.filename.should == @book.filename
|
717
1042
|
book.excel.should == @book.excel
|
@@ -719,7 +1044,7 @@ describe Workbook do
|
|
719
1044
|
end
|
720
1045
|
@book.close
|
721
1046
|
book2 = Workbook.open(@simple_file1)
|
722
|
-
book2.sheet(1)[1,1].Value.
|
1047
|
+
book2.sheet(1)[1,1].Value.should == @old_value
|
723
1048
|
end
|
724
1049
|
|
725
1050
|
it "should force to read-write" do
|
@@ -897,7 +1222,7 @@ describe Workbook do
|
|
897
1222
|
end
|
898
1223
|
|
899
1224
|
it "should force to read-only" do
|
900
|
-
Workbook.unobtrusively(@simple_file1, :read_only => true) do |book|
|
1225
|
+
Workbook.unobtrusively(@simple_file1, :read_only => true, :if_unsaved => :save) do |book|
|
901
1226
|
book.ReadOnly.should be true
|
902
1227
|
end
|
903
1228
|
@book.Saved.should be false
|
@@ -906,7 +1231,7 @@ describe Workbook do
|
|
906
1231
|
end
|
907
1232
|
|
908
1233
|
it "should force to read-only with writable false" do
|
909
|
-
Workbook.unobtrusively(@simple_file1, :read_only => true, :writable => false) do |book|
|
1234
|
+
Workbook.unobtrusively(@simple_file1, :if_unsaved => :save, :read_only => true, :writable => false) do |book|
|
910
1235
|
book.ReadOnly.should be true
|
911
1236
|
end
|
912
1237
|
@book.Saved.should be false
|
@@ -955,48 +1280,23 @@ describe Workbook do
|
|
955
1280
|
end
|
956
1281
|
|
957
1282
|
it "should open as read-only" do
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
book.filename.should == @book.filename
|
962
|
-
book.excel.should == @book.excel
|
963
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
964
|
-
end
|
965
|
-
@book.Saved.should be false
|
966
|
-
@book.ReadOnly.should be true
|
967
|
-
@book.sheet(1)[1,1].Value.should_not == @old_value
|
968
|
-
@book.close
|
969
|
-
book2 = Workbook.open(@simple_file1)
|
970
|
-
book2.sheet(1)[1,1].Value.should_not == @old_value
|
1283
|
+
expect{
|
1284
|
+
Workbook.unobtrusively(@simple_file1, :if_unsaved => :accept, :read_only => false, :writable => false)
|
1285
|
+
}.to raise_error(OptionInvalid)
|
971
1286
|
end
|
972
1287
|
|
973
|
-
it "should
|
974
|
-
Workbook.unobtrusively(@simple_file1, :
|
975
|
-
book.Readonly.should be
|
976
|
-
book.should
|
977
|
-
book.filename.should == @book.filename
|
978
|
-
book.excel.should == @book.excel
|
1288
|
+
it "should remain read-only and not write, even with :writable => true" do
|
1289
|
+
Workbook.unobtrusively(@simple_file1, :writable => true) do |book|
|
1290
|
+
book.Readonly.should be true
|
1291
|
+
book.Saved.should be false
|
979
1292
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
980
1293
|
end
|
981
|
-
@book.Saved.should be false
|
982
1294
|
@book.ReadOnly.should be true
|
983
1295
|
@book.sheet(1)[1,1].Value.should_not == @old_value
|
984
1296
|
@book.close
|
985
1297
|
book2 = Workbook.open(@simple_file1)
|
986
1298
|
book2.sheet(1)[1,1].Value.should_not == @old_value
|
987
1299
|
end
|
988
|
-
|
989
|
-
it "should raise an error" do
|
990
|
-
expect{
|
991
|
-
Workbook.unobtrusively(@simple_file1, :writable => true)
|
992
|
-
}.to raise_error(NotImplementedREOError, "unsaved read-only workbook shall be written")
|
993
|
-
end
|
994
|
-
|
995
|
-
it "should raise an error" do
|
996
|
-
expect{
|
997
|
-
Workbook.unobtrusively(@simple_file1, :writable => true)
|
998
|
-
}.to raise_error(NotImplementedREOError, "unsaved read-only workbook shall be written")
|
999
|
-
end
|
1000
1300
|
|
1001
1301
|
it "should force to read-only" do
|
1002
1302
|
Workbook.unobtrusively(@simple_file1, :read_only => true) do |book|
|
@@ -1097,21 +1397,20 @@ describe Workbook do
|
|
1097
1397
|
book = Workbook.open(@simple_file1)
|
1098
1398
|
book.sheet(1)[1,1].Value.should == @old_value
|
1099
1399
|
end
|
1100
|
-
|
1400
|
+
=begin
|
1101
1401
|
it "should write in the outer and not in the inner block" do
|
1102
|
-
Workbook.unobtrusively(@simple_file1) do |book|
|
1402
|
+
Workbook.unobtrusively(@simple_file1, :if_unsaved => :forget) do |book|
|
1103
1403
|
@old_value = book.sheet(1)[1,1].Value
|
1104
1404
|
book.ReadOnly.should be false
|
1105
1405
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
1106
1406
|
book.Saved.should be false
|
1107
1407
|
book.sheet(1)[1,1].Value.should_not == @old_value
|
1108
|
-
Workbook.unobtrusively(@simple_file1, :read_only => true) do |book2|
|
1408
|
+
Workbook.unobtrusively(@simple_file1, :if_unsaved => :forget, :read_only => true) do |book2|
|
1109
1409
|
book2.should == book
|
1110
1410
|
book2.ReadOnly.should be true
|
1111
|
-
book2.Saved.should be
|
1112
|
-
book2.sheet(1)[1,1].Value.should_not == @old_value
|
1411
|
+
book2.Saved.should be true
|
1113
1412
|
book2.sheet(1)[1,1] = book2.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
1114
|
-
book2.sheet(1)[1,1].Value.
|
1413
|
+
#book2.sheet(1)[1,1].Value.should_not == @old_value
|
1115
1414
|
end
|
1116
1415
|
book.should be_alive
|
1117
1416
|
book.Saved.should be false
|
@@ -1120,7 +1419,7 @@ describe Workbook do
|
|
1120
1419
|
book = Workbook.open(@simple_file1)
|
1121
1420
|
book.sheet(1)[1,1].Value.should_not == @old_value
|
1122
1421
|
end
|
1123
|
-
|
1422
|
+
=end
|
1124
1423
|
it "should write in the outer and not in the inner block" do
|
1125
1424
|
Workbook.unobtrusively(@simple_file1) do |book|
|
1126
1425
|
@old_value = book.sheet(1)[1,1].Value
|
@@ -1143,15 +1442,15 @@ describe Workbook do
|
|
1143
1442
|
book = Workbook.open(@simple_file1)
|
1144
1443
|
book.sheet(1)[1,1].Value.should == @old_value
|
1145
1444
|
end
|
1146
|
-
|
1445
|
+
=begin
|
1147
1446
|
it "should be read-only in the outer and write in the inner block" do
|
1148
|
-
Workbook.unobtrusively(@simple_file1, :read_only => true) do |book|
|
1447
|
+
Workbook.unobtrusively(@simple_file1, :read_only => true, :if_unsaved => :save) do |book|
|
1149
1448
|
@old_value = book.sheet(1)[1,1].Value
|
1150
1449
|
book.ReadOnly.should be true
|
1151
1450
|
book.sheet(1)[1,1] = book.sheet(1)[1,1].Value == "foo" ? "bar" : "foo"
|
1152
1451
|
book.Saved.should be false
|
1153
1452
|
book.sheet(1)[1,1].Value.should_not == @old_value
|
1154
|
-
Workbook.unobtrusively(@simple_file1) do |book2|
|
1453
|
+
Workbook.unobtrusively(@simple_file1, :if_unsaved => :save) do |book2|
|
1155
1454
|
book2.should == book
|
1156
1455
|
book2.ReadOnly.should be true
|
1157
1456
|
book2.Saved.should be false
|
@@ -1167,7 +1466,7 @@ describe Workbook do
|
|
1167
1466
|
book = Workbook.open(@simple_file1)
|
1168
1467
|
book.sheet(1)[1,1].Value.should == @old_value
|
1169
1468
|
end
|
1170
|
-
|
1469
|
+
=end
|
1171
1470
|
end
|
1172
1471
|
|
1173
1472
|
end
|
@@ -1235,7 +1534,7 @@ describe Workbook do
|
|
1235
1534
|
book1.ReadOnly.should be true
|
1236
1535
|
book1.close
|
1237
1536
|
book2 = Workbook.open(@simple_file1)
|
1238
|
-
book2.sheet(1)[1,1].Value.
|
1537
|
+
book2.sheet(1)[1,1].Value.should == old_value
|
1239
1538
|
end
|
1240
1539
|
|
1241
1540
|
end
|
@@ -1263,6 +1562,7 @@ describe Workbook do
|
|
1263
1562
|
|
1264
1563
|
it "should remain check-compatibility false" do
|
1265
1564
|
book1 = Workbook.open(@simple_file1, :check_compatibility => false)
|
1565
|
+
book1.CheckCompatibility.should be false
|
1266
1566
|
Workbook.unobtrusively(@simple_file1) do |book|
|
1267
1567
|
end
|
1268
1568
|
book1.CheckCompatibility.should be false
|
@@ -1270,6 +1570,7 @@ describe Workbook do
|
|
1270
1570
|
|
1271
1571
|
it "should remain check-compatibility true" do
|
1272
1572
|
book1 = Workbook.open(@simple_file1, :check_compatibility => true)
|
1573
|
+
book1.CheckCompatibility.should be true
|
1273
1574
|
Workbook.unobtrusively(@simple_file1) do |book|
|
1274
1575
|
end
|
1275
1576
|
book1.CheckCompatibility.should be true
|
@@ -1281,10 +1582,10 @@ describe Workbook do
|
|
1281
1582
|
|
1282
1583
|
it "should remain the calculation mode" do
|
1283
1584
|
book1 = Workbook.open(@simple_file1)
|
1284
|
-
old_calculation = book1.excel.calculation
|
1585
|
+
old_calculation = book1.excel.properties[:calculation]
|
1285
1586
|
Workbook.unobtrusively(@simple_file1) do |book|
|
1286
1587
|
end
|
1287
|
-
book1.excel.calculation.should == old_calculation
|
1588
|
+
book1.excel.properties[:calculation].should == old_calculation
|
1288
1589
|
end
|
1289
1590
|
|
1290
1591
|
it "should remain calculation manual" do
|
@@ -1311,7 +1612,7 @@ describe Workbook do
|
|
1311
1612
|
Workbook.unobtrusively(@simple_file) do |book|
|
1312
1613
|
book.should be_a Workbook
|
1313
1614
|
book.excel.Visible.should be false
|
1314
|
-
book.CheckCompatibility.should be
|
1615
|
+
book.CheckCompatibility.should be true
|
1315
1616
|
book.ReadOnly.should be false
|
1316
1617
|
end
|
1317
1618
|
end
|
@@ -1376,7 +1677,7 @@ describe Workbook do
|
|
1376
1677
|
expect{
|
1377
1678
|
Workbook.unobtrusively(@simple_file, :if_closed => :invalid_option) do |book|
|
1378
1679
|
end
|
1379
|
-
}.to raise_error(TypeREOError, "
|
1680
|
+
}.to raise_error(TypeREOError, "provided Excel option value is neither an Excel object nor a valid option")
|
1380
1681
|
end
|
1381
1682
|
|
1382
1683
|
end
|
@@ -1651,16 +1952,16 @@ describe Workbook do
|
|
1651
1952
|
Workbook.unobtrusively(@simple_file1, :if_closed => :new) do |book|
|
1652
1953
|
book.excel.should_not == @book.excel
|
1653
1954
|
book.excel.should_not == new_excel
|
1654
|
-
book.excel.visible.should be false
|
1655
|
-
book.excel.displayalerts.should == :if_visible
|
1955
|
+
book.excel.properties[:visible].should be false
|
1956
|
+
book.excel.properties[:displayalerts].should == :if_visible
|
1656
1957
|
@another_excel = book.excel
|
1657
1958
|
end
|
1658
1959
|
Workbook.unobtrusively(@simple_file1, :if_closed => :current) do |book|
|
1659
1960
|
book.excel.should_not == @book.excel
|
1660
1961
|
book.excel.should_not == new_excel
|
1661
1962
|
book.excel.should == @another_excel
|
1662
|
-
book.excel.visible.should be false
|
1663
|
-
book.excel.displayalerts.should == :if_visible
|
1963
|
+
book.excel.properties[:visible].should be false
|
1964
|
+
book.excel.properties[:displayalerts].should == :if_visible
|
1664
1965
|
end
|
1665
1966
|
end
|
1666
1967
|
|
@@ -2011,7 +2312,7 @@ describe Workbook do
|
|
2011
2312
|
end
|
2012
2313
|
end
|
2013
2314
|
|
2014
|
-
describe "
|
2315
|
+
describe "type-lifting" do
|
2015
2316
|
|
2016
2317
|
context "with standard" do
|
2017
2318
|
|
@@ -2024,7 +2325,7 @@ describe Workbook do
|
|
2024
2325
|
@book.close
|
2025
2326
|
end
|
2026
2327
|
|
2027
|
-
it "should
|
2328
|
+
it "should type-lift" do
|
2028
2329
|
Workbook.unobtrusively(@ole_workbook) do |book|
|
2029
2330
|
book.should === @book
|
2030
2331
|
book.equal?(@book).should be true
|
@@ -2057,7 +2358,8 @@ describe Workbook do
|
|
2057
2358
|
book.Saved.should be false
|
2058
2359
|
book.excel.should == @book.excel
|
2059
2360
|
end
|
2060
|
-
|
2361
|
+
Excel.kill_all
|
2362
|
+
new_book = Workbook.open(@simple_file1)
|
2061
2363
|
sheet = new_book.sheet(1)
|
2062
2364
|
sheet[1,1].Value.should == @old_cell_value
|
2063
2365
|
end
|
@@ -2071,7 +2373,8 @@ describe Workbook do
|
|
2071
2373
|
sheet[1,1] = cell.Value == "foo" ? "bar" : "foo"
|
2072
2374
|
book.excel.should == another_excel
|
2073
2375
|
end
|
2074
|
-
|
2376
|
+
Excel.kill_all
|
2377
|
+
new_book = Workbook.open(@simple_file1)
|
2075
2378
|
sheet = new_book.sheet(1)
|
2076
2379
|
sheet[1,1].Value.should == @old_cell_value
|
2077
2380
|
end
|
@@ -2084,10 +2387,11 @@ describe Workbook do
|
|
2084
2387
|
sheet[1,1] = cell.Value == "foo" ? "bar" : "foo"
|
2085
2388
|
book.excel.should_not == @book.excel
|
2086
2389
|
book.excel.should_not == new_excel
|
2087
|
-
book.excel.visible.should be false
|
2088
|
-
book.excel.displayalerts.should == :if_visible
|
2390
|
+
book.excel.properties[:visible].should be false
|
2391
|
+
book.excel.properties[:displayalerts].should == :if_visible
|
2089
2392
|
end
|
2090
|
-
|
2393
|
+
Excel.kill_all
|
2394
|
+
new_book = Workbook.open(@simple_file1)
|
2091
2395
|
sheet = new_book.sheet(1)
|
2092
2396
|
sheet[1,1].Value.should == @old_cell_value
|
2093
2397
|
end
|
@@ -2126,8 +2430,8 @@ describe Workbook do
|
|
2126
2430
|
sheet[1,1] = cell.Value == "foo" ? "bar" : "foo"
|
2127
2431
|
book.excel.should_not == @book.excel
|
2128
2432
|
book.excel.should_not == new_excel
|
2129
|
-
book.excel.visible.should be false
|
2130
|
-
book.excel.displayalerts.should == :if_visible
|
2433
|
+
book.excel.properties[:visible].should be false
|
2434
|
+
book.excel.properties[:displayalerts].should == :if_visible
|
2131
2435
|
end
|
2132
2436
|
new_book = Workbook.open(@simple_file1, :visible => true)
|
2133
2437
|
sheet = new_book.sheet(1)
|