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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +34 -1
  3. data/README.rdoc +20 -6
  4. data/___dummy_workbook.xls +0 -0
  5. data/docs/README_excel.rdoc +7 -1
  6. data/docs/README_open.rdoc +45 -20
  7. data/docs/README_ranges.rdoc +11 -2
  8. data/examples/example_ruby_library.rb +27 -0
  9. data/extconf.rb +13 -0
  10. data/lib/robust_excel_ole.rb +4 -3
  11. data/lib/robust_excel_ole/{address.rb → address_tool.rb} +23 -22
  12. data/lib/robust_excel_ole/{reo_common.rb → base.rb} +2 -90
  13. data/lib/robust_excel_ole/bookstore.rb +14 -77
  14. data/lib/robust_excel_ole/cell.rb +30 -18
  15. data/lib/robust_excel_ole/excel.rb +105 -64
  16. data/lib/robust_excel_ole/general.rb +40 -15
  17. data/lib/robust_excel_ole/range.rb +42 -19
  18. data/lib/robust_excel_ole/range_owners.rb +40 -25
  19. data/lib/robust_excel_ole/vba_objects.rb +30 -0
  20. data/lib/robust_excel_ole/version.rb +1 -1
  21. data/lib/robust_excel_ole/workbook.rb +310 -336
  22. data/lib/robust_excel_ole/worksheet.rb +51 -25
  23. data/robust_excel_ole.gemspec +1 -0
  24. data/spec/address_tool_spec.rb +175 -0
  25. data/spec/{reo_common_spec.rb → base_spec.rb} +19 -34
  26. data/spec/bookstore_spec.rb +3 -3
  27. data/spec/cell_spec.rb +67 -25
  28. data/spec/data/more_data/workbook.xls +0 -0
  29. data/spec/excel_spec.rb +137 -369
  30. data/spec/general_spec.rb +21 -27
  31. data/spec/range_spec.rb +57 -3
  32. data/spec/workbook_spec.rb +11 -79
  33. data/spec/workbook_specs/workbook_misc_spec.rb +29 -40
  34. data/spec/workbook_specs/workbook_open_spec.rb +570 -30
  35. data/spec/workbook_specs/workbook_unobtr_spec.rb +440 -136
  36. data/spec/worksheet_spec.rb +36 -4
  37. metadata +11 -7
  38. data/spec/address_spec.rb +0 -174
@@ -35,7 +35,15 @@ describe Workbook do
35
35
  #@simple_file_via_network = File.join('N:/', 'data') + '/workbook.xls'
36
36
  @simple_file_network_path = "N:/data/workbook.xls"
37
37
  @simple_file_hostname_share_path = '//DESKTOP-A3C5CJ6/spec/data/workbook.xls'
38
-
38
+ @simple_file_network_path_other_path = "N:/data/more_data/workbook.xls"
39
+ @simple_file_hostname_share_path_other_path = '//DESKTOP-A3C5CJ6/spec/data/more_data/workbook.xls'
40
+ @simple_file_network_path1 = @simple_file_network_path
41
+ @simple_file_hostname_share_path1 = @simple_file_hostname_share_path
42
+ @simple_file_network_path_other_path1 = @simple_file_network_path_other_path
43
+ @simple_file_hostname_share_path_other_path1 = @simple_file_hostname_share_path_other_path
44
+ @simple_file_xlsm1 = @simple_file_xlsm
45
+ @simple_file_xlsx1 = @simple_file_xlsx
46
+ @error_message_excel = "provided Excel option value is neither an Excel object nor a valid option"
39
47
  end
40
48
 
41
49
  after do
@@ -43,6 +51,198 @@ describe Workbook do
43
51
  rm_tmp(@dir)
44
52
  end
45
53
 
