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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +6 -0
  3. data/README.rdoc +1 -1
  4. data/docs/README_open.rdoc +1 -1
  5. data/docs/README_ranges.rdoc +60 -57
  6. data/docs/README_sheet.rdoc +1 -1
  7. data/examples/introducing_examples/example_introducing.rb +42 -0
  8. data/examples/introducing_examples/example_open.rb +49 -0
  9. data/examples/introducing_examples/example_range.rb +67 -0
  10. data/examples/{edit_sheets → modifying_sheets}/example_access_sheets_and_cells.rb +0 -0
  11. data/examples/{edit_sheets → modifying_sheets}/example_adding_sheets.rb +0 -0
  12. data/examples/{edit_sheets → modifying_sheets}/example_concating.rb +1 -1
  13. data/examples/{edit_sheets → modifying_sheets}/example_copying.rb +1 -1
  14. data/examples/{edit_sheets → modifying_sheets}/example_expanding.rb +1 -1
  15. data/examples/{edit_sheets → modifying_sheets}/example_naming.rb +1 -1
  16. data/examples/{edit_sheets → modifying_sheets}/example_ranges.rb +1 -1
  17. data/examples/{edit_sheets → modifying_sheets}/example_saving.rb +1 -1
  18. data/examples/open_save_close/example_control_to_excel.rb +2 -2
  19. data/examples/open_save_close/example_if_obstructed_save.rb +2 -2
  20. data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
  21. data/examples/open_save_close/example_if_unsaved_forget.rb +3 -3
  22. data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -4
  23. data/examples/open_save_close/example_read_only.rb +1 -1
  24. data/examples/open_save_close/example_rename_cells.rb +1 -1
  25. data/examples/open_save_close/example_simple.rb +1 -1
  26. data/examples/open_save_close/example_unobtrusively.rb +3 -3
  27. data/lib/robust_excel_ole.rb +2 -2
  28. data/lib/robust_excel_ole/bookstore.rb +1 -1
  29. data/lib/robust_excel_ole/cell.rb +15 -2
  30. data/lib/robust_excel_ole/excel.rb +14 -12
  31. data/lib/robust_excel_ole/general.rb +12 -0
  32. data/lib/robust_excel_ole/range.rb +37 -20
  33. data/lib/robust_excel_ole/reo_common.rb +63 -37
  34. data/lib/robust_excel_ole/version.rb +1 -1
  35. data/lib/robust_excel_ole/{book.rb → workbook.rb} +35 -33
  36. data/lib/robust_excel_ole/{sheet.rb → worksheet.rb} +22 -22
  37. data/spec/bookstore_spec.rb +38 -38
  38. data/spec/cell_spec.rb +10 -10
  39. data/spec/data/another_workbook.xls +0 -0
  40. data/spec/data/workbook.xls +0 -0
  41. data/spec/excel_spec.rb +113 -105
  42. data/spec/general_spec.rb +37 -5
  43. data/spec/range_spec.rb +34 -19
  44. data/spec/reo_common_spec.rb +58 -48
  45. data/spec/{book_spec.rb → workbook_spec.rb} +198 -198
  46. data/spec/workbook_specs/workbook_all_spec.rb +33 -0
  47. data/spec/{book_specs/book_close_spec.rb → workbook_specs/workbook_close_spec.rb} +10 -10
  48. data/spec/{book_specs/book_misc_spec.rb → workbook_specs/workbook_misc_spec.rb} +148 -128
  49. data/spec/{book_specs/book_open_spec.rb → workbook_specs/workbook_open_spec.rb} +427 -427
  50. data/spec/{book_specs/book_save_spec.rb → workbook_specs/workbook_save_spec.rb} +44 -44
  51. data/spec/{book_specs/book_sheet_spec.rb → workbook_specs/workbook_sheet_spec.rb} +19 -19
  52. data/spec/{book_specs/book_subclass_spec.rb → workbook_specs/workbook_subclass_spec.rb} +5 -6
  53. data/spec/{book_specs/book_unobtr_spec.rb → workbook_specs/workbook_unobtr_spec.rb} +339 -344
  54. data/spec/{sheet_spec.rb → worksheet_spec.rb} +85 -55
  55. metadata +25 -22
  56. data/spec/book_specs/book_all_spec.rb +0 -22
@@ -8,7 +8,7 @@ $VERBOSE = nil
8
8
  include RobustExcelOle
9
9
  include General
10
10
 
11
- describe Book do
11
+ describe Workbook do
12
12
 
13
13
  before(:all) do
14
14
  excel = Excel.new(:reuse => true)
@@ -52,61 +52,61 @@ describe Book do
52
52
  it "should simply open" do
53
53
  book = Workbook.open(@simple_file1, :if_unsaved => :accept)
54
54
  book.should be_alive
55
- book.should be_a Book
55
+ book.should be_a Workbook
56
56
  end
57
57
 
58
58
  it "should open in a new Excel" do
59
59
  book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
60
60
  book2.should be_alive
61
- book2.should be_a Book
61
+ book2.should be_a Workbook
62
62
  book2.excel.should_not == @ole_excel1
63
63
  book2.Readonly.should be true
64
64
  end
65
65
 
66
66
  it "should fetch the workbook" do
67
- new_book = Book.new(@ole_workbook1)
68
- new_book.should be_a Book
67
+ new_book = Workbook.new(@ole_workbook1)
68
+ new_book.should be_a Workbook
69
69
  new_book.should be_alive
70
70
  new_book.ole_workbook.should == @ole_workbook1
71
71
  new_book.excel.ole_excel.Hwnd.should == @ole_excel1.Hwnd
72
72
  end
73
73
 
74
74
  it "should fetch a closed workbook" do
75
- new_book = Book.new(@ole_workbook1)
75
+ new_book = Workbook.new(@ole_workbook1)
76
76
  new_book.close(:if_unsaved => :forget)
77
77
  new_book.should_not be_alive
78
- book2 = Book.open(@simple_file1)
78
+ book2 = Workbook.open(@simple_file1)
79
79
  book2.should === new_book
80
80
  book2.should be_alive
81
81
  book2.close
82
82
  end
83
83
 
84
84
  it "should force_excel with :reuse" do
85
- book2 = Book.open(@different_file, :force => {:excel => :current})
85
+ book2 = Workbook.open(@different_file, :force => {:excel => :current})
86
86
  book2.should be_alive
87
- book2.should be_a Book
87
+ book2.should be_a Workbook
88
88
  book2.excel.ole_excel.Hwnd.should == @ole_excel1.Hwnd
89
89
  end
90
90
 
91
91
  it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
92
- book1 = Book.open(@simple_file1, :if_unsaved => :forget)
92
+ book1 = Workbook.open(@simple_file1, :if_unsaved => :forget)
93
93
  excel2 = Excel.new(:reuse => false)
94
94
  book1.excel.close(:if_unsaved => :forget)
95
95
  sleep 1
96
- book2 = Book.open(@simple_file1, :force => {:excel => :current}, :default => {:excel => :new})
96
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :current}, :default => {:excel => :new})
97
97
  book2.should be_alive
98
- book2.should be_a Book
98
+ book2.should be_a Workbook
99
99
  book2.excel.ole_excel.Hwnd.should == @ole_excel2.Hwnd
100
100
  end
101
101
 
102
102
  it "should reopen the closed book" do
103
- book1 = Book.open(@simple_file1, :if_unsaved => :accept)
103
+ book1 = Workbook.open(@simple_file1, :if_unsaved => :accept)
104
104
  book1.should be_alive
105
105
  book2 = book1
106
106
  book1.close(:if_unsaved => :forget)
107
107
  book1.should_not be_alive
108
108
  book1.reopen
109
- book1.should be_a Book
109
+ book1.should be_a Workbook
110
110
  book1.should be_alive
111
111
  book1.should === book2
112
112
  end
@@ -115,10 +115,10 @@ describe Book do
115
115
  context "with :if_unsaved" do
116
116
 
117
117
  before do
118
- @book = Book.open(@simple_file1, :if_unsaved => :accept)
118
+ @book = Workbook.open(@simple_file1, :if_unsaved => :accept)
119
119
  sheet = @book.sheet(1)
120
120
  @old_value = sheet[1,1].Value
121
- sheet[1,1] = (sheet[1,1].value == "foo" ? "bar" : "foo")
121
+ sheet[1,1] = (sheet[1,1].Value == "foo" ? "bar" : "foo")
122
122
  @new_value = sheet[1,1].Value
123
123
  @book.Saved.should be false
124
124
  end
@@ -128,7 +128,7 @@ describe Book do
128
128
  end
129
129
 
130
130
  it "should let the book open, if :if_unsaved is :accept" do
131
- new_book = Book.open(@simple_file1, :if_unsaved => :accept)
131
+ new_book = Workbook.open(@simple_file1, :if_unsaved => :accept)
132
132
  @book.should be_alive
133
133
  new_book.should be_alive
134
134
  new_book.Saved.should be false
@@ -138,7 +138,7 @@ describe Book do
138
138
  end
139
139
 
140
140
  it "should open book and close old book, if :if_unsaved is :forget" do
141
- new_book = Book.open(@simple_file1, :if_unsaved => :forget)
141
+ new_book = Workbook.open(@simple_file1, :if_unsaved => :forget)
142
142
  @book.should_not be_alive
143
143
  new_book.should be_alive
144
144
  new_book.Saved.should be true
@@ -149,12 +149,12 @@ describe Book do
149
149
 
150
150
  it "should raise an error, if :if_obstructed is :raise" do
151
151
  expect {
152
- new_book = Book.open(@simple_file_other_path1)
152
+ new_book = Workbook.open(@simple_file_other_path1)
153
153
  }.to raise_error(WorkbookBlocked, /blocked by a workbook with the same name in a different path/)
154
154
  end
155
155
 
156
156
  it "should close the other book and open the new book, if :if_obstructed is :forget" do
157
- new_book = Book.open(@simple_file_other_path1, :if_obstructed => :forget)
157
+ new_book = Workbook.open(@simple_file_other_path1, :if_obstructed => :forget)
158
158
  expect{
159
159
  @ole_workbook1.Name
160
160
  }.to raise_error
@@ -166,11 +166,11 @@ describe Book do
166
166
  context "with :force => {:excel}" do
167
167
 
168
168
  it "should open in a provided Excel" do
169
- book1 = Book.open(@simple_file1, :force => {:excel => :new})
170
- book2 = Book.open(@simple_file1, :force => {:excel => :new})
171
- book3 = Book.open(@simple_file1, :force => {:excel => book2.excel})
169
+ book1 = Workbook.open(@simple_file1, :force => {:excel => :new})
170
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
171
+ book3 = Workbook.open(@simple_file1, :force => {:excel => book2.excel})
172
172
  book3.should be_alive
173
- book3.should be_a Book
173
+ book3.should be_a Workbook
174
174
  book3.excel.should == book2.excel
175
175
  book3.Readonly.should be true
176
176
  end
@@ -190,19 +190,19 @@ describe Book do
190
190
  it "should simply create a new one" do
191
191
  book = Workbook.new(@simple_file)
192
192
  book.should be_alive
193
- book.should be_a Book
193
+ book.should be_a Workbook
194
194
  end
195
195
 
196
196
  it "should set options" do
197
197
  book = Workbook.new(@simple_file, :visible => true, :read_only => true, :force => {:excel => :new})
198
198
  book.should be_alive
199
- book.should be_a Book
199
+ book.should be_a Workbook
200
200
  book.excel.Visible.should be true
201
201
  book.Windows(book.Name).Visible.should be true
202
202
  book.ReadOnly.should be true
203
203
  book2 = Workbook.new(@different_file, :force => {:excel => :new}, :v => true)
204
204
  book2.should be_alive
205
- book2.should be_a Book
205
+ book2.should be_a Workbook
206
206
  book2.excel.Visible.should be true
207
207
  book2.Windows(book2.Name).Visible.should be true
208
208
  book2.ReadOnly.should be false
@@ -216,12 +216,12 @@ describe Book do
216
216
  context "with calculation mode" do
217
217
 
218
218
  it "should set calculation mode" do
219
- book1 = Book.open(@simple_file1, :visible => true)
219
+ book1 = Workbook.open(@simple_file1, :visible => true)
220
220
  book1.excel.calculation = :manual
221
221
  book1.excel.Calculation.should == XlCalculationManual
222
222
  book1.save
223
223
  book1.excel.close
224
- book2 = Book.open(@simple_file1, :visible => true)
224
+ book2 = Workbook.open(@simple_file1, :visible => true)
225
225
  book2.excel.calculation = :automatic
226
226
  book2.excel.Calculation.should == XlCalculationAutomatic
227
227
  book2.save
@@ -229,28 +229,28 @@ describe Book do
229
229
  end
230
230
 
231
231
  it "should not set the default value" do
232
- book1 = Book.open(@simple_file)
232
+ book1 = Workbook.open(@simple_file)
233
233
  book1.excel.calculation.should == nil
234
234
  end
235
235
 
236
236
  it "should set the calculation mode to automatic" do
237
- book1 = Book.open(@simple_file)
237
+ book1 = Workbook.open(@simple_file)
238
238
  book1.excel.calculation = :automatic
239
239
  book1.excel.calculation.should == :automatic
240
240
  book1.excel.Calculation.should == XlCalculationAutomatic
241
241
  end
242
242
 
243
243
  it "should set the calculation mode to manual" do
244
- book1 = Book.open(@simple_file)
244
+ book1 = Workbook.open(@simple_file)
245
245
  book1.excel.calculation = :manual
246
246
  book1.excel.calculation.should == :manual
247
247
  book1.excel.Calculation.should == XlCalculationManual
248
248
  end
249
249
 
250
250
  it "should change the calculation mode from manual to automatic" do
251
- book1 = Book.open(@simple_file, :visible => true)
251
+ book1 = Workbook.open(@simple_file, :visible => true)
252
252
  excel1 = Excel.current(:calculation => :automatic)
253
- book2 = Book.open(@different_file, :visible => true)
253
+ book2 = Workbook.open(@different_file, :visible => true)
254
254
  book2.excel.Calculation.should == XlCalculationAutomatic
255
255
  book1.excel.Calculation.should == XlCalculationAutomatic
256
256
  end
@@ -260,11 +260,11 @@ describe Book do
260
260
  context "with causing warning dead excel without window handle" do
261
261
 
262
262
  it "combined" do
263
- book1 = Book.open(@simple_file1)
264
- book2 = Book.open(@different_file)
263
+ book1 = Workbook.open(@simple_file1)
264
+ book2 = Workbook.open(@different_file)
265
265
  Excel.kill_all
266
266
  #sleep 1 #then no warning
267
- Excel.current # or book3 = Book.open(@another_simple_file)
267
+ Excel.current # or book3 = Workbook.open(@another_simple_file)
268
268
  end
269
269
 
270
270
  end
@@ -282,7 +282,7 @@ describe Book do
282
282
  it "should open in a new Excel" do
