robust_excel_ole 1.3 → 1.4
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 +6 -0
- data/README.rdoc +1 -1
- data/docs/README_open.rdoc +1 -1
- data/docs/README_ranges.rdoc +60 -57
- data/docs/README_sheet.rdoc +1 -1
- data/examples/introducing_examples/example_introducing.rb +42 -0
- data/examples/introducing_examples/example_open.rb +49 -0
- data/examples/introducing_examples/example_range.rb +67 -0
- data/examples/{edit_sheets → modifying_sheets}/example_access_sheets_and_cells.rb +0 -0
- data/examples/{edit_sheets → modifying_sheets}/example_adding_sheets.rb +0 -0
- data/examples/{edit_sheets → modifying_sheets}/example_concating.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_copying.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_expanding.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_naming.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_ranges.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_saving.rb +1 -1
- data/examples/open_save_close/example_control_to_excel.rb +2 -2
- data/examples/open_save_close/example_if_obstructed_save.rb +2 -2
- data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
- data/examples/open_save_close/example_if_unsaved_forget.rb +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_rename_cells.rb +1 -1
- data/examples/open_save_close/example_simple.rb +1 -1
- data/examples/open_save_close/example_unobtrusively.rb +3 -3
- data/lib/robust_excel_ole.rb +2 -2
- data/lib/robust_excel_ole/bookstore.rb +1 -1
- data/lib/robust_excel_ole/cell.rb +15 -2
- data/lib/robust_excel_ole/excel.rb +14 -12
- data/lib/robust_excel_ole/general.rb +12 -0
- data/lib/robust_excel_ole/range.rb +37 -20
- data/lib/robust_excel_ole/reo_common.rb +63 -37
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/{book.rb → workbook.rb} +35 -33
- data/lib/robust_excel_ole/{sheet.rb → worksheet.rb} +22 -22
- data/spec/bookstore_spec.rb +38 -38
- data/spec/cell_spec.rb +10 -10
- data/spec/data/another_workbook.xls +0 -0
- data/spec/data/workbook.xls +0 -0
- data/spec/excel_spec.rb +113 -105
- data/spec/general_spec.rb +37 -5
- data/spec/range_spec.rb +34 -19
- data/spec/reo_common_spec.rb +58 -48
- data/spec/{book_spec.rb → workbook_spec.rb} +198 -198
- data/spec/workbook_specs/workbook_all_spec.rb +33 -0
- data/spec/{book_specs/book_close_spec.rb → workbook_specs/workbook_close_spec.rb} +10 -10
- data/spec/{book_specs/book_misc_spec.rb → workbook_specs/workbook_misc_spec.rb} +148 -128
- data/spec/{book_specs/book_open_spec.rb → workbook_specs/workbook_open_spec.rb} +427 -427
- data/spec/{book_specs/book_save_spec.rb → workbook_specs/workbook_save_spec.rb} +44 -44
- data/spec/{book_specs/book_sheet_spec.rb → workbook_specs/workbook_sheet_spec.rb} +19 -19
- data/spec/{book_specs/book_subclass_spec.rb → workbook_specs/workbook_subclass_spec.rb} +5 -6
- data/spec/{book_specs/book_unobtr_spec.rb → workbook_specs/workbook_unobtr_spec.rb} +339 -344
- data/spec/{sheet_spec.rb → worksheet_spec.rb} +85 -55
- metadata +25 -22
- data/spec/book_specs/book_all_spec.rb +0 -22
data/spec/bookstore_spec.rb
CHANGED
@@ -30,7 +30,7 @@ end
|
|
30
30
|
|
31
31
|
$mock_bookstore = MockBookstore.new
|
32
32
|
|
33
|
-
class
|
33
|
+
class Workbook
|
34
34
|
@@bookstore = $mock_bookstore
|
35
35
|
end
|
36
36
|
|
@@ -80,8 +80,8 @@ describe Bookstore do
|
|
80
80
|
|
81
81
|
describe "Mock-Test" do
|
82
82
|
it "should never store any book" do
|
83
|
-
b1 =
|
84
|
-
b2 =
|
83
|
+
b1 = Workbook.open(@simple_file1)
|
84
|
+
b2 = Workbook.open(@simple_file1)
|
85
85
|
b2.object_id.should_not == b1.object_id
|
86
86
|
end
|
87
87
|
end
|
@@ -92,7 +92,7 @@ describe Bookstore do
|
|
92
92
|
context "with one open book" do
|
93
93
|
|
94
94
|
before do
|
95
|
-
@book =
|
95
|
+
@book = Workbook.open(@simple_file)
|
96
96
|
end
|
97
97
|
|
98
98
|
after do
|
@@ -102,7 +102,7 @@ describe Bookstore do
|
|
102
102
|
it "should do simple store and fetch" do
|
103
103
|
@bookstore.store(@book)
|
104
104
|
new_book = @bookstore.fetch(@simple_file)
|
105
|
-
new_book.should be_a
|
105
|
+
new_book.should be_a Workbook
|
106
106
|
new_book.should be_alive
|
107
107
|
new_book.should == @book
|
108
108
|
new_book.close
|
@@ -112,10 +112,10 @@ describe Bookstore do
|
|
112
112
|
@bookstore.store(@book)
|
113
113
|
book1 = @bookstore.fetch(@simple_file1)
|
114
114
|
book2 = @bookstore.fetch(@simple_file1)
|
115
|
-
expect(book1).to be_a
|
115
|
+
expect(book1).to be_a Workbook
|
116
116
|
book1.should be_alive
|
117
117
|
book1.should == @book
|
118
|
-
book2.should be_a
|
118
|
+
book2.should be_a Workbook
|
119
119
|
book2.should be_alive
|
120
120
|
book2.should == @book
|
121
121
|
book1.should == book2
|
@@ -132,7 +132,7 @@ describe Bookstore do
|
|
132
132
|
@bookstore.store(@book)
|
133
133
|
@book.close
|
134
134
|
book1 = @bookstore.fetch(@simple_file)
|
135
|
-
book1.should be_a
|
135
|
+
book1.should be_a Workbook
|
136
136
|
book1.should_not be_alive
|
137
137
|
end
|
138
138
|
|
@@ -153,7 +153,7 @@ describe Bookstore do
|
|
153
153
|
context "with several books" do
|
154
154
|
|
155
155
|
before do
|
156
|
-
@book =
|
156
|
+
@book = Workbook.open(@simple_file)
|
157
157
|
@bookstore.store(@book)
|
158
158
|
end
|
159
159
|
|
@@ -163,14 +163,14 @@ describe Bookstore do
|
|
163
163
|
end
|
164
164
|
|
165
165
|
it "should store and open two different books" do
|
166
|
-
@book2 =
|
166
|
+
@book2 = Workbook.open(@different_file1)
|
167
167
|
@bookstore.store(@book2)
|
168
168
|
new_book = @bookstore.fetch(@simple_file)
|
169
169
|
new_book2 = @bookstore.fetch(@different_file1)
|
170
|
-
new_book.should be_a
|
170
|
+
new_book.should be_a Workbook
|
171
171
|
new_book.should be_alive
|
172
172
|
new_book.should == @book
|
173
|
-
new_book2.should be_a
|
173
|
+
new_book2.should be_a Workbook
|
174
174
|
new_book2.should be_alive
|
175
175
|
new_book2.should == @book2
|
176
176
|
new_book.should_not == new_book2
|
@@ -179,7 +179,7 @@ describe Bookstore do
|
|
179
179
|
end
|
180
180
|
|
181
181
|
it "should fetch the first, writable book" do
|
182
|
-
@book2 =
|
182
|
+
@book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
183
183
|
@bookstore.store(@book2)
|
184
184
|
@book.ReadOnly.should be false
|
185
185
|
@book2.ReadOnly.should be true
|
@@ -190,7 +190,7 @@ describe Bookstore do
|
|
190
190
|
end
|
191
191
|
|
192
192
|
it "should fetch the last book with :prefer_writeable => false" do
|
193
|
-
@book2 =
|
193
|
+
@book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
194
194
|
@bookstore.store(@book2)
|
195
195
|
@book.ReadOnly.should be false
|
196
196
|
@book2.ReadOnly.should be true
|
@@ -201,7 +201,7 @@ describe Bookstore do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
it "should fetch the second, open book, if the first book is closed" do
|
204
|
-
@book2 =
|
204
|
+
@book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
205
205
|
@bookstore.store(@book2)
|
206
206
|
@book.ReadOnly.should be false
|
207
207
|
@book2.ReadOnly.should be true
|
@@ -217,7 +217,7 @@ describe Bookstore do
|
|
217
217
|
end
|
218
218
|
|
219
219
|
it "should fetch the first, open book, if the second book is closed, even with :prefer_writeable => false" do
|
220
|
-
@book2 =
|
220
|
+
@book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
221
221
|
@bookstore.store(@book2)
|
222
222
|
@book.ReadOnly.should be false
|
223
223
|
@book2.ReadOnly.should be true
|
@@ -237,7 +237,7 @@ describe Bookstore do
|
|
237
237
|
context "with readonly book" do
|
238
238
|
|
239
239
|
before do
|
240
|
-
@book =
|
240
|
+
@book = Workbook.open(@simple_file, :read_only => true)
|
241
241
|
@bookstore.store(@book)
|
242
242
|
end
|
243
243
|
|
@@ -247,7 +247,7 @@ describe Bookstore do
|
|
247
247
|
end
|
248
248
|
|
249
249
|
it "should fetch the second, writable book" do
|
250
|
-
@book2 =
|
250
|
+
@book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
251
251
|
@bookstore.store(@book2)
|
252
252
|
@book.ReadOnly.should be true
|
253
253
|
@book2.ReadOnly.should be false
|
@@ -266,7 +266,7 @@ describe Bookstore do
|
|
266
266
|
end
|
267
267
|
|
268
268
|
it "should fetch the recent readonly book when there are only readonly books" do
|
269
|
-
@book2 =
|
269
|
+
@book2 = Workbook.open(@simple_file1, :force_excel => :new, :read_only => true)
|
270
270
|
@bookstore.store(@book2)
|
271
271
|
@book.ReadOnly.should be true
|
272
272
|
@book2.ReadOnly.should be true
|
@@ -277,8 +277,8 @@ describe Bookstore do
|
|
277
277
|
end
|
278
278
|
|
279
279
|
it "should fetch the second, writable book, if a writable, a readonly and an unsaved readonly book exist" do
|
280
|
-
@book2 =
|
281
|
-
@book3 =
|
280
|
+
@book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
281
|
+
@book3 = Workbook.open(@simple_file1, :force_excel => :new)
|
282
282
|
@bookstore.store(@book2)
|
283
283
|
@bookstore.store(@book3)
|
284
284
|
sheet = @book3.sheet(1)
|
@@ -303,10 +303,10 @@ describe Bookstore do
|
|
303
303
|
context "with several closed books" do
|
304
304
|
|
305
305
|
before do
|
306
|
-
@book =
|
306
|
+
@book = Workbook.open(@simple_file1)
|
307
307
|
@bookstore.store(@book)
|
308
308
|
@bookstore.store(@book)
|
309
|
-
@book2 =
|
309
|
+
@book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
310
310
|
@bookstore.store(@book2)
|
311
311
|
@book.close
|
312
312
|
@book2.close
|
@@ -323,7 +323,7 @@ describe Bookstore do
|
|
323
323
|
context "with changing file name" do
|
324
324
|
|
325
325
|
before do
|
326
|
-
@book =
|
326
|
+
@book = Workbook.open(@simple_file)
|
327
327
|
@book.save_as(@simple_save_file, :if_exists => :overwrite)
|
328
328
|
@bookstore.store(@book)
|
329
329
|
#@bookstore = @book.book_store
|
@@ -347,9 +347,9 @@ describe Bookstore do
|
|
347
347
|
context "with given excel instance and fetching readonly" do
|
348
348
|
|
349
349
|
before do
|
350
|
-
@book =
|
350
|
+
@book = Workbook.open(@simple_file1)
|
351
351
|
@bookstore.store(@book)
|
352
|
-
@book2 =
|
352
|
+
@book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
353
353
|
@bookstore.store(@book2)
|
354
354
|
end
|
355
355
|
|
@@ -361,7 +361,7 @@ describe Bookstore do
|
|
361
361
|
@book.ReadOnly.should be false
|
362
362
|
@book2.ReadOnly.should be true
|
363
363
|
book_new = @bookstore.fetch(@simple_file, :prefer_excel => @book2.excel)
|
364
|
-
book_new.should be_a
|
364
|
+
book_new.should be_a Workbook
|
365
365
|
book_new.should be_alive
|
366
366
|
book_new.should == @book2
|
367
367
|
end
|
@@ -373,7 +373,7 @@ describe Bookstore do
|
|
373
373
|
context "with an open book" do
|
374
374
|
|
375
375
|
before do
|
376
|
-
@book =
|
376
|
+
@book = Workbook.open(@simple_file)
|
377
377
|
@bookstore.store(@book)
|
378
378
|
end
|
379
379
|
|
@@ -393,11 +393,11 @@ describe Bookstore do
|
|
393
393
|
end
|
394
394
|
|
395
395
|
it "should have forgotten some books if they have no reference anymore" do
|
396
|
-
book_new =
|
396
|
+
book_new = Workbook.open(@different_file1)
|
397
397
|
@bookstore.store(book_new)
|
398
398
|
@book = nil
|
399
399
|
@book = "Bla"
|
400
|
-
@book =
|
400
|
+
@book = Workbook.open(@simple_file1)
|
401
401
|
@bookstore.store(@book)
|
402
402
|
@book = nil
|
403
403
|
GC.start
|
@@ -411,9 +411,9 @@ describe Bookstore do
|
|
411
411
|
describe "books" do
|
412
412
|
|
413
413
|
before do
|
414
|
-
@book =
|
414
|
+
@book = Workbook.open(@simple_file)
|
415
415
|
@bookstore.store(@book)
|
416
|
-
@book2 =
|
416
|
+
@book2 = Workbook.open(@different_file)
|
417
417
|
@bookstore.store(@book2)
|
418
418
|
end
|
419
419
|
|
@@ -432,9 +432,9 @@ describe Bookstore do
|
|
432
432
|
describe "print" do
|
433
433
|
|
434
434
|
before do
|
435
|
-
@book =
|
435
|
+
@book = Workbook.open(@simple_file)
|
436
436
|
@bookstore.store(@book)
|
437
|
-
@book2 =
|
437
|
+
@book2 = Workbook.open(@different_file)
|
438
438
|
@bookstore.store(@book2)
|
439
439
|
end
|
440
440
|
|
@@ -456,7 +456,7 @@ describe Bookstore do
|
|
456
456
|
context "with some open book" do
|
457
457
|
|
458
458
|
before do
|
459
|
-
@book =
|
459
|
+
@book = Workbook.open(@simple_file)
|
460
460
|
end
|
461
461
|
|
462
462
|
after do
|
@@ -468,7 +468,7 @@ describe Bookstore do
|
|
468
468
|
h_excel1.should_not == @book.excel
|
469
469
|
h_excel1.Visible.should be false
|
470
470
|
h_excel1.DisplayAlerts.should be false
|
471
|
-
book1 =
|
471
|
+
book1 = Workbook.open(@simple_file, :force_excel => @bookstore.hidden_excel)
|
472
472
|
book1.excel.should === h_excel1
|
473
473
|
book1.excel.should_not === @book.excel
|
474
474
|
Excel.close_all
|
@@ -477,14 +477,14 @@ describe Bookstore do
|
|
477
477
|
h_excel2.should_not == book1.excel
|
478
478
|
h_excel2.Visible.should be false
|
479
479
|
h_excel2.DisplayAlerts.should be false
|
480
|
-
book2 =
|
480
|
+
book2 = Workbook.open(@simple_file, :force_excel => @bookstore.hidden_excel)
|
481
481
|
book2.excel.should === h_excel2
|
482
482
|
book2.excel.should_not === @book.excel
|
483
483
|
book2.excel.should_not === book1.excel
|
484
484
|
end
|
485
485
|
|
486
486
|
it "should exclude hidden excel" do
|
487
|
-
book1 =
|
487
|
+
book1 = Workbook.open(@simple_file, :force_excel => @bookstore.hidden_excel)
|
488
488
|
@bookstore.store(book1)
|
489
489
|
book1.close
|
490
490
|
book2 = @bookstore.fetch(@simple_file)
|
data/spec/cell_spec.rb
CHANGED
@@ -22,7 +22,7 @@ describe Cell do
|
|
22
22
|
|
23
23
|
context "open simple.xls" do
|
24
24
|
before do
|
25
|
-
@book =
|
25
|
+
@book = Workbook.open(@dir + '/workbook.xls', :read_only => true)
|
26
26
|
@sheet = @book.sheet(2)
|
27
27
|
@cell = @sheet[1, 1]
|
28
28
|
end
|
@@ -33,14 +33,14 @@ describe Cell do
|
|
33
33
|
|
34
34
|
describe "#value" do
|
35
35
|
it "get cell's value" do
|
36
|
-
@cell.
|
36
|
+
@cell.Value.should eq 'simple'
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "#value=" do
|
41
41
|
it "change cell data to 'fooooo'" do
|
42
|
-
@cell.
|
43
|
-
@cell.
|
42
|
+
@cell.Value = 'fooooo'
|
43
|
+
@cell.Value.should eq 'fooooo'
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -54,7 +54,7 @@ describe Cell do
|
|
54
54
|
|
55
55
|
context "open merge_cells.xls" do
|
56
56
|
before do
|
57
|
-
@book =
|
57
|
+
@book = Workbook.open(@dir + '/merge_cells.xls', :read_only => true)
|
58
58
|
@sheet = @book.sheet(1)
|
59
59
|
end
|
60
60
|
|
@@ -63,14 +63,14 @@ describe Cell do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "merged cell get same value" do
|
66
|
-
@sheet[1, 1].
|
67
|
-
@sheet[2, 1].
|
66
|
+
@sheet[1, 1].Value.should be_nil
|
67
|
+
@sheet[2, 1].Value.should eq 'first merged'
|
68
68
|
end
|
69
69
|
|
70
70
|
it "set merged cell" do
|
71
|
-
@sheet[2, 1].
|
72
|
-
@sheet[2, 1].
|
73
|
-
@sheet[2, 2].
|
71
|
+
@sheet[2, 1].Value = "set merge cell"
|
72
|
+
@sheet[2, 1].Value.should eq "set merge cell"
|
73
|
+
@sheet[2, 2].Value.should eq "set merge cell"
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
Binary file
|
data/spec/data/workbook.xls
CHANGED
Binary file
|
data/spec/excel_spec.rb
CHANGED
@@ -131,14 +131,14 @@ module RobustExcelOle
|
|
131
131
|
context "Illegal Refrence" do
|
132
132
|
|
133
133
|
before do
|
134
|
-
book1 =
|
135
|
-
book2 =
|
134
|
+
book1 = Workbook.open(@simple_file1)
|
135
|
+
book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
136
136
|
a = book1.saved
|
137
137
|
end
|
138
138
|
|
139
139
|
it "should not cause warning 'Illegal Reference probably recycled'" do
|
140
140
|
Excel.close_all
|
141
|
-
book =
|
141
|
+
book = Workbook.open(@simple_file)
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
@@ -191,7 +191,7 @@ module RobustExcelOle
|
|
191
191
|
context "lifting an Excel instance given as WIN32Ole object" do
|
192
192
|
|
193
193
|
before do
|
194
|
-
@book =
|
194
|
+
@book = Workbook.open(@simple_file)
|
195
195
|
@excel = @book.excel
|
196
196
|
end
|
197
197
|
|
@@ -330,7 +330,7 @@ module RobustExcelOle
|
|
330
330
|
context "with a single Excel instance" do
|
331
331
|
|
332
332
|
before do
|
333
|
-
@book1 =
|
333
|
+
@book1 = Workbook.open(@simple_file)
|
334
334
|
@excel1 = @book1.excel
|
335
335
|
end
|
336
336
|
|
@@ -396,9 +396,9 @@ module RobustExcelOle
|
|
396
396
|
context "with several Excel instances" do
|
397
397
|
|
398
398
|
before do
|
399
|
-
@book1 =
|
400
|
-
@book2 =
|
401
|
-
@book3 =
|
399
|
+
@book1 = Workbook.open(@simple_file)
|
400
|
+
@book2 = Workbook.open(@another_simple_file, :force_excel => @book1)
|
401
|
+
@book3 = Workbook.open(@different_file, :force_excel => :new)
|
402
402
|
@excel1 = @book1.excel
|
403
403
|
@excel3 = @book3.excel
|
404
404
|
@excel1.visible = true
|
@@ -491,11 +491,11 @@ module RobustExcelOle
|
|
491
491
|
context "with one Excel instance" do
|
492
492
|
|
493
493
|
before do
|
494
|
-
book1 =
|
494
|
+
book1 = Workbook.open(@simple_file1, :visible => true)
|
495
495
|
@excel1 = book1.excel
|
496
496
|
sheet1 = book1.sheet(1)
|
497
|
-
@old_cell_value1 = sheet1[1,1].
|
498
|
-
sheet1[1,1] = sheet1[1,1].
|
497
|
+
@old_cell_value1 = sheet1[1,1].Value
|
498
|
+
sheet1[1,1] = sheet1[1,1].Value == "foo" ? "bar" : "foo"
|
499
499
|
book1.Saved.should be false
|
500
500
|
end
|
501
501
|
|
@@ -503,9 +503,9 @@ module RobustExcelOle
|
|
503
503
|
result = Excel.close_all(:if_unsaved => :save)
|
504
504
|
sleep 0.2
|
505
505
|
@excel1.should_not be_alive
|
506
|
-
new_book1 =
|
506
|
+
new_book1 = Workbook.open(@simple_file1)
|
507
507
|
new_sheet1 = new_book1.sheet(1)
|
508
|
-
new_sheet1[1,1].
|
508
|
+
new_sheet1[1,1].Value.should_not == @old_cell_value1
|
509
509
|
new_book1.close
|
510
510
|
result.should == [1,0]
|
511
511
|
end
|
@@ -514,9 +514,9 @@ module RobustExcelOle
|
|
514
514
|
result = Excel.close_all(:if_unsaved => :forget)
|
515
515
|
sleep 0.2
|
516
516
|
@excel1.should_not be_alive
|
517
|
-
new_book1 =
|
517
|
+
new_book1 = Workbook.open(@simple_file1)
|
518
518
|
new_sheet1 = new_book1.sheet(1)
|
519
|
-
new_sheet1[1,1].
|
519
|
+
new_sheet1[1,1].Value.should == @old_cell_value1
|
520
520
|
new_book1.close
|
521
521
|
result.should == [1,0]
|
522
522
|
end
|
@@ -525,13 +525,13 @@ module RobustExcelOle
|
|
525
525
|
context "with two Excel instances" do
|
526
526
|
|
527
527
|
before do
|
528
|
-
book1 =
|
529
|
-
book2 =
|
528
|
+
book1 = Workbook.open(@simple_file1, :force_excel => :new)
|
529
|
+
book2 = Workbook.open(@different_file, :force_excel => :new)
|
530
530
|
@excel1 = book1.excel
|
531
531
|
@excel2 = book2.excel
|
532
532
|
sheet2 = book2.sheet(1)
|
533
|
-
@old_cell_value2 = sheet2[1,1].
|
534
|
-
sheet2[1,1] = sheet2[1,1].
|
533
|
+
@old_cell_value2 = sheet2[1,1].Value
|
534
|
+
sheet2[1,1] = sheet2[1,1].Value == "foo" ? "bar" : "foo"
|
535
535
|
end
|
536
536
|
|
537
537
|
it "should close the first Excel without unsaved workbooks and then raise an error" do
|
@@ -565,9 +565,9 @@ module RobustExcelOle
|
|
565
565
|
sleep 0.2
|
566
566
|
@excel1.should_not be_alive
|
567
567
|
@excel2.should_not be_alive
|
568
|
-
new_book2 =
|
568
|
+
new_book2 = Workbook.open(@different_file1)
|
569
569
|
new_sheet2 = new_book2.sheet(1)
|
570
|
-
new_sheet2[1,1].
|
570
|
+
new_sheet2[1,1].Value.should_not == @old_cell_value2
|
571
571
|
new_book2.close
|
572
572
|
result.should == [2,0]
|
573
573
|
end
|
@@ -577,9 +577,9 @@ module RobustExcelOle
|
|
577
577
|
sleep 0.2
|
578
578
|
@excel1.should_not be_alive
|
579
579
|
@excel2.should_not be_alive
|
580
|
-
new_book2 =
|
580
|
+
new_book2 = Workbook.open(@different_file1)
|
581
581
|
new_sheet2 = new_book2.sheet(1)
|
582
|
-
new_sheet2[1,1].
|
582
|
+
new_sheet2[1,1].Value.should == @old_cell_value2
|
583
583
|
new_book2.close
|
584
584
|
result.should == [2,0]
|
585
585
|
end
|
@@ -594,10 +594,10 @@ module RobustExcelOle
|
|
594
594
|
context "with three Excel instances" do
|
595
595
|
|
596
596
|
before do
|
597
|
-
@book1 =
|
598
|
-
@book2 =
|
599
|
-
@book3 =
|
600
|
-
old_cell_value1 = @book2.sheet(1)[1,1].
|
597
|
+
@book1 = Workbook.open(@simple_file1, :force_excel => :new)
|
598
|
+
@book2 = Workbook.open(@another_simple_file, :force_excel => :new)
|
599
|
+
@book3 = Workbook.open(@different_file, :force_excel => :new)
|
600
|
+
old_cell_value1 = @book2.sheet(1)[1,1].Value
|
601
601
|
@book2.sheet(1)[1,1] = old_cell_value1 == "foo" ? "bar" : "foo"
|
602
602
|
end
|
603
603
|
|
@@ -619,10 +619,10 @@ module RobustExcelOle
|
|
619
619
|
|
620
620
|
before do
|
621
621
|
@ole_xl = WIN32OLE.new('Excel.Application')
|
622
|
-
@book1 =
|
623
|
-
@book2 =
|
624
|
-
@book3 =
|
625
|
-
old_cell_value1 = @book2.sheet(1)[1,1].
|
622
|
+
@book1 = Workbook.open(@simple_file1, :force_excel => :new)
|
623
|
+
@book2 = Workbook.open(@another_simple_file, :force_excel => :new)
|
624
|
+
@book3 = Workbook.open(@different_file, :force_excel => :new)
|
625
|
+
old_cell_value1 = @book2.sheet(1)[1,1].Value
|
626
626
|
@book2.sheet(1)[1,1] = old_cell_value1 == "foo" ? "bar" : "foo"
|
627
627
|
end
|
628
628
|
|
@@ -664,7 +664,7 @@ module RobustExcelOle
|
|
664
664
|
|
665
665
|
before do
|
666
666
|
@excel = Excel.create
|
667
|
-
@book =
|
667
|
+
@book = Workbook.open(@simple_file)
|
668
668
|
@excel.should be_alive
|
669
669
|
end
|
670
670
|
|
@@ -689,14 +689,14 @@ module RobustExcelOle
|
|
689
689
|
|
690
690
|
before do
|
691
691
|
@excel = Excel.create
|
692
|
-
@book =
|
692
|
+
@book = Workbook.open(@simple_file)
|
693
693
|
sheet = @book.sheet(1)
|
694
|
-
@old_cell_value = sheet[1,1].
|
695
|
-
sheet[1,1] = sheet[1,1].
|
696
|
-
@book2 =
|
694
|
+
@old_cell_value = sheet[1,1].Value
|
695
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
696
|
+
@book2 = Workbook.open(@another_simple_file)
|
697
697
|
sheet2 = @book2.sheet(1)
|
698
|
-
@old_cell_value2 = sheet2[1,1].
|
699
|
-
sheet2[1,1] = sheet2[1,1].
|
698
|
+
@old_cell_value2 = sheet2[1,1].Value
|
699
|
+
sheet2[1,1] = sheet2[1,1].Value == "foo" ? "bar" : "foo"
|
700
700
|
@excel.should be_alive
|
701
701
|
@book.should be_alive
|
702
702
|
@book.saved.should be false
|
@@ -721,9 +721,9 @@ module RobustExcelOle
|
|
721
721
|
sleep 0.2
|
722
722
|
@excel.should_not be_alive
|
723
723
|
result.should == 1
|
724
|
-
new_book =
|
724
|
+
new_book = Workbook.open(@simple_file)
|
725
725
|
new_sheet = new_book.sheet(1)
|
726
|
-
new_sheet[1,1].
|
726
|
+
new_sheet[1,1].Value.should == @old_cell_value
|
727
727
|
new_book.close
|
728
728
|
end
|
729
729
|
|
@@ -735,9 +735,9 @@ module RobustExcelOle
|
|
735
735
|
sleep 0.2
|
736
736
|
result.should == 1
|
737
737
|
@excel.should_not be_alive
|
738
|
-
new_book =
|
738
|
+
new_book = Workbook.open(@simple_file)
|
739
739
|
new_sheet = new_book.sheet(1)
|
740
|
-
new_sheet[1,1].
|
740
|
+
new_sheet[1,1].Value.should == @old_cell_value
|
741
741
|
new_book.close
|
742
742
|
end
|
743
743
|
|
@@ -747,9 +747,9 @@ module RobustExcelOle
|
|
747
747
|
sleep 0.2
|
748
748
|
result.should == 1
|
749
749
|
@excel.should_not be_alive
|
750
|
-
new_book =
|
750
|
+
new_book = Workbook.open(@simple_file)
|
751
751
|
new_sheet = new_book.sheet(1)
|
752
|
-
new_sheet[1,1].
|
752
|
+
new_sheet[1,1].Value.should_not == @old_cell_value
|
753
753
|
new_book.close
|
754
754
|
end
|
755
755
|
|
@@ -765,10 +765,10 @@ module RobustExcelOle
|
|
765
765
|
before do
|
766
766
|
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '/helpers/key_sender.rb') + '" "Microsoft Excel" ' , "w"
|
767
767
|
@excel = Excel.create(:visible => true)
|
768
|
-
@book =
|
768
|
+
@book = Workbook.open(@simple_file, :visible => true)
|
769
769
|
sheet = @book.sheet(1)
|
770
|
-
@old_cell_value = sheet[1,1].
|
771
|
-
sheet[1,1] = sheet[1,1].
|
770
|
+
@old_cell_value = sheet[1,1].Value
|
771
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
772
772
|
end
|
773
773
|
|
774
774
|
after do
|
@@ -782,9 +782,9 @@ module RobustExcelOle
|
|
782
782
|
result = @excel.close(:if_unsaved => :alert)
|
783
783
|
@excel.should_not be_alive
|
784
784
|
result.should == 1
|
785
|
-
new_book =
|
785
|
+
new_book = Workbook.open(@simple_file)
|
786
786
|
new_sheet = new_book.sheet(1)
|
787
|
-
new_sheet[1,1].
|
787
|
+
new_sheet[1,1].Value.should_not == @old_cell_value
|
788
788
|
new_book.close
|
789
789
|
end
|
790
790
|
|
@@ -797,9 +797,9 @@ module RobustExcelOle
|
|
797
797
|
@excel.should_not be_alive
|
798
798
|
result.should == 1
|
799
799
|
@book.should_not be_alive
|
800
|
-
new_book =
|
800
|
+
new_book = Workbook.open(@simple_file)
|
801
801
|
new_sheet = new_book.sheet(1)
|
802
|
-
new_sheet[1,1].
|
802
|
+
new_sheet[1,1].Value.should == @old_cell_value
|
803
803
|
new_book.close
|
804
804
|
end
|
805
805
|
|
@@ -822,15 +822,15 @@ module RobustExcelOle
|
|
822
822
|
context "with standard" do
|
823
823
|
|
824
824
|
before do
|
825
|
-
@book =
|
825
|
+
@book = Workbook.open(@simple_file)
|
826
826
|
sheet = @book.sheet(1)
|
827
|
-
@old_cell_value = sheet[1,1].
|
828
|
-
sheet[1,1] = sheet[1,1].
|
829
|
-
@book3 =
|
827
|
+
@old_cell_value = sheet[1,1].Value
|
828
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
829
|
+
@book3 = Workbook.open(@different_file, :read_only => true)
|
830
830
|
sheet3 = @book3.sheet(1)
|
831
|
-
sheet3[1,1] = sheet3[1,1].
|
831
|
+
sheet3[1,1] = sheet3[1,1].Value == "foo" ? "bar" : "foo"
|
832
832
|
@excel = @book.excel
|
833
|
-
@book2 =
|
833
|
+
@book2 = Workbook.open(@another_simple_file, :force_excel => :new)
|
834
834
|
end
|
835
835
|
|
836
836
|
it "should be ok if there are no unsaved workbooks" do
|
@@ -856,9 +856,9 @@ module RobustExcelOle
|
|
856
856
|
sleep 0.2
|
857
857
|
@excel.should be_alive
|
858
858
|
@excel.Workbooks.Count.should == 0
|
859
|
-
new_book =
|
859
|
+
new_book = Workbook.open(@simple_file)
|
860
860
|
new_sheet = new_book.sheet(1)
|
861
|
-
new_sheet[1,1].
|
861
|
+
new_sheet[1,1].Value.should == @old_cell_value
|
862
862
|
new_book.close
|
863
863
|
end
|
864
864
|
|
@@ -867,9 +867,9 @@ module RobustExcelOle
|
|
867
867
|
sleep 0.2
|
868
868
|
@excel.should be_alive
|
869
869
|
@excel.Workbooks.Count.should == 0
|
870
|
-
new_book =
|
870
|
+
new_book = Workbook.open(@simple_file)
|
871
871
|
new_sheet = new_book.sheet(1)
|
872
|
-
new_sheet[1,1].
|
872
|
+
new_sheet[1,1].Value.should_not == @old_cell_value
|
873
873
|
new_book.close
|
874
874
|
end
|
875
875
|
|
@@ -884,11 +884,11 @@ module RobustExcelOle
|
|
884
884
|
describe "retain_saved_workbooks" do
|
885
885
|
|
886
886
|
before do
|
887
|
-
@book1 =
|
888
|
-
@book2 =
|
889
|
-
@book3 =
|
887
|
+
@book1 = Workbook.open(@simple_file)
|
888
|
+
@book2 = Workbook.open(@another_simple_file)
|
889
|
+
@book3 = Workbook.open(@different_file)
|
890
890
|
sheet2 = @book2.sheet(1)
|
891
|
-
sheet2[1,1] = sheet2[1,1].
|
891
|
+
sheet2[1,1] = sheet2[1,1].Value == "foo" ? "bar" : "foo"
|
892
892
|
@book2.Saved.should be false
|
893
893
|
@excel = Excel.current
|
894
894
|
end
|
@@ -896,10 +896,10 @@ module RobustExcelOle
|
|
896
896
|
it "should retain saved workbooks" do
|
897
897
|
@excel.retain_saved_workbooks do
|
898
898
|
sheet1 = @book1.sheet(1)
|
899
|
-
sheet1[1,1] = sheet1[1,1].
|
899
|
+
sheet1[1,1] = sheet1[1,1].Value == "foo" ? "bar" : "foo"
|
900
900
|
@book1.Saved.should be false
|
901
901
|
sheet3 = @book3.sheet(1)
|
902
|
-
sheet3[1,1] = sheet3[1,1].
|
902
|
+
sheet3[1,1] = sheet3[1,1].Value == "foo" ? "bar" : "foo"
|
903
903
|
@book3.Saved.should be false
|
904
904
|
end
|
905
905
|
@book1.Saved.should be true
|
@@ -913,12 +913,12 @@ module RobustExcelOle
|
|
913
913
|
context "with standard" do
|
914
914
|
|
915
915
|
before do
|
916
|
-
@book =
|
916
|
+
@book = Workbook.open(@simple_file)
|
917
917
|
sheet = @book.sheet(1)
|
918
|
-
sheet[1,1] = sheet[1,1].
|
919
|
-
@book3 =
|
918
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
919
|
+
@book3 = Workbook.open(@different_file, :read_only => true)
|
920
920
|
sheet3 = @book3.sheet(1)
|
921
|
-
sheet3[1,1] = sheet3[1,1].
|
921
|
+
sheet3[1,1] = sheet3[1,1].Value == "foo" ? "bar" : "foo"
|
922
922
|
@book.Saved.should be false
|
923
923
|
@book3.Saved.should be false
|
924
924
|
end
|
@@ -944,15 +944,15 @@ module RobustExcelOle
|
|
944
944
|
end
|
945
945
|
|
946
946
|
it "should return empty list for first Excel instance" do
|
947
|
-
book =
|
947
|
+
book = Workbook.open(@simple_file)
|
948
948
|
Excel.unsaved_known_workbooks.should == [[]]
|
949
949
|
book.close
|
950
950
|
end
|
951
951
|
|
952
952
|
it "should return one unsaved book" do
|
953
|
-
book =
|
953
|
+
book = Workbook.open(@simple_file)
|
954
954
|
sheet = book.sheet(1)
|
955
|
-
sheet[1,1] = sheet[1,1].
|
955
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
956
956
|
# Excel.unsaved_known_workbooks.should == [[book.ole_workbook]]
|
957
957
|
unsaved_known_wbs = Excel.unsaved_known_workbooks
|
958
958
|
unsaved_known_wbs.size.should == 1
|
@@ -962,7 +962,7 @@ module RobustExcelOle
|
|
962
962
|
ole_workbook.Fullname.tr('\\','/').should == @simple_file
|
963
963
|
end
|
964
964
|
end
|
965
|
-
book2 =
|
965
|
+
book2 = Workbook.open(@another_simple_file)
|
966
966
|
# Excel.unsaved_known_workbooks.should == [[book.ole_workbook]]
|
967
967
|
unsaved_known_wbs = Excel.unsaved_known_workbooks
|
968
968
|
unsaved_known_wbs.size.should == 1
|
@@ -977,12 +977,12 @@ module RobustExcelOle
|
|
977
977
|
end
|
978
978
|
|
979
979
|
it "should return two unsaved books" do
|
980
|
-
book =
|
980
|
+
book = Workbook.open(@simple_file)
|
981
981
|
sheet = book.sheet(1)
|
982
|
-
sheet[1,1] = sheet[1,1].
|
983
|
-
book2 =
|
982
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
983
|
+
book2 = Workbook.open(@another_simple_file)
|
984
984
|
sheet2 = book2.sheet(1)
|
985
|
-
sheet2[1,1] = sheet2[1,1].
|
985
|
+
sheet2[1,1] = sheet2[1,1].Value == "foo" ? "bar" : "foo"
|
986
986
|
#Excel.unsaved_known_workbooks.should == [[book.ole_workbook, book2.ole_workbook]]
|
987
987
|
unsaved_known_wbs = Excel.unsaved_known_workbooks
|
988
988
|
unsaved_known_wbs.size.should == 1
|
@@ -997,13 +997,13 @@ module RobustExcelOle
|
|
997
997
|
end
|
998
998
|
|
999
999
|
it "should return two unsaved books" do
|
1000
|
-
book =
|
1001
|
-
book2 =
|
1000
|
+
book = Workbook.open(@simple_file)
|
1001
|
+
book2 = Workbook.open(@another_simple_file, :force_excel => :new)
|
1002
1002
|
open_books = [book, book2]
|
1003
1003
|
begin
|
1004
1004
|
open_books.each do |wb|
|
1005
1005
|
sheet = wb.sheet(1)
|
1006
|
-
sheet[1,1] = (sheet[1,1].
|
1006
|
+
sheet[1,1] = (sheet[1,1].Value == "foo") ? "bar" : "foo"
|
1007
1007
|
end
|
1008
1008
|
#Excel.unsaved_known_workbooks.should == [[book.ole_workbook], [book2.ole_workbook]]
|
1009
1009
|
unsaved_known_wbs = Excel.unsaved_known_workbooks
|
@@ -1461,6 +1461,7 @@ module RobustExcelOle
|
|
1461
1461
|
excel6.calculation.should == :manual
|
1462
1462
|
end
|
1463
1463
|
|
1464
|
+
=begin
|
1464
1465
|
it "should do with_calculation mode without workbooks" do
|
1465
1466
|
@excel1 = Excel.new
|
1466
1467
|
old_calculation_mode = @excel1.Calculation
|
@@ -1474,6 +1475,7 @@ module RobustExcelOle
|
|
1474
1475
|
@excel1.CalculateBeforeSave.should == old_calculatebeforesave
|
1475
1476
|
end
|
1476
1477
|
end
|
1478
|
+
=end
|
1477
1479
|
|
1478
1480
|
it "should set calculation mode without workbooks" do
|
1479
1481
|
@excel1 = Excel.new
|
@@ -1491,7 +1493,7 @@ module RobustExcelOle
|
|
1491
1493
|
|
1492
1494
|
it "should do with_calculation with workbook" do
|
1493
1495
|
@excel1 = Excel.new
|
1494
|
-
book =
|
1496
|
+
book = Workbook.open(@simple_file, :visible => true)
|
1495
1497
|
old_calculation_mode = @excel1.Calculation
|
1496
1498
|
@excel1.with_calculation(:manual) do
|
1497
1499
|
@excel1.calculation.should == :manual
|
@@ -1513,7 +1515,7 @@ module RobustExcelOle
|
|
1513
1515
|
|
1514
1516
|
it "should set calculation mode to manual with workbook" do
|
1515
1517
|
@excel1 = Excel.new
|
1516
|
-
book =
|
1518
|
+
book = Workbook.open(@simple_file, :visible => true)
|
1517
1519
|
book.Windows(book.Name).Visible = true
|
1518
1520
|
@excel1.calculation = :manual
|
1519
1521
|
@excel1.calculation.should == :manual
|
@@ -1524,7 +1526,7 @@ module RobustExcelOle
|
|
1524
1526
|
|
1525
1527
|
it "should set calculation mode to automatic with workbook" do
|
1526
1528
|
@excel1 = Excel.new
|
1527
|
-
book =
|
1529
|
+
book = Workbook.open(@simple_file, :visible => true)
|
1528
1530
|
@excel1.calculation = :automatic
|
1529
1531
|
@excel1.calculation.should == :automatic
|
1530
1532
|
@excel1.Calculation.should == XlCalculationAutomatic
|
@@ -1541,7 +1543,7 @@ module RobustExcelOle
|
|
1541
1543
|
|
1542
1544
|
it "should do Calculation to manual with workbook" do
|
1543
1545
|
@excel1 = Excel.new
|
1544
|
-
b =
|
1546
|
+
b = Workbook.open(@simple_file)
|
1545
1547
|
@excel1.Calculation = XlCalculationManual
|
1546
1548
|
@excel1.calculation.should == :manual
|
1547
1549
|
@excel1.Calculation.should == XlCalculationManual
|
@@ -1549,7 +1551,7 @@ module RobustExcelOle
|
|
1549
1551
|
|
1550
1552
|
it "should do Calculation to automatic with workbook" do
|
1551
1553
|
@excel1 = Excel.new
|
1552
|
-
b =
|
1554
|
+
b = Workbook.open(@simple_file)
|
1553
1555
|
@excel1.Calculation = XlCalculationAutomatic
|
1554
1556
|
@excel1.calculation.should == :automatic
|
1555
1557
|
@excel1.Calculation.should == XlCalculationAutomatic
|
@@ -1582,7 +1584,7 @@ module RobustExcelOle
|
|
1582
1584
|
|
1583
1585
|
before do
|
1584
1586
|
@excel = Excel.new(:reuse => false)
|
1585
|
-
book =
|
1587
|
+
book = Workbook.open(@simple_file)
|
1586
1588
|
book.excel.calculation = :manual
|
1587
1589
|
book.close(:if_unsaved => :save)
|
1588
1590
|
end
|
@@ -1592,7 +1594,7 @@ module RobustExcelOle
|
|
1592
1594
|
@excel.DisplayAlerts.should be true
|
1593
1595
|
@excel.Visible.should be true
|
1594
1596
|
@excel.ScreenUpdating.should be true
|
1595
|
-
book =
|
1597
|
+
book = Workbook.open(@simple_file)
|
1596
1598
|
@excel.Calculation.should == XlCalculationManual
|
1597
1599
|
book.close
|
1598
1600
|
end
|
@@ -1609,7 +1611,7 @@ module RobustExcelOle
|
|
1609
1611
|
end
|
1610
1612
|
|
1611
1613
|
it "should set options to true for a workbook" do
|
1612
|
-
book1 =
|
1614
|
+
book1 = Workbook.open(@simple_file)
|
1613
1615
|
book1.excel.for_all_workbooks(:visible => true, :read_only => true, :check_compatibility => true)
|
1614
1616
|
book1.excel.Visible.should be true
|
1615
1617
|
book1.Windows(book1.Name).Visible.should be true
|
@@ -1619,8 +1621,8 @@ module RobustExcelOle
|
|
1619
1621
|
end
|
1620
1622
|
|
1621
1623
|
it "should set options for two workbooks" do
|
1622
|
-
book1 =
|
1623
|
-
book2 =
|
1624
|
+
book1 = Workbook.open(@simple_file)
|
1625
|
+
book2 = Workbook.open(@different_file)
|
1624
1626
|
excel = book1.excel
|
1625
1627
|
excel.for_all_workbooks(:visible => true, :read_only => true, :check_compatibility => true)
|
1626
1628
|
excel.Visible.should be true
|
@@ -1766,7 +1768,7 @@ module RobustExcelOle
|
|
1766
1768
|
end
|
1767
1769
|
|
1768
1770
|
it "should generate a workbook if one is already existing" do
|
1769
|
-
book =
|
1771
|
+
book = Workbook.open(@simple_file)
|
1770
1772
|
workbook = @excel1.generate_workbook(@file_name)
|
1771
1773
|
workbook.should be_a WIN32OLE
|
1772
1774
|
workbook.Name.should == File.basename(@file_name)
|
@@ -1796,7 +1798,7 @@ module RobustExcelOle
|
|
1796
1798
|
context "setting the name of a range" do
|
1797
1799
|
|
1798
1800
|
before do
|
1799
|
-
@book1 =
|
1801
|
+
@book1 = Workbook.open(@dir + '/another_workbook.xls', :read_only => true, :visible => true)
|
1800
1802
|
@book1.excel.displayalerts = false
|
1801
1803
|
@excel1 = @book1.excel
|
1802
1804
|
end
|
@@ -1806,31 +1808,31 @@ module RobustExcelOle
|
|
1806
1808
|
end
|
1807
1809
|
|
1808
1810
|
it "should name an unnamed range with a giving address" do
|
1809
|
-
@excel1.add_name("foo",1,2)
|
1811
|
+
@excel1.add_name("foo",[1,2])
|
1810
1812
|
@excel1.Names.Item("foo").Name.should == "foo"
|
1811
|
-
@excel1.Names.Item("foo").Value.should == "=Sheet1!$B$1"
|
1813
|
+
@excel1.Names.Item("foo").Value.should == "=Sheet1!$B$1:$B$1"
|
1812
1814
|
end
|
1813
1815
|
|
1814
1816
|
it "should rename an already named range with a giving address" do
|
1815
|
-
@excel1.add_name("foo",1,1)
|
1817
|
+
@excel1.add_name("foo",[1,1])
|
1816
1818
|
@excel1.Names.Item("foo").Name.should == "foo"
|
1817
|
-
@excel1.Names.Item("foo").Value.should == "=Sheet1!$A$1"
|
1819
|
+
@excel1.Names.Item("foo").Value.should == "=Sheet1!$A$1:$A$1"
|
1818
1820
|
end
|
1819
1821
|
|
1820
1822
|
it "should raise an error" do
|
1821
1823
|
expect{
|
1822
|
-
@excel1.add_name("foo", -2, 1)
|
1823
|
-
}.to raise_error(RangeNotEvaluatable, /cannot add name "foo" to
|
1824
|
+
@excel1.add_name("foo", [-2, 1])
|
1825
|
+
}.to raise_error(RangeNotEvaluatable, /cannot add name "foo" to range/)
|
1824
1826
|
end
|
1825
1827
|
|
1826
1828
|
it "should rename a range" do
|
1827
|
-
@excel1.add_name("foo",1,1)
|
1829
|
+
@excel1.add_name("foo",[1,1])
|
1828
1830
|
@excel1.rename_range("foo","bar")
|
1829
1831
|
@excel1.namevalue_glob("bar").should == "foo"
|
1830
1832
|
end
|
1831
1833
|
|
1832
1834
|
it "should delete a name of a range" do
|
1833
|
-
@excel1.add_name("foo",1,1)
|
1835
|
+
@excel1.add_name("foo",[1,1])
|
1834
1836
|
@excel1.delete_name("foo")
|
1835
1837
|
expect{
|
1836
1838
|
@excel1.namevalue_glob("foo")
|
@@ -1838,16 +1840,22 @@ module RobustExcelOle
|
|
1838
1840
|
end
|
1839
1841
|
|
1840
1842
|
it "should add a name of a rectangular range" do
|
1841
|
-
@excel1.add_name("foo",1,1
|
1843
|
+
@excel1.add_name("foo",[1..3,1..4])
|
1844
|
+
@excel1["foo"].should == [["foo", "workbook", "sheet1", nil], ["foo", 1.0, 2.0, 4.0], ["matz", 3.0, 4.0, 4.0]]
|
1845
|
+
end
|
1846
|
+
|
1847
|
+
it "should accept the old interface" do
|
1848
|
+
@excel1.add_name("foo",1..3,1..4)
|
1842
1849
|
@excel1["foo"].should == [["foo", "workbook", "sheet1", nil], ["foo", 1.0, 2.0, 4.0], ["matz", 3.0, 4.0, 4.0]]
|
1843
1850
|
end
|
1851
|
+
|
1844
1852
|
end
|
1845
1853
|
|
1846
1854
|
|
1847
1855
|
describe "nameval, set_nameval" do
|
1848
1856
|
|
1849
1857
|
before do
|
1850
|
-
@book1 =
|
1858
|
+
@book1 = Workbook.open(@dir + '/another_workbook.xls')
|
1851
1859
|
@book1.Windows(@book1.Name).Visible = true
|
1852
1860
|
@excel1 = @book1.excel
|
1853
1861
|
end
|
@@ -1916,7 +1924,7 @@ module RobustExcelOle
|
|
1916
1924
|
describe "namevalue, set_namevalue" do
|
1917
1925
|
|
1918
1926
|
before do
|
1919
|
-
@book1 =
|
1927
|
+
@book1 = Workbook.open(@dir + '/another_workbook.xls')
|
1920
1928
|
@excel1 = @book1.excel
|
1921
1929
|
end
|
1922
1930
|
|