robust_excel_ole 0.5.1 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +13 -0
- data/README.rdoc +70 -21
- data/README_detail.rdoc +60 -27
- data/examples/edit_sheets/example_access_sheets_and_cells.rb +2 -2
- data/examples/edit_sheets/example_adding_sheets.rb +2 -2
- data/examples/edit_sheets/example_concating.rb +2 -3
- data/examples/edit_sheets/example_copying.rb +2 -3
- data/examples/edit_sheets/example_expanding.rb +2 -3
- data/examples/edit_sheets/example_naming.rb +2 -3
- data/examples/edit_sheets/example_ranges.rb +2 -2
- data/examples/edit_sheets/example_saving.rb +2 -3
- data/examples/open_save_close/example_control_to_excel.rb +3 -3
- data/examples/open_save_close/example_default_excel.rb +4 -4
- data/examples/open_save_close/example_force_excel.rb +2 -2
- data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +2 -2
- data/examples/open_save_close/example_if_obstructed_forget.rb +2 -2
- data/examples/open_save_close/example_if_obstructed_save.rb +2 -2
- data/examples/open_save_close/example_if_unsaved_accept.rb +2 -2
- data/examples/open_save_close/example_if_unsaved_forget.rb +2 -2
- data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -5
- data/examples/open_save_close/example_read_only.rb +2 -2
- data/examples/open_save_close/example_rename_cells.rb +3 -3
- data/examples/open_save_close/example_reuse.rb +2 -2
- data/examples/open_save_close/example_simple.rb +3 -4
- data/examples/open_save_close/example_unobtrusively.rb +2 -2
- data/lib/robust_excel_ole/book.rb +84 -78
- data/lib/robust_excel_ole/bookstore.rb +5 -1
- data/lib/robust_excel_ole/excel.rb +165 -188
- data/lib/robust_excel_ole/reo_common.rb +4 -0
- data/lib/robust_excel_ole/sheet.rb +15 -6
- data/lib/robust_excel_ole/version.rb +1 -1
- data/spec/book_spec.rb +104 -77
- data/spec/book_specs/book_close_spec.rb +9 -8
- data/spec/book_specs/book_misc_spec.rb +367 -26
- data/spec/book_specs/book_open_spec.rb +375 -94
- data/spec/book_specs/book_save_spec.rb +137 -112
- data/spec/book_specs/book_sheet_spec.rb +1 -1
- data/spec/book_specs/book_subclass_spec.rb +2 -1
- data/spec/book_specs/book_unobtr_spec.rb +87 -96
- data/spec/bookstore_spec.rb +8 -5
- data/spec/cell_spec.rb +1 -1
- data/spec/data/another_workbook.xls +0 -0
- data/spec/data/book_with_blank.xls +0 -0
- data/spec/data/workbook.xls +0 -0
- data/spec/excel_spec.rb +484 -72
- data/spec/range_spec.rb +1 -1
- data/spec/sheet_spec.rb +47 -1
- metadata +4 -5
@@ -18,6 +18,10 @@ module RobustExcelOle
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def workbook
|
22
|
+
book_class.new(self.Parent)
|
23
|
+
end
|
24
|
+
|
21
25
|
# returns name of the sheet
|
22
26
|
def name
|
23
27
|
@worksheet.Name
|
@@ -48,10 +52,15 @@ module RobustExcelOle
|
|
48
52
|
@cells[yx] = RobustExcelOle::Cell.new(@worksheet.Cells.Item(y, x))
|
49
53
|
else
|
50
54
|
name = p1
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
+
begin
|
56
|
+
nameval(name)
|
57
|
+
rescue SheetError
|
58
|
+
begin
|
59
|
+
book_class.new(self.Parent).nameval(name)
|
60
|
+
rescue ExcelError
|
61
|
+
rangeval(name)
|
62
|
+
end
|
63
|
+
end
|
55
64
|
end
|
56
65
|
end
|
57
66
|
|
@@ -67,7 +76,7 @@ module RobustExcelOle
|
|
67
76
|
set_nameval(name, value)
|
68
77
|
rescue SheetError
|
69
78
|
begin
|
70
|
-
|
79
|
+
workbook.set_nameval(name, value)
|
71
80
|
rescue ExcelError
|
72
81
|
set_rangeval(name, value)
|
73
82
|
end
|
@@ -145,7 +154,7 @@ module RobustExcelOle
|
|
145
154
|
raise SheetError, "cannot evaluate name #{name.inspect} in #{self.Name}"
|
146
155
|
end
|
147
156
|
end
|
148
|
-
if value == -2146826259
|
157
|
+
if value == RobustExcelOle::XlErrName # -2146826259
|
149
158
|
return opts[:default] if opts[:default]
|
150
159
|
raise SheetError, "cannot evaluate name #{name.inspect} in #{self.Name}"
|
151
160
|
end
|
data/spec/book_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe Book do
|
|
14
14
|
excel = Excel.new(:reuse => true)
|
15
15
|
open_books = excel == nil ? 0 : excel.Workbooks.Count
|
16
16
|
puts "*** open books *** : #{open_books}" if open_books > 0
|
17
|
-
Excel.
|
17
|
+
Excel.kill_all
|
18
18
|
end
|
19
19
|
|
20
20
|
before do
|
@@ -27,6 +27,8 @@ describe Book do
|
|
27
27
|
@linked_file = @dir + '/workbook_linked.xlsm'
|
28
28
|
@simple_file_xlsm = @dir + '/workbook.xls'
|
29
29
|
@simple_file_xlsx = @dir + '/workbook.xlsx'
|
30
|
+
@simple_file1 = @simple_file
|
31
|
+
@simple_file_other_path1 = @simple_file_other_path
|
30
32
|
end
|
31
33
|
|
32
34
|
after do
|
@@ -91,15 +93,16 @@ describe Book do
|
|
91
93
|
|
92
94
|
it "should yield an identical Book and set visible and displayalerts values" do
|
93
95
|
workbook = @book.ole_workbook
|
94
|
-
new_book = Book.new(workbook, :visible => true
|
96
|
+
new_book = Book.new(workbook, :visible => true)
|
97
|
+
new_book.excel.displayalerts = true
|
95
98
|
new_book.should be_a Book
|
96
99
|
new_book.should be_alive
|
97
100
|
new_book.should == @book
|
98
101
|
new_book.filename.should == @book.filename
|
99
102
|
new_book.excel.should == @book.excel
|
100
103
|
new_book.should === @book
|
101
|
-
new_book.excel.
|
102
|
-
new_book.excel.
|
104
|
+
new_book.excel.Visible.should be_true
|
105
|
+
new_book.excel.DisplayAlerts.should be_true
|
103
106
|
new_book.close
|
104
107
|
end
|
105
108
|
|
@@ -175,22 +178,22 @@ describe Book do
|
|
175
178
|
end
|
176
179
|
|
177
180
|
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
|
178
|
-
book2 = Book.open(@
|
181
|
+
book2 = Book.open(@simple_file1, :force_excel => :new)
|
179
182
|
book2.excel.should_not == @book.excel
|
180
|
-
book3 = Book.open(@
|
183
|
+
book3 = Book.open(@simple_file1, :force_excel => :new)
|
181
184
|
book3.excel.should_not == book2.excel
|
182
185
|
book3.excel.should_not == @book.excel
|
183
186
|
book2.close
|
184
187
|
book3.close
|
185
188
|
@book.close
|
186
|
-
book4 = Book.open(@
|
189
|
+
book4 = Book.open(@simple_file1, :force_excel => book2.excel, :read_only => true)
|
187
190
|
book4.should be_alive
|
188
191
|
book4.should be_a Book
|
189
192
|
book4.excel.should == book2.excel
|
190
193
|
book4.ReadOnly.should be_true
|
191
194
|
book4.should == book2
|
192
195
|
book4.close
|
193
|
-
book5 = Book.open(@
|
196
|
+
book5 = Book.open(@simple_file1, :force_excel => book2, :read_only => true)
|
194
197
|
book5.should be_alive
|
195
198
|
book5.should be_a Book
|
196
199
|
book5.excel.should == book2.excel
|
@@ -239,17 +242,18 @@ describe Book do
|
|
239
242
|
|
240
243
|
it "should open in a given Excel provided as Excel, Book, or WIN32OLE representing an Excel or Workbook" do
|
241
244
|
book2 = Book.open(@another_simple_file)
|
242
|
-
|
245
|
+
different_file1 = @different_file
|
246
|
+
book3 = Book.open(different_file1, :default_excel => book2.excel)
|
243
247
|
book3.excel.should === book2.excel
|
244
248
|
book3.close
|
245
|
-
book4 = Book.open(
|
249
|
+
book4 = Book.open(different_file1, :default_excel => book2)
|
246
250
|
book4.excel.should === book2.excel
|
247
251
|
book4.close
|
248
|
-
book5 = Book.open(
|
252
|
+
book5 = Book.open(different_file1, :default_excel => book2.ole_workbook)
|
249
253
|
book5.excel.should === book2.excel
|
250
254
|
book5.close
|
251
255
|
win32ole_excel1 = WIN32OLE.connect(book2.ole_workbook.Fullname).Application
|
252
|
-
book6 = Book.open(
|
256
|
+
book6 = Book.open(different_file1, :default_excel => win32ole_excel1)
|
253
257
|
book6.excel.should === book2.excel
|
254
258
|
book6.close
|
255
259
|
end
|
@@ -297,9 +301,9 @@ describe Book do
|
|
297
301
|
it "should open the new book and close the unsaved book, if user answers 'yes'" do
|
298
302
|
# "Yes" is the default. --> language independent
|
299
303
|
@key_sender.puts "{enter}"
|
300
|
-
@new_book = Book.open(@
|
304
|
+
@new_book = Book.open(@simple_file1, :if_unsaved => :alert)
|
301
305
|
@new_book.should be_alive
|
302
|
-
@new_book.filename.downcase.should == @
|
306
|
+
@new_book.filename.downcase.should == @simple_file1.downcase
|
303
307
|
@book.should_not be_alive
|
304
308
|
end
|
305
309
|
|
@@ -319,9 +323,9 @@ describe Book do
|
|
319
323
|
it "should open the new book and close the unsaved book, if user answers 'yes'" do
|
320
324
|
# "Yes" is the default. --> language independent
|
321
325
|
@key_sender.puts "{enter}"
|
322
|
-
@new_book = Book.open(@
|
326
|
+
@new_book = Book.open(@simple_file1, :if_unsaved => :excel)
|
323
327
|
@new_book.should be_alive
|
324
|
-
@new_book.filename.downcase.should == @
|
328
|
+
@new_book.filename.downcase.should == @simple_file1.downcase
|
325
329
|
@book.should_not be_alive
|
326
330
|
end
|
327
331
|
|
@@ -352,7 +356,7 @@ describe Book do
|
|
352
356
|
book_before = Book.open(@simple_file)
|
353
357
|
book_before.close
|
354
358
|
end
|
355
|
-
@book = Book.open(@
|
359
|
+
@book = Book.open(@simple_file_other_path1)
|
356
360
|
@sheet_count = @book.ole_workbook.Worksheets.Count
|
357
361
|
@sheet = @book.sheet(1)
|
358
362
|
@book.add_sheet(@sheet, :as => 'a_name')
|
@@ -364,11 +368,11 @@ describe Book do
|
|
364
368
|
end
|
365
369
|
|
366
370
|
it "should save the old book, close it, and open the new book, if :if_obstructed is :save" do
|
367
|
-
@new_book = Book.open(@
|
371
|
+
@new_book = Book.open(@simple_file1, :if_obstructed => :save)
|
368
372
|
@book.should_not be_alive
|
369
373
|
@new_book.should be_alive
|
370
|
-
@new_book.filename.downcase.should == @
|
371
|
-
old_book = Book.open(@
|
374
|
+
@new_book.filename.downcase.should == @simple_file1.downcase
|
375
|
+
old_book = Book.open(@simple_file_other_path1, :if_obstructed => :forget)
|
372
376
|
old_book.ole_workbook.Worksheets.Count.should == @sheet_count + 1
|
373
377
|
old_book.close
|
374
378
|
end
|
@@ -376,14 +380,14 @@ describe Book do
|
|
376
380
|
it "should raise an error, if the old book is unsaved, and close the old book and open the new book,
|
377
381
|
if :if_obstructed is :close_if_saved" do
|
378
382
|
expect{
|
379
|
-
@new_book = Book.open(@
|
383
|
+
@new_book = Book.open(@simple_file1, :if_obstructed => :close_if_saved)
|
380
384
|
}.to raise_error(ExcelErrorOpen, /workbook with the same name in a different path is unsaved/)
|
381
385
|
@book.save
|
382
|
-
@new_book = Book.open(@
|
386
|
+
@new_book = Book.open(@simple_file1, :if_obstructed => :close_if_saved)
|
383
387
|
@book.should_not be_alive
|
384
388
|
@new_book.should be_alive
|
385
|
-
@new_book.filename.downcase.should == @
|
386
|
-
old_book = Book.open(@
|
389
|
+
@new_book.filename.downcase.should == @simple_file1.downcase
|
390
|
+
old_book = Book.open(@simple_file_other_path1, :if_obstructed => :forget)
|
387
391
|
old_book.ole_workbook.Worksheets.Count.should == @sheet_count + 1
|
388
392
|
old_book.close
|
389
393
|
end
|
@@ -412,14 +416,14 @@ describe Book do
|
|
412
416
|
context "with :read_only" do
|
413
417
|
|
414
418
|
it "should reopen the book with writable (unsaved changes from readonly will not be saved)" do
|
415
|
-
book = Book.open(@
|
419
|
+
book = Book.open(@simple_file1, :read_only => true)
|
416
420
|
book.ReadOnly.should be_true
|
417
421
|
book.should be_alive
|
418
422
|
sheet = book.sheet(1)
|
419
423
|
old_cell_value = sheet[1,1].value
|
420
424
|
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
421
425
|
book.Saved.should be_false
|
422
|
-
new_book = Book.open(@
|
426
|
+
new_book = Book.open(@simple_file1, :read_only => false, :if_unsaved => :accept)
|
423
427
|
new_book.ReadOnly.should be_false
|
424
428
|
new_book.should be_alive
|
425
429
|
book.should be_alive
|
@@ -485,6 +489,52 @@ describe Book do
|
|
485
489
|
end
|
486
490
|
end
|
487
491
|
|
492
|
+
describe "visible" do
|
493
|
+
|
494
|
+
it "should preserve :visible if they are not set" do
|
495
|
+
excel1 = Excel.create(:visible => true)
|
496
|
+
book1 = Book.open(@simple_file)
|
497
|
+
book1.excel.Visible.should be_true
|
498
|
+
book1.close
|
499
|
+
end
|
500
|
+
|
501
|
+
it "should preserve :visible if they are not set" do
|
502
|
+
excel1 = Excel.create
|
503
|
+
book1 = Book.open(@simple_file, :visible => true)
|
504
|
+
book1.excel.Visible.should be_true
|
505
|
+
end
|
506
|
+
|
507
|
+
it "should preserve :visible if they are not set" do
|
508
|
+
excel1 = Excel.create(:visible => true)
|
509
|
+
book1 = Book.open(@different_file, :default_excel => :new)
|
510
|
+
book1.excel.Visible.should be_false
|
511
|
+
end
|
512
|
+
|
513
|
+
it "should preserve :visible if they are not set" do
|
514
|
+
excel1 = Excel.create(:visible => true)
|
515
|
+
excel2 = Excel.create(:visible => true)
|
516
|
+
book1 = Book.open(@different_file, :force_excel => excel2)
|
517
|
+
book1.excel.Visible.should be_true
|
518
|
+
book1.close
|
519
|
+
end
|
520
|
+
|
521
|
+
it "should let an open Book open" do
|
522
|
+
@book = Book.open(@simple_file, :visible => true)
|
523
|
+
Book.unobtrusively(@simple_file) do |book|
|
524
|
+
book.should be_a Book
|
525
|
+
book.should be_alive
|
526
|
+
book.excel.should == @book.excel
|
527
|
+
book.excel.Visible.should be_true
|
528
|
+
end
|
529
|
+
@book.should be_alive
|
530
|
+
@book.should be_a Book
|
531
|
+
@book.excel.Visible.should be_true
|
532
|
+
@book.close(:if_unsaved => :forget)
|
533
|
+
@book2.close(:if_unsaved => :forget) rescue nil
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
537
|
+
|
488
538
|
describe "unobtrusively" do
|
489
539
|
|
490
540
|
def unobtrusively_ok? # :nodoc: #
|
@@ -546,7 +596,7 @@ describe Book do
|
|
546
596
|
context "with an open book" do
|
547
597
|
|
548
598
|
before do
|
549
|
-
@book = Book.open(@
|
599
|
+
@book = Book.open(@simple_file1)
|
550
600
|
end
|
551
601
|
|
552
602
|
after do
|
@@ -559,7 +609,7 @@ describe Book do
|
|
559
609
|
@book.close
|
560
610
|
book2.close
|
561
611
|
@book.reopen
|
562
|
-
Book.unobtrusively(@
|
612
|
+
Book.unobtrusively(@simple_file1) do |book|
|
563
613
|
book.should be_a Book
|
564
614
|
book.should be_alive
|
565
615
|
book.excel.should == @book.excel
|
@@ -589,7 +639,7 @@ describe Book do
|
|
589
639
|
@book.should be_alive
|
590
640
|
@book.Saved.should be_false
|
591
641
|
@book.close(:if_unsaved => :forget)
|
592
|
-
@book2 = Book.open(@
|
642
|
+
@book2 = Book.open(@simple_file1)
|
593
643
|
sheet2 = @book2.sheet(1)
|
594
644
|
sheet2[1,1].value.should_not == old_cell_value
|
595
645
|
end
|
@@ -598,7 +648,7 @@ describe Book do
|
|
598
648
|
context "with a closed book" do
|
599
649
|
|
600
650
|
before do
|
601
|
-
@book = Book.open(@
|
651
|
+
@book = Book.open(@simple_file1)
|
602
652
|
end
|
603
653
|
|
604
654
|
after do
|
@@ -612,8 +662,8 @@ describe Book do
|
|
612
662
|
@book.should_not be_alive
|
613
663
|
unobtrusively_ok?
|
614
664
|
@book.should_not be_alive
|
615
|
-
|
616
|
-
sheet =
|
665
|
+
book2 = Book.open(@simple_file1)
|
666
|
+
sheet = book2.sheet(1)
|
617
667
|
sheet[1,1].Value.should_not == old_cell_value
|
618
668
|
end
|
619
669
|
|
@@ -624,7 +674,7 @@ describe Book do
|
|
624
674
|
old_cell_value = sheet[1,1].value
|
625
675
|
@book.close
|
626
676
|
@book.should_not be_alive
|
627
|
-
Book.unobtrusively(@
|
677
|
+
Book.unobtrusively(@simple_file1, :keep_open => true) do |book|
|
628
678
|
book.should be_a Book
|
629
679
|
book.excel.should == @book.excel
|
630
680
|
book.excel.should_not == excel
|
@@ -635,7 +685,7 @@ describe Book do
|
|
635
685
|
end
|
636
686
|
@book.should be_alive
|
637
687
|
@book.close
|
638
|
-
new_book = Book.open(@
|
688
|
+
new_book = Book.open(@simple_file1)
|
639
689
|
sheet = new_book.sheet(1)
|
640
690
|
sheet[1,1].value.should_not == old_cell_value
|
641
691
|
end
|
@@ -647,7 +697,7 @@ describe Book do
|
|
647
697
|
old_cell_value = sheet[1,1].value
|
648
698
|
@book.close
|
649
699
|
@book.should_not be_alive
|
650
|
-
Book.unobtrusively(@
|
700
|
+
Book.unobtrusively(@simple_file1, :hidden) do |book|
|
651
701
|
book.should be_a Book
|
652
702
|
book.should be_alive
|
653
703
|
book.excel.should_not == @book.excel
|
@@ -658,40 +708,17 @@ describe Book do
|
|
658
708
|
book.Saved.should be_false
|
659
709
|
end
|
660
710
|
@book.should_not be_alive
|
661
|
-
new_book = Book.open(@
|
711
|
+
new_book = Book.open(@simple_file1)
|
662
712
|
sheet = new_book.sheet(1)
|
663
713
|
sheet[1,1].value.should_not == old_cell_value
|
664
714
|
end
|
665
715
|
end
|
666
716
|
|
667
|
-
|
668
|
-
|
669
|
-
before do
|
670
|
-
@book = Book.open(@simple_file, :visible => true)
|
671
|
-
end
|
672
|
-
|
673
|
-
after do
|
674
|
-
@book.close(:if_unsaved => :forget)
|
675
|
-
@book2.close(:if_unsaved => :forget) rescue nil
|
676
|
-
end
|
677
|
-
|
678
|
-
it "should let an open Book open" do
|
679
|
-
Book.unobtrusively(@simple_file) do |book|
|
680
|
-
book.should be_a Book
|
681
|
-
book.should be_alive
|
682
|
-
book.excel.should == @book.excel
|
683
|
-
book.excel.Visible.should be_true
|
684
|
-
end
|
685
|
-
@book.should be_alive
|
686
|
-
@book.should be_a Book
|
687
|
-
@book.excel.Visible.should be_true
|
688
|
-
end
|
689
|
-
end
|
690
|
-
|
717
|
+
|
691
718
|
context "with a read_only book" do
|
692
719
|
|
693
720
|
before do
|
694
|
-
@book = Book.open(@
|
721
|
+
@book = Book.open(@simple_file1, :read_only => true)
|
695
722
|
end
|
696
723
|
|
697
724
|
after do
|
@@ -699,12 +726,12 @@ describe Book do
|
|
699
726
|
end
|
700
727
|
|
701
728
|
it "should open unobtrusively the book in a new Excel such that the book is writable" do
|
702
|
-
book2 = Book.open(@
|
729
|
+
book2 = Book.open(@simple_file1, :force_excel => :new, :read_only => true)
|
703
730
|
@book.ReadOnly.should be_true
|
704
731
|
book2.Readonly.should be_true
|
705
732
|
sheet = @book.sheet(1)
|
706
733
|
cell_value = sheet[1,1].value
|
707
|
-
Book.unobtrusively(@
|
734
|
+
Book.unobtrusively(@simple_file1, :hidden) do |book|
|
708
735
|
book.should be_a Book
|
709
736
|
book.excel.should_not == book2.excel
|
710
737
|
book.excel.should_not == @book.excel
|
@@ -717,7 +744,7 @@ describe Book do
|
|
717
744
|
@book.ReadOnly.should be_true
|
718
745
|
@book.close
|
719
746
|
book2.close
|
720
|
-
book3 = Book.open(@
|
747
|
+
book3 = Book.open(@simple_file1)
|
721
748
|
new_sheet = book3.sheet(1)
|
722
749
|
new_sheet[1,1].value.should_not == cell_value
|
723
750
|
book3.close
|
@@ -768,8 +795,8 @@ describe Book do
|
|
768
795
|
context "with several Excel instances" do
|
769
796
|
|
770
797
|
before do
|
771
|
-
@book1 = Book.open(@
|
772
|
-
@book2 = Book.open(@
|
798
|
+
@book1 = Book.open(@simple_file1)
|
799
|
+
@book2 = Book.open(@simple_file1, :force_excel => :new)
|
773
800
|
@book1.Readonly.should == false
|
774
801
|
@book2.Readonly.should == true
|
775
802
|
old_sheet = @book1.sheet(1)
|
@@ -790,7 +817,7 @@ describe Book do
|
|
790
817
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
791
818
|
book.Saved.should be_false
|
792
819
|
end
|
793
|
-
new_book = Book.open(@
|
820
|
+
new_book = Book.open(@simple_file1)
|
794
821
|
sheet = new_book.sheet(1)
|
795
822
|
sheet[1,1].value.should_not == @old_cell_value
|
796
823
|
end
|
@@ -805,7 +832,7 @@ describe Book do
|
|
805
832
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
806
833
|
book.Saved.should be_false
|
807
834
|
end
|
808
|
-
new_book = Book.open(@
|
835
|
+
new_book = Book.open(@simple_file1)
|
809
836
|
sheet = new_book.sheet(1)
|
810
837
|
sheet[1,1].Value.should_not == @old_cell_value
|
811
838
|
end
|
@@ -814,13 +841,13 @@ describe Book do
|
|
814
841
|
context "with :hidden" do
|
815
842
|
|
816
843
|
before do
|
817
|
-
@book1 = Book.open(@
|
844
|
+
@book1 = Book.open(@simple_file1)
|
818
845
|
@book1.close
|
819
846
|
end
|
820
847
|
|
821
848
|
it "should create a new hidden Excel instance and use this afterwards" do
|
822
849
|
hidden_excel = nil
|
823
|
-
Book.unobtrusively(@
|
850
|
+
Book.unobtrusively(@simple_file1, :hidden) do |book|
|
824
851
|
book.should be_a Book
|
825
852
|
book.should be_alive
|
826
853
|
book.excel.Visible.should be_false
|
@@ -843,7 +870,7 @@ describe Book do
|
|
843
870
|
context "open unobtrusively for reading and modifying" do
|
844
871
|
|
845
872
|
before do
|
846
|
-
@book = Book.open(@
|
873
|
+
@book = Book.open(@simple_file1)
|
847
874
|
sheet = @book.sheet(1)
|
848
875
|
@old_cell_value = sheet[1,1].value
|
849
876
|
@book.close
|
@@ -860,14 +887,14 @@ describe Book do
|
|
860
887
|
book.Saved.should be_false
|
861
888
|
book.excel.should == @book.excel
|
862
889
|
end
|
863
|
-
new_book = Book.open(@
|
890
|
+
new_book = Book.open(@simple_file1, :visible => true)
|
864
891
|
sheet = new_book.sheet(1)
|
865
892
|
sheet[1,1].Value.should == @old_cell_value
|
866
893
|
end
|
867
894
|
|
868
895
|
it "should not change the value and use the hidden Excel instance" do
|
869
896
|
new_excel = Excel.new(:reuse => false)
|
870
|
-
Book.for_reading(@
|
897
|
+
Book.for_reading(@simple_file1, :hidden) do |book|
|
871
898
|
sheet = book.sheet(1)
|
872
899
|
cell = sheet[1,1]
|
873
900
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
@@ -876,19 +903,19 @@ describe Book do
|
|
876
903
|
book.excel.visible.should be_false
|
877
904
|
book.excel.displayalerts.should be_false
|
878
905
|
end
|
879
|
-
new_book = Book.open(@
|
906
|
+
new_book = Book.open(@simple_file1, :visible => true)
|
880
907
|
sheet = new_book.sheet(1)
|
881
908
|
sheet[1,1].Value.should == @old_cell_value
|
882
909
|
end
|
883
910
|
|
884
911
|
it "should change the value" do
|
885
|
-
Book.for_modifying(@
|
912
|
+
Book.for_modifying(@simple_file1) do |book|
|
886
913
|
sheet = book.sheet(1)
|
887
914
|
cell = sheet[1,1]
|
888
915
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
889
916
|
book.excel.should == @book.excel
|
890
917
|
end
|
891
|
-
new_book = Book.open(@
|
918
|
+
new_book = Book.open(@simple_file1, :visible => true)
|
892
919
|
sheet = new_book.sheet(1)
|
893
920
|
sheet[1,1].Value.should_not == @old_cell_value
|
894
921
|
end
|
@@ -1050,7 +1077,7 @@ describe Book do
|
|
1050
1077
|
end
|
1051
1078
|
end
|
1052
1079
|
|
1053
|
-
describe "alive?, filename, ==,
|
1080
|
+
describe "alive?, filename, ==, activate, saved" do
|
1054
1081
|
|
1055
1082
|
context "with alive?" do
|
1056
1083
|
|