283
283
  book2 = Workbook.open(@simple_file, :force => {:excel => :new})
284
284
  book2.should be_alive
285
- book2.should be_a Book
285
+ book2.should be_a Workbook
286
286
  book2.excel.should_not == @book.excel
287
287
  book2.should_not == @book
288
288
  @book.Readonly.should be false
@@ -291,10 +291,10 @@ describe Book do
291
291
  end
292
292
  end
293
293
 
294
- context "lift a workbook to a Book object" do
294
+ context "lift a workbook to a Workbook object" do
295
295
 
296
296
  before do
297
- @book = Book.open(@simple_file)
297
+ @book = Workbook.open(@simple_file)
298
298
  end
299
299
 
300
300
  after do
@@ -303,8 +303,8 @@ describe Book do
303
303
 
304
304
  it "should fetch the workbook" do
305
305
  workbook = @book.ole_workbook
306
- new_book = Book.new(workbook)
307
- new_book.should be_a Book
306
+ new_book = Workbook.new(workbook)
307
+ new_book.should be_a Workbook
308
308
  new_book.should be_alive
309
309
  new_book.should == @book
310
310
  new_book.filename.should == @book.filename
@@ -317,8 +317,8 @@ describe Book do
317
317
 
318
318
  it "should fetch the workbook" do
319
319
  workbook = @book.ole_workbook
320
- new_book = Book.new(workbook, :visible => true)
321
- new_book.should be_a Book
320
+ new_book = Workbook.new(workbook, :visible => true)
321
+ new_book.should be_a Workbook
322
322
  new_book.should be_alive
323
323
  new_book.should == @book
324
324
  new_book.filename.should == @book.filename
@@ -329,11 +329,11 @@ describe Book do
329
329
  new_book.close
330
330
  end
331
331
 
332
- it "should yield an identical Book and set visible value" do
332
+ it "should yield an identical Workbook and set visible value" do
333
333
  workbook = @book.ole_workbook
334
- new_book = Book.new(workbook, :visible => true)
334
+ new_book = Workbook.new(workbook, :visible => true)
335
335
  new_book.excel.displayalerts = true
336
- new_book.should be_a Book
336
+ new_book.should be_a Workbook
337
337
  new_book.should be_alive
338
338
  new_book.should == @book
339
339
  new_book.filename.should == @book.filename
@@ -348,7 +348,7 @@ describe Book do
348
348
 
349
349
  context "with standard options" do
350
350
  before do
351
- @book = Book.open(@simple_file)
351
+ @book = Workbook.open(@simple_file)
352
352
  end
353
353
 
354
354
  after do
@@ -363,69 +363,69 @@ describe Book do
363
363
  context "with identity transperence" do
364
364
 
365
365
  before do
366
- @book = Book.open(@simple_file1)
366
+ @book = Workbook.open(@simple_file1)
367
367
  end
368
368
 
369
369
  after do
370
370
  @book.close
371
371
  end
372
372
 
373
- it "should yield identical Book objects for identical Excel books" do
374
- book2 = Book.open(@simple_file1)
373
+ it "should yield identical Workbook objects for identical Excel books" do
374
+ book2 = Workbook.open(@simple_file1)
375
375
  book2.should === @book
376
376
  book2.close
377
377
  end
378
378
 
379
- it "should yield different Book objects for different Excel books" do
380
- book2 = Book.open(@different_file)
379
+ it "should yield different Workbook objects for different Excel books" do
380
+ book2 = Workbook.open(@different_file)
381
381
  book2.should_not === @book
382
382
  book2.close
383
383
  end
384
384
 
385
- it "should yield different Book objects when opened the same file in different Excel instances" do
386
- book2 = Book.open(@simple_file, :force => {:excel => :new})
385
+ it "should yield different Workbook objects when opened the same file in different Excel instances" do
386
+ book2 = Workbook.open(@simple_file, :force => {:excel => :new})
387
387
  book2.should_not === @book
388
388
  book2.close
389
389
  end
390
390
 
391
- it "should yield identical Book objects for identical Excel books when reopening" do
391
+ it "should yield identical Workbook objects for identical Excel books when reopening" do
392
392
  @book.should be_alive
393
393
  @book.close
394
394
  @book.should_not be_alive
395
- book2 = Book.open(@simple_file1)
395
+ book2 = Workbook.open(@simple_file1)
396
396
  book2.should === @book
397
397
  book2.should be_alive
398
398
  book2.close
399
399
  end
400
400
 
401
- it "should yield identical Book objects when reopening and the Excel is closed" do
401
+ it "should yield identical Workbook objects when reopening and the Excel is closed" do
402
402
  @book.should be_alive
403
403
  @book.close
404
404
  Excel.close_all
405
- book2 = Book.open(@simple_file1)
405
+ book2 = Workbook.open(@simple_file1)
406
406
  book2.should be_alive
407
407
  book2.should === @book
408
408
  book2.close
409
409
  end
410
410
 
411
- it "should yield different Book objects when reopening in a new Excel" do
411
+ it "should yield different Workbook objects when reopening in a new Excel" do
412
412
  @book.should be_alive
413
413
  old_excel = @book.excel
414
414
  @book.close
415
415
  @book.should_not be_alive
416
- book2 = Book.open(@simple_file1, :force => {:excel => :new})
416
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
417
417
  book2.should_not === @book
418
418
  book2.should be_alive
419
419
  book2.excel.should_not == old_excel
420
420
  book2.close
421
421
  end
422
422
 
423
- it "should yield different Book objects when reopening in a new given Excel instance" do
423
+ it "should yield different Workbook objects when reopening in a new given Excel instance" do
424
424
  old_excel = @book.excel
425
425
  new_excel = Excel.new(:reuse => false)
426
426
  @book.close
427
427
  @book.should_not be_alive
428
- book2 = Book.open(@simple_file1, :force => {:excel => new_excel})
428
+ book2 = Workbook.open(@simple_file1, :force => {:excel => new_excel})
429
429
  #@book.should be_alive
430
430
  #book2.should === @book
431
431
  book2.should be_alive
@@ -434,12 +434,12 @@ describe Book do
434
434
  book2.close
435
435
  end
436
436
 
437
- it "should yield identical Book objects when reopening in the old excel" do
437
+ it "should yield identical Workbook objects when reopening in the old excel" do
438
438
  old_excel = @book.excel
439
439
  new_excel = Excel.new(:reuse => false)
440
440
  @book.close
441
441
  @book.should_not be_alive
442
- book2 = Book.open(@simple_file1, :force => {:excel => old_excel})
442
+ book2 = Workbook.open(@simple_file1, :force => {:excel => old_excel})
443
443
  book2.should === @book
444
444
  book2.should be_alive
445
445
  book2.excel.should == old_excel
@@ -452,7 +452,7 @@ describe Book do
452
452
  context "with abbrevations" do
453
453
 
454
454
  before do
455
- @book = Book.open(@simple_file1)
455
+ @book = Workbook.open(@simple_file1)
456
456
  end
457
457
 
458
458
  after do
@@ -460,61 +460,61 @@ describe Book do
460
460
  end
461
461
 
462
462
  it "should work as force" do
463
- book2 = Book.open(@another_simple_file, :excel => :new)
463
+ book2 = Workbook.open(@another_simple_file, :excel => :new)
464
464
  book2.excel.should_not == @book.excel
465
- book3 = Book.open(@different_file, :excel => book2.excel)
465
+ book3 = Workbook.open(@different_file, :excel => book2.excel)
466
466
  book3.excel.should == book2.excel
467
467
  end
468
468
 
469
469
  it "should work with abbrevation of force and excel" do
470
- book2 = Book.open(@another_simple_file, :f => {:e => :new})
470
+ book2 = Workbook.open(@another_simple_file, :f => {:e => :new})
471
471
  book2.excel.should_not == @book.excel
472
- book3 = Book.open(@different_file, :f => {:e => book2.excel})
472
+ book3 = Workbook.open(@different_file, :f => {:e => book2.excel})
473
473
  book3.excel.should == book2.excel
474
474
  end
475
475
 
476
476
  it "should work with abbrevation of force" do
477
- book2 = Book.open(@another_simple_file, :f => {:excel => :new})
477
+ book2 = Workbook.open(@another_simple_file, :f => {:excel => :new})
478
478
  book2.excel.should_not == @book.excel
479
- book3 = Book.open(@different_file, :f => {:excel => book2.excel})
479
+ book3 = Workbook.open(@different_file, :f => {:excel => book2.excel})
480
480
  book3.excel.should == book2.excel
481
481
  end
482
482
 
483
483
  it "should work with abbrevation of force" do
484
- book2 = Book.open(@another_simple_file, :force => {:e => :new})
484
+ book2 = Workbook.open(@another_simple_file, :force => {:e => :new})
485
485
  book2.excel.should_not == @book.excel
486
- book3 = Book.open(@different_file, :force => {:e => book2.excel})
486
+ book3 = Workbook.open(@different_file, :force => {:e => book2.excel})
487
487
  book3.excel.should == book2.excel
488
488
  end
489
489
 
490
- it "should open in a given Excel provided as Excel, Book, or WIN32OLE representing an Excel or Workbook" do
491
- book2 = Book.open(@another_simple_file)
492
- book3 = Book.open(@different_file)
493
- book3 = Book.open(@simple_file1, :excel => book2.excel)
490
+ it "should open in a given Excel provided as Excel, Workbook, or WIN32OLE representing an Excel or Workbook" do
491
+ book2 = Workbook.open(@another_simple_file)
492
+ book3 = Workbook.open(@different_file)
493
+ book3 = Workbook.open(@simple_file1, :excel => book2.excel)
494
494
  book3.excel.should === book2.excel
495
- book4 = Book.open(@simple_file1, :excel => @book)
495
+ book4 = Workbook.open(@simple_file1, :excel => @book)
496
496
  book4.excel.should === @book.excel
497
497
  book3.close
498
498
  book4.close
499
- book5 = Book.open(@simple_file1, :excel => book2.ole_workbook)
499
+ book5 = Workbook.open(@simple_file1, :excel => book2.ole_workbook)
500
500
  book5.excel.should === book2.excel
501
501
  win32ole_excel1 = WIN32OLE.connect(@book.ole_workbook.Fullname).Application
502
- book6 = Book.open(@simple_file1, :excel => win32ole_excel1)
502
+ book6 = Workbook.open(@simple_file1, :excel => win32ole_excel1)
503
503
  book6.excel.should === @book.excel
504
504
  end
505
505
 
506
506
  it "should use abbreviations of default" do
507
- book2 = Book.open(@simple_file1, :d => {:excel => :current})
507
+ book2 = Workbook.open(@simple_file1, :d => {:excel => :current})
508
508
  book2.excel.should == @book.excel
509
509
  end
510
510
 
511
511
  it "should use abbreviations of default" do
512
- book2 = Book.open(@simple_file1, :d => {:e => :current})
512
+ book2 = Workbook.open(@simple_file1, :d => {:e => :current})
513
513
  book2.excel.should == @book.excel
514
514
  end
515
515
 
516
516
  it "should use abbreviations of default" do
517
- book2 = Book.open(@simple_file1, :default => {:e => :current})
517
+ book2 = Workbook.open(@simple_file1, :default => {:e => :current})
518
518
  book2.excel.should == @book.excel
519
519
  end
520
520
 
@@ -522,12 +522,12 @@ describe Book do
522
522
  excel1 = @book.excel
523
523
  excel2 = Excel.new(:reuse => false)
524
524
  @book.close
525
- book2 = Book.open(@simple_file1, :d => {:e => :current})
525
+ book2 = Workbook.open(@simple_file1, :d => {:e => :current})
526
526
  book2.excel.should == excel1
527
527
  book2.close
528
- book3 = Book.open(@simple_file1, :e => excel2)
528
+ book3 = Workbook.open(@simple_file1, :e => excel2)
529
529
  book3.close
530
- book3 = Book.open(@simple_file1, :d => {:e => :current})
530
+ book3 = Workbook.open(@simple_file1, :d => {:e => :current})
531
531
  book3.excel.should == excel2
532
532
  book3.close
533
533
  end
@@ -537,7 +537,7 @@ describe Book do
537
537
  context "with :force => {:excel}" do
538
538
 
539
539
  before do
540
- @book = Book.open(@simple_file1)
540
+ @book = Workbook.open(@simple_file1)
541
541
  end
542
542
 
543
543
  after do
@@ -547,30 +547,30 @@ describe Book do
547
547
  it "should open not in the reserved Excel instance" do
548
548
  Excel.kill_all
549
549
  sleep 1
550
- book2 = Book.open(@simple_file1, :force => {:excel => :reserved_new})
550
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :reserved_new})
551
551
  Excel.current.should_not == book2.excel
552
- book3 = Book.open(@different_file1, :default => {:excel => :current})
552
+ book3 = Workbook.open(@different_file1, :default => {:excel => :current})
553
553
  book3.excel.should_not == book2.excel
554
- book4 = Book.open(@another_simple_file1, :default => {:excel => :new})
554
+ book4 = Workbook.open(@another_simple_file1, :default => {:excel => :new})
555
555
  book4.excel.should_not == book2.excel
556
556
  book4.close
557
557
  sleep 1
558
- book5 = Book.open(@another_simple_file1, :default => {:excel => :reserved_new})
558
+ book5 = Workbook.open(@another_simple_file1, :default => {:excel => :reserved_new})
559
559
  book5.excel.should_not == book2.excel
560
560
  end
561
561
 
562
562
  it "should open in the reserved Excel instance" do
563
563
  excel1 = @book.excel
564
564
  @book.close
565
- book2 = Book.open(@simple_file1, :force => {:excel => :reserved_new})
565
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :reserved_new})
566
566
  book2.excel.should_not == excel1
567
567
  end
568
568
 
569
569
  it "should open in the reserved Excel instance" do
570
- book2 = Book.open(@simple_file1, :force => {:excel => :reserved_new})
571
- book3 = Book.open(@different_file1, :force => {:excel => :reserved_new})
572
- book4 = Book.open(@another_simple_file1, :force => {:excel => :new})
573
- book5 = Book.open(@another_simple_file1, :force => {:excel => :current})
570
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :reserved_new})
571
+ book3 = Workbook.open(@different_file1, :force => {:excel => :reserved_new})
572
+ book4 = Workbook.open(@another_simple_file1, :force => {:excel => :new})
573
+ book5 = Workbook.open(@another_simple_file1, :force => {:excel => :current})
574
574
  book2.excel.should_not == @book.excel
575
575
  book3.excel.should_not == book2.excel
576
576
  book4.excel.should_not == @book.excel
@@ -579,33 +579,33 @@ describe Book do
579
579
  end
580
580
 
581
581
  it "should open in the reserved Excel instance" do
582
- book2 = Book.open(@another_simple_file1, :force => {:excel => :new})
583
- book3 = Book.open(@different_file1, :force => {:excel => :reserved_new})
582
+ book2 = Workbook.open(@another_simple_file1, :force => {:excel => :new})
583
+ book3 = Workbook.open(@different_file1, :force => {:excel => :reserved_new})
584
584
  book2.excel.should_not == @book.excel