54
+ describe "basic tests with xlsx-workbooks" do
55
+
56
+ context "with simple file" do
57
+
58
+ it "should simply create a new workbook given a file" do
59
+ book = Workbook.new(@simple_file_xlsx1)
60
+ book.should be_alive
61
+ book.should be_a Workbook
62
+ book.filename.should == @simple_file_xlsx1
63
+ end
64
+
65
+ end
66
+
67
+ context "with transparency identity" do
68
+
69
+ before do
70
+ @book = Workbook.open(@simple_file_xlsx1)
71
+ end
72
+
73
+ after do
74
+ @book.close
75
+ end
76
+
77
+ it "should yield identical Workbook objects referring to identical WIN32OLE objects" do
78
+ book2 = Workbook.new(@book.ole_workbook)
79
+ book2.equal?(@book).should be true
80
+ end
81
+
82
+ end
83
+
84
+ context "with connecting to one unknown workbook" do
85
+
86
+ before do
87
+ ole_e1 = WIN32OLE.new('Excel.Application')
88
+ ws = ole_e1.Workbooks
89
+ abs_filename = General.absolute_path(@simple_file_xlsx1)
90
+ @ole_wb = ws.Open(abs_filename)
91
+ end
92
+
93
+ it "should connect to an unknown workbook" do
94
+ Workbook.open(@simple_file_xlsx1) do |book|
95
+ book.filename.should == @simple_file_xlsx1
96
+ book.should be_alive
97
+ book.should be_a Workbook
98
+ book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
99
+ Excel.excels_number.should == 1
100
+ end
101
+ end
102
+ end
103
+
104
+ context "with :force => excel" do
105
+
106
+ before do
107
+ @book = Workbook.open(@simple_file_xlsx1)
108
+ end
109
+
110
+ it "should open in a new Excel" do
111
+ book2 = Workbook.open(@simple_file_xlsx1, :force => {:excel => :new})
112
+ book2.should be_alive
113
+ book2.should be_a Workbook
114
+ book2.excel.should_not == @book.excel
115
+ book2.should_not == @book
116
+ @book.Readonly.should be false
117
+ book2.Readonly.should be true
118
+ book2.close
119
+ end
120
+
121
+ end
122
+
123
+ context "with :if_unsaved" do
124
+
125
+ before do
126
+ @book = Workbook.open(@simple_file_xlsx1)
127
+ @sheet = @book.sheet(1)
128
+ @book.add_sheet(@sheet, :as => 'a_name')
129
+ @book.visible = true
130
+ end
131
+
132
+ after do
133
+ @book.close(:if_unsaved => :forget)
134
+ @new_book.close rescue nil
135
+ end
136
+
137
+ it "should let the book open, if :if_unsaved is :accept" do
138
+ expect {
139
+ @new_book = Workbook.open(@simple_file_xlsx1, :if_unsaved => :accept)
140
+ }.to_not raise_error
141
+ @book.should be_alive
142
+ @new_book.should be_alive
143
+ @new_book.should == @book
144
+ end
145
+
146
+ end
147
+
148
+ end
149
+
150
+ describe "basic tests with xlsm-workbooks" do
151
+
152
+ context "with simple file" do
153
+
154
+ it "should simply create a new workbook given a file" do
155
+ book = Workbook.new(@simple_file_xlsm1)
156
+ book.should be_alive
157
+ book.should be_a Workbook
158
+ book.filename.should == @simple_file_xlsm1
159
+ end
160
+
161
+ end
162
+
163
+ context "with transparency identity" do
164
+
165
+ before do
166
+ @book = Workbook.open(@simple_file_xlsm1)
167
+ end
168
+
169
+ after do
170
+ @book.close
171
+ end
172
+
173
+ it "should yield identical Workbook objects referring to identical WIN32OLE objects" do
174
+ book2 = Workbook.new(@book.ole_workbook)
175
+ book2.equal?(@book).should be true
176
+ end
177
+
178
+ end
179
+
180
+ context "connecting to one unknown workbook" do
181
+
182
+ before do
183
+ ole_e1 = WIN32OLE.new('Excel.Application')
184
+ ws = ole_e1.Workbooks
185
+ abs_filename = General.absolute_path(@simple_file_xlsm1)
186
+ @ole_wb = ws.Open(abs_filename)
187
+ end
188
+
189
+ it "should connect to an unknown workbook" do
190
+ Workbook.open(@simple_file_xlsm1) do |book|
191
+ book.filename.should == @simple_file_xlsm1
192
+ book.should be_alive
193
+ book.should be_a Workbook
194
+ book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
195
+ Excel.excels_number.should == 1
196
+ end
197
+ end
198
+ end
199
+
200
+ context "with :force => excel" do
201
+
202
+ before do
203
+ @book = Workbook.open(@simple_file_xlsm1)
204
+ end
205
+
206
+ it "should open in a new Excel" do
207
+ book2 = Workbook.open(@simple_file_xlsm1, :force => {:excel => :new})
208
+ book2.should be_alive
209
+ book2.should be_a Workbook
210
+ book2.excel.should_not == @book.excel
211
+ book2.should_not == @book
212
+ @book.Readonly.should be false
213
+ book2.Readonly.should be true
214
+ book2.close
215
+ end
216
+
217
+ end
218
+
219
+ context "with :if_unsaved" do
220
+
221
+ before do
222
+ @book = Workbook.open(@simple_file_xlsm1)
223
+ @sheet = @book.sheet(1)
224
+ @book.add_sheet(@sheet, :as => 'a_name')
225
+ @book.visible = true
226
+ end
227
+
228
+ after do
229
+ @book.close(:if_unsaved => :forget)
230
+ @new_book.close rescue nil
231
+ end
232
+
233
+ it "should let the book open, if :if_unsaved is :accept" do
234
+ expect {
235
+ @new_book = Workbook.open(@simple_file_xlsm1, :if_unsaved => :accept)
236
+ }.to_not raise_error
237
+ @book.should be_alive
238
+ @new_book.should be_alive
239
+ @new_book.should == @book
240
+ end
241
+
242
+ end
243
+
244
+ end
245
+
46
246
  describe "open and new" do
