robust_excel_ole 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +12 -1
- data/README.rdoc +114 -276
- data/README_detail.rdoc +31 -14
- data/lib/robust_excel_ole/book.rb +89 -113
- data/lib/robust_excel_ole/excel.rb +38 -10
- data/lib/robust_excel_ole/sheet.rb +2 -2
- data/lib/robust_excel_ole/version.rb +1 -1
- data/spec/book_spec.rb +23 -20
- data/spec/book_specs/book_misc_spec.rb +6 -12
- data/spec/book_specs/book_open_spec.rb +22 -63
- data/spec/book_specs/book_unobtr_spec.rb +174 -231
- data/spec/data/another_workbook.xls +0 -0
- data/spec/data/different_workbook.xls +0 -0
- data/spec/data/more_data/workbook.xls +0 -0
- data/spec/data/workbook.xls +0 -0
- data/spec/excel_spec.rb +32 -5
- metadata +4 -4
@@ -176,7 +176,7 @@ module RobustExcelOle
|
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
|
-
# returns the contents of a range with a defined
|
179
|
+
# returns the contents of a range with a locally defined name
|
180
180
|
# evaluates the formula if the contents is a formula
|
181
181
|
# if no contents could be returned, then return default value, if provided, raise error otherwise
|
182
182
|
# @param [String] name the name of a range
|
@@ -200,7 +200,7 @@ module RobustExcelOle
|
|
200
200
|
value
|
201
201
|
end
|
202
202
|
|
203
|
-
# assigns a value to a range given a defined
|
203
|
+
# assigns a value to a range given a locally defined name
|
204
204
|
# @param [String] name the name of a range
|
205
205
|
# @param [Variant] value the assigned value
|
206
206
|
def set_rangeval(name,value)
|
data/spec/book_spec.rb
CHANGED
@@ -314,9 +314,9 @@ describe Book do
|
|
314
314
|
@key_sender.puts "{right}{enter}"
|
315
315
|
@key_sender.puts "{right}{enter}"
|
316
316
|
@key_sender.puts "{right}{enter}"
|
317
|
-
expect{
|
318
|
-
|
319
|
-
|
317
|
+
#expect{
|
318
|
+
# Book.open(@simple_file, :if_unsaved => :alert)
|
319
|
+
# }.to raise_error(ExcelError, /user canceled or runtime error/)
|
320
320
|
@book.should be_alive
|
321
321
|
end
|
322
322
|
|
@@ -336,9 +336,9 @@ describe Book do
|
|
336
336
|
@key_sender.puts "{right}{enter}"
|
337
337
|
@key_sender.puts "{right}{enter}"
|
338
338
|
@key_sender.puts "{right}{enter}"
|
339
|
-
expect{
|
340
|
-
|
341
|
-
|
339
|
+
#expect{
|
340
|
+
# Book.open(@simple_file, :if_unsaved => :excel)
|
341
|
+
# }.to raise_error(ExcelError, /user canceled or runtime error/)
|
342
342
|
@book.should be_alive
|
343
343
|
end
|
344
344
|
|
@@ -575,16 +575,16 @@ describe Book do
|
|
575
575
|
end
|
576
576
|
|
577
577
|
it "should open unobtrusively in a new Excel" do
|
578
|
-
Book.unobtrusively(@simple_file, :
|
578
|
+
Book.unobtrusively(@simple_file, :if_closed => :current) do |book|
|
579
579
|
book.should be_a Book
|
580
580
|
book.should be_alive
|
581
|
-
book.excel.
|
581
|
+
book.excel.should == @excel1
|
582
582
|
book.excel.should_not == @excel2
|
583
583
|
end
|
584
584
|
end
|
585
585
|
|
586
586
|
it "should open unobtrusively in a given Excel" do
|
587
|
-
Book.unobtrusively(@simple_file, @excel2) do |book|
|
587
|
+
Book.unobtrusively(@simple_file, :if_closed => @excel2) do |book|
|
588
588
|
book.should be_a Book
|
589
589
|
book.should be_alive
|
590
590
|
book.excel.should_not == @excel1
|
@@ -690,17 +690,16 @@ describe Book do
|
|
690
690
|
sheet[1,1].value.should_not == old_cell_value
|
691
691
|
end
|
692
692
|
|
693
|
-
# book shall be reanimated even with :hidden
|
694
693
|
it "should use the excel of the book and keep open the book" do
|
695
694
|
excel = Excel.new(:reuse => false)
|
696
695
|
sheet = @book.sheet(1)
|
697
696
|
old_cell_value = sheet[1,1].value
|
698
697
|
@book.close
|
699
698
|
@book.should_not be_alive
|
700
|
-
Book.unobtrusively(@simple_file1, :
|
699
|
+
Book.unobtrusively(@simple_file1, :if_closed => :current) do |book|
|
701
700
|
book.should be_a Book
|
702
701
|
book.should be_alive
|
703
|
-
book.excel.
|
702
|
+
book.excel.should == @book.excel
|
704
703
|
book.excel.should_not == excel
|
705
704
|
sheet = book.sheet(1)
|
706
705
|
cell = sheet[1,1]
|
@@ -731,7 +730,7 @@ describe Book do
|
|
731
730
|
book2.Readonly.should be_true
|
732
731
|
sheet = @book.sheet(1)
|
733
732
|
cell_value = sheet[1,1].value
|
734
|
-
Book.unobtrusively(@simple_file1, :
|
733
|
+
Book.unobtrusively(@simple_file1, :if_closed => :current) do |book|
|
735
734
|
book.should be_a Book
|
736
735
|
book.excel.should_not == book2.excel
|
737
736
|
book.excel.should_not == @book.excel
|
@@ -753,7 +752,7 @@ describe Book do
|
|
753
752
|
|
754
753
|
context "with a virgin Book class" do
|
755
754
|
before do
|
756
|
-
class Book
|
755
|
+
class Book # :nodoc: #
|
757
756
|
@@bookstore = nil
|
758
757
|
end
|
759
758
|
end
|
@@ -764,7 +763,7 @@ describe Book do
|
|
764
763
|
|
765
764
|
context "with a book never opened before" do
|
766
765
|
before do
|
767
|
-
class Book
|
766
|
+
class Book # :nodoc: #
|
768
767
|
@@bookstore = nil
|
769
768
|
end
|
770
769
|
other_book = Book.open(@different_file)
|
@@ -809,8 +808,8 @@ describe Book do
|
|
809
808
|
|
810
809
|
it "should open unobtrusively the closed book in the most recent Excel where it was open before" do
|
811
810
|
Book.unobtrusively(@simple_file) do |book|
|
812
|
-
book.excel.
|
813
|
-
book.excel.
|
811
|
+
book.excel.should_not == @book2.excel
|
812
|
+
book.excel.should == @book1.excel
|
814
813
|
book.ReadOnly.should == false
|
815
814
|
sheet = book.sheet(1)
|
816
815
|
cell = sheet[1,1]
|
@@ -823,9 +822,9 @@ describe Book do
|
|
823
822
|
end
|
824
823
|
|
825
824
|
it "should open unobtrusively the closed book in the new hidden Excel" do
|
826
|
-
Book.unobtrusively(@simple_file, :
|
825
|
+
Book.unobtrusively(@simple_file, :if_closed => :current) do |book|
|
827
826
|
book.excel.should_not == @book2.excel
|
828
|
-
book.excel.
|
827
|
+
book.excel.should == @book1.excel
|
829
828
|
book.ReadOnly.should == false
|
830
829
|
sheet = book.sheet(1)
|
831
830
|
cell = sheet[1,1]
|
@@ -837,7 +836,9 @@ describe Book do
|
|
837
836
|
sheet[1,1].Value.should_not == @old_cell_value
|
838
837
|
end
|
839
838
|
end
|
839
|
+
end
|
840
840
|
|
841
|
+
=begin
|
841
842
|
context "with :hidden" do
|
842
843
|
|
843
844
|
before do
|
@@ -864,6 +865,7 @@ describe Book do
|
|
864
865
|
end
|
865
866
|
end
|
866
867
|
end
|
868
|
+
=end
|
867
869
|
|
868
870
|
describe "for_reading, for_modifying" do
|
869
871
|
|
@@ -892,9 +894,10 @@ describe Book do
|
|
892
894
|
sheet[1,1].Value.should == @old_cell_value
|
893
895
|
end
|
894
896
|
|
897
|
+
|
895
898
|
it "should not change the value and use the hidden Excel instance" do
|
896
899
|
new_excel = Excel.new(:reuse => false)
|
897
|
-
Book.for_reading(@simple_file1, :
|
900
|
+
Book.for_reading(@simple_file1, :if_closed => :new) do |book|
|
898
901
|
sheet = book.sheet(1)
|
899
902
|
cell = sheet[1,1]
|
900
903
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
@@ -961,21 +961,15 @@ describe Book do
|
|
961
961
|
|
962
962
|
context "with compatibility" do
|
963
963
|
|
964
|
-
it "should open
|
965
|
-
book = Book.open(@simple_file, :visible => true, :check_compatibility =>
|
966
|
-
book.CheckCompatibility.should be_false
|
967
|
-
book.CheckCompatibility = true
|
964
|
+
it "should open with checking compatibility" do
|
965
|
+
book = Book.open(@simple_file, :visible => true, :check_compatibility => true)
|
968
966
|
book.CheckCompatibility.should be_true
|
969
|
-
Book.unobtrusively(@simple_file, :visible => true, :check_compatibility => false) do |book|
|
970
|
-
book.CheckCompatibility.should be_false
|
971
|
-
end
|
972
|
-
Book.unobtrusively(@simple_file, :visible => true, :check_compatibility => true) do |book|
|
973
|
-
book.CheckCompatibility.should be_true
|
974
|
-
end
|
975
|
-
|
976
967
|
end
|
977
968
|
|
969
|
+
it "should open without checking compatibility" do
|
970
|
+
book = Book.open(@simple_file, :visible => true, :check_compatibility => false)
|
971
|
+
book.CheckCompatibility.should be_false
|
972
|
+
end
|
978
973
|
end
|
979
|
-
|
980
974
|
end
|
981
975
|
end
|
@@ -41,43 +41,14 @@ describe Book do
|
|
41
41
|
context "with calculation mode" do
|
42
42
|
|
43
43
|
it "should set calculation mode" do
|
44
|
-
book1 = Book.open(@
|
44
|
+
book1 = Book.open(@simple_file1, :visible => true)
|
45
|
+
book1.excel.calculation = :manual
|
45
46
|
book1.excel.Calculation.should == -4135
|
46
|
-
book1.excel.calculation.should == :manual
|
47
|
-
book1.save
|
48
|
-
book1.excel.close
|
49
|
-
book2 = Book.open(@simple_file, :visible => true, :calculation => :automatic)
|
50
|
-
book2.excel.Calculation.should == -4105
|
51
|
-
book2.excel.calculation.should == :automatic
|
52
|
-
book2.save
|
53
|
-
book2.excel.close
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should set calculation mode and overwrite Excel calculation mode" do
|
57
|
-
excel1 = Excel.new(:calculation => :automatic)
|
58
|
-
book1 = Book.open(@simple_file, :visible => true, :calculation => :manual)
|
59
|
-
book1.excel.Calculation.should == -4135
|
60
|
-
book1.excel.calculation.should == :manual
|
61
47
|
book1.save
|
62
48
|
book1.excel.close
|
63
|
-
|
64
|
-
book2
|
49
|
+
book2 = Book.open(@simple_file1, :visible => true)
|
50
|
+
book2.excel.calculation = :automatic
|
65
51
|
book2.excel.Calculation.should == -4105
|
66
|
-
book2.excel.calculation.should == :automatic
|
67
|
-
book2.save
|
68
|
-
book2.excel.close
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should set calculation mode" do
|
72
|
-
excel1 = Excel.new(:calculation => :automatic)
|
73
|
-
book1 = Book.open(@simple_file, :visible => true)
|
74
|
-
book1.excel.Calculation.should == -4105
|
75
|
-
book1.excel.calculation.should == :automatic
|
76
|
-
book1.save
|
77
|
-
book1.close
|
78
|
-
book2 = Book.open(@simple_file, :visible => true, :calculation => :manual)
|
79
|
-
book2.excel.Calculation.should == -4135
|
80
|
-
book2.excel.calculation.should == :manual
|
81
52
|
book2.save
|
82
53
|
book2.excel.close
|
83
54
|
end
|
@@ -87,33 +58,20 @@ describe Book do
|
|
87
58
|
book1.excel.calculation.should == nil
|
88
59
|
end
|
89
60
|
|
90
|
-
it "should set the default value" do
|
91
|
-
book1 = Book.open(@simple_file)
|
92
|
-
book1.excel.calculation.should == nil
|
93
|
-
end
|
94
|
-
|
95
61
|
it "should set the calculation mode to automatic" do
|
96
|
-
excel = Excel.create(:calculation => :automatic)
|
97
|
-
excel.calculation.should == :automatic
|
98
62
|
book1 = Book.open(@simple_file)
|
63
|
+
book1.excel.calculation = :automatic
|
64
|
+
book1.excel.calculation.should == :automatic
|
99
65
|
book1.excel.Calculation.should == -4105
|
100
66
|
end
|
101
67
|
|
102
68
|
it "should set the calculation mode to manual" do
|
103
|
-
excel = Excel.create(:calculation => :manual)
|
104
|
-
excel.calculation.should == :manual
|
105
69
|
book1 = Book.open(@simple_file)
|
106
|
-
excel.calculation
|
70
|
+
book1.excel.calculation = :manual
|
71
|
+
book1.excel.calculation.should == :manual
|
107
72
|
book1.excel.Calculation.should == -4135
|
108
73
|
end
|
109
74
|
|
110
|
-
it "should set the calculation mode to automatic" do
|
111
|
-
excel = Excel.create(:calculation => :automatic)
|
112
|
-
excel.calculation.should == :automatic
|
113
|
-
book1 = Book.open(@simple_file)
|
114
|
-
book1.excel.Calculation.should == -4105
|
115
|
-
end
|
116
|
-
|
117
75
|
it "should change the calculation mode from manual to automatic" do
|
118
76
|
book1 = Book.open(@simple_file, :visible => true)
|
119
77
|
excel1 = Excel.current(:calculation => :automatic)
|
@@ -121,17 +79,6 @@ describe Book do
|
|
121
79
|
book2.excel.Calculation.should == -4105
|
122
80
|
book1.excel.Calculation.should == -4105
|
123
81
|
end
|
124
|
-
|
125
|
-
it "should change the calculation mode from automatic to manual" do
|
126
|
-
excel = Excel.create(:calculation => :automatic)
|
127
|
-
book1 = Book.open(@simple_file)
|
128
|
-
book1.excel.Calculation.should == -4105
|
129
|
-
excel2 = Excel.new(:reuse => false, :calculation => :manual)
|
130
|
-
book2 = Book.open(@different_file, :force => {:excel => excel2})
|
131
|
-
book2.excel.Calculation.should == -4135
|
132
|
-
book1.excel.Calculation.should == -4105
|
133
|
-
end
|
134
|
-
|
135
82
|
end
|
136
83
|
|
137
84
|
|
@@ -1281,7 +1228,9 @@ describe Book do
|
|
1281
1228
|
@new_book.filename.downcase.should == @simple_file.downcase
|
1282
1229
|
@book.should_not be_alive
|
1283
1230
|
end
|
1284
|
-
|
1231
|
+
end
|
1232
|
+
=begin
|
1233
|
+
# only for Excel2007:
|
1285
1234
|
it "should not open the new book and not close the unsaved book, if user answers 'no'" do
|
1286
1235
|
# "No" is right to "Yes" (the default). --> language independent
|
1287
1236
|
# strangely, in the "no" case, the question will sometimes be repeated three times
|
@@ -1294,7 +1243,8 @@ describe Book do
|
|
1294
1243
|
}.to raise_error(ExcelError, "user canceled or runtime error")
|
1295
1244
|
@book.should be_alive
|
1296
1245
|
end
|
1297
|
-
|
1246
|
+
|
1247
|
+
=end
|
1298
1248
|
|
1299
1249
|
context "with :if_unsaved => :excel" do
|
1300
1250
|
before do
|
@@ -1314,6 +1264,7 @@ describe Book do
|
|
1314
1264
|
@book.should_not be_alive
|
1315
1265
|
end
|
1316
1266
|
|
1267
|
+
=begin
|
1317
1268
|
it "should not open the new book and not close the unsaved book, if user answers 'no'" do
|
1318
1269
|
# "No" is right to "Yes" (the default). --> language independent
|
1319
1270
|
# strangely, in the "no" case, the question will sometimes be repeated three times
|
@@ -1326,6 +1277,8 @@ describe Book do
|
|
1326
1277
|
}.to raise_error(ExcelError, "user canceled or runtime error")
|
1327
1278
|
@book.should be_alive
|
1328
1279
|
end
|
1280
|
+
=end
|
1281
|
+
|
1329
1282
|
end
|
1330
1283
|
|
1331
1284
|
it "should open the book in a new excel instance, if :if_unsaved is :new_excel" do
|
@@ -1474,6 +1427,12 @@ describe Book do
|
|
1474
1427
|
}.to raise_error(FileNameNotGiven, "filename is nil")
|
1475
1428
|
end
|
1476
1429
|
|
1430
|
+
it "should raise error if file is a directory" do
|
1431
|
+
expect{
|
1432
|
+
Book.open(@dir)
|
1433
|
+
}.to raise_error(FileNotFound, "file #{General::absolute_path(@dir).gsub("/","\\").inspect} is a directory")
|
1434
|
+
end
|
1435
|
+
|
1477
1436
|
it "should raise error if file does not exist" do
|
1478
1437
|
File.delete @simple_save_file rescue nil
|
1479
1438
|
expect {
|
@@ -48,12 +48,150 @@ describe Book do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
it "should do simple unobtrusively" do
|
52
|
+
expect{unobtrusively_ok?}.to_not raise_error
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "unchanging" do
|
56
|
+
|
57
|
+
context "with openess" do
|
58
|
+
|
59
|
+
it "should remain closed" do
|
60
|
+
Book.unobtrusively(@simple_file) do |book|
|
61
|
+
end
|
62
|
+
Excel.current.Workbooks.Count.should == 0
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should remain open" do
|
66
|
+
book1 = Book.open(@simple_file1)
|
67
|
+
Book.unobtrusively(@simple_file1) do |book|
|
68
|
+
#book.should be_a Book
|
69
|
+
book.should be_alive
|
70
|
+
end
|
71
|
+
#book1.should be_alive
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
context "with writability" do
|
77
|
+
|
78
|
+
it "should remain writable" do
|
79
|
+
book1 = Book.open(@simple_file1, :read_only => false)
|
80
|
+
Book.unobtrusively(@simple_file1) do |book|
|
81
|
+
end
|
82
|
+
book1.ReadOnly.should be_false
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should remain read_only" do
|
86
|
+
book1 = Book.open(@simple_file1, :read_only => true)
|
87
|
+
Book.unobtrusively(@simple_file1) do |book|
|
88
|
+
end
|
89
|
+
book1.ReadOnly.should be_true
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should write and remain read_only and open the workbook in another Excel" do
|
93
|
+
book1 = Book.open(@simple_file1, :read_only => true)
|
94
|
+
old_value = book1.sheet(1)[1,1].Value
|
95
|
+
Book.unobtrusively(@simple_file1) do |book|
|
96
|
+
sheet = book.sheet(1)
|
97
|
+
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
98
|
+
book.excel.should_not == book1.excel
|
99
|
+
end
|
100
|
+
book1.ReadOnly.should be_true
|
101
|
+
book1.close
|
102
|
+
book2 = Book.open(@simple_file1)
|
103
|
+
book2.sheet(1)[1,1].Value.should_not == old_value
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should write and remain read_only and open the workbook in the same Excel" do
|
107
|
+
book1 = Book.open(@simple_file1, :read_only => true)
|
108
|
+
old_value = book1.sheet(1)[1,1].Value
|
109
|
+
Book.unobtrusively(@simple_file1, :readonly_excel => true) do |book|
|
110
|
+
sheet = book.sheet(1)
|
111
|
+
sheet[1,1] = sheet[1,1].value == "foo" ? "bar" : "foo"
|
112
|
+
book.excel.should == book1.excel
|
113
|
+
end
|
114
|
+
book1.ReadOnly.should be_true
|
115
|
+
book1.close
|
116
|
+
book2 = Book.open(@simple_file1)
|
117
|
+
book2.sheet(1)[1,1].Value.should_not == old_value
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
context "with visibility" do
|
123
|
+
|
124
|
+
it "should remain invisible" do
|
125
|
+
book1 = Book.open(@simple_file1, :visible => false)
|
126
|
+
Book.unobtrusively(@simple_file1) do |book|
|
127
|
+
end
|
128
|
+
book1.excel.Visible.should be_false
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should remain visible" do
|
132
|
+
book1 = Book.open(@simple_file1, :visible => true)
|
133
|
+
Book.unobtrusively(@simple_file1) do |book|
|
134
|
+
end
|
135
|
+
book1.excel.Visible.should be_true
|
136
|
+
book1.Windows(book1.Name).Visible.should be_true
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
context "with check-compatibility" do
|
142
|
+
|
143
|
+
it "should remain check-compatibility false" do
|
144
|
+
book1 = Book.open(@simple_file1, :check_compatibility => false)
|
145
|
+
Book.unobtrusively(@simple_file1) do |book|
|
146
|
+
end
|
147
|
+
book1.CheckCompatibility.should be_false
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should remain check-compatibility true" do
|
151
|
+
book1 = Book.open(@simple_file1, :check_compatibility => true)
|
152
|
+
Book.unobtrusively(@simple_file1) do |book|
|
153
|
+
end
|
154
|
+
book1.CheckCompatibility.should be_true
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
context "with calculation" do
|
160
|
+
|
161
|
+
it "should remain the calculation mode" do
|
162
|
+
book1 = Book.open(@simple_file1)
|
163
|
+
old_calculation = book1.excel.calculation
|
164
|
+
Book.unobtrusively(@simple_file1) do |book|
|
165
|
+
end
|
166
|
+
book1.excel.calculation.should == old_calculation
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should remain calculation manual" do
|
170
|
+
book1 = Book.open(@simple_file1, :calculation => :manual)
|
171
|
+
Book.unobtrusively(@simple_file1) do |book|
|
172
|
+
end
|
173
|
+
book1.excel.Calculation.should == -4135
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should remain calculation automatic" do
|
177
|
+
book1 = Book.open(@simple_file1, :calculation => :automatic)
|
178
|
+
Book.unobtrusively(@simple_file1) do |book|
|
179
|
+
end
|
180
|
+
book1.excel.Calculation.should == -4105
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
51
186
|
context "with no open book" do
|
52
187
|
|
53
188
|
it "should open unobtrusively if no Excel is open" do
|
54
189
|
Excel.close_all
|
55
190
|
Book.unobtrusively(@simple_file) do |book|
|
56
191
|
book.should be_a Book
|
192
|
+
book.excel.Visible.should be_false
|
193
|
+
book.CheckCompatibility.should be_false
|
194
|
+
book.ReadOnly.should be_false
|
57
195
|
end
|
58
196
|
end
|
59
197
|
|
@@ -83,7 +221,7 @@ describe Book do
|
|
83
221
|
end
|
84
222
|
|
85
223
|
it "should open unobtrusively in a new Excel" do
|
86
|
-
Book.unobtrusively(@simple_file, :
|
224
|
+
Book.unobtrusively(@simple_file, :if_closed => :new) do |book|
|
87
225
|
book.should be_a Book
|
88
226
|
book.should be_alive
|
89
227
|
book.excel.should_not == @excel1
|
@@ -92,7 +230,7 @@ describe Book do
|
|
92
230
|
end
|
93
231
|
|
94
232
|
it "should open unobtrusively in a given Excel" do
|
95
|
-
Book.unobtrusively(@simple_file, @excel2) do |book|
|
233
|
+
Book.unobtrusively(@simple_file, :if_closed => @excel2) do |book|
|
96
234
|
book.should be_a Book
|
97
235
|
book.should be_alive
|
98
236
|
book.excel.should_not == @excel1
|
@@ -103,7 +241,7 @@ describe Book do
|
|
103
241
|
it "should raise an error if the excel instance is not alive" do
|
104
242
|
Excel.close_all
|
105
243
|
expect{
|
106
|
-
Book.unobtrusively(@simple_file, @excel2) do |book|
|
244
|
+
Book.unobtrusively(@simple_file, :if_closed => @excel2) do |book|
|
107
245
|
end
|
108
246
|
}.to_not raise_error
|
109
247
|
end
|
@@ -111,71 +249,11 @@ describe Book do
|
|
111
249
|
|
112
250
|
it "should raise an error if the option is invalid" do
|
113
251
|
expect{
|
114
|
-
Book.unobtrusively(@simple_file, :invalid_option) do |book|
|
252
|
+
Book.unobtrusively(@simple_file, :if_closed => :invalid_option) do |book|
|
115
253
|
end
|
116
254
|
}.to raise_error(TypeErrorREO, "given object is neither an Excel, a Workbook, nor a Win32ole")
|
117
255
|
end
|
118
256
|
|
119
|
-
it "should be visible" do
|
120
|
-
Book.unobtrusively(@simple_file, :visible => true) do |book|
|
121
|
-
book.should be_a Book
|
122
|
-
book.should be_alive
|
123
|
-
book.excel.Visible.should be_true
|
124
|
-
book.Windows(book.Name).Visible.should be_true
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should be visible and displayalerts" do
|
129
|
-
excel = Excel.new(:reuse => false, :displayalerts => true)
|
130
|
-
Book.unobtrusively(@simple_file, :visible => true) do |book|
|
131
|
-
book.should be_a Book
|
132
|
-
book.should be_alive
|
133
|
-
book.excel.Visible.should be_true
|
134
|
-
book.Windows(book.Name).Visible.should be_true
|
135
|
-
book.excel.DisplayAlerts.should be_true
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should do default-visible" do
|
140
|
-
excel = Excel.new(:reuse => false, :visible => false)
|
141
|
-
Book.unobtrusively(@simple_file, :default => {:visible => true}) do |book|
|
142
|
-
book.should be_a Book
|
143
|
-
book.should be_alive
|
144
|
-
book.excel.Visible.should_not be_true
|
145
|
-
book.Windows(book.Name).Visible.should be_true
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should do default-invisible" do
|
150
|
-
excel = Excel.new(:reuse => false, :visible => true)
|
151
|
-
Book.unobtrusively(@simple_file, :default => {:visible => false}) do |book|
|
152
|
-
book.should be_a Book
|
153
|
-
book.should be_alive
|
154
|
-
book.excel.Visible.should be_true
|
155
|
-
book.Windows(book.Name).Visible.should be_false
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should do force-visible" do
|
160
|
-
excel = Excel.new(:reuse => false, :visible => false)
|
161
|
-
Book.unobtrusively(@simple_file, :force => {:visible => true}) do |book|
|
162
|
-
book.should be_a Book
|
163
|
-
book.should be_alive
|
164
|
-
book.excel.Visible.should be_true
|
165
|
-
book.Windows(book.Name).Visible.should be_true
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
it "should do force-invisible" do
|
170
|
-
excel = Excel.new(:reuse => false, :visible => true)
|
171
|
-
Book.unobtrusively(@simple_file, :force => {:visible => false}) do |book|
|
172
|
-
book.should be_a Book
|
173
|
-
book.should be_alive
|
174
|
-
book.excel.Visible.should be_true
|
175
|
-
book.Windows(book.Name).Visible.should be_false
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
257
|
end
|
180
258
|
|
181
259
|
context "with an open book" do
|
@@ -189,16 +267,6 @@ describe Book do
|
|
189
267
|
@book2.close(:if_unsaved => :forget) rescue nil
|
190
268
|
end
|
191
269
|
|
192
|
-
#it "should let an open Book open" do
|
193
|
-
# Book.unobtrusively(@simple_file) do |book|
|
194
|
-
# book.should be_a Book
|
195
|
-
# book.should be_alive
|
196
|
-
# book.excel.should == @book.excel
|
197
|
-
# end
|
198
|
-
# @book.should be_alive
|
199
|
-
# @book.should be_a Book
|
200
|
-
#end
|
201
|
-
|
202
270
|
it "should let an open Book open if it has been closed and opened again" do
|
203
271
|
@book.close
|
204
272
|
@book.reopen
|
@@ -228,7 +296,7 @@ describe Book do
|
|
228
296
|
it "should open in the Excel of the given Book" do
|
229
297
|
#book1 = Book.open(@different_file)
|
230
298
|
@book2 = Book.open(@another_simple_file, :force_excel => :new)
|
231
|
-
Book.unobtrusively(@different_file, @book2) do |book|
|
299
|
+
Book.unobtrusively(@different_file, :if_closed => @book2) do |book|
|
232
300
|
book.should be_a Book
|
233
301
|
book.should be_alive
|
234
302
|
book.excel.should_not == @book.excel
|
@@ -279,26 +347,8 @@ describe Book do
|
|
279
347
|
sheet2[1,1].value.should_not == old_cell_value
|
280
348
|
end
|
281
349
|
|
282
|
-
it "should set checkcompatibilty to true" do
|
283
|
-
@book.CheckCompatibility.should be_false
|
284
|
-
Book.unobtrusively(@simple_file, :check_compatibility => true) do |book|
|
285
|
-
book.should be_a Book
|
286
|
-
book.CheckCompatibility.should be_true
|
287
|
-
end
|
288
|
-
@book.CheckCompatibility.should be_false
|
289
|
-
end
|
290
|
-
|
291
|
-
it "should set the checkcompatibilty to false" do
|
292
|
-
@book.CheckCompatibility.should be_false
|
293
|
-
Book.unobtrusively(@simple_file, :check_compatibility => false) do |book|
|
294
|
-
book.should be_a Book
|
295
|
-
book.CheckCompatibility.should be_false
|
296
|
-
end
|
297
|
-
@book.CheckCompatibility.should be_false
|
298
|
-
end
|
299
|
-
|
300
350
|
end
|
301
|
-
|
351
|
+
|
302
352
|
context "with a closed book" do
|
303
353
|
|
304
354
|
before do
|
@@ -343,29 +393,15 @@ describe Book do
|
|
343
393
|
sheet = new_book.sheet(1)
|
344
394
|
sheet[1,1].value.should_not == old_cell_value
|
345
395
|
end
|
346
|
-
=begin
|
347
|
-
it "should set can_be_closed" do
|
348
|
-
Excel.close_all
|
349
|
-
Book.unobtrusively(@simple_file, :keep_open => true) do |book|
|
350
|
-
book.should be_a Book
|
351
|
-
book.should be_alive
|
352
|
-
book.can_be_closed.should be_false
|
353
|
-
@book2 = book
|
354
|
-
end
|
355
|
-
@book2.should be_alive
|
356
|
-
book = Book.open(@simple_file)
|
357
|
-
book.can_be_closed.should be_true
|
358
|
-
end
|
359
|
-
=end
|
360
396
|
|
361
|
-
# book shall be reanimated
|
397
|
+
# book shall be reanimated
|
362
398
|
it "should use the excel of the book and keep open the book" do
|
363
399
|
excel = Excel.new(:reuse => false)
|
364
400
|
sheet = @book.sheet(1)
|
365
401
|
old_cell_value = sheet[1,1].value
|
366
402
|
@book.close
|
367
403
|
@book.should_not be_alive
|
368
|
-
Book.unobtrusively(@simple_file, :
|
404
|
+
Book.unobtrusively(@simple_file, :if_closed => :new) do |book|
|
369
405
|
book.should be_a Book
|
370
406
|
book.should be_alive
|
371
407
|
book.excel.should_not == @book.excel
|
@@ -382,16 +418,12 @@ describe Book do
|
|
382
418
|
end
|
383
419
|
|
384
420
|
it "should use another excel if the Excels are closed" do
|
385
|
-
excel = Excel.new(:reuse => false)
|
386
421
|
sheet = @book.sheet(1)
|
387
422
|
old_cell_value = sheet[1,1].value
|
388
423
|
@book.close
|
389
424
|
@book.should_not be_alive
|
390
|
-
Excel.kill_all
|
391
425
|
Book.unobtrusively(@simple_file, :keep_open => true) do |book|
|
392
426
|
book.should be_a Book
|
393
|
-
book.excel.should == @book.excel
|
394
|
-
book.excel.should_not == excel
|
395
427
|
sheet = book.sheet(1)
|
396
428
|
cell = sheet[1,1]
|
397
429
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
@@ -411,7 +443,7 @@ describe Book do
|
|
411
443
|
@book.close
|
412
444
|
@book.should_not be_alive
|
413
445
|
Excel.kill_all
|
414
|
-
Book.unobtrusively(@simple_file, :
|
446
|
+
Book.unobtrusively(@simple_file, :if_closed => :new, :keep_open => true) do |book|
|
415
447
|
book.should be_a Book
|
416
448
|
book.excel.should_not == @book.excel
|
417
449
|
book.excel.should_not == excel
|
@@ -483,34 +515,34 @@ describe Book do
|
|
483
515
|
it "should use a given Excel" do
|
484
516
|
new_excel = Excel.new(:reuse => false)
|
485
517
|
another_excel = Excel.new(:reuse => false)
|
486
|
-
Book.unobtrusively(@simple_file1, another_excel) do |book|
|
518
|
+
Book.unobtrusively(@simple_file1, :if_closed => another_excel) do |book|
|
487
519
|
book.excel.should_not == @book.excel
|
488
520
|
book.excel.should_not == new_excel
|
489
521
|
book.excel.should == another_excel
|
490
522
|
end
|
491
523
|
end
|
492
524
|
|
493
|
-
it "should use
|
525
|
+
it "should use another Excel" do
|
494
526
|
new_excel = Excel.new(:reuse => false)
|
495
|
-
Book.unobtrusively(@simple_file1, :
|
527
|
+
Book.unobtrusively(@simple_file1, :if_closed => :new) do |book|
|
496
528
|
book.excel.should_not == @book.excel
|
497
529
|
book.excel.should_not == new_excel
|
498
530
|
book.excel.visible.should be_false
|
499
531
|
book.excel.displayalerts.should == :if_visible
|
500
|
-
@
|
532
|
+
@another_excel = book.excel
|
501
533
|
end
|
502
|
-
Book.unobtrusively(@simple_file1, :
|
503
|
-
book.excel.
|
534
|
+
Book.unobtrusively(@simple_file1, :if_closed => :reuse) do |book|
|
535
|
+
book.excel.should == @book.excel
|
504
536
|
book.excel.should_not == new_excel
|
505
537
|
book.excel.visible.should be_false
|
506
538
|
book.excel.displayalerts.should == :if_visible
|
507
|
-
book.excel.
|
539
|
+
book.excel.should_not == @another_excel
|
508
540
|
end
|
509
541
|
end
|
510
542
|
|
511
543
|
it "should reuse Excel" do
|
512
544
|
new_excel = Excel.new(:reuse => false)
|
513
|
-
Book.unobtrusively(@simple_file1, :reuse) do |book|
|
545
|
+
Book.unobtrusively(@simple_file1, :if_closed => :reuse) do |book|
|
514
546
|
book.excel.should == @book.excel
|
515
547
|
book.excel.should_not == new_excel
|
516
548
|
end
|
@@ -581,7 +613,7 @@ describe Book do
|
|
581
613
|
book2.Readonly.should be_false
|
582
614
|
sheet = @book.sheet(1)
|
583
615
|
cell_value = sheet[1,1].value
|
584
|
-
Book.unobtrusively(@simple_file1, :
|
616
|
+
Book.unobtrusively(@simple_file1, :if_closed => :new) do |book|
|
585
617
|
book.should be_a Book
|
586
618
|
book.excel.should == book2.excel
|
587
619
|
book.excel.should_not == @book.excel
|
@@ -606,7 +638,7 @@ describe Book do
|
|
606
638
|
book2.Readonly.should be_true
|
607
639
|
sheet = @book.sheet(1)
|
608
640
|
cell_value = sheet[1,1].value
|
609
|
-
Book.unobtrusively(@simple_file, :
|
641
|
+
Book.unobtrusively(@simple_file, :if_closed => :new) do |book|
|
610
642
|
book.should be_a Book
|
611
643
|
book.excel.should_not == book2.excel
|
612
644
|
book.excel.should_not == @book.excel
|
@@ -631,7 +663,7 @@ describe Book do
|
|
631
663
|
book2.Readonly.should be_true
|
632
664
|
sheet = @book.sheet(1)
|
633
665
|
cell_value = sheet[1,1].value
|
634
|
-
Book.unobtrusively(@simple_file, :
|
666
|
+
Book.unobtrusively(@simple_file, :if_closed => :new) do |book|
|
635
667
|
book.should be_a Book
|
636
668
|
book.excel.should_not == book2.excel
|
637
669
|
book.excel.should_not == @book.excel
|
@@ -658,7 +690,7 @@ describe Book do
|
|
658
690
|
book2.Readonly.should be_true
|
659
691
|
sheet = @book.sheet(1)
|
660
692
|
cell_value = sheet[1,1].value
|
661
|
-
Book.unobtrusively(@simple_file1, :
|
693
|
+
Book.unobtrusively(@simple_file1, :if_closed => :new, :readonly_excel => false) do |book|
|
662
694
|
book.should be_a Book
|
663
695
|
book.ReadOnly.should be_false
|
664
696
|
book.excel.should_not == book2.excel
|
@@ -688,7 +720,7 @@ describe Book do
|
|
688
720
|
book2.Readonly.should be_true
|
689
721
|
sheet = @book.sheet(1)
|
690
722
|
cell_value = sheet[1,1].value
|
691
|
-
Book.unobtrusively(@simple_file1, :
|
723
|
+
Book.unobtrusively(@simple_file1, :if_closed => :new, :readonly_excel => true) do |book|
|
692
724
|
book.should be_a Book
|
693
725
|
book.excel.should == book2.excel
|
694
726
|
book.ReadOnly.should be_false
|
@@ -698,7 +730,7 @@ describe Book do
|
|
698
730
|
book.Saved.should be_false
|
699
731
|
end
|
700
732
|
book2.Saved.should be_true
|
701
|
-
book2.ReadOnly.should
|
733
|
+
book2.ReadOnly.should be_true
|
702
734
|
@book.close
|
703
735
|
book2.close
|
704
736
|
book3 = Book.open(@simple_file1)
|
@@ -713,7 +745,7 @@ describe Book do
|
|
713
745
|
book2.Readonly.should be_true
|
714
746
|
sheet = @book.sheet(1)
|
715
747
|
cell_value = sheet[1,1].value
|
716
|
-
Book.unobtrusively(@simple_file1, :
|
748
|
+
Book.unobtrusively(@simple_file1, :if_closed => :new, :read_only => true) do |book|
|
717
749
|
book.should be_a Book
|
718
750
|
book.excel.should == book2.excel
|
719
751
|
book.excel.should_not == @book.excel
|
@@ -763,7 +795,7 @@ describe Book do
|
|
763
795
|
|
764
796
|
it "should save if the book was modified during unobtrusively" do
|
765
797
|
m_time = File.mtime(@book1.stored_filename)
|
766
|
-
Book.unobtrusively(@simple_file1, :
|
798
|
+
Book.unobtrusively(@simple_file1, :if_closed => :new) do |book|
|
767
799
|
@book1.Saved.should be_true
|
768
800
|
book.Saved.should be_true
|
769
801
|
sheet = book.sheet(1)
|
@@ -857,8 +889,8 @@ describe Book do
|
|
857
889
|
|
858
890
|
it "should open unobtrusively the closed book in the most recent Excel where it was open before" do
|
859
891
|
Book.unobtrusively(@simple_file1) do |book|
|
860
|
-
book.excel.
|
861
|
-
book.excel.
|
892
|
+
book.excel.should_not == @book2.excel
|
893
|
+
book.excel.should == @book1.excel
|
862
894
|
book.ReadOnly.should == false
|
863
895
|
sheet = book.sheet(1)
|
864
896
|
cell = sheet[1,1]
|
@@ -870,8 +902,8 @@ describe Book do
|
|
870
902
|
sheet[1,1].value.should_not == @old_cell_value
|
871
903
|
end
|
872
904
|
|
873
|
-
it "should open unobtrusively the closed book in the new
|
874
|
-
Book.unobtrusively(@simple_file1, :
|
905
|
+
it "should open unobtrusively the closed book in the new Excel" do
|
906
|
+
Book.unobtrusively(@simple_file1, :if_closed => :new) do |book|
|
875
907
|
book.excel.should_not == @book2.excel
|
876
908
|
book.excel.should_not == @book1.excel
|
877
909
|
book.ReadOnly.should == false
|
@@ -887,7 +919,7 @@ describe Book do
|
|
887
919
|
|
888
920
|
it "should open unobtrusively the closed book in a new Excel if the Excel is not alive anymore" do
|
889
921
|
Excel.kill_all
|
890
|
-
Book.unobtrusively(@simple_file1, :
|
922
|
+
Book.unobtrusively(@simple_file1, :if_closed => :new) do |book|
|
891
923
|
book.ReadOnly.should == false
|
892
924
|
book.excel.should_not == @book1.excel
|
893
925
|
book.excel.should_not == @book2.excel
|
@@ -901,94 +933,6 @@ describe Book do
|
|
901
933
|
sheet[1,1].Value.should_not == @old_cell_value
|
902
934
|
end
|
903
935
|
end
|
904
|
-
|
905
|
-
context "with :hidden" do
|
906
|
-
|
907
|
-
before do
|
908
|
-
@book1 = Book.open(@simple_file1)
|
909
|
-
@book1.close
|
910
|
-
end
|
911
|
-
|
912
|
-
it "should create a new hidden Excel instance" do
|
913
|
-
Book.unobtrusively(@simple_file1, :hidden) do |book|
|
914
|
-
book.should be_a Book
|
915
|
-
book.should be_alive
|
916
|
-
book.excel.Visible.should be_false
|
917
|
-
book.excel.DisplayAlerts.should be_false
|
918
|
-
end
|
919
|
-
end
|
920
|
-
|
921
|
-
it "should create a new hidden Excel instance and use this afterwards" do
|
922
|
-
hidden_excel = nil
|
923
|
-
Book.unobtrusively(@simple_file1, :hidden) do |book|
|
924
|
-
book.should be_a Book
|
925
|
-
book.should be_alive
|
926
|
-
book.excel.Visible.should be_false
|
927
|
-
book.excel.DisplayAlerts.should be_false
|
928
|
-
hidden_excel = book.excel
|
929
|
-
end
|
930
|
-
Book.unobtrusively(@different_file, :hidden) do |book|
|
931
|
-
book.should be_a Book
|
932
|
-
book.should be_alive
|
933
|
-
book.excel.Visible.should be_false
|
934
|
-
book.excel.DisplayAlerts.should be_false
|
935
|
-
book.excel.should == hidden_excel
|
936
|
-
end
|
937
|
-
end
|
938
|
-
|
939
|
-
it "should create a new hidden Excel instance if the Excel is closed" do
|
940
|
-
Excel.close_all
|
941
|
-
Book.unobtrusively(@simple_file1, :hidden) do |book|
|
942
|
-
book.should be_a Book
|
943
|
-
book.should be_alive
|
944
|
-
book.excel.Visible.should be_false
|
945
|
-
book.excel.DisplayAlerts.should be_false
|
946
|
-
book.excel.should_not == @book1.excel
|
947
|
-
end
|
948
|
-
end
|
949
|
-
|
950
|
-
it "should exclude hidden Excel when reuse in unobtrusively" do
|
951
|
-
hidden_excel = nil
|
952
|
-
Book.unobtrusively(@simple_file1, :hidden) do |book|
|
953
|
-
book.should be_a Book
|
954
|
-
book.should be_alive
|
955
|
-
book.excel.Visible.should be_false
|
956
|
-
book.excel.DisplayAlerts.should be_false
|
957
|
-
book.excel.should_not == @book1.excel
|
958
|
-
hidden_excel = book.excel
|
959
|
-
end
|
960
|
-
Book.unobtrusively(@simple_file1) do |book|
|
961
|
-
book.should be_a Book
|
962
|
-
book.should be_alive
|
963
|
-
book.excel.Visible.should be_false
|
964
|
-
book.excel.DisplayAlerts.should be_false
|
965
|
-
book.excel.should_not == hidden_excel
|
966
|
-
end
|
967
|
-
end
|
968
|
-
|
969
|
-
it "should exclude hidden Excel when reuse in open" do
|
970
|
-
hidden_excel = nil
|
971
|
-
Book.unobtrusively(@simple_file1, :hidden) do |book|
|
972
|
-
book.should be_a Book
|
973
|
-
book.should be_alive
|
974
|
-
book.excel.Visible.should be_false
|
975
|
-
book.excel.DisplayAlerts.should be_false
|
976
|
-
book.excel.should_not == @book1.excel
|
977
|
-
hidden_excel = book.excel
|
978
|
-
end
|
979
|
-
book2 = Book.open(@simple_file1, :default_excel => :current)
|
980
|
-
book2.excel.should_not == hidden_excel
|
981
|
-
end
|
982
|
-
|
983
|
-
it "should exclude hidden Excel when reuse in open" do
|
984
|
-
book1 = Book.open(@simple_file1)
|
985
|
-
book1.close
|
986
|
-
book2 = Book.open(@simple_file1, :default_excel => :current)
|
987
|
-
book2.excel.should == book1.excel
|
988
|
-
book1.should be_alive
|
989
|
-
book2.close
|
990
|
-
end
|
991
|
-
end
|
992
936
|
end
|
993
937
|
|
994
938
|
describe "for_reading, for_modifying" do
|
@@ -1021,7 +965,7 @@ describe Book do
|
|
1021
965
|
it "should not change the value and use a given Excel" do
|
1022
966
|
new_excel = Excel.new(:reuse => false)
|
1023
967
|
another_excel = Excel.new(:reuse => false)
|
1024
|
-
Book.for_reading(@simple_file1, another_excel) do |book|
|
968
|
+
Book.for_reading(@simple_file1, :if_closed => another_excel) do |book|
|
1025
969
|
sheet = book.sheet(1)
|
1026
970
|
cell = sheet[1,1]
|
1027
971
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
@@ -1032,9 +976,9 @@ describe Book do
|
|
1032
976
|
sheet[1,1].Value.should == @old_cell_value
|
1033
977
|
end
|
1034
978
|
|
1035
|
-
it "should not change the value and use the
|
979
|
+
it "should not change the value and use the new Excel instance" do
|
1036
980
|
new_excel = Excel.new(:reuse => false)
|
1037
|
-
Book.for_reading(@simple_file1, :
|
981
|
+
Book.for_reading(@simple_file1, :if_closed => :new) do |book|
|
1038
982
|
sheet = book.sheet(1)
|
1039
983
|
cell = sheet[1,1]
|
1040
984
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
@@ -1063,7 +1007,7 @@ describe Book do
|
|
1063
1007
|
it "should change the value and use a given Excel" do
|
1064
1008
|
new_excel = Excel.new(:reuse => false)
|
1065
1009
|
another_excel = Excel.new(:reuse => false)
|
1066
|
-
Book.for_modifying(@simple_file1, another_excel) do |book|
|
1010
|
+
Book.for_modifying(@simple_file1, :if_closed => another_excel) do |book|
|
1067
1011
|
sheet = book.sheet(1)
|
1068
1012
|
cell = sheet[1,1]
|
1069
1013
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
@@ -1074,9 +1018,9 @@ describe Book do
|
|
1074
1018
|
sheet[1,1].Value.should_not == @old_cell_value
|
1075
1019
|
end
|
1076
1020
|
|
1077
|
-
it "should change the value and use the
|
1021
|
+
it "should change the value and use the new Excel instance" do
|
1078
1022
|
new_excel = Excel.new(:reuse => false)
|
1079
|
-
Book.for_modifying(@simple_file1, :
|
1023
|
+
Book.for_modifying(@simple_file1, :if_closed => :new) do |book|
|
1080
1024
|
sheet = book.sheet(1)
|
1081
1025
|
cell = sheet[1,1]
|
1082
1026
|
sheet[1,1] = cell.value == "foo" ? "bar" : "foo"
|
@@ -1091,6 +1035,5 @@ describe Book do
|
|
1091
1035
|
end
|
1092
1036
|
end
|
1093
1037
|
end
|
1094
|
-
|
1095
1038
|
|
1096
1039
|
end
|