585
585
  book3.excel.should_not == @book.excel
586
586
  book3.excel.should_not == book2.excel
587
587
  end
588
588
 
589
- it "should open in a given Excel provided as Excel, Book, or WIN32OLE representing an Excel or Workbook" do
590
- book2 = Book.open(@another_simple_file)
591
- book3 = Book.open(@different_file)
592
- book3 = Book.open(@simple_file1, :force => {:excel => book2.excel})
589
+ it "should open in a given Excel provided as Excel, Workbook, or WIN32OLE representing an Excel or Workbook" do
590
+ book2 = Workbook.open(@another_simple_file)
591
+ book3 = Workbook.open(@different_file)
592
+ book3 = Workbook.open(@simple_file1, :force => {:excel => book2.excel})
593
593
  book3.excel.should === book2.excel
594
- book4 = Book.open(@simple_file1, :force => {:excel => @book})
594
+ book4 = Workbook.open(@simple_file1, :force => {:excel => @book})
595
595
  book4.excel.should === @book.excel
596
596
  book3.close
597
597
  book4.close
598
- book5 = Book.open(@simple_file1, :force => {:excel => book2.ole_workbook})
598
+ book5 = Workbook.open(@simple_file1, :force => {:excel => book2.ole_workbook})
599
599
  book5.excel.should === book2.excel
600
600
  win32ole_excel1 = WIN32OLE.connect(@book.ole_workbook.Fullname).Application
601
- book6 = Book.open(@simple_file1, :force => {:excel => win32ole_excel1})
601
+ book6 = Workbook.open(@simple_file1, :force => {:excel => win32ole_excel1})
602
602
  book6.excel.should === @book.excel
603
603
  end
604
604
 
605
605
  it "should open in a new Excel" do
606
- book2 = Book.open(@simple_file1, :force => {:excel => :new})
606
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
607
607
  book2.should be_alive
608
- book2.should be_a Book
608
+ book2.should be_a Workbook
609
609
  book2.excel.should_not == @book.excel
610
610
  book2.should_not == @book
611
611
  @book.Readonly.should be false
@@ -614,22 +614,22 @@ describe Book do
614
614
  end
615
615
 
616
616
  it "should open in a given Excel, not provide identity transparency, because old book readonly, new book writable" do
617
- book2 = Book.open(@simple_file1, :force => {:excel => :new})
617
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
618
618
  book2.excel.should_not == @book.excel
619
- book3 = Book.open(@simple_file1, :force => {:excel => :new})
619
+ book3 = Workbook.open(@simple_file1, :force => {:excel => :new})
620
620
  book3.excel.should_not == book2.excel
621
621
  book3.excel.should_not == @book.excel
622
622
  book2.close
623
- book4 = Book.open(@simple_file1, :force => {:excel => book2.excel})
623
+ book4 = Workbook.open(@simple_file1, :force => {:excel => book2.excel})
624
624
  book4.should be_alive
625
- book4.should be_a Book
625
+ book4.should be_a Workbook
626
626
  book4.excel.should == book2.excel
627
627
  #book4.Readonly.should == true
628
628
  book4.should_not == book2
629
629
  book4.close
630
- book5 = Book.open(@simple_file1, :force => {:excel => book2})
630
+ book5 = Workbook.open(@simple_file1, :force => {:excel => book2})
631
631
  book5.should be_alive
632
- book5.should be_a Book
632
+ book5.should be_a Workbook
633
633
  book5.excel.should == book2.excel
634
634
  #book5.Readonly.should == true
635
635
  book5.should_not == book2
@@ -638,24 +638,24 @@ describe Book do
638
638
  end
639
639
 
640
640
  it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
641
- book2 = Book.open(@simple_file1, :force => {:excel => :new})
641
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
642
642
  book2.excel.should_not == @book.excel
643
- book3 = Book.open(@simple_file1, :force => {:excel => :new})
643
+ book3 = Workbook.open(@simple_file1, :force => {:excel => :new})
644
644
  book3.excel.should_not == book2.excel
645
645
  book3.excel.should_not == @book.excel
646
646
  book2.close
647
647
  book3.close
648
648
  @book.close
649
- book4 = Book.open(@simple_file1, :force => {:excel => book2.excel}, :read_only => true)
649
+ book4 = Workbook.open(@simple_file1, :force => {:excel => book2.excel}, :read_only => true)
650
650
  book4.should be_alive
651
- book4.should be_a Book
651
+ book4.should be_a Workbook
652
652
  book4.excel.should == book2.excel
653
653
  book4.ReadOnly.should be true
654
654
  book4.should == book2
655
655
  book4.close
656
- book5 = Book.open(@simple_file1, :force => {:excel => book2}, :read_only => true)
656
+ book5 = Workbook.open(@simple_file1, :force => {:excel => book2}, :read_only => true)
657
657
  book5.should be_alive
658
- book5.should be_a Book
658
+ book5.should be_a Workbook
659
659
  book5.excel.should == book2.excel
660
660
  book5.ReadOnly.should be true
661
661
  book5.should == book2
@@ -664,69 +664,69 @@ describe Book do
664
664
  end
665
665
 
666
666
  it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
667
- book2 = Book.open(@simple_file1, :force => {:excel => :new})
667
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :new})
668
668
  book2.excel.should_not == @book.excel
669
669
  book2.close
670
670
  @book.close
671
- book4 = Book.open(@simple_file1, :force => {:excel => book2}, :read_only => true)
671
+ book4 = Workbook.open(@simple_file1, :force => {:excel => book2}, :read_only => true)
672
672
  book4.should be_alive
673
- book4.should be_a Book
673
+ book4.should be_a Workbook
674
674
  book4.excel.should == book2.excel
675
675
  book4.ReadOnly.should be true
676
676
  book4.should == book2
677
677
  book4.close
678
678
  end
679
679
 
680
- it "should raise an error if no Excel or Book is given" do
680
+ it "should raise an error if no Excel or Workbook is given" do
681
681
  expect{
682
- Book.open(@simple_file1, :force => {:excel => :b})
682
+ Workbook.open(@simple_file1, :force => {:excel => :b})
683
683
  }.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
684
684
  end
685
685
 
686
686
  it "should do force_excel even if both force_ and default_excel is given" do
687
- book2 = Book.open(@simple_file1, :default => {:excel => @book.excel}, :force => {:excel => :new})
687
+ book2 = Workbook.open(@simple_file1, :default => {:excel => @book.excel}, :force => {:excel => :new})
688
688
  book2.should be_alive
689
- book2.should be_a Book
689
+ book2.should be_a Workbook
690
690
  book2.excel.should_not == @book.excel
691
691
  book2.should_not == @book
692
692
  end
693
693
 
694
694
  it "should do default_excel if force_excel is nil" do
695
- book2 = Book.open(@another_simple_file, :force => {:excel => nil})
695
+ book2 = Workbook.open(@another_simple_file, :force => {:excel => nil})
696
696
  book2.should be_alive
697
- book2.should be_a Book
697
+ book2.should be_a Workbook
698
698
  book2.excel.should == @book.excel
699
699
  end
700
700
 
701
701
  it "should force_excel with :reuse" do
702
- book2 = Book.open(@different_file, :force => {:excel => :current})
702
+ book2 = Workbook.open(@different_file, :force => {:excel => :current})
703
703
  book2.should be_alive
704
- book2.should be_a Book
704
+ book2.should be_a Workbook
705
705
  book2.excel.should == @book.excel
706
706
  end
707
707
 
708
708
  it "should force_excel with :reuse even if :default_excel says sth. else" do
709
- book2 = Book.open(@different_file, :force => {:excel => :current}, :default => {:excel => :new})
709
+ book2 = Workbook.open(@different_file, :force => {:excel => :current}, :default => {:excel => :new})
710
710
  book2.should be_alive
711
- book2.should be_a Book
711
+ book2.should be_a Workbook
712
712
  book2.excel.should == @book.excel
713
713
  end
714
714
 
715
715
  it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
716
716
  excel2 = Excel.new(:reuse => false)
717
717
  @book.excel.close
718
- book2 = Book.open(@simple_file1, :force => {:excel => :current}, :default => {:excel => :new})
718
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :current}, :default => {:excel => :new})
719
719
  book2.should be_alive
720
- book2.should be_a Book
720
+ book2.should be_a Workbook
721
721
  book2.excel.should === excel2
722
722
  end
723
723
 
724
724
  it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
725
- book2 = Book.open(@different_file1, :force => {:excel => :new})
725
+ book2 = Workbook.open(@different_file1, :force => {:excel => :new})
726
726
  book2.excel.close
727
- book3 = Book.open(@different_file1, :force => {:excel => :current}, :default => {:excel => :new})
727
+ book3 = Workbook.open(@different_file1, :force => {:excel => :current}, :default => {:excel => :new})
728
728
  book3.should be_alive
729
- book3.should be_a Book
729
+ book3.should be_a Workbook
730
730
  book3.excel.should == @book.excel
731
731
  end
732
732
 
@@ -735,33 +735,33 @@ describe Book do
735
735
  context "with leaving out :force => {:excel}" do
736
736
 
737
737
  before do
738
- @book = Book.open(@simple_file1)
738
+ @book = Workbook.open(@simple_file1)
739
739
  end
740
740
 
741
741
  after do
742
742
  @book.close rescue nil
743
743
  end
744
744
 
745
- it "should open in a given Excel provided as Excel, Book, or WIN32OLE representing an Excel or Workbook" do
746
- book2 = Book.open(@another_simple_file)
747
- book3 = Book.open(@different_file)
748
- book3 = Book.open(@simple_file1, :excel => book2.excel)
745
+ it "should open in a given Excel provided as Excel, Workbook, or WIN32OLE representing an Excel or Workbook" do
746
+ book2 = Workbook.open(@another_simple_file)
747
+ book3 = Workbook.open(@different_file)
748
+ book3 = Workbook.open(@simple_file1, :excel => book2.excel)
749
749
  book3.excel.should === book2.excel
750
- book4 = Book.open(@simple_file1, :excel => @book)
750
+ book4 = Workbook.open(@simple_file1, :excel => @book)
751
751
  book4.excel.should === @book.excel
752
752
  book3.close
753
753
  book4.close
754
- book5 = Book.open(@simple_file1, :excel => book2.ole_workbook)
754
+ book5 = Workbook.open(@simple_file1, :excel => book2.ole_workbook)
755
755
  book5.excel.should === book2.excel
756
756
  win32ole_excel1 = WIN32OLE.connect(@book.ole_workbook.Fullname).Application
757
- book6 = Book.open(@simple_file1, :excel => win32ole_excel1)
757
+ book6 = Workbook.open(@simple_file1, :excel => win32ole_excel1)
758
758
  book6.excel.should === @book.excel
759
759
  end
760
760
 
761
761
  it "should open in a new Excel" do
762
- book2 = Book.open(@simple_file1, :excel => :new)
762
+ book2 = Workbook.open(@simple_file1, :excel => :new)
763
763
  book2.should be_alive
764
- book2.should be_a Book
764
+ book2.should be_a Workbook
765
765
  book2.excel.should_not == @book.excel
766
766
  book2.should_not == @book
767
767
  @book.Readonly.should be false
@@ -770,22 +770,22 @@ describe Book do
770
770
  end
771
771
 
772
772
  it "should open in a given Excel, not provide identity transparency, because old book readonly, new book writable" do
773
- book2 = Book.open(@simple_file1, :excel => :new)
773
+ book2 = Workbook.open(@simple_file1, :excel => :new)
774
774
  book2.excel.should_not == @book.excel
775
- book3 = Book.open(@simple_file1, :excel => :new)
775
+ book3 = Workbook.open(@simple_file1, :excel => :new)
776
776
  book3.excel.should_not == book2.excel
777
777
  book3.excel.should_not == @book.excel
778
778
  book2.close
779
- book4 = Book.open(@simple_file1, :excel => book2.excel)
779
+ book4 = Workbook.open(@simple_file1, :excel => book2.excel)
780
780
  book4.should be_alive
781
- book4.should be_a Book
781
+ book4.should be_a Workbook
782
782
  book4.excel.should == book2.excel
783
783
  #book4.Readonly.should == true
784
784
  book4.should_not == book2
785
785
  book4.close
786
- book5 = Book.open(@simple_file1, :excel => book2)
786
+ book5 = Workbook.open(@simple_file1, :excel => book2)
787
787
  book5.should be_alive
788
- book5.should be_a Book
788
+ book5.should be_a Workbook
789
789
  book5.excel.should == book2.excel
790
790
  #book5.Readonly.should == true
791
791
  book5.should_not == book2
@@ -794,24 +794,24 @@ describe Book do
794
794
  end
795
795
 
796
796
  it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
797
- book2 = Book.open(@simple_file1, :excel => :new)
797
+ book2 = Workbook.open(@simple_file1, :excel => :new)
798
798
  book2.excel.should_not == @book.excel
799
- book3 = Book.open(@simple_file1, :excel => :new)
799
+ book3 = Workbook.open(@simple_file1, :excel => :new)
800
800
  book3.excel.should_not == book2.excel
801
801
  book3.excel.should_not == @book.excel
802
802
  book2.close
803
803
  book3.close
804
804
  @book.close
805
- book4 = Book.open(@simple_file1, :excel => book2.excel, :read_only => true)
805
+ book4 = Workbook.open(@simple_file1, :excel => book2.excel, :read_only => true)
806
806
  book4.should be_alive
807
- book4.should be_a Book
807
+ book4.should be_a Workbook
808
808
  book4.excel.should == book2.excel
809
809
  book4.ReadOnly.should be true
810
810
  book4.should == book2
811
811
  book4.close
812
- book5 = Book.open(@simple_file1, :excel => book2, :read_only => true)
812
+ book5 = Workbook.open(@simple_file1, :excel => book2, :read_only => true)
813
813
  book5.should be_alive
814
- book5.should be_a Book
814
+ book5.should be_a Workbook
815
815
  book5.excel.should == book2.excel
816
816
  book5.ReadOnly.should be true
817
817
  book5.should == book2
@@ -820,69 +820,69 @@ describe Book do
820
820
  end
821
821
 
822
822
  it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
823
- book2 = Book.open(@simple_file1, :excel => :new)
823
+ book2 = Workbook.open(@simple_file1, :excel => :new)
824
824
  book2.excel.should_not == @book.excel
825
825
  book2.close
826
826
  @book.close
827
- book4 = Book.open(@simple_file1, :excel => book2, :read_only => true)
827
+ book4 = Workbook.open(@simple_file1, :excel => book2, :read_only => true)
828
828
  book4.should be_alive
829
- book4.should be_a Book
829
+ book4.should be_a Workbook
830
830
  book4.excel.should == book2.excel
831
831
  book4.ReadOnly.should be true
832
832
  book4.should == book2
833
833
  book4.close
834
834
  end