47
247
 
48
248
  context "with standard" do
@@ -67,8 +267,340 @@ describe Workbook do
67
267
 
68
268
  end
69
269
 
270
+ describe "fetching workbooks with network and hostname share paths" do
271
+
272
+ before do
273
+ bookstore = Bookstore.new
274
+ end
275
+
276
+ it "should fetch a network path file given a hostname share file" do
277
+ book1 = Workbook.open(@simple_file_hostname_share_path)
278
+ book2 = Workbook.open(@simple_file_network_path)
279
+ book2.should === book1
280
+ book2.Fullname.should == book1.Fullname
281
+ book1.excel.Workbooks.Count.should == 1
282
+ end
283
+
284
+ it "should fetch a hostname share file given a network path file" do
285
+ book1 = Workbook.open(@simple_file_network_path)
286
+ book2 = Workbook.open(@simple_file_hostname_share_path)
287
+ book2.should === book1
288
+ book2.Fullname.should == book1.Fullname
289
+ book1.excel.Workbooks.Count.should == 1
290
+ end
291
+
292
+ it "should raise WorkbookBlocked" do
293
+ book1 = Workbook.open(@simple_file_hostname_share_path)
294
+ expect{
295
+ book2 = Workbook.open(@simple_file)
296
+ }.to raise_error(WorkbookBlocked)
297
+ end
298
+
299
+ it "should raise an error fetching an hostname share file having opened a local path file" do
300
+ book1 = Workbook.open(@simple_file)
301
+ expect{
302
+ Workbook.open(@simple_file_hostname_share_path)
303
+ }.to raise_error(WorkbookBlocked)
304
+ end
305
+
306
+ it "should raise an error fetching a local path file having opened a network path file" do
307
+ book1 = Workbook.open(@simple_file_network_path)
308
+ expect{
309
+ Workbook.open(@simple_file)
310
+ }.to raise_error(WorkbookBlocked)
311
+ end
312
+
313
+ it "should raise an error fetching a network path file having opened a local path file" do
314
+ book1 = Workbook.open(@simple_file)
315
+ expect{
316
+ Workbook.open(@simple_file_network_path)
317
+ }.to raise_error(WorkbookBlocked)
318
+ end
319
+
320
+ it "should raise an error fetching a local path file having opened a hostname share path file" do
321
+ book1 = Workbook.open(@simple_file_hostname_share_path)
322
+ expect{
323
+ Workbook.open(@simple_file)
324
+ }.to raise_error(WorkbookBlocked)
325
+ end
326
+
327
+ it "should raise an WorkbookBlockederror" do
328
+ book1 = Workbook.open(@simple_file_network_path1)
329
+ expect{
330
+ Workbook.open(@simple_file_network_path_other_path1)
331
+ }.to raise_error(WorkbookBlocked)
332
+ end
333
+
334
+ it "should raise an WorkbookBlockederror" do
335
+ book1 = Workbook.open(@simple_file_network_path_other_path1)
336
+ expect{
337
+ Workbook.open(@simple_file_network_path1)
338
+ }.to raise_error(WorkbookBlocked)
339
+ end
340
+
341
+ it "should raise an WorkbookBlockederror" do
342
+ book1 = Workbook.open(@simple_file_hostname_share_path1)
343
+ expect{
344
+ Workbook.open(@simple_file_hostname_share_path_other_path1)
345
+ }.to raise_error(WorkbookBlocked)
346
+ end
347
+
348
+ it "should raise an WorkbookBlockederror" do
349
+ book1 = Workbook.open(@simple_file_hostname_share_path_other_path1)
350
+ expect{
351
+ Workbook.open(@simple_file_hostname_share_path1)
352
+ }.to raise_error(WorkbookBlocked)
353
+ end
354
+
355
+ it "should raise an WorkbookBlockederror" do
356
+ book1 = Workbook.open(@simple_file_hostname_share_path1)
357
+ expect{
358
+ Workbook.open(@simple_file_network_path_other_path1)
359
+ }.to raise_error(WorkbookBlocked)
360
+ end
361
+
362
+ it "should raise an WorkbookBlockederror" do
363
+ book1 = Workbook.open(@simple_file_hostname_share_path_other_path1)
364
+ expect{
365
+ Workbook.open(@simple_file_network_path1)
366
+ }.to raise_error(WorkbookBlocked)
367
+ end
368
+
369
+ it "should raise an WorkbookBlockederror" do
370
+ book1 = Workbook.open(@simple_file_network_path1)
371
+ expect{
372
+ Workbook.open(@simple_file_hostname_share_path_other_path1)
373
+ }.to raise_error(WorkbookBlocked)
374
+ end
375
+
376
+ it "should raise an WorkbookBlockederror" do
377
+ book1 = Workbook.open(@simple_file_network_path_other_path1)
378
+ expect{
379
+ Workbook.open(@simple_file_hostname_share_path1)
380
+ }.to raise_error(WorkbookBlocked)
381
+ end
382
+
383
+ end
384
+
385
+
70
386
  describe "connecting to unknown workbooks" do
