robust_excel_ole 0.5.1 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/Changelog +13 -0
  2. data/README.rdoc +70 -21
  3. data/README_detail.rdoc +60 -27
  4. data/examples/edit_sheets/example_access_sheets_and_cells.rb +2 -2
  5. data/examples/edit_sheets/example_adding_sheets.rb +2 -2
  6. data/examples/edit_sheets/example_concating.rb +2 -3
  7. data/examples/edit_sheets/example_copying.rb +2 -3
  8. data/examples/edit_sheets/example_expanding.rb +2 -3
  9. data/examples/edit_sheets/example_naming.rb +2 -3
  10. data/examples/edit_sheets/example_ranges.rb +2 -2
  11. data/examples/edit_sheets/example_saving.rb +2 -3
  12. data/examples/open_save_close/example_control_to_excel.rb +3 -3
  13. data/examples/open_save_close/example_default_excel.rb +4 -4
  14. data/examples/open_save_close/example_force_excel.rb +2 -2
  15. data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +2 -2
  16. data/examples/open_save_close/example_if_obstructed_forget.rb +2 -2
  17. data/examples/open_save_close/example_if_obstructed_save.rb +2 -2
  18. data/examples/open_save_close/example_if_unsaved_accept.rb +2 -2
  19. data/examples/open_save_close/example_if_unsaved_forget.rb +2 -2
  20. data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -5
  21. data/examples/open_save_close/example_read_only.rb +2 -2
  22. data/examples/open_save_close/example_rename_cells.rb +3 -3
  23. data/examples/open_save_close/example_reuse.rb +2 -2
  24. data/examples/open_save_close/example_simple.rb +3 -4
  25. data/examples/open_save_close/example_unobtrusively.rb +2 -2
  26. data/lib/robust_excel_ole/book.rb +84 -78
  27. data/lib/robust_excel_ole/bookstore.rb +5 -1
  28. data/lib/robust_excel_ole/excel.rb +165 -188
  29. data/lib/robust_excel_ole/reo_common.rb +4 -0
  30. data/lib/robust_excel_ole/sheet.rb +15 -6
  31. data/lib/robust_excel_ole/version.rb +1 -1
  32. data/spec/book_spec.rb +104 -77
  33. data/spec/book_specs/book_close_spec.rb +9 -8
  34. data/spec/book_specs/book_misc_spec.rb +367 -26
  35. data/spec/book_specs/book_open_spec.rb +375 -94
  36. data/spec/book_specs/book_save_spec.rb +137 -112
  37. data/spec/book_specs/book_sheet_spec.rb +1 -1
  38. data/spec/book_specs/book_subclass_spec.rb +2 -1
  39. data/spec/book_specs/book_unobtr_spec.rb +87 -96
  40. data/spec/bookstore_spec.rb +8 -5
  41. data/spec/cell_spec.rb +1 -1
  42. data/spec/data/another_workbook.xls +0 -0
  43. data/spec/data/book_with_blank.xls +0 -0
  44. data/spec/data/workbook.xls +0 -0
  45. data/spec/excel_spec.rb +484 -72
  46. data/spec/range_spec.rb +1 -1
  47. data/spec/sheet_spec.rb +47 -1
  48. metadata +4 -5
@@ -14,7 +14,7 @@ describe Book do
14
14
  excel = Excel.new(:reuse => true)
15
15
  open_books = excel == nil ? 0 : excel.Workbooks.Count
16
16
  puts "*** open books *** : #{open_books}" if open_books > 0
17
- Excel.close_all
17
+ Excel.kill_all
18
18
  end
19
19
 
20
20
  before do
@@ -27,6 +27,7 @@ describe Book do
27
27
  @linked_file = @dir + '/workbook_linked.xlsm'
28
28
  @simple_file_xlsm = @dir + '/workbook.xls'
29
29
  @simple_file_xlsx = @dir + '/workbook.xlsx'
30
+ @simple_file1 = @simple_file
30
31
  end
31
32
 
32
33
  after do