835
835
 
836
- it "should raise an error if no Excel or Book is given" do
836
+ it "should raise an error if no Excel or Workbook is given" do
837
837
  expect{
838
- Book.open(@simple_file1, :excel => :b)
838
+ Workbook.open(@simple_file1, :excel => :b)
839
839
  }.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
840
840
  end
841
841
 
842
842
  it "should do force_excel even if both force_ and default_excel is given" do
843
- book2 = Book.open(@simple_file1, :default => {:excel => @book.excel}, :force => {:excel => :new})
843
+ book2 = Workbook.open(@simple_file1, :default => {:excel => @book.excel}, :force => {:excel => :new})
844
844
  book2.should be_alive
845
- book2.should be_a Book
845
+ book2.should be_a Workbook
846
846
  book2.excel.should_not == @book.excel
847
847
  book2.should_not == @book
848
848
  end
849
849
 
850
850
  it "should do default_excel if force_excel is nil" do
851
- book2 = Book.open(@another_simple_file, :excel => nil)
851
+ book2 = Workbook.open(@another_simple_file, :excel => nil)
852
852
  book2.should be_alive
853
- book2.should be_a Book
853
+ book2.should be_a Workbook
854
854
  book2.excel.should == @book.excel
855
855
  end
856
856
 
857
857
  it "should force_excel with :reuse" do
858
- book2 = Book.open(@different_file, :excel => :current)
858
+ book2 = Workbook.open(@different_file, :excel => :current)
859
859
  book2.should be_alive
860
- book2.should be_a Book
860
+ book2.should be_a Workbook
861
861
  book2.excel.should == @book.excel
862
862
  end
863
863
 
864
864
  it "should force_excel with :reuse even if :default_excel says sth. else" do
865
- book2 = Book.open(@different_file, :excel => :current, :default => {:excel => :new})
865
+ book2 = Workbook.open(@different_file, :excel => :current, :default => {:excel => :new})
866
866
  book2.should be_alive
867
- book2.should be_a Book
867
+ book2.should be_a Workbook
868
868
  book2.excel.should == @book.excel
869
869
  end
870
870
 
871
871
  it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
872
872
  excel2 = Excel.new(:reuse => false)
873
873
  @book.excel.close
874
- book2 = Book.open(@simple_file1, :excel => :current, :default => {:excel => :new})
874
+ book2 = Workbook.open(@simple_file1, :excel => :current, :default => {:excel => :new})
875
875
  book2.should be_alive
876
- book2.should be_a Book
876
+ book2.should be_a Workbook
877
877
  book2.excel.should === excel2
878
878
  end
879
879
 
880
880
  it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
881
- book2 = Book.open(@different_file1, :excel => :new)
881
+ book2 = Workbook.open(@different_file1, :excel => :new)
882
882
  book2.excel.close
883
- book3 = Book.open(@different_file1, :excel => :current, :default => {:excel => :new})
883
+ book3 = Workbook.open(@different_file1, :excel => :current, :default => {:excel => :new})
884
884
  book3.should be_alive
885
- book3.should be_a Book
885
+ book3.should be_a Workbook
886
886
  book3.excel.should == @book.excel
887
887
  end
888
888
 
@@ -892,34 +892,34 @@ describe Book do
892
892
  context "with :force_excel" do
893
893
 
894
894
  before do
895
- @book = Book.open(@simple_file1)
895
+ @book = Workbook.open(@simple_file1)
896
896
  end
897
897
 
898
898
  after do
899
899
  @book.close rescue nil
900
900
  end
901
901
 
902
- it "should open in a given Excel provided as Excel, Book, or WIN32OLE representing an Excel or Workbook" do
903
- book2 = Book.open(@another_simple_file)
904
- book3 = Book.open(@different_file)
905
- book3 = Book.open(@simple_file1, :force_excel => book2.excel)
902
+ it "should open in a given Excel provided as Excel, Workbook, or WIN32OLE representing an Excel or Workbook" do
903
+ book2 = Workbook.open(@another_simple_file)
904
+ book3 = Workbook.open(@different_file)
905
+ book3 = Workbook.open(@simple_file1, :force_excel => book2.excel)
906
906
  book3.excel.should === book2.excel
907
- book4 = Book.open(@simple_file1, :force_excel => @book)
907
+ book4 = Workbook.open(@simple_file1, :force_excel => @book)
908
908
  book4.excel.should === @book.excel
909
909
  book3.close
910
910
  book4.close
911
- book5 = Book.open(@simple_file1, :force_excel => book2.ole_workbook)
911
+ book5 = Workbook.open(@simple_file1, :force_excel => book2.ole_workbook)
912
912
  book5.excel.should === book2.excel
913
913
  win32ole_excel1 = WIN32OLE.connect(@book.ole_workbook.Fullname).Application
914
- book6 = Book.open(@simple_file1, :force_excel => win32ole_excel1)
914
+ book6 = Workbook.open(@simple_file1, :force_excel => win32ole_excel1)
915
915
  book6.excel.should === @book.excel
916
916
  end
917
917
 
918
918
 
919
919
  it "should open in a new Excel" do
920
- book2 = Book.open(@simple_file1, :force_excel => :new)
920
+ book2 = Workbook.open(@simple_file1, :force_excel => :new)
921
921
  book2.should be_alive
922
- book2.should be_a Book
922
+ book2.should be_a Workbook
923
923
  book2.excel.should_not == @book.excel
924
924
  book2.should_not == @book
925
925
  @book.Readonly.should be false
@@ -928,22 +928,22 @@ describe Book do
928
928
  end
929
929
 
930
930
  it "should open in a given Excel, not provide identity transparency, because old book readonly, new book writable" do
931
- book2 = Book.open(@simple_file1, :force_excel => :new)
931
+ book2 = Workbook.open(@simple_file1, :force_excel => :new)
932
932
  book2.excel.should_not == @book.excel
933
- book3 = Book.open(@simple_file1, :force_excel => :new)
933
+ book3 = Workbook.open(@simple_file1, :force_excel => :new)
934
934
  book3.excel.should_not == book2.excel
935
935
  book3.excel.should_not == @book.excel
936
936
  book2.close
937
- book4 = Book.open(@simple_file1, :force_excel => book2.excel)
937
+ book4 = Workbook.open(@simple_file1, :force_excel => book2.excel)
938
938
  book4.should be_alive
939
- book4.should be_a Book
939
+ book4.should be_a Workbook
940
940
  book4.excel.should == book2.excel
941
941
  #book4.Readonly.should == false
942
942
  book4.should_not == book2
943
943
  book4.close
944
- book5 = Book.open(@simple_file1, :force_excel => book2)
944
+ book5 = Workbook.open(@simple_file1, :force_excel => book2)
945
945
  book5.should be_alive
946
- book5.should be_a Book
946
+ book5.should be_a Workbook
947
947
  book5.excel.should == book2.excel
948
948
  #book5.Readonly.should == false
949
949
  book5.should_not == book2
@@ -952,24 +952,24 @@ describe Book do
952
952
  end
953
953
 
954
954
  it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
955
- book2 = Book.open(@simple_file1, :force_excel => :new)
955
+ book2 = Workbook.open(@simple_file1, :force_excel => :new)
956
956
  book2.excel.should_not == @book.excel
957
- book3 = Book.open(@simple_file1, :force_excel => :new)
957
+ book3 = Workbook.open(@simple_file1, :force_excel => :new)
958
958
  book3.excel.should_not == book2.excel
959
959
  book3.excel.should_not == @book.excel
960
960
  book2.close
961
961
  book3.close
962
962
  @book.close
963
- book4 = Book.open(@simple_file1, :force_excel => book2.excel, :read_only => true)
963
+ book4 = Workbook.open(@simple_file1, :force_excel => book2.excel, :read_only => true)
964
964
  book4.should be_alive
965
- book4.should be_a Book
965
+ book4.should be_a Workbook
966
966
  book4.excel.should == book2.excel
967
967
  book4.ReadOnly.should be true
968
968
  book4.should == book2
969
969
  book4.close
970
- book5 = Book.open(@simple_file1, :force_excel => book2, :read_only => true)
970
+ book5 = Workbook.open(@simple_file1, :force_excel => book2, :read_only => true)
971
971
  book5.should be_alive
972
- book5.should be_a Book
972
+ book5.should be_a Workbook
973
973
  book5.excel.should == book2.excel
974
974
  book5.ReadOnly.should be true
975
975
  book5.should == book2
@@ -978,69 +978,69 @@ describe Book do
978
978
  end
979
979
 
980
980
  it "should open in a given Excel, provide identity transparency, because book can be readonly, such that the old and the new book are readonly" do
981
- book2 = Book.open(@simple_file1, :force_excel => :new)
981
+ book2 = Workbook.open(@simple_file1, :force_excel => :new)
982
982
  book2.excel.should_not == @book.excel
983
983
  book2.close
984
984
  @book.close
985
- book4 = Book.open(@simple_file1, :force_excel => book2, :read_only => true)
985
+ book4 = Workbook.open(@simple_file1, :force_excel => book2, :read_only => true)
986
986
  book4.should be_alive
987
- book4.should be_a Book
987
+ book4.should be_a Workbook
988
988
  book4.excel.should == book2.excel
989
989
  book4.ReadOnly.should be true
990
990
  book4.should == book2
991
991
  book4.close
992
992
  end
993
993
 
994
- it "should raise an error if no Excel or Book is given" do
994
+ it "should raise an error if no Excel or Workbook is given" do
995
995
  expect{
996
- Book.open(@simple_file1, :force_excel => :b)
996
+ Workbook.open(@simple_file1, :force_excel => :b)
997
997
  }.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
998
998
  end
999
999
 
1000
1000
  it "should do force_excel even if both force_ and default_excel is given" do
1001
- book2 = Book.open(@simple_file1, :default_excel => @book.excel, :force_excel => :new)
1001
+ book2 = Workbook.open(@simple_file1, :default_excel => @book.excel, :force_excel => :new)
1002
1002
  book2.should be_alive
1003
- book2.should be_a Book
1003
+ book2.should be_a Workbook
1004
1004
  book2.excel.should_not == @book.excel
1005
1005
  book2.should_not == @book
1006
1006
  end
1007
1007
 
1008
1008
  it "should do default_excel if force_excel is nil" do
1009
- book2 = Book.open(@another_simple_file, :force_excel => nil)
1009
+ book2 = Workbook.open(@another_simple_file, :force_excel => nil)
1010
1010
  book2.should be_alive
1011
- book2.should be_a Book
1011
+ book2.should be_a Workbook
1012
1012
  book2.excel.should == @book.excel
1013
1013
  end
1014
1014
 
1015
1015
  it "should force_excel with :reuse" do
1016
- book2 = Book.open(@different_file, :force_excel => :current)
1016
+ book2 = Workbook.open(@different_file, :force_excel => :current)
1017
1017
  book2.should be_alive
1018
- book2.should be_a Book
1018
+ book2.should be_a Workbook
1019
1019
  book2.excel.should == @book.excel
1020
1020
  end
1021
1021
 
1022
1022
  it "should force_excel with :reuse even if :default_excel says sth. else" do
1023
- book2 = Book.open(@different_file, :force_excel => :current, :default_excel => :new)
1023
+ book2 = Workbook.open(@different_file, :force_excel => :current, :default_excel => :new)
1024
1024
  book2.should be_alive
1025
- book2.should be_a Book
1025
+ book2.should be_a Workbook
1026
1026
  book2.excel.should == @book.excel
1027
1027
  end
1028
1028
 
1029
1029
  it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
1030
1030
  excel2 = Excel.new(:reuse => false)
1031
1031
  @book.excel.close
1032
- book2 = Book.open(@simple_file1, :force_excel => :current, :default_excel => :new)
1032
+ book2 = Workbook.open(@simple_file1, :force_excel => :current, :default_excel => :new)
1033
1033
  book2.should be_alive
1034
- book2.should be_a Book
1034
+ book2.should be_a Workbook
1035
1035
  book2.excel.should === excel2
1036
1036
  end
1037
1037
 
1038
1038
  it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
1039
- book2 = Book.open(@different_file1, :force_excel => :new)
1039
+ book2 = Workbook.open(@different_file1, :force_excel => :new)
1040
1040
  book2.excel.close
1041
- book3 = Book.open(@different_file1, :force_excel => :current, :default_excel => :new)
1041
+ book3 = Workbook.open(@different_file1, :force_excel => :current, :default_excel => :new)
1042
1042
  book3.should be_alive
1043
- book3.should be_a Book
1043
+ book3.should be_a Workbook
1044
1044
  book3.excel.should == @book.excel
1045
1045
  end
1046
1046
 
@@ -1049,7 +1049,7 @@ describe Book do
1049
1049
  context "with :default => {:excel}" do
1050
1050
 
1051
1051
  before do
1052
- @book = Book.open(@simple_file1, :visible => true)
1052
+ @book = Workbook.open(@simple_file1, :visible => true)
1053
1053
  end
1054
1054
 
1055
1055
  after do
@@ -1059,62 +1059,62 @@ describe Book do
1059
1059
  context "with :default => {:excel => :reserved_new}" do
1060
1060
 
1061
1061
  it "should open in the reserved Excel instance" do
1062
- book3 = Book.open(@different_file1, :default => {:excel => :reserved_new})
1062
+ book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
1063
1063
  book3.excel.should_not == @book.excel
1064
1064
  end
1065
1065
 
1066
1066
  it "should open in separate Excel instances" do
1067
1067
  Excel.kill_all
1068
1068
  sleep 1
1069
- book2 = Book.open(@simple_file1, :default => {:excel => :reserved_new})
1070
- book3 = Book.open(@different_file1, :default => {:excel => :reserved_new})
1069
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
1070
+ book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
1071
1071
  book2.excel.should_not == book3.excel
1072
- book4 = Book.open(@another_simple_file1, :default => {:excel => :current})
1072
+ book4 = Workbook.open(@another_simple_file1, :default => {:excel => :current})
1073
1073
  book4.excel.should_not == book2.excel
1074
1074
  book4.excel.should_not == book3.excel
1075
1075
  end
1076
1076
 
1077
1077
  it "should use the open book" do
1078
- book2 = Book.open(@simple_file1, :default => {:excel => :reserved_new})
1078
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
1079
1079
  book2.excel.should == @book.excel
1080
1080
  book2.should be_alive
1081
- book2.should be_a Book
1081
+ book2.should be_a Workbook
1082
1082
  book2.should == @book
1083
1083
  book2.close
1084
1084
  end
1085
1085
 
1086
1086
  it "should open in the old Excel instance" do
1087
1087
  @book.close
1088
- book2 = Book.open(@simple_file1, :default => {:excel => :reserved_new})
1088
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
1089
1089
  book2.should be_alive
1090
- book2.should be_a Book
1090
+ book2.should be_a Workbook
1091
1091
  book2.should == @book
1092
1092
  book2.excel.should == @book.excel
1093
1093
  end
1094
1094
 