71
387
 
388
+ context "with one unknown network path or hostname share file" do
389
+
390
+ it "should connect to a network path workbook from a network path file" do
391
+ ole_e1 = WIN32OLE.new('Excel.Application')
392
+ ws = ole_e1.Workbooks
393
+ abs_filename = General.absolute_path(@simple_file_network_path1)
394
+ @ole_wb = ws.Open(abs_filename)
395
+ Workbook.open(@simple_file_network_path1) do |book|
396
+ book.should be_alive
397
+ book.should be_a Workbook
398
+ book.filename.should == @simple_file_network_path1
399
+ book.Fullname.should == @ole_wb.Fullname
400
+ book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
401
+ Excel.excels_number.should == 1
402
+ book.excel.Workbooks.Count.should == 1
403
+ end
404
+ end
405
+
406
+ it "should connect to a hostname share workbook from a network path file" do
407
+ ole_e1 = WIN32OLE.new('Excel.Application')
408
+ ws = ole_e1.Workbooks
409
+ abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
410
+ @ole_wb = ws.Open(abs_filename)
411
+ Workbook.open(@simple_file_network_path1) do |book|
412
+ book.should be_alive
413
+ book.should be_a Workbook
414
+ book.filename.should == @simple_file_hostname_share_path1.downcase
415
+ book.Fullname.should == @ole_wb.Fullname
416
+ book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
417
+ Excel.excels_number.should == 1
418
+ book.excel.Workbooks.Count.should == 1
419
+ end
420
+ end
421
+
422
+ it "should raise WorkbookBlocked trying to connect to a local path file from a network path file" do
423
+ ole_e1 = WIN32OLE.new('Excel.Application')
424
+ ws = ole_e1.Workbooks
425
+ abs_filename = General.absolute_path(@simple_file1)
426
+ @ole_wb = ws.Open(abs_filename)
427
+ expect{
428
+ Workbook.open(@simple_file_network_path1)
429
+ }.to raise_error(WorkbookBlocked)
430
+ end
431
+
432
+ it "should raise WorkbookBlocked trying to connect to a network path file from a local path file" do
433
+ ole_e1 = WIN32OLE.new('Excel.Application')
434
+ ws = ole_e1.Workbooks
435
+ abs_filename = General.absolute_path(@simple_file_network_path1)
436
+ @ole_wb = ws.Open(abs_filename)
437
+ expect{
438
+ Workbook.open(@simple_file1)
439
+ }.to raise_error(WorkbookBlocked)
440
+ end
441
+
442
+ it "should raise WorkbookBlocked trying to connect a hostname share file from a local path file" do
443
+ ole_e1 = WIN32OLE.new('Excel.Application')
444
+ ws = ole_e1.Workbooks
445
+ abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
446
+ @ole_wb = ws.Open(abs_filename)
447
+ expect{
448
+ Workbook.open(@simple_file1)
449
+ }.to raise_error(WorkbookBlocked)
450
+ end
451
+
452
+ it "should raise WorkbookBlocked trying to connect to a local path workbook from a hostname share file" do
453
+ ole_e1 = WIN32OLE.new('Excel.Application')
454
+ ws = ole_e1.Workbooks
455
+ abs_filename = General.absolute_path(@simple_file1)
456
+ @ole_wb = ws.Open(abs_filename)
457
+ expect{
458
+ Workbook.open(@simple_file_hostname_share_path1)
459
+ }.to raise_error(WorkbookBlocked)
460
+ end
461
+
462
+ it "should connect to a network path workbook from a hostname share file" do
463
+ ole_e1 = WIN32OLE.new('Excel.Application')
464
+ ws = ole_e1.Workbooks
465
+ abs_filename = General.absolute_path(@simple_file_network_path1)
466
+ @ole_wb = ws.Open(abs_filename)
467
+ Workbook.open(@simple_file_hostname_share_path1) do |book|
468
+ book.should be_alive
469
+ book.should be_a Workbook
470
+ book.filename.should == @simple_file_network_path1
471
+ book.Fullname.should == @ole_wb.Fullname
472
+ book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
473
+ Excel.excels_number.should == 1
474
+ book.excel.Workbooks.Count.should == 1
475
+ end
476
+ end
477
+
478
+ it "should connect to a hostname share workbook from a hostname share file" do
479
+ ole_e1 = WIN32OLE.new('Excel.Application')
480
+ ws = ole_e1.Workbooks
481
+ abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
482
+ @ole_wb = ws.Open(abs_filename)
483
+ Workbook.open(@simple_file_hostname_share_path1) do |book|
484
+ book.should be_alive
485
+ book.should be_a Workbook
486
+ book.filename.should == @simple_file_hostname_share_path1.downcase
487
+ book.Fullname.should == @ole_wb.Fullname
488
+ book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
489
+ Excel.excels_number.should == 1
490
+ book.excel.Workbooks.Count.should == 1
491
+ end
492
+ end
493
+
494
+ it "should raise WorkbookBlocked error" do
495
+ ole_e1 = WIN32OLE.new('Excel.Application')
496
+ ws = ole_e1.Workbooks
497
+ abs_filename = General.absolute_path(@simple_file_network_path1)
498
+ @ole_wb = ws.Open(abs_filename)
499
+ expect{
500
+ Workbook.open(@simple_file_network_path_other_path1)
501
+ }.to raise_error(WorkbookBlocked)
502
+ end
503
+
504
+ it "should raise WorkbookBlocked error" do
505
+ ole_e1 = WIN32OLE.new('Excel.Application')
506
+ ws = ole_e1.Workbooks
507
+ abs_filename = General.absolute_path(@simple_file_network_path_other_path1)
508
+ @ole_wb = ws.Open(abs_filename)
509
+ expect{
510
+ Workbook.open(@simple_file_network_path1)
511
+ }.to raise_error(WorkbookBlocked)
512
+ end
513
+
514
+ it "should raise WorkbookBlocked error" do
515
+ ole_e1 = WIN32OLE.new('Excel.Application')
516
+ ws = ole_e1.Workbooks
517
+ abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
518
+ @ole_wb = ws.Open(abs_filename)
519
+ expect{
520
+ Workbook.open(@simple_file_hostname_share_path_other_path1)
521
+ }.to raise_error(WorkbookBlocked)
522
+ end
523
+
524
+ it "should raise WorkbookBlocked error" do
525
+ ole_e1 = WIN32OLE.new('Excel.Application')
526
+ ws = ole_e1.Workbooks
527
+ abs_filename = General.absolute_path(@simple_file_hostname_share_path_other_path1)
528
+ @ole_wb = ws.Open(abs_filename)
529
+ expect{
530
+ Workbook.open(@simple_file_hostname_share_path1)
531
+ }.to raise_error(WorkbookBlocked)
532
+ end
533
+
534
+ it "should raise WorkbookBlocked error" do
535
+ ole_e1 = WIN32OLE.new('Excel.Application')
536
+ ws = ole_e1.Workbooks
537
+ abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
538
+ @ole_wb = ws.Open(abs_filename)
539
+ expect{
540
+ Workbook.open(@simple_file_network_path_other_path1)
541
+ }.to raise_error(WorkbookBlocked)
542
+ end
543
+
544
+ it "should raise WorkbookBlocked error" do
545
+ ole_e1 = WIN32OLE.new('Excel.Application')
546
+ ws = ole_e1.Workbooks
547
+ abs_filename = General.absolute_path(@simple_file_network_path_other_path1)
548
+ @ole_wb = ws.Open(abs_filename)
549
+ expect{
550
+ Workbook.open(@simple_file_hostname_share_path1)
551
+ }.to raise_error(WorkbookBlocked)
552
+ end
553
+
554
+ it "should raise WorkbookBlocked error" do
555
+ ole_e1 = WIN32OLE.new('Excel.Application')
556
+ ws = ole_e1.Workbooks
557
+ abs_filename = General.absolute_path(@simple_file_network_path1)
558
+ @ole_wb = ws.Open(abs_filename)
559
+ expect{
560
+ Workbook.open(@simple_file_hostname_share_path_other_path1)
561
+ }.to raise_error(WorkbookBlocked)
562
+ end
563
+
564
+ it "should raise WorkbookBlocked error" do
565
+ ole_e1 = WIN32OLE.new('Excel.Application')
566
+ ws = ole_e1.Workbooks
567
+ abs_filename = General.absolute_path(@simple_file_hostname_share_path_other_path1)
568
+ @ole_wb = ws.Open(abs_filename)
569
+ expect{
570
+ Workbook.open(@simple_file_network_path1)
571
+ }.to raise_error(WorkbookBlocked)
572
+ end
573
+
574
+ end
575
+
576
+ context "with one unknown hostname share path file" do
577
+
578
+ before do
579
+ ole_e1 = WIN32OLE.new('Excel.Application')
580
+ ws = ole_e1.Workbooks
581
+ abs_filename = General.absolute_path( @simple_file_hostname_share_path1)
582
+ @ole_wb = ws.Open(abs_filename)
583
+ end
584
+
585
+ it "should connect to an unknown hostname share path workbook" do
586
+ Workbook.open(@simple_file_hostname_share_path1) do |book|
587
+ book.filename.should == @simple_file_hostname_share_path1.downcase
588
+ book.should be_alive
589
+ book.should be_a Workbook
590
+ book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
591
+ Excel.excels_number.should == 1
592
+ book.excel.Workbooks.Count.should == 1
593
+ end
594
+ end
595
+
596
+ it "should raise error because blocking" do
597
+ expect{
598
+ Workbook.open(@simple_file1)
599
+ }.to raise_error(WorkbookBlocked)
600
+ end
601
+
602
+ end
603
+
72
604
  context "with none workbook" do
