robust_excel_ole 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog +13 -0
- data/README.rdoc +107 -73
- data/{README_excel.rdoc → docs/README_excel.rdoc} +2 -0
- data/{README_open.rdoc → docs/README_open.rdoc} +12 -16
- data/{README_ranges.rdoc → docs/README_ranges.rdoc} +1 -1
- data/{README_save_close.rdoc → docs/README_save_close.rdoc} +0 -0
- data/{README_sheet.rdoc → docs/README_sheet.rdoc} +0 -0
- data/examples/open_save_close/example_control_to_excel.rb +3 -3
- data/examples/open_save_close/example_default_excel.rb +2 -2
- 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 +3 -3
- data/examples/open_save_close/example_if_unsaved_forget.rb +7 -3
- data/examples/open_save_close/example_if_unsaved_forget_more.rb +1 -1
- data/examples/open_save_close/example_read_only.rb +2 -2
- data/examples/open_save_close/example_rename_cells.rb +2 -2
- data/examples/open_save_close/example_reuse.rb +2 -2
- data/examples/open_save_close/example_simple.rb +1 -1
- data/examples/open_save_close/example_unobtrusively.rb +2 -2
- data/lib/robust_excel_ole/book.rb +75 -76
- data/lib/robust_excel_ole/bookstore.rb +9 -9
- data/lib/robust_excel_ole/excel.rb +5 -5
- data/lib/robust_excel_ole/general.rb +11 -4
- data/lib/robust_excel_ole/reo_common.rb +3 -0
- data/lib/robust_excel_ole/version.rb +1 -1
- data/robust_excel_ole.gemspec +2 -2
- data/spec/book_spec.rb +67 -63
- data/spec/book_specs/book_close_spec.rb +12 -10
- data/spec/book_specs/book_misc_spec.rb +279 -279
- data/spec/book_specs/book_open_spec.rb +258 -105
- data/spec/book_specs/book_save_spec.rb +28 -28
- data/spec/book_specs/book_unobtr_spec.rb +862 -164
- data/spec/bookstore_spec.rb +22 -22
- data/spec/data/another_workbook.xls +0 -0
- data/spec/data/different_workbook.xls +0 -0
- data/spec/data/workbook.xls +0 -0
- data/spec/excel_spec.rb +256 -254
- data/spec/general_spec.rb +7 -7
- data/spec/ruby1.8.6_rspec2.14/book_spec.rb +1421 -0
- data/spec/ruby1.8.6_rspec2.14/book_specs/book_all_spec.rb +22 -0
- data/spec/ruby1.8.6_rspec2.14/book_specs/book_close_spec.rb +252 -0
- data/spec/ruby1.8.6_rspec2.14/book_specs/book_misc_spec.rb +1070 -0
- data/spec/ruby1.8.6_rspec2.14/book_specs/book_open_spec.rb +1855 -0
- data/spec/ruby1.8.6_rspec2.14/book_specs/book_save_spec.rb +514 -0
- data/spec/ruby1.8.6_rspec2.14/book_specs/book_sheet_spec.rb +395 -0
- data/spec/ruby1.8.6_rspec2.14/book_specs/book_subclass_spec.rb +51 -0
- data/spec/ruby1.8.6_rspec2.14/book_specs/book_unobtr_spec.rb +1737 -0
- data/spec/ruby1.8.6_rspec2.14/bookstore_spec.rb +495 -0
- data/spec/ruby1.8.6_rspec2.14/cell_spec.rb +76 -0
- data/spec/ruby1.8.6_rspec2.14/cygwin_spec.rb +42 -0
- data/spec/ruby1.8.6_rspec2.14/excel_spec.rb +1820 -0
- data/spec/ruby1.8.6_rspec2.14/general_spec.rb +212 -0
- data/spec/ruby1.8.6_rspec2.14/range_spec.rb +131 -0
- data/spec/ruby1.8.6_rspec2.14/reo_common_spec.rb +130 -0
- data/spec/ruby1.8.6_rspec2.14/sheet_spec.rb +663 -0
- data/spec/ruby1.8.6_rspec2.14/spec_helper.rb +35 -0
- data/spec/sheet_spec.rb +2 -2
- metadata +28 -12
- data/README_detail.rdoc +0 -852
- data/README_development.rdoc +0 -5
@@ -32,12 +32,12 @@ module RobustExcelOle
|
|
32
32
|
@filename2books[filename_key] = weakref_books
|
33
33
|
weakref_books.each do |wr_book|
|
34
34
|
if (not wr_book.weakref_alive?)
|
35
|
-
trace "warn: this should never happen"
|
35
|
+
#trace "warn: this should never happen"
|
36
36
|
begin
|
37
37
|
@filename2books[filename_key].delete(wr_book)
|
38
38
|
rescue
|
39
|
-
trace "#{$!.message}"
|
40
|
-
trace "Warning: deleting dead reference failed: file: #{filename.inspect}"
|
39
|
+
#trace "#{$!.message}"
|
40
|
+
#trace "Warning: deleting dead reference failed: file: #{filename.inspect}"
|
41
41
|
end
|
42
42
|
else
|
43
43
|
book = wr_book.__getobj__
|
@@ -104,19 +104,19 @@ module RobustExcelOle
|
|
104
104
|
|
105
105
|
# prints the book store
|
106
106
|
def print # :nodoc: #
|
107
|
-
trace "@filename2books:"
|
107
|
+
#trace "@filename2books:"
|
108
108
|
if @filename2books
|
109
109
|
@filename2books.each do |filename,books|
|
110
|
-
trace " filename: #{filename}"
|
111
|
-
trace " books:"
|
110
|
+
#trace " filename: #{filename}"
|
111
|
+
#trace " books:"
|
112
112
|
if books.empty?
|
113
|
-
trace " []"
|
113
|
+
#trace " []"
|
114
114
|
else
|
115
115
|
books.each do |book|
|
116
116
|
if book.weakref_alive?
|
117
|
-
trace "#{book}"
|
117
|
+
#trace "#{book}"
|
118
118
|
else # this should never happen
|
119
|
-
trace "weakref not alive"
|
119
|
+
#trace "weakref not alive"
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
@@ -482,12 +482,12 @@ module RobustExcelOle
|
|
482
482
|
begin
|
483
483
|
empty_workbook.SaveAs(filename)
|
484
484
|
rescue WIN32OLERuntimeError => msg
|
485
|
-
if msg.message =~ /SaveAs/ and msg.message =~ /Workbook/ then
|
485
|
+
#if msg.message =~ /SaveAs/ and msg.message =~ /Workbook/ then
|
486
486
|
raise FileNotFound, "could not save workbook with filename #{file_name.inspect}"
|
487
|
-
else
|
488
|
-
|
489
|
-
|
490
|
-
end
|
487
|
+
#else
|
488
|
+
# # todo some time: find out when this occurs :
|
489
|
+
# raise UnexpectedREOError, "unknown WIN32OLERuntimeError with filename #{file_name.inspect}: \n#{msg.message}"
|
490
|
+
#end
|
491
491
|
end
|
492
492
|
end
|
493
493
|
empty_workbook
|
@@ -107,13 +107,20 @@ end
|
|
107
107
|
|
108
108
|
module MethodHelpers
|
109
109
|
|
110
|
-
def respond_to?(meth_name, include_private = false) # :nodoc: #
|
111
|
-
|
112
|
-
|
110
|
+
def respond_to?(meth_name, include_private = false) # :nodoc: #
|
111
|
+
if alive?
|
112
|
+
methods.include?(meth_name.to_s)
|
113
|
+
else
|
114
|
+
super
|
115
|
+
end
|
113
116
|
end
|
114
117
|
|
115
118
|
def methods # :nodoc: #
|
116
|
-
|
119
|
+
if alive?
|
120
|
+
(super.map{|m| m.to_s} + ole_object.ole_methods.map{|m| m.to_s}).uniq.select{|m| m =~ /^(?!\_)/}.sort
|
121
|
+
else
|
122
|
+
super
|
123
|
+
end
|
117
124
|
end
|
118
125
|
|
119
126
|
end
|
data/robust_excel_ole.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = ["Thomas.Raths@gmx.net"]
|
10
10
|
s.homepage = "https://github.com/Thomas008/robust_excel_ole"
|
11
11
|
|
12
|
-
s.summary = "RobustExcelOle automates processing Excel
|
13
|
-
s.description = "RobustExcelOle automates
|
12
|
+
s.summary = "RobustExcelOle automates processing Excel workbooks in Windows by using the win32ole library."
|
13
|
+
s.description = "RobustExcelOle automates reading and writing Excel workbooks in Windows by using the win32ole library.
|
14
14
|
It is disigned to cope with several kinds of concurrency of both simultaneously running
|
15
15
|
Excel instances and simultanously happening user interactions.
|
16
16
|
RobustExcelOle deals with various cases of Excel (and user) behaviour,
|
data/spec/book_spec.rb
CHANGED
@@ -79,7 +79,7 @@ describe Book do
|
|
79
79
|
it "should save to 'simple_save_file.xls'" do
|
80
80
|
book = Book.open(@simple_file1)
|
81
81
|
Book.save_as(@simple_file1, @simple_save_file1, :if_exists => :overwrite)
|
82
|
-
File.exist?(@simple_save_file1).should
|
82
|
+
File.exist?(@simple_save_file1).should be true
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -122,7 +122,7 @@ describe Book do
|
|
122
122
|
excel.Workbooks.Count.should == 0
|
123
123
|
book.ole_workbook.should == nil
|
124
124
|
book.should_not be_alive
|
125
|
-
expect{ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
|
125
|
+
#expect{ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
|
126
126
|
new_book = Book.open(@simple_file1)
|
127
127
|
begin
|
128
128
|
new_book.ole_workbook.Worksheets.Count.should == sheet_count + 1
|
@@ -159,8 +159,8 @@ describe Book do
|
|
159
159
|
book2.should be_a Book
|
160
160
|
book2.excel.should_not == @book.excel
|
161
161
|
book2.should_not == @book
|
162
|
-
@book.Readonly.should
|
163
|
-
book2.Readonly.should
|
162
|
+
@book.Readonly.should be false
|
163
|
+
book2.Readonly.should be true
|
164
164
|
book2.close
|
165
165
|
end
|
166
166
|
end
|
@@ -185,8 +185,8 @@ describe Book do
|
|
185
185
|
new_book.filename.should == @book.filename
|
186
186
|
new_book.excel.should == @book.excel
|
187
187
|
new_book.should === @book
|
188
|
-
new_book.excel.Visible.should
|
189
|
-
new_book.excel.DisplayAlerts.should
|
188
|
+
new_book.excel.Visible.should be true
|
189
|
+
new_book.excel.DisplayAlerts.should be true
|
190
190
|
new_book.close
|
191
191
|
end
|
192
192
|
|
@@ -256,8 +256,8 @@ describe Book do
|
|
256
256
|
book2.should be_a Book
|
257
257
|
book2.excel.should_not == @book.excel
|
258
258
|
book2.should_not == @book
|
259
|
-
@book.Readonly.should
|
260
|
-
book2.Readonly.should
|
259
|
+
@book.Readonly.should be false
|
260
|
+
book2.Readonly.should be true
|
261
261
|
book2.close
|
262
262
|
end
|
263
263
|
|
@@ -274,14 +274,14 @@ describe Book do
|
|
274
274
|
book4.should be_alive
|
275
275
|
book4.should be_a Book
|
276
276
|
book4.excel.should == book2.excel
|
277
|
-
book4.ReadOnly.should
|
277
|
+
book4.ReadOnly.should be true
|
278
278
|
book4.should == book2
|
279
279
|
book4.close
|
280
280
|
book5 = Book.open(@simple_file1, :force => {:excel => book2}, :read_only => true)
|
281
281
|
book5.should be_alive
|
282
282
|
book5.should be_a Book
|
283
283
|
book5.excel.should == book2.excel
|
284
|
-
book5.ReadOnly.should
|
284
|
+
book5.ReadOnly.should be true
|
285
285
|
book5.should == book2
|
286
286
|
book5.close
|
287
287
|
book3.close
|
@@ -410,7 +410,7 @@ describe Book do
|
|
410
410
|
@new_book = Book.open(@simple_file1, :if_unsaved => :excel)
|
411
411
|
@new_book.should be_alive
|
412
412
|
@new_book.filename.downcase.should == @simple_file1.downcase
|
413
|
-
|
413
|
+
#@book.should_not be_alive
|
414
414
|
end
|
415
415
|
|
416
416
|
it "should not open the new book and not close the unsaved book, if user answers 'no'" do
|
@@ -486,7 +486,7 @@ describe Book do
|
|
486
486
|
book = Book.open(@simple_save_file, :if_absent => :create)
|
487
487
|
book.should be_a Book
|
488
488
|
book.close
|
489
|
-
File.exist?(@simple_save_file).should
|
489
|
+
File.exist?(@simple_save_file).should be true
|
490
490
|
end
|
491
491
|
|
492
492
|
it "should raise an exception by default" do
|
@@ -501,14 +501,14 @@ describe Book do
|
|
501
501
|
|
502
502
|
it "should reopen the book with writable (unsaved changes from readonly will not be saved)" do
|
503
503
|
book = Book.open(@simple_file1, :read_only => true)
|
504
|
-
book.ReadOnly.should
|
504
|
+
book.ReadOnly.should be true
|
505
505
|
book.should be_alive
|
506
506
|
sheet = book.sheet(1)
|
507
507
|
old_cell_value = sheet[1,1].value
|
508
508
|
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
509
|
-
book.Saved.should
|
509
|
+
book.Saved.should be false
|
510
510
|
new_book = Book.open(@simple_file1, :read_only => false, :if_unsaved => :accept)
|
511
|
-
new_book.ReadOnly.should
|
511
|
+
new_book.ReadOnly.should be false
|
512
512
|
new_book.should be_alive
|
513
513
|
book.should be_alive
|
514
514
|
new_book.should == book
|
@@ -578,27 +578,27 @@ describe Book do
|
|
578
578
|
it "should preserve :visible if they are not set" do
|
579
579
|
excel1 = Excel.create(:visible => true)
|
580
580
|
book1 = Book.open(@simple_file)
|
581
|
-
book1.excel.Visible.should
|
581
|
+
book1.excel.Visible.should be true
|
582
582
|
book1.close
|
583
583
|
end
|
584
584
|
|
585
585
|
it "should preserve :visible if they are not set" do
|
586
586
|
excel1 = Excel.create
|
587
587
|
book1 = Book.open(@simple_file, :visible => true)
|
588
|
-
book1.excel.Visible.should
|
588
|
+
book1.excel.Visible.should be true
|
589
589
|
end
|
590
590
|
|
591
591
|
it "should preserve :visible if they are not set" do
|
592
592
|
excel1 = Excel.create(:visible => true)
|
593
593
|
book1 = Book.open(@different_file, :default => {:excel => :new})
|
594
|
-
book1.excel.Visible.should
|
594
|
+
book1.excel.Visible.should be false
|
595
595
|
end
|
596
596
|
|
597
597
|
it "should preserve :visible if they are not set" do
|
598
598
|
excel1 = Excel.create(:visible => true)
|
599
599
|
excel2 = Excel.create(:visible => true)
|
600
600
|
book1 = Book.open(@different_file, :force => {:excel => excel2})
|
601
|
-
book1.excel.Visible.should
|
601
|
+
book1.excel.Visible.should be true
|
602
602
|
book1.close
|
603
603
|
end
|
604
604
|
|
@@ -608,11 +608,11 @@ describe Book do
|
|
608
608
|
book.should be_a Book
|
609
609
|
book.should be_alive
|
610
610
|
book.excel.should == @book.excel
|
611
|
-
book.excel.Visible.should
|
611
|
+
book.excel.Visible.should be true
|
612
612
|
end
|
613
613
|
@book.should be_alive
|
614
614
|
@book.should be_a Book
|
615
|
-
@book.excel.Visible.should
|
615
|
+
@book.excel.Visible.should be true
|
616
616
|
@book.close(:if_unsaved => :forget)
|
617
617
|
@book2.close(:if_unsaved => :forget) rescue nil
|
618
618
|
end
|
@@ -627,7 +627,7 @@ describe Book do
|
|
627
627
|
sheet = book.sheet(1)
|
628
628
|
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
629
629
|
book.should be_alive
|
630
|
-
book.Saved.should
|
630
|
+
book.Saved.should be false
|
631
631
|
end
|
632
632
|
end
|
633
633
|
|
@@ -703,12 +703,12 @@ describe Book do
|
|
703
703
|
end
|
704
704
|
|
705
705
|
it "should let a saved book saved" do
|
706
|
-
@book.Saved.should
|
706
|
+
@book.Saved.should be true
|
707
707
|
@book.should be_alive
|
708
708
|
sheet = @book.sheet(1)
|
709
709
|
old_cell_value = sheet[1,1].value
|
710
710
|
unobtrusively_ok?
|
711
|
-
@book.Saved.should
|
711
|
+
@book.Saved.should be true
|
712
712
|
@book.should be_alive
|
713
713
|
sheet = @book.sheet(1)
|
714
714
|
sheet[1,1].value.should_not == old_cell_value
|
@@ -718,10 +718,10 @@ describe Book do
|
|
718
718
|
sheet = @book.sheet(1)
|
719
719
|
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
720
720
|
old_cell_value = sheet[1,1].value
|
721
|
-
@book.Saved.should
|
721
|
+
@book.Saved.should be false
|
722
722
|
unobtrusively_ok?
|
723
723
|
@book.should be_alive
|
724
|
-
@book.Saved.should
|
724
|
+
@book.Saved.should be false
|
725
725
|
@book.close(:if_unsaved => :forget)
|
726
726
|
@book2 = Book.open(@simple_file1)
|
727
727
|
sheet2 = @book2.sheet(1)
|
@@ -765,7 +765,7 @@ describe Book do
|
|
765
765
|
sheet = book.sheet(1)
|
766
766
|
cell = sheet[1,1]
|
767
767
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
768
|
-
book.Saved.should
|
768
|
+
book.Saved.should be false
|
769
769
|
end
|
770
770
|
@book.should be_alive
|
771
771
|
@book.close
|
@@ -788,7 +788,7 @@ describe Book do
|
|
788
788
|
sheet = book.sheet(1)
|
789
789
|
cell = sheet[1,1]
|
790
790
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
791
|
-
book.Saved.should
|
791
|
+
book.Saved.should be false
|
792
792
|
end
|
793
793
|
@book.should_not be_alive
|
794
794
|
new_book = Book.open(@simple_file1)
|
@@ -810,21 +810,21 @@ describe Book do
|
|
810
810
|
|
811
811
|
it "should open unobtrusively the book in a new Excel such that the book is writable" do
|
812
812
|
book2 = Book.open(@simple_file1, :force => {:excel => :new}, :read_only => true)
|
813
|
-
@book.ReadOnly.should
|
814
|
-
book2.Readonly.should
|
813
|
+
@book.ReadOnly.should be true
|
814
|
+
book2.Readonly.should be true
|
815
815
|
sheet = @book.sheet(1)
|
816
816
|
cell_value = sheet[1,1].value
|
817
|
-
Book.unobtrusively(@simple_file1, :if_closed => :current) do |book|
|
817
|
+
Book.unobtrusively(@simple_file1, :rw_change_excel => :new, :if_closed => :current, :writable => true) do |book|
|
818
818
|
book.should be_a Book
|
819
819
|
book.excel.should_not == book2.excel
|
820
820
|
book.excel.should_not == @book.excel
|
821
821
|
sheet = book.sheet(1)
|
822
822
|
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
823
823
|
book.should be_alive
|
824
|
-
book.Saved.should
|
824
|
+
book.Saved.should be false
|
825
825
|
end
|
826
|
-
@book.Saved.should
|
827
|
-
@book.ReadOnly.should
|
826
|
+
@book.Saved.should be true
|
827
|
+
@book.ReadOnly.should be true
|
828
828
|
@book.close
|
829
829
|
book2.close
|
830
830
|
book3 = Book.open(@simple_file1)
|
@@ -869,7 +869,7 @@ describe Book do
|
|
869
869
|
it "should yield the block result true" do
|
870
870
|
result =
|
871
871
|
Book.unobtrusively(@simple_file) do |book|
|
872
|
-
@book1.Saved.should
|
872
|
+
@book1.Saved.should be true
|
873
873
|
end
|
874
874
|
result.should == true
|
875
875
|
end
|
@@ -898,7 +898,7 @@ describe Book do
|
|
898
898
|
sheet = book.sheet(1)
|
899
899
|
cell = sheet[1,1]
|
900
900
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
901
|
-
book.Saved.should
|
901
|
+
book.Saved.should be false
|
902
902
|
end
|
903
903
|
new_book = Book.open(@simple_file1)
|
904
904
|
sheet = new_book.sheet(1)
|
@@ -913,7 +913,7 @@ describe Book do
|
|
913
913
|
sheet = book.sheet(1)
|
914
914
|
cell = sheet[1,1]
|
915
915
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
916
|
-
book.Saved.should
|
916
|
+
book.Saved.should be false
|
917
917
|
end
|
918
918
|
new_book = Book.open(@simple_file1)
|
919
919
|
sheet = new_book.sheet(1)
|
@@ -935,15 +935,15 @@ describe Book do
|
|
935
935
|
Book.unobtrusively(@simple_file1, :hidden) do |book|
|
936
936
|
book.should be_a Book
|
937
937
|
book.should be_alive
|
938
|
-
book.excel.Visible.should
|
939
|
-
book.excel.DisplayAlerts.should
|
938
|
+
book.excel.Visible.should be false
|
939
|
+
book.excel.DisplayAlerts.should be false
|
940
940
|
hidden_excel = book.excel
|
941
941
|
end
|
942
942
|
Book.unobtrusively(@different_file, :hidden) do |book|
|
943
943
|
book.should be_a Book
|
944
944
|
book.should be_alive
|
945
|
-
book.excel.Visible.should
|
946
|
-
book.excel.DisplayAlerts.should
|
945
|
+
book.excel.Visible.should be false
|
946
|
+
book.excel.DisplayAlerts.should be false
|
947
947
|
book.excel.should == hidden_excel
|
948
948
|
end
|
949
949
|
end
|
@@ -966,11 +966,11 @@ describe Book do
|
|
966
966
|
Book.for_reading(@simple_file) do |book|
|
967
967
|
book.should be_a Book
|
968
968
|
book.should be_alive
|
969
|
-
book.Saved.should
|
969
|
+
book.Saved.should be true
|
970
970
|
sheet = book.sheet(1)
|
971
971
|
cell = sheet[1,1]
|
972
972
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
973
|
-
book.Saved.should
|
973
|
+
book.Saved.should be false
|
974
974
|
book.excel.should == @book.excel
|
975
975
|
end
|
976
976
|
new_book = Book.open(@simple_file1, :visible => true)
|
@@ -987,7 +987,7 @@ describe Book do
|
|
987
987
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
988
988
|
book.excel.should_not == @book.excel
|
989
989
|
book.excel.should_not == new_excel
|
990
|
-
book.excel.visible.should
|
990
|
+
book.excel.visible.should be false
|
991
991
|
book.excel.displayalerts.should == :if_visible
|
992
992
|
end
|
993
993
|
new_book = Book.open(@simple_file1, :visible => true)
|
@@ -1021,7 +1021,7 @@ describe Book do
|
|
1021
1021
|
end
|
1022
1022
|
|
1023
1023
|
it "should send Saved to workbook" do
|
1024
|
-
@book.Saved.should
|
1024
|
+
@book.Saved.should be true
|
1025
1025
|
end
|
1026
1026
|
end
|
1027
1027
|
end
|
@@ -1123,8 +1123,8 @@ describe Book do
|
|
1123
1123
|
excel.Workbooks.Count.should == 0
|
1124
1124
|
@book.ole_workbook.should == nil
|
1125
1125
|
@book.should_not be_alive
|
1126
|
-
expect{
|
1127
|
-
|
1126
|
+
#expect{
|
1127
|
+
# ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
|
1128
1128
|
new_book = Book.open(@simple_file)
|
1129
1129
|
begin
|
1130
1130
|
new_book.ole_workbook.Worksheets.Count.should == @sheet_count + 1
|
@@ -1159,7 +1159,7 @@ describe Book do
|
|
1159
1159
|
end
|
1160
1160
|
|
1161
1161
|
it "should save to 'simple_save_file.xlsx'" do
|
1162
|
-
File.exist?(@simple_save_file).should
|
1162
|
+
File.exist?(@simple_save_file).should be true
|
1163
1163
|
end
|
1164
1164
|
end
|
1165
1165
|
end
|
@@ -1233,7 +1233,10 @@ describe Book do
|
|
1233
1233
|
@book2.close(:if_unsaved => :forget)
|
1234
1234
|
@key_sender.close
|
1235
1235
|
end
|
1236
|
+
end
|
1237
|
+
end
|
1236
1238
|
|
1239
|
+
=begin
|
1237
1240
|
it "should bring a book to focus" do
|
1238
1241
|
sheet = @book.sheet(2)
|
1239
1242
|
sheet.Activate
|
@@ -1246,8 +1249,8 @@ describe Book do
|
|
1246
1249
|
sleep 0.2
|
1247
1250
|
sheet2[3,2].Value.should == "a"
|
1248
1251
|
@book.focus
|
1249
|
-
@book.Windows(1).Visible.should
|
1250
|
-
@book.Windows(@book.Name).Visible.should
|
1252
|
+
@book.Windows(1).Visible.should be true
|
1253
|
+
@book.Windows(@book.Name).Visible.should be true
|
1251
1254
|
@key_sender.puts "{a}{enter}"
|
1252
1255
|
sleep 0.2
|
1253
1256
|
sheet[2,3].Value.should == "a"
|
@@ -1255,6 +1258,7 @@ describe Book do
|
|
1255
1258
|
end
|
1256
1259
|
end
|
1257
1260
|
end
|
1261
|
+
=end
|
1258
1262
|
|
1259
1263
|
describe "#add_sheet" do
|
1260
1264
|
before do
|
@@ -1366,24 +1370,24 @@ describe Book do
|
|
1366
1370
|
it "should keep the save state 'unsaved'" do
|
1367
1371
|
sheet = @book.sheet(1)
|
1368
1372
|
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
1369
|
-
@book.Saved.should
|
1373
|
+
@book.Saved.should be false
|
1370
1374
|
@book.retain_saved do
|
1371
1375
|
sheet = @book.sheet(1)
|
1372
1376
|
a = sheet[1,1]
|
1373
1377
|
b = @book.visible
|
1374
1378
|
end
|
1375
|
-
@book.Saved.should
|
1379
|
+
@book.Saved.should be false
|
1376
1380
|
end
|
1377
1381
|
|
1378
1382
|
it "should keep the save state 'unsaved' even when the workbook was saved before" do
|
1379
1383
|
sheet = @book.sheet(1)
|
1380
1384
|
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
1381
|
-
@book.Saved.should
|
1385
|
+
@book.Saved.should be false
|
1382
1386
|
@book.retain_saved do
|
1383
1387
|
@book.save
|
1384
|
-
@book.Saved.should
|
1388
|
+
@book.Saved.should be true
|
1385
1389
|
end
|
1386
|
-
@book.Saved.should
|
1390
|
+
@book.Saved.should be false
|
1387
1391
|
end
|
1388
1392
|
end
|
1389
1393
|
|
@@ -1392,18 +1396,18 @@ describe Book do
|
|
1392
1396
|
|
1393
1397
|
it "should keep the save status" do
|
1394
1398
|
book1 = Book.open(@simple_file, :visible => true)
|
1395
|
-
book1.Saved.should
|
1399
|
+
book1.Saved.should be true
|
1396
1400
|
book2 = Book.open(@another_simple_file, :visible => true)
|
1397
|
-
book1.Saved.should
|
1398
|
-
book2.Saved.should
|
1401
|
+
book1.Saved.should be true
|
1402
|
+
book2.Saved.should be true
|
1399
1403
|
sheet2 = book2.sheet(1)
|
1400
1404
|
sheet2[1,1] = sheet2[1,1].value == "foo" ? "bar" : "foo"
|
1401
|
-
book1.Saved.should
|
1402
|
-
book2.Saved.should
|
1405
|
+
book1.Saved.should be true
|
1406
|
+
book2.Saved.should be false
|
1403
1407
|
book3 = Book.open(@different_file, :visible => true)
|
1404
|
-
book1.Saved.should
|
1405
|
-
book2.Saved.should
|
1406
|
-
book3.Saved.should
|
1408
|
+
book1.Saved.should be true
|
1409
|
+
book2.Saved.should be false
|
1410
|
+
book3.Saved.should be true
|
1407
1411
|
end
|
1408
1412
|
end
|
1409
1413
|
=end
|