1095
1095
  it "should open one book in the reserved Excel instance" do
1096
- book3 = Book.open(@different_file1, :default => {:excel => :reserved_new})
1096
+ book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
1097
1097
  @book.close
1098
- book2 = Book.open(@simple_file1, :default => {:excel => :reserved_new})
1098
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
1099
1099
  book2.excel.should_not == book3.excel
1100
1100
  end
1101
1101
 
1102
1102
  it "should not use the reserved Excel instance" do
1103
- book3 = Book.open(@different_file1, :default => {:excel => :reserved_new})
1103
+ book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
1104
1104
  @book.close
1105
- book2 = Book.open(@simple_file1, :default => {:excel => :new})
1105
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :new})
1106
1106
  book2.excel.should_not == book3.excel
1107
1107
  end
1108
1108
 
1109
1109
  it "should not reopen in the reserved Excel instance" do
1110
- book3 = Book.open(@different_file1, :default => {:excel => :reserved_new})
1110
+ book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
1111
1111
  @book.close
1112
1112
  @book.reopen
1113
1113
  @book.excel.should_not == book3.excel
1114
1114
  end
1115
1115
 
1116
1116
  it "should reopen in the reserved Excel instance" do
1117
- book3 = Book.open(@different_file1, :default => {:excel => :reserved_new})
1117
+ book3 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
1118
1118
  @book.close
1119
1119
  book3.close
1120
1120
  @book.reopen
@@ -1125,10 +1125,10 @@ describe Book do
1125
1125
  it "should not reopen in the reserved Excel instance when opened the reserved Excel instance first" do
1126
1126
  Excel.kill_all
1127
1127
  sleep 1
1128
- book1 = Book.open(@simple_file1, :default => {:excel => :reserved_new})
1129
- book2 = Book.open(@different_file1, :default => {:excel => :new})
1128
+ book1 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
1129
+ book2 = Workbook.open(@different_file1, :default => {:excel => :new})
1130
1130
  book2.excel.should_not == book1.excel
1131
- book3 = Book.open(@another_simple_file1, :default => {:excel => :current})
1131
+ book3 = Workbook.open(@another_simple_file1, :default => {:excel => :current})
1132
1132
  book3.excel.should_not == book1.excel
1133
1133
  book2.close
1134
1134
  book2.reopen
@@ -1143,8 +1143,8 @@ describe Book do
1143
1143
  end
1144
1144
 
1145
1145
  it "should open several workbooks in the reserved Excel instance" do
1146
- book2 = Book.open(@different_file1, :default => {:excel => :reserved_new})
1147
- book3 = Book.open(@another_simple_file1, :default => {:excel => :reserved_new})
1146
+ book2 = Workbook.open(@different_file1, :default => {:excel => :reserved_new})
1147
+ book3 = Workbook.open(@another_simple_file1, :default => {:excel => :reserved_new})
1148
1148
  book2.excel.should_not == @book.excel
1149
1149
  book3.excel.should_not == @book.excel
1150
1150
  book2.excel.should_not == book3.excel
@@ -1152,9 +1152,9 @@ describe Book do
1152
1152
 
1153
1153
  it "should open several workbooks in the reserved Excel instance" do
1154
1154
  Excel.kill_all
1155
- book1 = Book.open(@simple_file1, :default => {:excel => :reserved_new})
1156
- book2 = Book.open(@different_file1, :default => {:excel => :current})
1157
- book3 = Book.open(@another_simple_file1, :default => {:excel => :current})
1155
+ book1 = Workbook.open(@simple_file1, :default => {:excel => :reserved_new})
1156
+ book2 = Workbook.open(@different_file1, :default => {:excel => :current})
1157
+ book3 = Workbook.open(@another_simple_file1, :default => {:excel => :current})
1158
1158
  book2.excel.should_not == book1.excel
1159
1159
  book3.excel.should_not == book1.excel
1160
1160
  book2.excel.should == book3.excel
@@ -1165,10 +1165,10 @@ describe Book do
1165
1165
  context "with :default => {:excel => :current}" do
1166
1166
 
1167
1167
  it "should use the open book" do
1168
- book2 = Book.open(@simple_file1, :default => {:excel => :current})
1168
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :current})
1169
1169
  book2.excel.should == @book.excel
1170
1170
  book2.should be_alive
1171
- book2.should be_a Book
1171
+ book2.should be_a Workbook
1172
1172
  book2.should == @book
1173
1173
  book2.close
1174
1174
  end
@@ -1176,9 +1176,9 @@ describe Book do
1176
1176
  it "should reopen the book in the excel instance where it was opened before" do
1177
1177
  excel = Excel.new(:reuse => false)
1178
1178
  @book.close
1179
- book2 = Book.open(@simple_file1)
1179
+ book2 = Workbook.open(@simple_file1)
1180
1180
  book2.should be_alive
1181
- book2.should be_a Book
1181
+ book2.should be_a Workbook
1182
1182
  book2.excel.should == @book.excel
1183
1183
  book2.excel.should_not == excel
1184
1184
  book2.filename.should == @book.filename
@@ -1193,9 +1193,9 @@ describe Book do
1193
1193
  fn = @book.filename
1194
1194
  @book.close
1195
1195
  Excel.close_all
1196
- book2 = Book.open(@simple_file1, :default => {:excel => :current})
1196
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :current})
1197
1197
  book2.should be_alive
1198
- book2.should be_a Book
1198
+ book2.should be_a Workbook
1199
1199
  book2.filename.should == fn
1200
1200
  @book.should be_alive
1201
1201
  book2.should == @book
@@ -1207,9 +1207,9 @@ describe Book do
1207
1207
  Excel.close_all
1208
1208
  new_excel = Excel.new(:reuse => false)
1209
1209
  new_excel2 = Excel.new(:reuse => false)
1210
- book2 = Book.open(@simple_file1, :default => {:excel => :current})
1210
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :current})
1211
1211
  book2.should be_alive
1212
- book2.should be_a Book
1212
+ book2.should be_a Workbook
1213
1213
  book2.excel.should_not == excel
1214
1214
  book2.excel.should_not == new_excel2
1215
1215
  book2.excel.should == new_excel
@@ -1223,9 +1223,9 @@ describe Book do
1223
1223
  Excel.close_all
1224
1224
  excel1 = Excel.new(:reuse => false)
1225
1225
  excel2 = Excel.new(:reuse => false)
1226
- book2 = Book.open(@different_file, :default => {:excel => :current})
1226
+ book2 = Workbook.open(@different_file, :default => {:excel => :current})
1227
1227
  book2.should be_alive
1228
- book2.should be_a Book
1228
+ book2.should be_a Workbook
1229
1229
  book2.excel.should == excel1
1230
1230
  book2.excel.should_not == excel2
1231
1231
  book2.close
@@ -1235,12 +1235,12 @@ describe Book do
1235
1235
  excel1 = @book.excel
1236
1236
  excel2 = Excel.new(:reuse => false)
1237
1237
  @book.close
1238
- book2 = Book.open(@simple_file1, :default => {:excel => :current})
1238
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :current})
1239
1239
  book2.excel.should == excel1
1240
1240
  book2.close
1241
- book3 = Book.open(@simple_file1, :force => {:excel => excel2})
1241
+ book3 = Workbook.open(@simple_file1, :force => {:excel => excel2})
1242
1242
  book3.close
1243
- book3 = Book.open(@simple_file1, :default => {:excel => :current})
1243
+ book3 = Workbook.open(@simple_file1, :default => {:excel => :current})
1244
1244
  book3.excel.should == excel2
1245
1245
  book3.close
1246
1246
  end
@@ -1250,12 +1250,12 @@ describe Book do
1250
1250
  context "with :default => {:excel => :new}" do
1251
1251
 
1252
1252
  it "should reopen a book in the excel instance where it was opened most recently" do
1253
- book2 = Book.open(@simple_file, :force => {:excel => :new})
1253
+ book2 = Workbook.open(@simple_file, :force => {:excel => :new})
1254
1254
  @book.close
1255
1255
  book2.close
1256
- book3 = Book.open(@simple_file1)
1256
+ book3 = Workbook.open(@simple_file1)
1257
1257
  book2.should be_alive
1258
- book2.should be_a Book
1258
+ book2.should be_a Workbook
1259
1259
  book3.excel.should == book2.excel
1260
1260
  book3.excel.should_not == @book.excel
1261
1261
  book3.should == book2
@@ -1263,9 +1263,9 @@ describe Book do
1263
1263
  end
1264
1264
 
1265
1265
  it "should open the book in a new excel if the book was not opened before" do
1266
- book2 = Book.open(@different_file, :default => {:excel => :current})
1266
+ book2 = Workbook.open(@different_file, :default => {:excel => :current})
1267
1267
  book2.excel.should == @book.excel
1268
- book3 = Book.open(@another_simple_file, :default => {:excel => :new})
1268
+ book3 = Workbook.open(@another_simple_file, :default => {:excel => :new})
1269
1269
  book3.excel.should_not == @book.excel
1270
1270
  end
1271
1271
 
@@ -1273,7 +1273,7 @@ describe Book do
1273
1273
  excel = @book.excel
1274
1274
  excel2 = Excel.new(:reuse => false)
1275
1275
  excel.close
1276
- book2 = Book.open(@simple_file1, :default => {:excel => :new})
1276
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :new})
1277
1277
  book2.excel.should_not == excel2
1278
1278
  book2.close
1279
1279
  end
@@ -1283,26 +1283,26 @@ describe Book do
1283
1283
  context "with :default => {:excel => <excel-instance>}" do
1284
1284
 
1285
1285
  it "should open the book in a given excel if the book was not opened before" do
1286
- book2 = Book.open(@different_file, :default => {:excel => :current})
1286
+ book2 = Workbook.open(@different_file, :default => {:excel => :current})
1287
1287
  book2.excel.should == @book.excel
1288
1288
  excel = Excel.new(:reuse => false)
1289
- book3 = Book.open(@another_simple_file, :default => {:excel => excel})
1289
+ book3 = Workbook.open(@another_simple_file, :default => {:excel => excel})
1290
1290
  book3.excel.should == excel
1291
1291
  end
1292
1292
 
1293
1293
  it "should open the book in a given excel if the book was opened before but the excel has been closed" do
1294
1294
  excel2 = Excel.new(:reuse => false, :visible => true)
1295
1295
  @book.excel.close
1296
- book2 = Book.open(@simple_file1, :default => {:excel => excel2, :visible => true})
1296
+ book2 = Workbook.open(@simple_file1, :default => {:excel => excel2, :visible => true})
1297
1297
  book2.excel.should == excel2
1298
1298
  end
1299
1299
 
1300
1300
  it "should open a new excel, if the book cannot be reopened" do
1301
1301
  @book.close
1302
1302
  new_excel = Excel.new(:reuse => false)
1303
- book2 = Book.open(@different_file, :default => {:excel => :new})
1303
+ book2 = Workbook.open(@different_file, :default => {:excel => :new})
1304
1304
  book2.should be_alive
1305
- book2.should be_a Book
1305
+ book2.should be_a Workbook
1306
1306
  book2.excel.should_not == new_excel
1307
1307
  book2.excel.should_not == @book.excel
1308
1308
  book2.close
@@ -1311,9 +1311,9 @@ describe Book do
1311
1311
  it "should open a given excel, if the book cannot be reopened" do
1312
1312
  @book.close
1313
1313
  new_excel = Excel.new(:reuse => false)
1314
- book2 = Book.open(@different_file, :default => {:excel => @book.excel})
1314
+ book2 = Workbook.open(@different_file, :default => {:excel => @book.excel})
1315
1315
  book2.should be_alive
1316
- book2.should be_a Book
1316
+ book2.should be_a Workbook
1317
1317
  book2.excel.should_not == new_excel
1318
1318
  book2.excel.should == @book.excel
1319
1319
  book2.close
@@ -1322,9 +1322,9 @@ describe Book do
1322
1322
  it "should open a given excel, if the book cannot be reopened" do
1323
1323
  @book.close
1324
1324
  new_excel = Excel.new(:reuse => false)
1325
- book2 = Book.open(@different_file, :default => {:excel => @book})
1325
+ book2 = Workbook.open(@different_file, :default => {:excel => @book})
1326
1326
  book2.should be_alive
1327
- book2.should be_a Book
1327
+ book2.should be_a Workbook
1328
1328
  book2.excel.should_not == new_excel
1329
1329
  book2.excel.should == @book.excel
1330
1330
  book2.close
@@ -1333,14 +1333,14 @@ describe Book do
1333
1333
  end
1334
1334
 
1335
1335
  it "should reuse an open book by default" do
1336
- book2 = Book.open(@simple_file1)
1336
+ book2 = Workbook.open(@simple_file1)
1337
1337
  book2.excel.should == @book.excel
1338
1338
  book2.should == @book
1339
1339
  end
1340
1340
 
1341
- it "should raise an error if no Excel or Book is given" do
1341
+ it "should raise an error if no Excel or Workbook is given" do
1342
1342
  expect{
1343
- Book.open(@different_file, :default => {:excel => :a})
1343
+ Workbook.open(@different_file, :default => {:excel => :a})
1344
1344
  }.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
1345
1345
  end
1346
1346
 
@@ -1349,7 +1349,7 @@ describe Book do
1349
1349
  context "with :default_excel" do
1350
1350
 
1351
1351
  before do
1352
- @book = Book.open(@simple_file1, :visible => true)
1352
+ @book = Workbook.open(@simple_file1, :visible => true)
1353
1353
  end
1354
1354
 
1355
1355
  after do
@@ -1357,10 +1357,10 @@ describe Book do
1357
1357
  end
1358
1358
 
1359
1359
  it "should use the open book" do
1360
- book2 = Book.open(@simple_file1, :default_excel => :current)
1360
+ book2 = Workbook.open(@simple_file1, :default_excel => :current)
1361
1361
  book2.excel.should == @book.excel
1362
1362
  book2.should be_alive
1363
- book2.should be_a Book
1363
+ book2.should be_a Workbook
1364
1364
  book2.should == @book
1365
1365
  book2.close
1366
1366
  end
@@ -1368,9 +1368,9 @@ describe Book do
1368
1368
  it "should reopen the book in the excel instance where it was opened before" do
1369
1369
  excel = Excel.new(:reuse => false)
1370
1370
  @book.close
1371
- book2 = Book.open(@simple_file1)
1371
+ book2 = Workbook.open(@simple_file1)
1372
1372
  book2.should be_alive
1373
- book2.should be_a Book
1373
+ book2.should be_a Workbook
1374
1374
  book2.excel.should == @book.excel
1375
1375
  book2.excel.should_not == excel
1376
1376
  book2.filename.should == @book.filename
@@ -1385,9 +1385,9 @@ describe Book do
1385
1385
  fn = @book.filename
1386
1386
  @book.close
1387
1387
  Excel.close_all
1388
- book2 = Book.open(@simple_file1, :default_excel => :current)
1388
+ book2 = Workbook.open(@simple_file1, :default_excel => :current)
1389
1389
  book2.should be_alive