73
605
 
74
606
  it "should open one new Excel with the worbook" do
@@ -78,7 +610,7 @@ describe Workbook do
78
610
  Excel.excels_number.should == 1
79
611
  book1.ReadOnly.should be false
80
612
  book1.excel.Visible.should be false
81
- book1.CheckCompatibility.should be false
613
+ book1.CheckCompatibility.should be true
82
614
  book1.Saved.should be true
83
615
  end
84
616
 
@@ -380,7 +912,7 @@ describe Workbook do
380
912
  excel1.close
381
913
  expect{
382
914
  book1 = Workbook.open(@simple_file1, :force => {:excel => excel1})
383
- }.to raise_error(ExcelREOError, "excel is not alive")
915
+ }.to raise_error(ExcelREOError, "Excel is not alive")
384
916
  end
385
917
 
386
918
  it "should open in a provided Excel" do
@@ -402,18 +934,7 @@ describe Workbook do
402
934
  end
403
935
 
404
936
  end
405
-
406
- describe "network paths" do
407
-
408
- it "should open the workbook via network path" do
409
- book1 = Workbook.open(@simple_file_hostname_share_path)
410
- book2 = Workbook.open(@simple_file_network_path)
411
- book1.should === book2
412
- book1.Fullname.should == book2.Fullname
413
- end
414
-
415
- end
416
-
937
+
417
938
  describe "new" do