@@ -51,7 +52,7 @@ describe Book do
51
52
 
52
53
  context "with unsaved read_only book" do
53
54
  before do
54
- @book = Book.open(@simple_file, :read_only => true)
55
+ @book = Book.open(@simple_file1, :read_only => true)
55
56
  @sheet_count = @book.ole_workbook.Worksheets.Count
56
57
  @book.add_sheet(@sheet, :as => 'a_name')
57
58
  end
@@ -60,7 +61,7 @@ describe Book do
60
61
  expect{
61
62
  @book.close
62
63
  }.to_not raise_error
63
- new_book = Book.open(@simple_file)
64
+ new_book = Book.open(@simple_file1)
64
65
  new_book.ole_workbook.Worksheets.Count.should == @sheet_count
65
66
  new_book.close
66
67
  end
@@ -68,7 +69,7 @@ describe Book do
68
69
 
69
70
  context "with unsaved book" do
70
71
  before do
71
- @book = Book.open(@simple_file)
72
+ @book = Book.open(@simple_file1)
72
73
  @sheet_count = @book.ole_workbook.Worksheets.Count
73
74
  @book.add_sheet(@sheet, :as => 'a_name')
74
75
  @sheet = @book.sheet(1)
@@ -109,7 +110,7 @@ describe Book do
109
110
  @book.should_not be_alive