1390
- book2.should be_a Book
1390
+ book2.should be_a Workbook
1391
1391
  book2.filename.should == fn
1392
1392
  @book.should be_alive
1393
1393
  book2.should == @book
@@ -1399,9 +1399,9 @@ describe Book do
1399
1399
  Excel.close_all
1400
1400
  new_excel = Excel.new(:reuse => false)
1401
1401
  new_excel2 = Excel.new(:reuse => false)
1402
- book2 = Book.open(@simple_file1, :default_excel => :current)
1402
+ book2 = Workbook.open(@simple_file1, :default_excel => :current)
1403
1403
  book2.should be_alive
1404
- book2.should be_a Book
1404
+ book2.should be_a Workbook
1405
1405
  book2.excel.should_not == excel
1406
1406
  book2.excel.should_not == new_excel2
1407
1407
  book2.excel.should == new_excel
@@ -1415,9 +1415,9 @@ describe Book do
1415
1415
  Excel.close_all
1416
1416
  excel1 = Excel.new(:reuse => false)
1417
1417
  excel2 = Excel.new(:reuse => false)
1418
- book2 = Book.open(@different_file, :default_excel => :current)
1418
+ book2 = Workbook.open(@different_file, :default_excel => :current)
1419
1419
  book2.should be_alive
1420
- book2.should be_a Book
1420
+ book2.should be_a Workbook
1421
1421
  book2.excel.should == excel1
1422
1422
  book2.excel.should_not == excel2
1423
1423
  book2.close
@@ -1427,23 +1427,23 @@ describe Book do
1427
1427
  excel1 = @book.excel
1428
1428
  excel2 = Excel.new(:reuse => false)
1429
1429
  @book.close
1430
- book2 = Book.open(@simple_file1, :default_excel => :current)
1430
+ book2 = Workbook.open(@simple_file1, :default_excel => :current)
1431
1431
  book2.excel.should == excel1
1432
1432
  book2.close
1433
- book3 = Book.open(@simple_file1, :force_excel => excel2)
1433
+ book3 = Workbook.open(@simple_file1, :force_excel => excel2)
1434
1434
  book3.close
1435
- book3 = Book.open(@simple_file1, :default_excel => :current)
1435
+ book3 = Workbook.open(@simple_file1, :default_excel => :current)
1436
1436
  book3.excel.should == excel2
1437
1437
  book3.close
1438
1438
  end
1439
1439
 
1440
1440
  it "should reopen a book in the excel instance where it was opened most recently" do
1441
- book2 = Book.open(@simple_file, :force_excel => :new)
1441
+ book2 = Workbook.open(@simple_file, :force_excel => :new)
1442
1442
  @book.close
1443
1443
  book2.close
1444
- book3 = Book.open(@simple_file1)
1444
+ book3 = Workbook.open(@simple_file1)
1445
1445
  book2.should be_alive
1446
- book2.should be_a Book
1446
+ book2.should be_a Workbook
1447
1447
  book3.excel.should == book2.excel
1448
1448
  book3.excel.should_not == @book.excel
1449
1449
  book3.should == book2
@@ -1451,9 +1451,9 @@ describe Book do
1451
1451
  end
1452
1452
 
1453
1453
  it "should open the book in a new excel if the book was not opened before" do
1454
- book2 = Book.open(@different_file, :default_excel => :current)
1454
+ book2 = Workbook.open(@different_file, :default_excel => :current)
1455
1455
  book2.excel.should == @book.excel
1456
- book3 = Book.open(@another_simple_file, :default_excel => :new)
1456
+ book3 = Workbook.open(@another_simple_file, :default_excel => :new)
1457
1457
  book3.excel.should_not == @book.excel
1458
1458
  end
1459
1459
 
@@ -1461,32 +1461,32 @@ describe Book do
1461
1461
  excel = @book.excel
1462
1462
  excel2 = Excel.new(:reuse => false)
1463
1463
  excel.close
1464
- book2 = Book.open(@simple_file1, :default_excel => :new)
1464
+ book2 = Workbook.open(@simple_file1, :default_excel => :new)
1465
1465
  book2.excel.should_not == excel2
1466
1466
  book2.close
1467
1467
  end
1468
1468
 
1469
1469
  it "should open the book in a given excel if the book was not opened before" do
1470
- book2 = Book.open(@different_file, :default_excel => :current)
1470
+ book2 = Workbook.open(@different_file, :default_excel => :current)
1471
1471
  book2.excel.should == @book.excel
1472
1472
  excel = Excel.new(:reuse => false)
1473
- book3 = Book.open(@another_simple_file, :default_excel => excel)
1473
+ book3 = Workbook.open(@another_simple_file, :default_excel => excel)
1474
1474
  book3.excel.should == excel
1475
1475
  end
1476
1476
 
1477
1477
  it "should open the book in a given excel if the book was opened before but the excel has been closed" do
1478
1478
  excel2 = Excel.new(:reuse => false, :visible => true)
1479
1479
  @book.excel.close
1480
- book2 = Book.open(@simple_file1, :visible => true, :default_excel => excel2)
1480
+ book2 = Workbook.open(@simple_file1, :visible => true, :default_excel => excel2)
1481
1481
  book2.excel.should == excel2
1482
1482
  end
1483
1483
 
1484
1484
  it "should open a new excel, if the book cannot be reopened" do
1485
1485
  @book.close
1486
1486
  new_excel = Excel.new(:reuse => false)
1487
- book2 = Book.open(@different_file, :default_excel => :new)
1487
+ book2 = Workbook.open(@different_file, :default_excel => :new)
1488
1488
  book2.should be_alive
1489
- book2.should be_a Book
1489
+ book2.should be_a Workbook
1490
1490
  book2.excel.should_not == new_excel
1491
1491
  book2.excel.should_not == @book.excel
1492
1492
  book2.close
@@ -1495,9 +1495,9 @@ describe Book do
1495
1495
  it "should open a given excel, if the book cannot be reopened" do
1496
1496
  @book.close
1497
1497
  new_excel = Excel.new(:reuse => false)
1498
- book2 = Book.open(@different_file, :default_excel => @book.excel)
1498
+ book2 = Workbook.open(@different_file, :default_excel => @book.excel)
1499
1499
  book2.should be_alive
1500
- book2.should be_a Book
1500
+ book2.should be_a Workbook
1501
1501
  book2.excel.should_not == new_excel
1502
1502
  book2.excel.should == @book.excel
1503
1503
  book2.close
@@ -1506,23 +1506,23 @@ describe Book do
1506
1506
  it "should open a given excel, if the book cannot be reopened" do
1507
1507
  @book.close
1508
1508
  new_excel = Excel.new(:reuse => false)
1509
- book2 = Book.open(@different_file, :default_excel => @book)
1509
+ book2 = Workbook.open(@different_file, :default_excel => @book)
1510
1510
  book2.should be_alive
1511
- book2.should be_a Book
1511
+ book2.should be_a Workbook
1512
1512
  book2.excel.should_not == new_excel
1513
1513
  book2.excel.should == @book.excel
1514
1514
  book2.close
1515
1515
  end
1516
1516
 
1517
1517
  it "should reuse an open book by default" do
1518
- book2 = Book.open(@simple_file1)
1518
+ book2 = Workbook.open(@simple_file1)
1519
1519
  book2.excel.should == @book.excel
1520
1520
  book2.should == @book
1521
1521
  end
1522
1522
 
1523
- it "should raise an error if no Excel or Book is given" do
1523
+ it "should raise an error if no Excel or Workbook is given" do
1524
1524
  expect{
1525
- Book.open(@different_file, :default_excel => :a)
1525
+ Workbook.open(@different_file, :default_excel => :a)
1526
1526
  }.to raise_error(TypeREOError, "given object is neither an Excel, a Workbook, nor a Win32ole")
1527
1527
  end
1528
1528
 
@@ -1531,7 +1531,7 @@ describe Book do
1531
1531
  context "with :active instead of :current" do
1532
1532
 
1533
1533
  before do
1534
- @book = Book.open(@simple_file1)
1534
+ @book = Workbook.open(@simple_file1)
1535
1535
  end
1536
1536
 
1537
1537
  after do
@@ -1539,42 +1539,42 @@ describe Book do
1539
1539
  end
1540
1540
 
1541
1541
  it "should force_excel with :active" do
1542
- book2 = Book.open(@different_file, :force => {:excel => :active})
1542
+ book2 = Workbook.open(@different_file, :force => {:excel => :active})
1543
1543
  book2.should be_alive
1544
- book2.should be_a Book
1544
+ book2.should be_a Workbook
1545
1545
  book2.excel.should == @book.excel
1546
1546
  end
1547
1547
 
1548
1548
  it "should force_excel with :reuse even if :default_excel says sth. else" do
1549
- book2 = Book.open(@different_file, :force => {:excel => :active}, :default => {:excel => :new})
1549
+ book2 = Workbook.open(@different_file, :force => {:excel => :active}, :default => {:excel => :new})
1550
1550
  book2.should be_alive
1551
- book2.should be_a Book
1551
+ book2.should be_a Workbook
1552
1552
  book2.excel.should == @book.excel
1553
1553
  end
1554
1554
 
1555
1555
  it "should open force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
1556
1556
  excel2 = Excel.new(:reuse => false)
1557
1557
  @book.excel.close
1558
- book2 = Book.open(@simple_file1, :force => {:excel => :active}, :default => {:excel => :new})
1558
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :active}, :default => {:excel => :new})
1559
1559
  book2.should be_alive
1560
- book2.should be_a Book
1560
+ book2.should be_a Workbook
1561
1561
  book2.excel.should === excel2
1562
1562
  end
1563
1563
 
1564
1564
  it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
1565
- book2 = Book.open(@different_file1, :force => {:excel => :new})
1565
+ book2 = Workbook.open(@different_file1, :force => {:excel => :new})
1566
1566
  book2.excel.close
1567
- book3 = Book.open(@different_file1, :force => {:excel => :active}, :default => {:excel => :new})
1567
+ book3 = Workbook.open(@different_file1, :force => {:excel => :active}, :default => {:excel => :new})
1568
1568
  book3.should be_alive
1569
- book3.should be_a Book
1569
+ book3.should be_a Workbook
1570
1570
  book3.excel.should == @book.excel
1571
1571
  end
1572
1572
 
1573
1573
  it "should use the open book" do
1574
- book2 = Book.open(@simple_file1, :default => {:excel => :active})
1574
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :active})
1575
1575
  book2.excel.should == @book.excel
1576
1576
  book2.should be_alive
1577
- book2.should be_a Book
1577
+ book2.should be_a Workbook
1578
1578
  book2.should == @book
1579
1579
  book2.close
1580
1580
  end
@@ -1585,9 +1585,9 @@ describe Book do
1585
1585
  fn = @book.filename
1586
1586
  @book.close
1587
1587
  Excel.close_all
1588
- book2 = Book.open(@simple_file1, :default => {:excel => :active})
1588
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :active})
1589
1589
  book2.should be_alive
1590
- book2.should be_a Book
1590
+ book2.should be_a Workbook
1591
1591
  book2.filename.should == fn
1592
1592
  @book.should be_alive
1593
1593
  book2.should == @book
@@ -1599,9 +1599,9 @@ describe Book do
1599
1599
  Excel.close_all
1600
1600
  new_excel = Excel.new(:reuse => false)
1601
1601
  new_excel2 = Excel.new(:reuse => false)
1602
- book2 = Book.open(@simple_file1, :default => {:excel => :active})
1602
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :active})
1603
1603
  book2.should be_alive
1604
- book2.should be_a Book
1604
+ book2.should be_a Workbook
1605
1605
  book2.excel.should_not == excel
1606
1606
  book2.excel.should_not == new_excel2
1607
1607
  book2.excel.should == new_excel
@@ -1615,9 +1615,9 @@ describe Book do
1615
1615
  Excel.close_all
1616
1616
  excel1 = Excel.new(:reuse => false)
1617
1617
  excel2 = Excel.new(:reuse => false)
1618
- book2 = Book.open(@different_file, :default => {:excel => :active})
1618
+ book2 = Workbook.open(@different_file, :default => {:excel => :active})
1619
1619
  book2.should be_alive
1620
- book2.should be_a Book
1620
+ book2.should be_a Workbook
1621
1621
  book2.excel.should == excel1
1622
1622
  book2.excel.should_not == excel2
1623
1623
  book2.close
@@ -1627,12 +1627,12 @@ describe Book do
1627
1627
  excel1 = @book.excel
1628
1628
  excel2 = Excel.new(:reuse => false)
1629
1629
  @book.close
1630
- book2 = Book.open(@simple_file1, :default => {:excel => :active})
1630
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :active})
1631
1631
  book2.excel.should == excel1
1632
1632
  book2.close
1633
- book3 = Book.open(@simple_file1, :force => {:excel => excel2})
1633
+ book3 = Workbook.open(@simple_file1, :force => {:excel => excel2})
1634
1634
  book3.close
1635
- book3 = Book.open(@simple_file1, :default => {:excel => :active})
1635
+ book3 = Workbook.open(@simple_file1, :default => {:excel => :active})
1636
1636
  book3.excel.should == excel2
1637
1637
  book3.close
1638
1638
  end
@@ -1642,7 +1642,7 @@ describe Book do
1642
1642
  context "with :reuse instead of :current" do
1643
1643
 
1644
1644
  before do
1645
- @book = Book.open(@simple_file1)
1645
+ @book = Workbook.open(@simple_file1)
1646
1646
  end
1647
1647
 
1648
1648
  after do
@@ -1650,42 +1650,42 @@ describe Book do
1650
1650
  end
1651
1651
 
1652
1652
  it "should force_excel with :reuse" do
1653
- book2 = Book.open(@different_file, :force => {:excel => :reuse})
1653
+ book2 = Workbook.open(@different_file, :force => {:excel => :reuse})
1654
1654
  book2.should be_alive
1655
- book2.should be_a Book
1655
+ book2.should be_a Workbook
1656
1656
  book2.excel.should == @book.excel
1657
1657
  end
1658
1658
 
1659
1659
  it "should force_excel with :reuse even if :default_excel says sth. else" do
1660
- book2 = Book.open(@different_file, :force => {:excel => :reuse}, :default => {:excel => :new})
1660
+ book2 = Workbook.open(@different_file, :force => {:excel => :reuse}, :default => {:excel => :new})
1661
1661
  book2.should be_alive
1662
- book2.should be_a Book
1662
+ book2.should be_a Workbook
1663
1663
  book2.excel.should == @book.excel
1664
1664
  end
1665
1665
 
1666
1666
  it "should open force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
1667
1667
  excel2 = Excel.new(:reuse => false)
1668
1668
  @book.excel.close
1669
- book2 = Book.open(@simple_file1, :force => {:excel => :reuse}, :default => {:excel => :new})
1669
+ book2 = Workbook.open(@simple_file1, :force => {:excel => :reuse}, :default => {:excel => :new})
1670
1670
  book2.should be_alive