418
939
 
419
940
  context "with transparency identity" do
@@ -510,7 +1031,26 @@ describe Workbook do
510
1031
  book2.excel.should_not == book.excel
511
1032
  end
512
1033
 
513
- it "should promote an open known workbook" do
1034
+ it "should type-lift an workbook" do
1035
+ book = Workbook.open(@simple_file)
1036
+ new_book = Workbook.new(book)
1037
+ new_book.should == book
1038
+ new_book.equal?(book).should be true
1039
+ new_book.Fullname.should == book.Fullname
1040
+ new_book.excel.should == book.excel
1041
+ end
1042
+
1043
+ it "should type-lift an workbook and supply option" do
1044
+ book = Workbook.open(@simple_file)
1045
+ new_book = Workbook.new(book, :visible => true)
1046
+ new_book.should == book
1047
+ new_book.equal?(book).should be true
1048
+ new_book.Fullname.should == book.Fullname
1049
+ new_book.excel.should == book.excel
1050
+ new_book.visible.should be true
1051
+ end
1052
+
1053
+ it "should type-lift an open known win32ole workbook" do
514
1054
  book = Workbook.open(@simple_file)
515
1055
  ole_workbook = book.ole_workbook
516
1056
  new_book = Workbook.new(ole_workbook)
@@ -520,7 +1060,7 @@ describe Workbook do
520
1060
  new_book.excel.should == book.excel