110
111
  expect{
111
112
  ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
112
- new_book = Book.open(@simple_file)
113
+ new_book = Book.open(@simple_file1)
113
114
  begin
114
115
  new_book.ole_workbook.Worksheets.Count.should == @sheet_count
115
116
  ensure
@@ -134,7 +135,7 @@ describe Book do
134
135
  @book.should_not be_alive
135
136
  expect{
136
137
  ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
137
- new_book = Book.open(@simple_file)
138
+ new_book = Book.open(@simple_file1)
138
139
  begin
139
140
  new_book.ole_workbook.Worksheets.Count.should == @sheet_count + 1
140
141
  ensure
@@ -174,7 +175,7 @@ describe Book do
174
175
  @book.should_not be_alive
175
176
  expect{ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
176
177
  end
177
- new_book = Book.open(@simple_file, :if_unsaved => :forget)
178
+ new_book = Book.open(@simple_file1, :if_unsaved => :forget)
178
179
  begin
179
180
  new_book.ole_workbook.Worksheets.Count.should == @sheet_count + (answer==:yes ? 1 : 0)
180
181
  new_book.excel.DisplayAlerts.should == displayalert_value
@@ -217,7 +218,7 @@ describe Book do
217
218
  @book.should_not be_alive
218
219
  expect{ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
219
220
  end
220
- new_book = Book.open(@simple_file, :if_unsaved => :forget)
221
+ new_book = Book.open(@simple_file1, :if_unsaved => :forget)
221
222
  begin
222
223
  new_book.ole_workbook.Worksheets.Count.should == @sheet_count + (answer==:yes ? 1 : 0)
223
224
  new_book.excel.DisplayAlerts.should == displayalert_value
@@ -14,7 +14,7 @@ describe Book do
14
14
  excel = Excel.new(:reuse => true)
15
15
  open_books = excel == nil ? 0 : excel.Workbooks.Count
16
16
  puts "*** open books *** : #{open_books}" if open_books > 0
17
- Excel.close_all
17
+ Excel.kill_all
18
18
  end
19
19
 
20
20
  before do
@@ -27,6 +27,7 @@ describe Book do
27
27
  @linked_file = @dir + '/workbook_linked.xlsm'
28
28
  @simple_file_xlsm = @dir + '/workbook.xls'
29
29
  @simple_file_xlsx = @dir + '/workbook.xlsx'
30
+ @simple_file1 = @simple_file
30
31
  end
31
32
 
32
33
  after do
@@ -46,6 +47,221 @@ describe Book do
46
47
  end
47
48
  end
48
49
 
50
+ describe "with visible" do
51
+
52
+ it "should preserve :visible if it is not set" do
53
+ book1 = Book.open(@simple_file)
54
+ book1.excel.Visible.should be_false
55
+ book1.Windows(book1.Name).Visible.should be_true
56
+ book1.visible.should be_false
57
+ end
58
+
59
+ it "should set :visible to false" do
60
+ book1 = Book.open(@simple_file, :visible => false)
61
+ book1.excel.Visible.should be_false
62
+ book1.Windows(book1.Name).Visible.should be_true
63
+ book1.visible.should be_false
64
+ end
65
+
66
+ it "should set :visible to true" do
67
+ book1 = Book.open(@simple_file, :visible => true)
68
+ book1.excel.Visible.should be_true
69
+ book1.Windows(book1.Name).Visible.should be_true
70
+ book1.visible.should be_true
71
+ end
72
+
73
+ it "should preserve :visible if they are set to visible" do
74
+ excel1 = Excel.create(:visible => true)
75
+ book1 = Book.open(@simple_file)
76
+ book1.excel.Visible.should be_true
77
+ book1.Windows(book1.Name).Visible.should be_true
78
+ book1.visible.should be_true
79
+ end
80
+
81
+ it "should preserve :visible if it is set to false" do
82
+ excel1 = Excel.create
83
+ book1 = Book.open(@simple_file, :visible => false)
84
+ book1.excel.Visible.should be_false
85
+ book1.Windows(book1.Name).Visible.should be_true
86
+ book1.visible.should be_false
87
+ end
88
+
89
+ it "should preserve :visible if it is not set" do
90
+ excel1 = Excel.create
91
+ book1 = Book.open(@simple_file)
92
+ book1.excel.Visible.should be_false
93
+ book1.Windows(book1.Name).Visible.should be_true
94
+ book1.visible.should be_false
95
+ end
96
+
97
+ it "should overwrite :visible to false" do
98
+ excel1 = Excel.create(:visible => true)
99
+ book1 = Book.open(@simple_file, :visible => false)
100
+ book1.excel.Visible.should be_true
101
+ book1.Windows(book1.Name).Visible.should be_false
102
+ book1.visible.should be_false
103
+ end
104
+
105
+ it "should overwrite :visible to true" do
106
+ excel1 = Excel.create(:visible => false)
107
+ book1 = Book.open(@simple_file, :visible => true)
108
+ book1.excel.Visible.should be_true
109
+ book1.Windows(book1.Name).Visible.should be_true
110
+ book1.visible.should be_true
111
+ end
112
+
113
+ it "should preserve :visible if it is not set with default_excel" do
114
+ excel1 = Excel.create(:visible => true)
115
+ book1 = Book.open(@simple_file)
116
+ book2 = Book.open(@different_file, :default_excel => :new)
117
+ book2.excel.Visible.should be_false
118
+ book2.Windows(book2.Name).Visible.should be_true
119
+ book2.visible.should be_false
120
+ end
121
+
122
+ it "should set :visible to true with default_excel" do
123
+ excel1 = Excel.create(:visible => true)
124
+ book1 = Book.open(@simple_file)
125
+ book2 = Book.open(@different_file, :default_excel => :new, :visible => true)
126
+ book2.excel.Visible.should be_true
127
+ book2.Windows(book2.Name).Visible.should be_true
128
+ book2.visible.should be_true
129
+ end
130
+
131
+ it "should set :visible to false with default_excel" do
132
+ excel1 = Excel.create(:visible => true)
133
+ book1 = Book.open(@simple_file)
134
+ book2 = Book.open(@different_file, :default_excel => :new, :visible => false)
135
+ book2.excel.Visible.should be_false
136
+ book2.Windows(book2.Name).Visible.should be_true
137
+ book2.visible.should be_false
138
+ end
139
+
140
+ it "should preserve :visible if it is set to true with default_excel" do
141
+ excel1 = Excel.create(:visible => true)
142
+ excel2 = Excel.create(:visible => true)
143
+ book1 = Book.open(@different_file, :default_excel => excel2)
144
+ book1.excel.Visible.should be_true
145
+ book1.Windows(book1.Name).Visible.should be_true
146
+ book1.visible.should be_true
147
+ end
148
+
149
+ it "should overwrite :visible to false with default_excel" do
150
+ excel1 = Excel.create(:visible => true)
151
+ excel2 = Excel.create(:visible => true)
152
+ book1 = Book.open(@different_file, :default_excel => excel2, :visible => false)
153
+ book1.excel.Visible.should be_true
154
+ book1.Windows(book1.Name).Visible.should be_false
155
+ book1.visible.should be_false
156
+ end
157
+
158
+ it "should preserve :visible if it is not set with force_excel => new" do
159
+ excel1 = Excel.create(:visible => true)
160
+ book1 = Book.open(@different_file, :force_excel => :new)
161
+ book1.excel.Visible.should be_false
162
+ book1.Windows(book1.Name).Visible.should be_true
163
+ book1.visible.should be_false
164
+ end
165
+
166
+ it "should set :visible to true with force_excel" do
167
+ excel1 = Excel.create(:visible => true)
168
+ book1 = Book.open(@different_file, :force_excel => :new, :visible => true)
169
+ book1.excel.Visible.should be_true
170
+ book1.Windows(book1.Name).Visible.should be_true
171
+ book1.visible.should be_true
172
+ end
173
+
174
+ it "should preserve :visible if it is not set with force_excel => excel" do
175
+ excel1 = Excel.create(:visible => true)
176
+ excel2 = Excel.create(:visible => true)
177
+ book1 = Book.open(@different_file, :force_excel => excel2)
178
+ book1.excel.Visible.should be_true
179
+ book1.Windows(book1.Name).Visible.should be_true
180
+ book1.visible.should be_true
181
+ end
182
+
183
+ it "should set visible to false with force_excel => excel" do
184
+ excel1 = Excel.create(:visible => true)
185
+ excel2 = Excel.create(:visible => true)
186
+ book1 = Book.open(@different_file, :force_excel => excel2, :visible => false)
187
+ book1.excel.Visible.should be_true
188
+ book1.Windows(book1.Name).Visible.should be_false
189
+ book1.visible.should be_false
190
+ end
191
+
192
+ it "should set visible to true with force_excel => excel" do
193
+ excel1 = Excel.create(:visible => true)
194
+ excel2 = Excel.create(:visible => true)
195
+ book1 = Book.open(@different_file, :force_excel => excel2, :visible => true)
196
+ book1.excel.Visible.should be_true
197
+ book1.Windows(book1.Name).Visible.should be_true
198
+ book1.visible.should be_true
199
+ end
200
+
201
+ it "should preserve :visible if it is set to true with force_excel => current" do
202
+ excel1 = Excel.create(:visible => true)
203
+ book1 = Book.open(@different_file, :force_excel => :current)
204
+ book1.excel.Visible.should be_true
205
+ book1.Windows(book1.Name).Visible.should be_true
206
+ book1.visible.should be_true
207
+ end
208
+
209
+ it "should set :visible to false with force_excel => current" do
210
+ excel1 = Excel.create(:visible => true)
211
+ book1 = Book.open(@different_file, :force_excel => :current, :visible => false)
212
+ book1.excel.Visible.should be_true
213
+ book1.Windows(book1.Name).Visible.should be_false
214
+ book1.visible.should be_false
215
+ end
216
+
217
+ it "should preserve :visible if it is set to false with force_excel => current" do
218
+ excel1 = Excel.create(:visible => false)
219
+ book1 = Book.open(@simple_file, :force_excel => :current)
220
+ book1.excel.Visible.should be_false
221
+ book1.Windows(book1.Name).Visible.should be_true
222
+ book1.visible.should be_false
223
+ end
224
+
225
+ it "should set :visible to false with force_excel => current" do
226
+ excel1 = Excel.create(:visible => false)
227
+ book1 = Book.open(@simple_file, :force_excel => :current, :visible => true)
228
+ book1.excel.Visible.should be_true
229
+ book1.Windows(book1.Name).Visible.should be_true
230
+ book1.visible.should be_true
231
+ end
232
+
233
+ it "should let an open Book open" do
234
+ @book = Book.open(@simple_file1, :visible => true)
235
+ Book.unobtrusively(@simple_file1) do |book|
236
+ book.should be_a Book
237
+ book.should be_alive
238
+ book.excel.should == @book.excel
239
+ book.excel.Visible.should be_true
240
+ end
241
+ @book.should be_alive
242
+ @book.should be_a Book
243
+ @book.excel.Visible.should be_true
244
+ @book.close(:if_unsaved => :forget)
245
+ @book2.close(:if_unsaved => :forget) rescue nil
246
+ end
247
+
248
+ it "should set visible and displayalerts if displayalerts => :if_visible" do
249
+ book1 = Book.open(@simple_file)
250
+ book1.excel.Visible.should be_false
251
+ book1.excel.displayalerts = :if_visible
252
+ book1.excel.displayalerts.should == :if_visible
253
+ book1.Windows(book1.Name).Visible.should be_true
254
+ book1.visible.should be_false
255
+ book2 = Book.open(@different_file, :visible => true)
256
+ book2.excel.Visible.should be_true
257
+ book2.Windows(book2.Name).Visible.should be_true
258
+ book2.visible.should be_true
259
+ book2.excel.visible.should be_true
260
+ book2.excel.displayalerts.should be_true
261
+ book2.excel.DisplayAlerts.should be_true
262
+ end
263
+ end
264
+
49
265
  describe "send methods to workbook" do
50
266
 
51
267
  context "with standard" do
@@ -84,7 +300,7 @@ describe Book do
84
300
  context "with some open book" do
85
301
 
86
302
  before do
87
- @book = Book.open(@simple_file)
303
+ @book = Book.open(@simple_file1)
88
304
  end
89
305
 
90
306
  after do
@@ -92,10 +308,10 @@ describe Book do
92
308
  end
93
309
 
94
310
  it "should create and use a hidden Excel instance" do
95
- book2 = Book.open(@simple_file, :force_excel => @book.bookstore.hidden_excel)
311
+ book2 = Book.open(@simple_file1, :force_excel => @book.bookstore.hidden_excel)
96
312
  book2.excel.should_not == @book.excel
97
313
  book2.excel.visible.should be_false
98
- book2.excel.displayalerts.should be_false
314
+ book2.excel.displayalerts.should == :if_visible
99
315
  book2.close
100
316
  end
101
317
  end
@@ -147,7 +363,6 @@ describe Book do
147
363
  @book1["named_formula"].should == 4
148
364
  end
149
365
 
150
-
151
366
  it "should return default value if name not defined" do
152
367
  @book1.nameval("foo", :default => 2).should == 2
153
368
  end
@@ -172,6 +387,17 @@ describe Book do
172
387
  @book1["named_formula"] = "bar"
173
388
  }.to raise_error(ExcelError, /cannot assign value to range named "named_formula" in "another_workbook.xls"/)
174
389
  end
390
+
391
+ # Excel Bug: for local names without uqifier: takes the first sheet as default even if another sheet is activated
392
+ it "should take the first sheet as default even if the second sheet is activated" do
393
+ @book1.nameval("Sheet1!localname").should == "bar"
394
+ @book1.nameval("Sheet2!localname").should == "simple"
395
+ @book1.nameval("localname").should == "bar"
396
+ @book1.Worksheets.Item(2).Activate
397
+ @book1.nameval("localname").should == "bar"
398
+ @book1.Worksheets.Item(1).Delete
399
+ @book1.nameval("localname").should == "simple"
400
+ end
175
401
  end
176
402
 
177
403
  describe "rename_range" do
@@ -193,7 +419,7 @@ describe Book do
193
419
  end
194
420
  end
195
421
 
196
- describe "alive?, filename, ==, visible, displayalerts, activate, saved, check_compatibility" do
422
+ describe "alive?, filename, ==, visible, activate, saved, check_compatibility" do
197
423
 
198
424
  context "with alive?" do
199
425
 
@@ -240,7 +466,7 @@ describe Book do
240
466
  context "with ==" do
241
467
 
242
468
  before do
243
- @book = Book.open(@simple_file)
469
+ @book = Book.open(@simple_file1)
244
470
  end
245
471
 
246
472
  after do
@@ -249,7 +475,7 @@ describe Book do
249
475
  end
250
476
 
251
477
  it "should be true with two identical books" do
252
- @new_book = Book.open(@simple_file)
478
+ @new_book = Book.open(@simple_file1)
253
479
  @new_book.should == @book
254
480
  end
255
481
 
@@ -296,29 +522,142 @@ describe Book do
296
522
  end
297
523
  end
298
524
 
299
- context "with visible" do
300
525
 
301
- before do
302
- @book = Book.open(@simple_file)
526
+ context "with :visible => " do
527
+
528
+ it "should leave the excel invisible when opening with default option" do
529
+ excel1 = Excel.new(:reuse => false, :visible => false)
530
+ book1 = Book.open(@simple_file)
531
+ excel1.Visible.should be_false
532
+ book1.Windows(book1.Name).Visible.should be_true
533
+ book1.visible.should be_false
534
+ end
535
+
536
+ it "should leave the excel invisible when opening with :visible => false" do
537
+ excel1 = Excel.new(:reuse => false, :visible => false)
538
+ book1 = Book.open(@simple_file, :visible => false)
539
+ excel1.Visible.should be_false
540
+ book1.Windows(book1.Name).Visible.should be_true
541
+ book1.visible.should be_false
542
+ end
543
+
544
+ it "should leave the excel visible" do
545
+ excel1 = Excel.new(:reuse => false, :visible => false)
546
+ book1 = Book.open(@simple_file, :visible => true)
547
+ excel1.Visible.should be_true
548
+ book1.Windows(book1.Name).Visible.should be_true
549
+ book1.visible.should be_true
550
+ book2 = Book.open(@another_simple_file)
551
+ excel1.Visible.should be_true
552
+ book2.Windows(book2.Name).Visible.should be_true
553
+ book2.visible.should be_true
554
+ book3 = Book.open(@different_file, :visible => false)
555
+ excel1.Visible.should be_true
556
+ book3.Windows(book3.Name).Visible.should be_false
557
+ book3.visible.should be_false
558
+ end
559
+
560
+ it "should leave the excel visible when opening with default option" do
561
+ excel1 = Excel.new(:reuse => false, :visible => true)
562
+ book1 = Book.open(@simple_file)
563
+ excel1.Visible.should be_true
564
+ book1.Windows(book1.Name).Visible.should be_true
565
+ book1.visible.should be_true
566
+ end
567
+
568
+ it "should leave the excel visible when opening with :visible => false" do
569
+ excel1 = Excel.new(:reuse => false, :visible => true)
570
+ book1 = Book.open(@simple_file, :visible => false)
571
+ excel1.Visible.should be_true
572
+ book1.Windows(book1.Name).Visible.should be_false
573
+ book1.visible.should be_false
574
+ book2 = Book.open(@another_simple_file)
575
+ excel1.Visible.should be_true
576
+ book2.Windows(book2.Name).Visible.should be_true
577
+ book2.visible.should be_true
578
+ end
579
+
580
+ it "should leave the excel visible" do
581
+ excel1 = Excel.new(:reuse => false, :visible => true)
582
+ book1 = Book.open(@simple_file, :visible => true)
583
+ excel1.Visible.should be_true
584
+ book1.Windows(book1.Name).Visible.should be_true
585
+ book1.visible.should be_true
586
+ book2 = Book.open(@different_file, :visible => false)
587
+ excel1.Visible.should be_true
588
+ book2.Windows(book2.Name).Visible.should be_false
589
+ book2.visible.should be_false
590
+ end
591
+
592
+ it "should leave the visibility of Excel" do
593
+ excel1 = Excel.new(:reuse => false, :visible => false)
594
+ book1 = Book.open(@simple_file, :visible => true)
595
+ excel1.Visible.should be_true
596
+ book1.Windows(book1.Name).Visible.should be_true
597
+ book1.visible.should be_true
598
+ excel1.visible = false
599
+ book2 = Book.open(@different_file)
600
+ excel1.Visible.should be_false
601
+ book2.Windows(book2.Name).Visible.should be_true
602
+ book2.visible.should be_false
603
+ end
604
+
605
+ it "should leave the visibility of Excel" do
606
+ excel1 = Excel.new(:reuse => false, :visible => false)
607
+ book1 = Book.open(@simple_file, :visible => false)
608
+ excel1.Visible.should be_false
609
+ book1.Windows(book1.Name).Visible.should be_true
610
+ book1.visible.should be_false
611
+ excel1.visible = true
612
+ book2 = Book.open(@different_file)
613
+ excel1.Visible.should be_true
614
+ book2.Windows(book2.Name).Visible.should be_true
615
+ book2.visible.should be_true
303
616
  end
617
+ end
304
618
 
305
- after do
306
- @book.close
619
+ context "with visible, visible=" do
620
+
621
+ before do
622
+ @book1 = Book.open(@simple_file)
623
+ @book2 = Book.open(@different_file, :force_excel => :new, :visible => true)
307
624
  end
308
625
 
309
- it "should make the workbook visible" do
310
- @book.excel.visible = true
311
- @book.excel.visible.should be_true
312
- @book.visible.should be_true
313
- @book.excel.Windows(@book.ole_workbook.Name).Visible.should be_true
314
- @book.visible = false
315
- @book.excel.visible.should be_true
316
- @book.visible.should be_false
317
- @book.excel.Windows(@book.ole_workbook.Name).Visible.should be_false
318
- @book.visible = true
319
- @book.excel.visible.should be_true
320
- @book.visible.should be_true
321
- @book.excel.Windows(@book.ole_workbook.Name).Visible.should be_true
626
+ after do
627
+ @book1.close
628
+ @book2.close
629
+ end
630
+
631
+ it "should make the invisible workbook visible and invisible" do
632
+ @book1.excel.Visible.should be_false
633
+ @book1.Windows(@book1.Name).Visible.should be_true
634
+ @book1.visible.should be_false
635
+ @book1.visible = true
636
+ @book1.Saved.should be_true
637
+ @book1.excel.Visible.should be_true
638
+ @book1.Windows(@book1.Name).Visible.should be_true
639
+ @book1.visible.should be_true
640
+ @book1.visible = false
641
+ @book1.Saved.should be_true
642
+ @book1.excel.should be_true
643
+ @book1.Windows(@book1.Name).Visible.should be_false
644
+ @book1.visible.should be_false
645
+ @book2.excel.Visible.should be_true
646
+ end
647
+
648
+ it "should make the visible workbook and the invisible workbook invisible" do
649
+ @book2.Windows(@book2.Name).Visible.should be_true
650
+ @book2.visible.should be_true
651
+ @book2.visible = true
652
+ @book2.Saved.should be_true
653
+ @book2.excel.Visible.should be_true
654
+ @book2.Windows(@book2.Name).Visible.should be_true
655
+ @book2.excel.visible = false
656
+ @book2.visible = false
657
+ @book2.Saved.should be_true
658
+ @book2.excel.Visible.should be_false
659
+ @book2.Windows(@book2.Name).Visible.should be_true
660
+ @book2.visible.should be_false
322
661
  end
323
662
 
324
663
  end
@@ -328,7 +667,9 @@ describe Book do
328
667
  before do
329
668
  @key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '../helpers/key_sender.rb') + '" "Microsoft Office Excel" ' , "w"
330
669
  @book = Book.open(@simple_file, :visible => true)
670
+ @book.excel.displayalerts = false
331
671
  @book2 = Book.open(@another_simple_file, :force_excel => :new, :visible => true)
672
+ @book2.excel.displayalerts = false
332
673
  end
333
674
 
334
675
  after do