1671
- book2.should be_a Book
1671
+ book2.should be_a Workbook
1672
1672
  book2.excel.should === excel2
1673
1673
  end
1674
1674
 
1675
1675
  it "should force_excel with :reuse when reopening and the Excel is not alive even if :default_excel says sth. else" do
1676
- book2 = Book.open(@different_file1, :force => {:excel => :new})
1676
+ book2 = Workbook.open(@different_file1, :force => {:excel => :new})
1677
1677
  book2.excel.close
1678
- book3 = Book.open(@different_file1, :force => {:excel => :reuse}, :default => {:excel => :new})
1678
+ book3 = Workbook.open(@different_file1, :force => {:excel => :reuse}, :default => {:excel => :new})
1679
1679
  book3.should be_alive
1680
- book3.should be_a Book
1680
+ book3.should be_a Workbook
1681
1681
  book3.excel.should == @book.excel
1682
1682
  end
1683
1683
 
1684
1684
  it "should use the open book" do
1685
- book2 = Book.open(@simple_file1, :default => {:excel => :reuse})
1685
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :reuse})
1686
1686
  book2.excel.should == @book.excel
1687
1687
  book2.should be_alive
1688
- book2.should be_a Book
1688
+ book2.should be_a Workbook
1689
1689
  book2.should == @book
1690
1690
  book2.close
1691
1691
  end
@@ -1696,9 +1696,9 @@ describe Book do
1696
1696
  fn = @book.filename
1697
1697
  @book.close
1698
1698
  Excel.close_all
1699
- book2 = Book.open(@simple_file1, :default => {:excel => :reuse})
1699
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :reuse})
1700
1700
  book2.should be_alive
1701
- book2.should be_a Book
1701
+ book2.should be_a Workbook
1702
1702
  book2.filename.should == fn
1703
1703
  @book.should be_alive
1704
1704
  book2.should == @book
@@ -1710,9 +1710,9 @@ describe Book do
1710
1710
  Excel.close_all
1711
1711
  new_excel = Excel.new(:reuse => false)
1712
1712
  new_excel2 = Excel.new(:reuse => false)
1713
- book2 = Book.open(@simple_file1, :default => {:excel => :reuse})
1713
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :reuse})
1714
1714
  book2.should be_alive
1715
- book2.should be_a Book
1715
+ book2.should be_a Workbook
1716
1716
  book2.excel.should_not == excel
1717
1717
  book2.excel.should_not == new_excel2
1718
1718
  book2.excel.should == new_excel
@@ -1726,9 +1726,9 @@ describe Book do
1726
1726
  Excel.close_all
1727
1727
  excel1 = Excel.new(:reuse => false)
1728
1728
  excel2 = Excel.new(:reuse => false)
1729
- book2 = Book.open(@different_file, :default => {:excel => :reuse})
1729
+ book2 = Workbook.open(@different_file, :default => {:excel => :reuse})
1730
1730
  book2.should be_alive
1731
- book2.should be_a Book
1731
+ book2.should be_a Workbook
1732
1732
  book2.excel.should == excel1
1733
1733
  book2.excel.should_not == excel2
1734
1734
  book2.close
@@ -1738,12 +1738,12 @@ describe Book do
1738
1738
  excel1 = @book.excel
1739
1739
  excel2 = Excel.new(:reuse => false)
1740
1740
  @book.close
1741
- book2 = Book.open(@simple_file1, :default => {:excel => :reuse})
1741
+ book2 = Workbook.open(@simple_file1, :default => {:excel => :reuse})
1742
1742
  book2.excel.should == excel1
1743
1743
  book2.close
1744
- book3 = Book.open(@simple_file1, :force => {:excel => excel2})
1744
+ book3 = Workbook.open(@simple_file1, :force => {:excel => excel2})
1745
1745
  book3.close
1746
- book3 = Book.open(@simple_file1, :default => {:excel => :reuse})
1746
+ book3 = Workbook.open(@simple_file1, :default => {:excel => :reuse})
1747
1747
  book3.excel.should == excel2
1748
1748
  book3.close
1749
1749
  end
@@ -1751,16 +1751,16 @@ describe Book do
1751
1751
  end
1752
1752
 
1753
1753
  it "should new_excel" do
1754
- book = Book.open(@simple_file1)
1754
+ book = Workbook.open(@simple_file1)
1755
1755
  book.sheet(1)[1,1].Value = "f"
1756
1756
  book.Saved.should be false
1757
- book2 = Book.open(@simple_file1, :if_unsaved => :new_excel)
1757
+ book2 = Workbook.open(@simple_file1, :if_unsaved => :new_excel)
1758
1758
  end
1759
1759
 
1760
1760
  context "with :if_unsaved" do
1761
1761
 
1762
1762
  before do
1763
- @book = Book.open(@simple_file)
1763
+ @book = Workbook.open(@simple_file)
1764
1764
  @sheet = @book.sheet(1)
1765
1765
  @book.add_sheet(@sheet, :as => 'a_name')
1766
1766
  end
@@ -1772,13 +1772,13 @@ describe Book do
1772
1772
 
1773
1773
  it "should raise an error, if :if_unsaved is :raise" do
1774
1774
  expect {
1775
- @new_book = Book.open(@simple_file, :if_unsaved => :raise)
1775
+ @new_book = Workbook.open(@simple_file, :if_unsaved => :raise)
1776
1776
  }.to raise_error(WorkbookNotSaved, /workbook is already open but not saved: "workbook.xls"/)
1777
1777
  end
1778
1778
 
1779
1779
  it "should let the book open, if :if_unsaved is :accept" do
1780
1780
  expect {
1781
- @new_book = Book.open(@simple_file, :if_unsaved => :accept)
1781
+ @new_book = Workbook.open(@simple_file, :if_unsaved => :accept)
1782
1782
  }.to_not raise_error
1783
1783
  @book.should be_alive
1784
1784
  @new_book.should be_alive
@@ -1797,7 +1797,7 @@ describe Book do
1797
1797
  it "should open the new book and close the unsaved book, if user answers 'yes'" do
1798
1798
  # "Yes" is the default. --> language independent
1799
1799
  @key_sender.puts "{enter}"
1800
- @new_book = Book.open(@simple_file1, :if_unsaved => :alert)
1800
+ @new_book = Workbook.open(@simple_file1, :if_unsaved => :alert)
1801
1801
  @new_book.should be_alive
1802
1802
  @new_book.filename.downcase.should == @simple_file1.downcase
1803
1803
  @book.should_not be_alive
@@ -1811,7 +1811,7 @@ describe Book do
1811
1811
  @key_sender.puts "{right}{enter}"
1812
1812
  @key_sender.puts "{right}{enter}"
1813
1813
  expect{
1814
- Book.open(@simple_file, :if_unsaved => :alert)
1814
+ Workbook.open(@simple_file, :if_unsaved => :alert)
1815
1815
  }.to raise_error(UnexpectedREOError)
1816
1816
  @book.should be_alive
1817
1817
  end
@@ -1819,7 +1819,7 @@ describe Book do
1819
1819
  it "should open the new book and close the unsaved book, if user answers 'yes'" do
1820
1820
  # "Yes" is the default. --> language independent
1821
1821
  @key_sender.puts "{enter}"
1822
- @new_book = Book.open(@simple_file1, :if_unsaved => :excel)
1822
+ @new_book = Workbook.open(@simple_file1, :if_unsaved => :excel)
1823
1823
  @new_book.should be_alive
1824
1824
  @new_book.filename.downcase.should == @simple_file1.downcase
1825
1825
  #@book.should_not be_alive
@@ -1833,7 +1833,7 @@ describe Book do
1833
1833
  @key_sender.puts "{right}{enter}"
1834
1834
  @key_sender.puts "{right}{enter}"
1835
1835
  expect{
1836
- Book.open(@simple_file, :if_unsaved => :excel)
1836
+ Workbook.open(@simple_file, :if_unsaved => :excel)
1837
1837
  }.to raise_error(UnexpectedREOError)
1838
1838
  @book.should be_alive
1839
1839
  end
@@ -1849,16 +1849,16 @@ describe Book do
1849
1849
 
1850
1850
  before do
1851
1851
  if i == 1 then
1852
- book_before = Book.open(@simple_file1)
1852
+ book_before = Workbook.open(@simple_file1)
1853
1853
  book_before.close
1854
1854
  end
1855
- @book = Book.open(@simple_file_other_path1)
1855
+ @book = Workbook.open(@simple_file_other_path1)
1856
1856
  #@book.Windows(@book.Name).Visible = true
1857
1857
  #@sheet_count = @book.ole_workbook.Worksheets.Count
1858
1858
  sheet = @book.sheet(1)
1859
1859
  #@book.add_sheet(@sheet, :as => 'a_name')
1860
1860
  @old_value = sheet[1,1].Value
1861
- sheet[1,1] = (sheet[1,1].value == "foo" ? "bar" : "foo")
1861
+ sheet[1,1] = (sheet[1,1].Value == "foo" ? "bar" : "foo")
1862
1862
  @new_value = sheet[1,1].Value
1863
1863
  @book.Saved.should be false
1864
1864
  end
@@ -1870,25 +1870,25 @@ describe Book do
1870
1870
 
1871
1871
  it "should raise an error, if :if_obstructed is :raise" do
1872
1872
  expect {
1873
- new_book = Book.open(@simple_file1, :if_obstructed => :raise)
1873
+ new_book = Workbook.open(@simple_file1, :if_obstructed => :raise)
1874
1874
  }.to raise_error(WorkbookBlocked, /blocked by a workbook with the same name in a different path/)
1875
1875
  end
1876
1876
 
1877
1877
  it "should close the other book and open the new book, if :if_obstructed is :forget" do
1878
- new_book = Book.open(@simple_file1, :if_obstructed => :forget)
1878
+ new_book = Workbook.open(@simple_file1, :if_obstructed => :forget)
1879
1879
  @book.should_not be_alive
1880
1880
  new_book.should be_alive
1881
1881
  new_book.filename.downcase.should == @simple_file.downcase
1882
- old_book = Book.open(@simple_file_other_path1, :if_obstructed => :forget)
1882
+ old_book = Workbook.open(@simple_file_other_path1, :if_obstructed => :forget)
1883
1883
  old_book.sheet(1)[1,1].Value.should == @old_value
1884
1884
  end
1885
1885
 
1886
1886
  it "should save the old book, close it, and open the new book, if :if_obstructed is :save" do
1887
- new_book = Book.open(@simple_file1, :if_obstructed => :save)
1887
+ new_book = Workbook.open(@simple_file1, :if_obstructed => :save)
1888
1888
  @book.should_not be_alive
1889
1889
  new_book.should be_alive
1890
1890
  new_book.filename.downcase.should == @simple_file1.downcase
1891
- old_book = Book.open(@simple_file_other_path1, :if_obstructed => :forget)
1891
+ old_book = Workbook.open(@simple_file_other_path1, :if_obstructed => :forget)
1892
1892
  old_book.sheet(1)[1,1].Value.should == @new_value
1893
1893
  #old_book.ole_workbook.Worksheets.Count.should == @sheet_count + 1
1894
1894
  old_book.close
@@ -1897,14 +1897,14 @@ describe Book do
1897
1897
  it "should raise an error, if the old book is unsaved, and close the old book and open the new book,
1898
1898
  if :if_obstructed is :close_if_saved" do
1899
1899
  expect{
1900
- new_book = Book.open(@simple_file1, :if_obstructed => :close_if_saved)
1900
+ new_book = Workbook.open(@simple_file1, :if_obstructed => :close_if_saved)
1901
1901
  }.to raise_error(WorkbookBlocked, /workbook with the same name in a different path is unsaved/)
1902
1902
  @book.save
1903
- new_book = Book.open(@simple_file1, :if_obstructed => :close_if_saved)
1903
+ new_book = Workbook.open(@simple_file1, :if_obstructed => :close_if_saved)
1904
1904
  @book.should_not be_alive
1905
1905
  new_book.should be_alive
1906
1906
  new_book.filename.downcase.should == @simple_file1.downcase
1907
- old_book = Book.open(@simple_file_other_path1, :if_obstructed => :forget)
1907
+ old_book = Workbook.open(@simple_file_other_path1, :if_obstructed => :forget)
1908
1908
  old_book.sheet(1)[1,1].Value.should == @new_value
1909
1909
  #old_book.ole_workbook.Worksheets.Count.should == @sheet_count + 1
1910
1910
  old_book.close
@@ -1912,12 +1912,12 @@ describe Book do
1912
1912
 
1913
1913
  it "should close the old book and open the new book, if :if_obstructed is :close_if_saved" do
1914
1914
  @book.close(:if_unsaved => :forget)
1915
- book = Book.open(@simple_file_other_path)
1916
- book2 = Book.open(@simple_file1, :if_obstructed => :close_if_saved)
1915
+ book = Workbook.open(@simple_file_other_path)
1916
+ book2 = Workbook.open(@simple_file1, :if_obstructed => :close_if_saved)
1917
1917
  end
1918
1918
 
1919
1919
  it "should open the book in a new excel instance, if :if_obstructed is :new_excel" do
1920
- new_book = Book.open(@simple_file1, :if_obstructed => :new_excel)
1920
+ new_book = Workbook.open(@simple_file1, :if_obstructed => :new_excel)
1921
1921
  @book.should be_alive
1922
1922
  @book.Saved.should be false
1923
1923
  @book.sheet(1)[1,1].Value.should == @new_value
@@ -1929,13 +1929,13 @@ describe Book do
1929
1929
 
1930
1930
  it "should raise an error, if :if_obstructed is default" do
1931
1931
  expect {
1932
- new_book = Book.open(@simple_file1)
1932
+ new_book = Workbook.open(@simple_file1)
1933
1933
  }.to raise_error(WorkbookBlocked, /blocked by a workbook with the same name in a different path/)
1934
1934
  end
1935
1935
 
1936
1936
  it "should raise an error, if :if_obstructed is invalid option" do
1937
1937
  expect {
1938
- new_book = Book.open(@simple_file1, :if_obstructed => :invalid_option)
1938
+ new_book = Workbook.open(@simple_file1, :if_obstructed => :invalid_option)
1939
1939
  }.to raise_error(OptionInvalid, ":if_obstructed: invalid option: :invalid_option")
1940
1940
  end
1941
1941
  end
@@ -1944,7 +1944,7 @@ describe Book do
1944
1944
 
1945
1945
  context "with an already saved book" do
1946
1946
  before do
1947
- @book = Book.open(@simple_file)
1947
+ @book = Workbook.open(@simple_file)
1948
1948
  end
1949
1949
 
1950
1950
  after do
@@ -1955,16 +1955,16 @@ describe Book do
1955
1955
  possible_options.each do |options_value|
1956
1956
  context "with :if_unsaved => #{options_value} and in the same and different path" do
1957
1957
  before do