521
1061
  end
522
1062
 
523
- it "should promote an open known workbook and let it be visible" do
1063
+ it "should type-lift an open known win32ole workbook and let it be visible" do
524
1064
  book = Workbook.open(@simple_file, :visible => true)
525
1065
  ole_workbook = book.ole_workbook
526
1066
  new_book = Workbook.new(ole_workbook)
@@ -532,7 +1072,7 @@ describe Workbook do
532
1072
  new_book.Windows(new_book.ole_workbook.Name).Visible.should == true
533
1073
  end
534
1074
 
535
- it "should promote an open known workbook and let it be visible and readonly" do
1075
+ it "should type-lift an open known win32ole workbook and let it be visible and readonly" do
536
1076
  book = Workbook.open(@simple_file, :visible => true, :read_only => true)
537
1077
  ole_workbook = book.ole_workbook
538
1078
  new_book = Workbook.new(ole_workbook)
@@ -545,7 +1085,7 @@ describe Workbook do
545
1085
  new_book.ReadOnly.should == true
546
1086
  end
547
1087
 
548
- it "should promote an open known workbook and make it visible" do
1088
+ it "should type-lift an open known win32ole workbook and make it visible" do
549
1089
  book = Workbook.open(@simple_file)
550
1090
  ole_workbook = book.ole_workbook
551
1091
  new_book = Workbook.new(ole_workbook, :visible => true)
@@ -557,7 +1097,7 @@ describe Workbook do
557
1097
  new_book.Windows(new_book.ole_workbook.Name).Visible.should == true
558
1098
  end
559
1099
 
560
- it "should promote an open unknown workbook" do
1100
+ it "should type-lift an open unknown win32ole workbook" do
561
1101
  ole_excel = WIN32OLE.new('Excel.Application')
562
1102
  ws = ole_excel.Workbooks
563
1103
  abs_filename = General.absolute_path(@simple_file1)
@@ -567,7 +1107,7 @@ describe Workbook do
567
1107
  new_book.excel.Hwnd.should == ole_excel.Hwnd