1958
- @new_book = Book.open(@simple_file1, :reuse => true, :if_unsaved => options_value)
1959
- @different_book = Book.open(@different_file, :reuse => true, :if_unsaved => options_value)
1958
+ @new_book = Workbook.open(@simple_file1, :reuse => true, :if_unsaved => options_value)
1959
+ @different_book = Workbook.open(@different_file, :reuse => true, :if_unsaved => options_value)
1960
1960
  end
1961
1961
  after do
1962
1962
  @new_book.close
1963
1963
  @different_book.close
1964
1964
  end
1965
1965
  it "should open without problems " do
1966
- @new_book.should be_a Book
1967
- @different_book.should be_a Book
1966
+ @new_book.should be_a Workbook
1967
+ @different_book.should be_a Workbook
1968
1968
  end
1969
1969
  it "should belong to the same Excel instance" do
1970
1970
  @new_book.excel.should == @book.excel
@@ -1978,27 +1978,27 @@ describe Book do
1978
1978
 
1979
1979
  it "should raise error if filename is nil" do
1980
1980
  expect{
1981
- Book.open(@nonexisting)
1981
+ Workbook.open(@nonexisting)
1982
1982
  }.to raise_error(FileNameNotGiven, "filename is nil")
1983
1983
  end
1984
1984
 
1985
1985
  it "should raise error if file is a directory" do
1986
1986
  expect{
1987
- Book.open(@dir)
1987
+ Workbook.open(@dir)
1988
1988
  }.to raise_error(FileNotFound, "file #{General::absolute_path(@dir).gsub("/","\\").inspect} is a directory")
1989
1989
  end
1990
1990
 
1991
1991
  it "should raise error if file does not exist" do
1992
1992
  File.delete @simple_save_file rescue nil
1993
1993
  expect {
1994
- Book.open(@simple_save_file, :if_absent => :raise)
1994
+ Workbook.open(@simple_save_file, :if_absent => :raise)
1995
1995
  }.to raise_error(FileNotFound, "file #{General::absolute_path(@simple_save_file).gsub("/","\\").inspect} not found")
1996
1996
  end
1997
1997
 
1998
1998
  it "should create a workbook" do
1999
1999
  File.delete @simple_save_file rescue nil
2000
- book = Book.open(@simple_save_file, :if_absent => :create)
2001
- book.should be_a Book
2000
+ book = Workbook.open(@simple_save_file, :if_absent => :create)
2001
+ book.should be_a Workbook
2002
2002
  book.close
2003
2003
  File.exist?(@simple_save_file).should be true
2004
2004
  end
@@ -2006,7 +2006,7 @@ describe Book do
2006
2006
  it "should raise an exception by default" do
2007
2007
  File.delete @simple_save_file rescue nil
2008
2008
  expect {
2009
- Book.open(@simple_save_file)
2009
+ Workbook.open(@simple_save_file)
2010
2010
  }.to raise_error(FileNotFound, "file #{General::absolute_path(@simple_save_file).gsub("/","\\").inspect} not found")
2011
2011
  end
2012
2012
 
@@ -2015,7 +2015,7 @@ describe Book do
2015
2015
  context "with attr_reader excel" do
2016
2016
 
2017
2017
  before do
2018
- @new_book = Book.open(@simple_file)
2018
+ @new_book = Workbook.open(@simple_file)
2019
2019
  end
2020
2020
  after do
2021
2021
  @new_book.close
@@ -2032,25 +2032,25 @@ describe Book do
2032
2032
  context "with :update_links" do
2033
2033
 
2034
2034
  it "should set update_links to :alert" do
2035
- book = Book.open(@simple_file, :update_links => :alert)
2035
+ book = Workbook.open(@simple_file, :update_links => :alert)
2036
2036
  book.UpdateLinks.should == XlUpdateLinksUserSetting
2037
2037
  book.Saved.should be true
2038
2038
  end
2039
2039
 
2040
2040
  it "should set update_links to :never" do
2041
- book = Book.open(@simple_file, :update_links => :never)
2041
+ book = Workbook.open(@simple_file, :update_links => :never)
2042
2042
  book.UpdateLinks.should == XlUpdateLinksNever
2043
- book = Book.open(@simple_file, :update_links => :foo)
2043
+ book = Workbook.open(@simple_file, :update_links => :foo)
2044
2044
  book.UpdateLinks.should == XlUpdateLinksNever
2045
2045
  end
2046
2046
 
2047
2047
  it "should set update_links to :always" do
2048
- book = Book.open(@simple_file, :update_links => :always)
2048
+ book = Workbook.open(@simple_file, :update_links => :always)
2049
2049
  book.UpdateLinks.should == XlUpdateLinksAlways
2050
2050
  end
2051
2051
 
2052
2052
  it "should set update_links to :never per default" do
2053
- book = Book.open(@simple_file)
2053
+ book = Workbook.open(@simple_file)
2054
2054
  book.UpdateLinks.should == XlUpdateLinksNever
2055
2055
  end
2056
2056
 
@@ -2060,84 +2060,84 @@ describe Book do
2060
2060
  context "with :read_only" do
2061
2061
 
2062
2062
  it "should reopen the book with writable (unsaved changes from readonly will not be saved)" do
2063
- book = Book.open(@simple_file1, :read_only => true)
2063
+ book = Workbook.open(@simple_file1, :read_only => true)
2064
2064
  book.ReadOnly.should be true
2065
2065
  book.should be_alive
2066
2066
  sheet = book.sheet(1)
2067
- old_cell_value = sheet[1,1].value
2068
- sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
2067
+ old_cell_value = sheet[1,1].Value
2068
+ sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
2069
2069
  book.Saved.should be false
2070
- new_book = Book.open(@simple_file1, :read_only => false, :if_unsaved => :accept)
2070
+ new_book = Workbook.open(@simple_file1, :read_only => false, :if_unsaved => :accept)
2071
2071
  new_book.ReadOnly.should be false
2072
2072
  new_book.should be_alive
2073
2073
  book.should be_alive
2074
2074
  new_book.should == book
2075
2075
  new_sheet = new_book.sheet(1)
2076
- new_cell_value = new_sheet[1,1].value
2076
+ new_cell_value = new_sheet[1,1].Value
2077
2077
  new_cell_value.should == old_cell_value
2078
2078
  end
2079
2079
 
2080
2080
  it "should not raise an error when trying to reopen the book as read_only while the writable book had unsaved changes" do
2081
- book = Book.open(@simple_file1, :read_only => false)
2081
+ book = Workbook.open(@simple_file1, :read_only => false)
2082
2082
  book.ReadOnly.should be false
2083
2083
  book.should be_alive
2084
2084
  sheet = book.sheet(1)
2085
- old_cell_value = sheet[1,1].value
2086
- sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
2085
+ old_cell_value = sheet[1,1].Value
2086
+ sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
2087
2087
  book.Saved.should be false
2088
- new_book = Book.open(@simple_file1, :read_only => true, :if_unsaved => :accept)
2088
+ new_book = Workbook.open(@simple_file1, :read_only => true, :if_unsaved => :accept)
2089
2089
  new_book.ReadOnly.should be true
2090
2090
  new_book.Saved.should be true
2091
2091
  new_book.should == book
2092
2092
  end
2093
2093
 
2094
2094
  it "should reopen the book with writable in the same Excel instance (unsaved changes from readonly will not be saved)" do
2095
- book = Book.open(@simple_file1, :read_only => true)
2095
+ book = Workbook.open(@simple_file1, :read_only => true)
2096
2096
  book.ReadOnly.should be true
2097
2097
  book.should be_alive
2098
2098
  sheet = book.sheet(1)
2099
- old_cell_value = sheet[1,1].value
2100
- sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
2099
+ old_cell_value = sheet[1,1].Value
2100
+ sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
2101
2101
  book.Saved.should be false
2102
- new_book = Book.open(@simple_file1, :if_unsaved => :accept, :force => {:excel => book.excel}, :read_only => false)
2102
+ new_book = Workbook.open(@simple_file1, :if_unsaved => :accept, :force => {:excel => book.excel}, :read_only => false)
2103
2103
  new_book.ReadOnly.should be false
2104
2104
  new_book.should be_alive
2105
2105
  book.should be_alive
2106
2106
  new_book.should == book
2107
2107
  new_sheet = new_book.sheet(1)
2108
- new_cell_value = new_sheet[1,1].value
2108
+ new_cell_value = new_sheet[1,1].Value
2109
2109
  new_cell_value.should == old_cell_value
2110
2110
  end
2111
2111
 
2112
2112
  it "should reopen the book with readonly (unsaved changes of the writable should be saved)" do
2113
- book = Book.open(@simple_file1, :force => {:excel => :new}, :read_only => false)
2113
+ book = Workbook.open(@simple_file1, :force => {:excel => :new}, :read_only => false)
2114
2114
  book.ReadOnly.should be false
2115
2115
  book.should be_alive
2116
2116
  sheet = book.sheet(1)
2117
- old_cell_value = sheet[1,1].value
2118
- sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
2117
+ old_cell_value = sheet[1,1].Value
2118
+ sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
2119
2119
  book.Saved.should be false
2120
- new_book = Book.open(@simple_file1, :force => {:excel => book.excel}, :read_only => true, :if_unsaved => :accept)
2120
+ new_book = Workbook.open(@simple_file1, :force => {:excel => book.excel}, :read_only => true, :if_unsaved => :accept)
2121
2121
  new_book.ReadOnly.should be true
2122
2122
  new_book.Saved.should be true
2123
2123
  new_book.should == book
2124
2124
  new_sheet = new_book.sheet(1)
2125
- new_cell_value = new_sheet[1,1].value
2125
+ new_cell_value = new_sheet[1,1].Value
2126
2126
  new_cell_value.should_not == old_cell_value
2127
2127
  end
2128
2128
 
2129
2129
  it "should open the second book in another Excel as writable" do
2130
- book = Book.open(@simple_file1, :read_only => true)
2130
+ book = Workbook.open(@simple_file1, :read_only => true)
2131
2131
  book.ReadOnly.should be true
2132
- new_book = Book.open(@simple_file1, :force => {:excel => :new}, :read_only => false)
2132
+ new_book = Workbook.open(@simple_file1, :force => {:excel => :new}, :read_only => false)
2133
2133
  new_book.ReadOnly.should be false
2134
2134
  new_book.close
2135
2135
  book.close
2136
2136
  end
2137
2137
 
2138
2138
  it "should be able to save, if :read_only => false" do
2139
- book = Book.open(@simple_file1, :read_only => false)
2140
- book.should be_a Book
2139
+ book = Workbook.open(@simple_file1, :read_only => false)
2140
+ book.should be_a Workbook
2141
2141
  expect {
2142
2142
  book.save_as(@simple_save_file, :if_exists => :overwrite)
2143
2143
  }.to_not raise_error
@@ -2145,8 +2145,8 @@ describe Book do
2145
2145
  end
2146
2146
 
2147
2147
  it "should be able to save, if :read_only is default" do
2148
- book = Book.open(@simple_file1)
2149
- book.should be_a Book
2148
+ book = Workbook.open(@simple_file1)
2149
+ book.should be_a Workbook
2150
2150
  expect {
2151
2151
  book.save_as(@simple_save_file, :if_exists => :overwrite)
2152
2152
  }.to_not raise_error
@@ -2154,8 +2154,8 @@ describe Book do
2154
2154
  end
2155
2155
 
2156
2156
  it "should raise an error, if :read_only => true" do
2157
- book = Book.open(@simple_file, :read_only => true)
2158
- book.should be_a Book
2157
+ book = Workbook.open(@simple_file, :read_only => true)
2158
+ book.should be_a Workbook
2159
2159
  expect {
2160
2160
  book.save_as(@simple_save_file, :if_exists => :overwrite)
2161
2161
  }.to raise_error
@@ -2166,26 +2166,26 @@ describe Book do
2166
2166
  context "with various file formats" do
2167
2167
 
2168
2168
  it "should open linked workbook" do
2169
- book = Book.open(@linked_file, :visible => true)
2169
+ book = Workbook.open(@linked_file, :visible => true)
2170
2170
  book.close
2171
2171
  end
2172
2172
 
2173
2173
  #it "should open xlsm file" do
2174
- # book = Book.open(@simple_file_xlsm, :visible => true)
2174
+ # book = Workbook.open(@simple_file_xlsm, :visible => true)
2175
2175
  # book.close
2176
2176
  #end
2177
2177
 
2178
2178
  it "should open xlsx file" do
2179
- book = Book.open(@simple_file_xlsx, :visible => true)
2179
+ book = Workbook.open(@simple_file_xlsx, :visible => true)
2180
2180
  book.close
2181
2181
  end
2182
2182
  end
2183
2183
 
2184
2184
 
2185
2185
  context "with block" do
2186
- it 'block parameter should be instance of Book' do
2187
- Book.open(@simple_file) do |book|
2188
- book.should be_a Book
2186
+ it 'block parameter should be instance of Workbook' do
2187
+ Workbook.open(@simple_file) do |book|
2188
+ book.should be_a Workbook
2189
2189
  end
2190
2190
  end
2191
2191
  end
@@ -2195,7 +2195,7 @@ describe Book do
2195
2195
  path = '~/Abrakadabra.xlsx'
2196
2196
  expected_path = Regexp.new(File.expand_path(path).gsub(/\//, "."))
2197
2197
  expect {
2198
- Book.open(path)
2198
+ Workbook.open(path)
2199
2199
  }.to raise_error(FileNotFound, "file #{General::absolute_path(path).gsub("/","\\").inspect} not found")
2200
2200
  end
2201
2201
  end
@@ -2206,7 +2206,7 @@ describe Book do
2206
2206
  context "with standard" do
2207
2207
 
2208
2208
  before do
2209
- @book = Book.open(@simple_file)
2209
+ @book = Workbook.open(@simple_file)
2210
2210
  end
2211
2211
 
2212
2212
  after do
@@ -2219,7 +2219,7 @@ describe Book do
2219
2219
  @book.close
2220
2220
  @book.should_not be_alive
2221
2221
  @book.reopen
2222
- @book.should be_a Book
2222
+ @book.should be_a Workbook
2223
2223
  @book.should be_alive
2224
2224
  @book.should === book1
2225
2225
  end
@@ -2231,7 +2231,7 @@ describe Book do
2231
2231
  context "with standard" do
2232
2232
 
2233
2233
  before do
2234
- @book = Book.open(@simple_file)
2234
+ @book = Workbook.open(@simple_file)
2235
2235
  end
2236
2236
 
2237
2237
  after do
@@ -2240,8 +2240,8 @@ describe Book do
2240
2240
 
2241
2241
  it "should uplift a workbook to a book with an open book" do
2242
2242
  workbook = @book.ole_workbook
2243
- book1 = Book.new(workbook)
2244
- book1.should be_a Book
2243
+ book1 = Workbook.new(workbook)
2244
+ book1.should be_a Workbook
2245
2245
  book1.should be_alive
2246
2246
  book1.should == @book
2247
2247
  end