568
1108
  end
569
1109
 
570
- it "should promote an open unknown workbook and make it visible" do
1110
+ it "should type-lift an open unknown win32ole workbook and make it visible" do
571
1111
  ole_excel = WIN32OLE.new('Excel.Application')
572
1112
  ws = ole_excel.Workbooks
573
1113
  abs_filename = General.absolute_path(@simple_file1)
@@ -579,7 +1119,7 @@ describe Workbook do
579
1119
  new_book.Windows(new_book.ole_workbook.Name).Visible.should == true
580
1120
  end
581
1121
 
582
- it "should promote an open unknown workbook and make it visible and readonly" do
1122
+ it "should type-lift an open unknown win32ole workbook and make it visible and readonly" do
583
1123
  ole_excel = WIN32OLE.new('Excel.Application')
584
1124
  ws = ole_excel.Workbooks
585
1125
  abs_filename = General.absolute_path(@simple_file1)
@@ -612,20 +1152,20 @@ describe Workbook do
612
1152
 
613
1153
  it "should not set the default value" do
614
1154
  book1 = Workbook.open(@simple_file)
615
- book1.excel.calculation.should == nil
1155
+ book1.excel.properties[:calculation].should == nil
616
1156
  end
617
1157
 
618
1158
  it "should set the calculation mode to automatic" do
619
1159
  book1 = Workbook.open(@simple_file)
620
1160
  book1.excel.calculation = :automatic
621
- book1.excel.calculation.should == :automatic
1161
+ book1.excel.properties[:calculation].should == :automatic
622
1162
  book1.excel.Calculation.should == XlCalculationAutomatic
623
1163
  end
624
1164
 
625
1165
  it "should set the calculation mode to manual" do
626
1166
  book1 = Workbook.open(@simple_file)
627
1167
  book1.excel.calculation = :manual
628
- book1.excel.calculation.should == :manual
1168
+ book1.excel.properties[:calculation].should == :manual
629
1169
  book1.excel.Calculation.should == XlCalculationManual
630
1170
  end
631
1171
 
@@ -1040,7 +1580,7 @@ describe Workbook do
1040
1580
  it "should raise an error if no Excel or Workbook is given" do
1041
1581
  expect{
1042
1582
  Workbook.open(@simple_file1, :force => {:excel => :b})
1043
- }.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
1583
+ }.to raise_error(TypeREOError, @error_message_excel)
1044
1584
  end
1045
1585
 
1046
1586
  it "should do force_excel even if both force_ and default_excel is given" do
@@ -1196,7 +1736,7 @@ describe Workbook do
1196
1736
  it "should raise an error if no Excel or Workbook is given" do
1197
1737
  expect{
1198
1738
  Workbook.open(@simple_file1, :excel => :b)
1199
- }.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
1739
+ }.to raise_error(TypeREOError, @error_message_excel)
1200
1740
  end
1201
1741
 
1202
1742
  it "should do force_excel even if both force_ and default_excel is given" do
@@ -1354,7 +1894,7 @@ describe Workbook do
1354
1894
  it "should raise an error if no Excel or Workbook is given" do
1355
1895
  expect{
1356
1896
  Workbook.open(@simple_file1, :force_excel => :b)
1357
- }.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
1897
+ }.to raise_error(TypeREOError, @error_message_excel)
1358
1898
  end
1359
1899
 
1360
1900
  it "should do force_excel even if both force_ and default_excel is given" do
@@ -1595,7 +2135,7 @@ describe Workbook do
1595
2135
  it "should raise an error if no Excel or Workbook is given" do
1596
2136
  expect{
1597
2137
  Workbook.open(@different_file, :default => {:excel => :a})
1598
- }.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
2138
+ }.to raise_error(TypeREOError, @error_message_excel)
1599
2139
  end
1600
2140
 
1601
2141
  end
@@ -1777,7 +2317,7 @@ describe Workbook do
1777
2317
  it "should raise an error if no Excel or Workbook is given" do
1778
2318
  expect{
1779
2319
  Workbook.open(@different_file, :default_excel => :a)
1780
- }.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
2320
+ }.to raise_error(TypeREOError, @error_message_excel)
1781
2321
  end
1782
2322
 
1783
2323
  end