robust_excel_ole 1.27 → 1.32
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 +36 -2
- data/README.rdoc +121 -19
- data/___dummy_workbook.xls +0 -0
- data/benchmarking/creek_example.rb +1 -1
- data/benchmarking/reo_example.rb +1 -1
- data/benchmarking/reo_example1.rb +1 -1
- data/benchmarking/reo_example2.rb +1 -1
- data/benchmarking/roo_example.rb +1 -1
- data/benchmarking/simple_xlsx_reader_example.rb +1 -1
- data/benchmarking/spreadsheet_example.rb +1 -1
- data/bin/jreo +19 -0
- data/bin/reo +19 -0
- data/docs/README_excel.rdoc +16 -24
- data/docs/README_listobjects.rdoc +176 -0
- data/docs/README_open.rdoc +20 -16
- data/docs/README_ranges.rdoc +72 -55
- data/docs/README_save_close.rdoc +3 -3
- data/docs/README_sheet.rdoc +19 -20
- data/examples/example_ruby_library.rb +2 -2
- data/examples/introductory_examples/example_open.rb +11 -0
- data/examples/introductory_examples/example_range.rb +2 -2
- data/examples/modifying_sheets/example_access_sheets_and_cells.rb +6 -6
- data/examples/modifying_sheets/example_add_names.rb +1 -1
- data/examples/modifying_sheets/example_concating.rb +1 -1
- data/examples/modifying_sheets/example_copying.rb +2 -2
- data/examples/modifying_sheets/example_listobjects.rb +86 -0
- data/examples/modifying_sheets/example_naming.rb +1 -1
- data/examples/modifying_sheets/example_ranges.rb +1 -1
- data/examples/open_save_close/example_control_to_excel.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_save.rb +3 -3
- data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
- data/examples/open_save_close/example_if_unsaved_forget.rb +3 -3
- data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -4
- data/examples/open_save_close/example_read_only.rb +1 -1
- data/examples/open_save_close/example_simple.rb +1 -1
- data/examples/open_save_close/example_unobtrusively.rb +3 -3
- data/lib/robust_excel_ole.rb +19 -16
- data/lib/robust_excel_ole/address_tool.rb +54 -44
- data/lib/robust_excel_ole/base.rb +9 -6
- data/lib/robust_excel_ole/bookstore.rb +3 -17
- data/lib/robust_excel_ole/cell.rb +17 -22
- data/lib/robust_excel_ole/cygwin.rb +2 -0
- data/lib/robust_excel_ole/excel.rb +136 -201
- data/lib/robust_excel_ole/general.rb +249 -238
- data/lib/robust_excel_ole/list_object.rb +186 -210
- data/lib/robust_excel_ole/list_row.rb +155 -0
- data/lib/robust_excel_ole/range.rb +130 -94
- data/lib/robust_excel_ole/range_owners.rb +54 -135
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/workbook.rb +230 -196
- data/lib/robust_excel_ole/worksheet.rb +254 -133
- data/lib/spec_helper.rb +1 -1
- data/robust_excel_ole.gemspec +4 -3
- data/spec/address_tool_spec.rb +2 -2
- data/spec/base_spec.rb +19 -17
- data/spec/bookstore_spec.rb +3 -4
- data/spec/cell_spec.rb +10 -10
- data/spec/cygwin_spec.rb +1 -1
- data/spec/data/more_data/workbook.xls +0 -0
- data/spec/excel_spec.rb +133 -86
- data/spec/general_spec.rb +79 -18
- data/spec/list_object_spec.rb +259 -81
- data/spec/list_row_spec.rb +218 -0
- data/spec/range_spec.rb +75 -41
- data/spec/spec_helper.rb +16 -2
- data/spec/workbook_spec.rb +87 -46
- data/spec/workbook_specs/workbook_all_spec.rb +9 -28
- data/spec/workbook_specs/workbook_close_spec.rb +1 -1
- data/spec/workbook_specs/workbook_misc_spec.rb +52 -45
- data/spec/workbook_specs/workbook_open_spec.rb +103 -50
- data/spec/workbook_specs/workbook_save_spec.rb +22 -23
- data/spec/workbook_specs/workbook_sheet_spec.rb +4 -4
- data/spec/workbook_specs/workbook_subclass_spec.rb +1 -1
- data/spec/workbook_specs/workbook_unobtr_spec.rb +553 -395
- data/spec/worksheet_spec.rb +544 -308
- metadata +38 -3
- data/lib/reo_console.rb +0 -42
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../spec_helper'
|
4
4
|
|
5
5
|
|
6
6
|
$VERBOSE = nil
|
@@ -207,9 +207,9 @@ describe Workbook do
|
|
207
207
|
|
208
208
|
it "should copy the second sheet, append it and leave the references so far" do
|
209
209
|
@book2.add_sheet(@book2.sheet(2), :after => @book2.sheet(3))
|
210
|
-
@book2.sheet(1)[2,1].
|
211
|
-
@book2.sheet(1)[2,2].
|
212
|
-
@book2.sheet(1)[2,3].
|
210
|
+
@book2.sheet(1)[2,1].should == "x"
|
211
|
+
@book2.sheet(1)[2,2].should == "y"
|
212
|
+
@book2.sheet(1)[2,3].should == "z"
|
213
213
|
end
|
214
214
|
|
215
215
|
it "should copy and append a given sheet" do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../spec_helper'
|
4
4
|
|
5
5
|
|
6
6
|
$VERBOSE = nil
|
@@ -24,7 +24,10 @@ describe Workbook do
|
|
24
24
|
@different_file = @dir + '/different_workbook.xls'
|
25
25
|
@simple_file_other_path = @dir + '/more_data/workbook.xls'
|
26
26
|
@another_simple_file = @dir + '/another_workbook.xls'
|
27
|
-
|
27
|
+
#@main_file = @dir + '/workbook_linked.xlsm'
|
28
|
+
#@linked_sub_file = @dir + '/workbook_sub.xlsm'
|
29
|
+
@main_file = @dir + '/workbook_linked3.xlsm'
|
30
|
+
@sub_file = @dir + '/workbook_linked_sub.xlsm'
|
28
31
|
@simple_file_xlsm = @dir + '/workbook.xlsm'
|
29
32
|
@simple_file_xlsx = @dir + '/workbook.xlsx'
|
30
33
|
@simple_file1 = @simple_file
|
@@ -35,13 +38,207 @@ describe Workbook do
|
|
35
38
|
rm_tmp(@dir)
|
36
39
|
end
|
37
40
|
|
38
|
-
describe "
|
39
|
-
|
40
|
-
context "with
|
41
|
+
describe "writable" do
|
42
|
+
|
43
|
+
context "with no book" do
|
44
|
+
|
45
|
+
it "should open in read-only mode" do
|
46
|
+
Workbook.unobtrusively(@simple_file1, :writable => false) do |book|
|
47
|
+
book.ReadOnly.should be true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should open in writable mode" do
|
52
|
+
Workbook.unobtrusively(@simple_file1, :writable => true) do |book|
|
53
|
+
book.ReadOnly.should be false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
context "with open writable book" do
|
60
|
+
|
61
|
+
before do
|
62
|
+
@book = Workbook.open(@simple_file1)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should keep the read-only mode" do
|
66
|
+
Workbook.unobtrusively(@simple_file1, :writable => false) do |book|
|
67
|
+
book.ReadOnly.should be false
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
context "with open read-only book" do
|
74
|
+
|
75
|
+
before do
|
76
|
+
@book = Workbook.open(@simple_file1, :read_only => true)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should keep the read-only mode" do
|
80
|
+
Workbook.unobtrusively(@simple_file1, :writable => true) do |book|
|
81
|
+
book.ReadOnly.should be true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "for_reading, for_modifying" do
|
90
|
+
|
91
|
+
context "with no workbook" do
|
92
|
+
|
93
|
+
it "should open with read-only" do
|
94
|
+
Workbook.for_reading(@simple_file1) do |book|
|
95
|
+
book.should be_a Workbook
|
96
|
+
book.should be_alive
|
97
|
+
book.ReadOnly.should be true
|
98
|
+
book.Saved.should be true
|
99
|
+
sheet = book.sheet(1)
|
100
|
+
cell = sheet[1,1]
|
101
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
102
|
+
@new_cell_value = sheet[1,1]
|
103
|
+
book.Saved.should be false
|
104
|
+
end
|
105
|
+
Excel.kill_all
|
106
|
+
new_book = Workbook.open(@simple_file1)
|
107
|
+
sheet = new_book.sheet(1)
|
108
|
+
sheet[1,1].should_not == @new_cell_value
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should change the value" do
|
112
|
+
Workbook.for_modifying(@simple_file1) do |book|
|
113
|
+
book.should be_a Workbook
|
114
|
+
book.should be_alive
|
115
|
+
book.ReadOnly.should be false
|
116
|
+
book.Saved.should be true
|
117
|
+
sheet = book.sheet(1)
|
118
|
+
cell = sheet[1,1]
|
119
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
120
|
+
@new_cell_value = sheet[1,1]
|
121
|
+
book.Saved.should be false
|
122
|
+
end
|
123
|
+
Excel.kill_all
|
124
|
+
new_book = Workbook.open(@simple_file1)
|
125
|
+
sheet = new_book.sheet(1)
|
126
|
+
sheet[1,1].should == @new_cell_value
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
context "with closed writable workbook" do
|
132
|
+
|
133
|
+
before do
|
134
|
+
@book = Workbook.open(@simple_file1)
|
135
|
+
sheet = @book.sheet(1)
|
136
|
+
@old_cell_value = sheet[1,1]
|
137
|
+
@book.close
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should not change the value" do
|
141
|
+
Workbook.for_reading(@simple_file1) do |book|
|
142
|
+
book.should be_a Workbook
|
143
|
+
book.should be_alive
|
144
|
+
book.ReadOnly.should be true
|
145
|
+
book.Saved.should be true
|
146
|
+
sheet = book.sheet(1)
|
147
|
+
cell = sheet[1,1]
|
148
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
149
|
+
book.Saved.should be false
|
150
|
+
book.excel.should == @book.excel
|
151
|
+
end
|
152
|
+
Excel.kill_all
|
153
|
+
new_book = Workbook.open(@simple_file1)
|
154
|
+
sheet = new_book.sheet(1)
|
155
|
+
sheet[1,1].should == @old_cell_value
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should not change the value and use a given Excel" do
|
159
|
+
new_excel = Excel.new(:reuse => false)
|
160
|
+
another_excel = Excel.new(:reuse => false)
|
161
|
+
Workbook.for_reading(@simple_file1, :if_closed => another_excel) do |book|
|
162
|
+
sheet = book.sheet(1)
|
163
|
+
cell = sheet[1,1]
|
164
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
165
|
+
book.excel.should == another_excel
|
166
|
+
end
|
167
|
+
Excel.kill_all
|
168
|
+
new_book = Workbook.open(@simple_file1)
|
169
|
+
sheet = new_book.sheet(1)
|
170
|
+
sheet[1,1].should == @old_cell_value
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should not change the value and use the new Excel instance" do
|
174
|
+
new_excel = Excel.new(:reuse => false)
|
175
|
+
Workbook.for_reading(@simple_file1, :if_closed => :new) do |book|
|
176
|
+
sheet = book.sheet(1)
|
177
|
+
cell = sheet[1,1]
|
178
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
179
|
+
book.excel.should_not == @book.excel
|
180
|
+
book.excel.should_not == new_excel
|
181
|
+
book.excel.properties[:visible].should be false
|
182
|
+
book.excel.properties[:displayalerts].should == :if_visible
|
183
|
+
end
|
184
|
+
Excel.kill_all
|
185
|
+
new_book = Workbook.open(@simple_file1)
|
186
|
+
sheet = new_book.sheet(1)
|
187
|
+
sheet[1,1].should == @old_cell_value
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should change the value" do
|
191
|
+
Workbook.for_modifying(@simple_file1) do |book|
|
192
|
+
sheet = book.sheet(1)
|
193
|
+
cell = sheet[1,1]
|
194
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
195
|
+
book.excel.should == @book.excel
|
196
|
+
end
|
197
|
+
new_book = Workbook.open(@simple_file, :visible => true)
|
198
|
+
sheet = new_book.sheet(1)
|
199
|
+
sheet[1,1].should_not == @old_cell_value
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should change the value and use a given Excel" do
|
203
|
+
@book.close
|
204
|
+
new_excel = Excel.new(:reuse => false)
|
205
|
+
another_excel = Excel.new(:reuse => false)
|
206
|
+
Workbook.for_modifying(@simple_file1, :if_closed => another_excel) do |book|
|
207
|
+
sheet = book.sheet(1)
|
208
|
+
cell = sheet[1,1]
|
209
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
210
|
+
book.excel.should == another_excel
|
211
|
+
end
|
212
|
+
new_book = Workbook.open(@simple_file1, :visible => true)
|
213
|
+
sheet = new_book.sheet(1)
|
214
|
+
sheet[1,1].should_not == @old_cell_value
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should change the value and use the new Excel instance" do
|
218
|
+
new_excel = Excel.new(:reuse => false)
|
219
|
+
Workbook.for_modifying(@simple_file1, :if_closed => :new) do |book|
|
220
|
+
sheet = book.sheet(1)
|
221
|
+
cell = sheet[1,1]
|
222
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
223
|
+
book.excel.should_not == @book.excel
|
224
|
+
book.excel.should_not == new_excel
|
225
|
+
book.excel.properties[:visible].should be false
|
226
|
+
book.excel.properties[:displayalerts].should == :if_visible
|
227
|
+
end
|
228
|
+
new_book = Workbook.open(@simple_file1, :visible => true)
|
229
|
+
sheet = new_book.sheet(1)
|
230
|
+
sheet[1,1].should_not == @old_cell_value
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe "Workbook.for_reading, for_modifying" do
|
236
|
+
|
237
|
+
context "with open writable book" do
|
41
238
|
|
42
239
|
before do
|
43
240
|
@book = Workbook.open(@simple_file1)
|
44
|
-
@old_value = @book.sheet(1)[1,1]
|
241
|
+
@old_value = @book.sheet(1)[1,1]
|
45
242
|
end
|
46
243
|
|
47
244
|
after do
|
@@ -52,13 +249,14 @@ describe Workbook do
|
|
52
249
|
@book.for_reading do |book|
|
53
250
|
book.should be_a Workbook
|
54
251
|
book.should be_alive
|
252
|
+
book.ReadOnly.should be false
|
55
253
|
book.Saved.should be true
|
56
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
254
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
57
255
|
book.Saved.should be false
|
58
256
|
end
|
59
257
|
@book.close(:if_unsaved => :forget)
|
60
258
|
new_book = Workbook.open(@simple_file1)
|
61
|
-
new_book.sheet(1)[1,1].
|
259
|
+
new_book.sheet(1)[1,1].should == @old_value
|
62
260
|
end
|
63
261
|
|
64
262
|
it "should change the value" do
|
@@ -66,12 +264,12 @@ describe Workbook do
|
|
66
264
|
book.should be_a Workbook
|
67
265
|
book.should be_alive
|
68
266
|
book.Saved.should be true
|
69
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
267
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
70
268
|
book.Saved.should be false
|
71
269
|
end
|
72
270
|
@book.close(:if_unsaved => :forget)
|
73
271
|
new_book = Workbook.open(@simple_file1)
|
74
|
-
new_book.sheet(1)[1,1].
|
272
|
+
new_book.sheet(1)[1,1].should_not == @old_value
|
75
273
|
end
|
76
274
|
|
77
275
|
it "should not change the value and make visible" do
|
@@ -80,12 +278,12 @@ describe Workbook do
|
|
80
278
|
book.should be_alive
|
81
279
|
book.visible.should be true
|
82
280
|
book.Saved.should be true
|
83
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
281
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
84
282
|
book.Saved.should be false
|
85
283
|
end
|
86
284
|
@book.close(:if_unsaved => :forget)
|
87
285
|
new_book = Workbook.open(@simple_file1)
|
88
|
-
new_book.sheet(1)[1,1].
|
286
|
+
new_book.sheet(1)[1,1].should == @old_value
|
89
287
|
end
|
90
288
|
|
91
289
|
it "should change the value and make visible" do
|
@@ -94,25 +292,89 @@ describe Workbook do
|
|
94
292
|
book.should be_alive
|
95
293
|
book.visible.should be true
|
96
294
|
book.Saved.should be true
|
97
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
295
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
98
296
|
book.Saved.should be false
|
99
297
|
end
|
100
298
|
@book.close(:if_unsaved => :forget)
|
101
299
|
new_book = Workbook.open(@simple_file1)
|
102
|
-
new_book.sheet(1)[1,1].
|
300
|
+
new_book.sheet(1)[1,1].should_not == @old_value
|
103
301
|
end
|
104
302
|
|
105
303
|
end
|
106
304
|
|
107
305
|
end
|
108
306
|
|
307
|
+
describe "with referenced workbooks" do
|
308
|
+
|
309
|
+
context "with no books" do
|
310
|
+
|
311
|
+
it "should open the linked workbook in read-only" do
|
312
|
+
Workbook.unobtrusively(@sub_file, :writable => false) do |book|
|
313
|
+
book.ReadOnly.should be true
|
314
|
+
book.filename.should == @sub_file
|
315
|
+
end
|
316
|
+
Excel.current.workbooks.should == []
|
317
|
+
end
|
318
|
+
|
319
|
+
it "should open the workbook and its linked workbook in read-only" do
|
320
|
+
Workbook.unobtrusively(@main_file, :writable => false) do |book|
|
321
|
+
book.ReadOnly.should be true
|
322
|
+
book.filename.should == @main_file
|
323
|
+
book.excel.workbooks.map{|b| b.filename}.should == [@sub_file, @main_file]
|
324
|
+
end
|
325
|
+
Excel.current.workbooks.map{|b| b.filename}.should == [@sub_file]
|
326
|
+
end
|
327
|
+
|
328
|
+
it "should not write the linked workbook and close it" do
|
329
|
+
Workbook.unobtrusively(@sub_file, :writable => false) do |book|
|
330
|
+
book.ReadOnly.should be true
|
331
|
+
book.filename.should == @sub_file
|
332
|
+
@old_value = book.sheet(1)[1,1]
|
333
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
334
|
+
end
|
335
|
+
Excel.current.workbooks.should == []
|
336
|
+
end
|
337
|
+
|
338
|
+
it "should not write the main workbook and close the linked file as well" do
|
339
|
+
Workbook.unobtrusively(@main_file, :writable => false) do |book|
|
340
|
+
book.ReadOnly.should be true
|
341
|
+
book.filename.should == @main_file
|
342
|
+
@old_value = book.sheet(1)[1,1]
|
343
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
344
|
+
end
|
345
|
+
Excel.current.workbooks.map{|b| b.filename}.should == [@sub_file]
|
346
|
+
end
|
347
|
+
|
348
|
+
end
|
349
|
+
|
350
|
+
context "with open books" do
|
351
|
+
|
352
|
+
before do
|
353
|
+
@book_main = Workbook.open(@main_file)
|
354
|
+
end
|
355
|
+
|
356
|
+
it "should leave the read-only mode" do
|
357
|
+
Workbook.unobtrusively(@sub_file, :read_only_default => true) do |book|
|
358
|
+
book.ReadOnly.should be false
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
it "should force to read-only" do
|
363
|
+
expect{
|
364
|
+
Workbook.unobtrusively(@sub_file, :read_only => true) do
|
365
|
+
end
|
366
|
+
}.to raise_error(WorkbookLinked)
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
109
371
|
describe "Workbook#unobtrusively" do
|
110
372
|
|
111
373
|
context "with a writable saved workbook" do
|
112
374
|
|
113
375
|
before do
|
114
376
|
@book = Workbook.open(@simple_file1, :visible => true)
|
115
|
-
@old_value = @book.sheet(1)[1,1]
|
377
|
+
@old_value = @book.sheet(1)[1,1]
|
116
378
|
end
|
117
379
|
|
118
380
|
after do
|
@@ -124,41 +386,41 @@ describe Workbook do
|
|
124
386
|
book.saved.should be true
|
125
387
|
book.visible.should be true
|
126
388
|
book.writable.should be true
|
127
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
389
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
128
390
|
end
|
129
391
|
@book.saved.should be true
|
130
392
|
@book.visible.should be true
|
131
393
|
@book.writable.should be true
|
132
|
-
@book.sheet(1)[1,1].
|
394
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
133
395
|
@book.close
|
134
396
|
new_book = Workbook.open(@simple_file1)
|
135
|
-
new_book.sheet(1)[1,1].
|
397
|
+
new_book.sheet(1)[1,1].should_not == @old_value
|
136
398
|
end
|
137
399
|
|
138
400
|
it "should unobtrusively open, modify, and not save the changes" do
|
139
401
|
@book.unobtrusively(:writable => false) do |book|
|
140
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
402
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
141
403
|
end
|
142
404
|
@book.saved.should be true
|
143
405
|
@book.visible.should be true
|
144
406
|
@book.writable.should be true
|
145
|
-
@book.sheet(1)[1,1].
|
407
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
146
408
|
@book.close
|
147
409
|
new_book = Workbook.open(@simple_file1)
|
148
|
-
new_book.sheet(1)[1,1].
|
410
|
+
new_book.sheet(1)[1,1].should == @old_value
|
149
411
|
end
|
150
412
|
|
151
413
|
it "should unobtrusively open, modify, and save the changes" do
|
152
414
|
@book.unobtrusively(:writable => true) do |book|
|
153
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
415
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
154
416
|
end
|
155
417
|
@book.saved.should be true
|
156
418
|
@book.visible.should be true
|
157
419
|
@book.writable.should be true
|
158
|
-
@book.sheet(1)[1,1].
|
420
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
159
421
|
@book.close
|
160
422
|
new_book = Workbook.open(@simple_file1)
|
161
|
-
new_book.sheet(1)[1,1].
|
423
|
+
new_book.sheet(1)[1,1].should_not == @old_value
|
162
424
|
end
|
163
425
|
|
164
426
|
end
|
@@ -167,9 +429,9 @@ describe Workbook do
|
|
167
429
|
|
168
430
|
before do
|
169
431
|
@book = Workbook.open(@simple_file1, :visible => true)
|
170
|
-
@old_value = @book.sheet(1)[1,1]
|
432
|
+
@old_value = @book.sheet(1)[1,1]
|
171
433
|
sheet = @book.sheet(1)
|
172
|
-
sheet[1,1] = sheet[1,1]
|
434
|
+
sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
|
173
435
|
end
|
174
436
|
|
175
437
|
after do
|
@@ -181,15 +443,15 @@ describe Workbook do
|
|
181
443
|
book.saved.should be false
|
182
444
|
book.visible.should be true
|
183
445
|
book.writable.should be true
|
184
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
446
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
185
447
|
end
|
186
448
|
@book.saved.should be false
|
187
449
|
@book.visible.should be true
|
188
450
|
@book.writable.should be true
|
189
|
-
@book.sheet(1)[1,1].
|
451
|
+
@book.sheet(1)[1,1].should == @old_value
|
190
452
|
@book.close(:if_unsaved => :forget)
|
191
453
|
@book = Workbook.open(@simple_file1)
|
192
|
-
@book.sheet(1)[1,1].
|
454
|
+
@book.sheet(1)[1,1].should == @old_value
|
193
455
|
end
|
194
456
|
|
195
457
|
it "should unobtrusively open, modify, and not save the changes" do
|
@@ -199,23 +461,23 @@ describe Workbook do
|
|
199
461
|
@book.saved.should be false
|
200
462
|
@book.visible.should be true
|
201
463
|
@book.writable.should be true
|
202
|
-
@book.sheet(1)[1,1].
|
464
|
+
@book.sheet(1)[1,1].should == "bla"
|
203
465
|
@book.close(:if_unsaved => :forget)
|
204
466
|
new_book = Workbook.open(@simple_file1)
|
205
|
-
new_book.sheet(1)[1,1].
|
467
|
+
new_book.sheet(1)[1,1].should == @old_value
|
206
468
|
end
|
207
469
|
|
208
470
|
it "should unobtrusively open, modify, and save the changes" do
|
209
471
|
@book.unobtrusively(:writable => true) do |book|
|
210
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
472
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
211
473
|
end
|
212
474
|
@book.saved.should be false
|
213
475
|
@book.visible.should be true
|
214
476
|
@book.writable.should be true
|
215
|
-
@book.sheet(1)[1,1].
|
477
|
+
@book.sheet(1)[1,1].should == @old_value
|
216
478
|
@book.close(:if_unsaved => :forget)
|
217
479
|
new_book = Workbook.open(@simple_file1)
|
218
|
-
new_book.sheet(1)[1,1].
|
480
|
+
new_book.sheet(1)[1,1].should == @old_value
|
219
481
|
end
|
220
482
|
|
221
483
|
end
|
@@ -224,7 +486,7 @@ describe Workbook do
|
|
224
486
|
|
225
487
|
before do
|
226
488
|
@book = Workbook.open(@simple_file1, :visible => true)
|
227
|
-
@old_value = @book.sheet(1)[1,1]
|
489
|
+
@old_value = @book.sheet(1)[1,1]
|
228
490
|
@book.close
|
229
491
|
end
|
230
492
|
|
@@ -238,11 +500,11 @@ describe Workbook do
|
|
238
500
|
book.saved.should be true
|
239
501
|
book.visible.should be true
|
240
502
|
book.writable.should be true
|
241
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
503
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
242
504
|
end
|
243
505
|
@book.should_not be_alive
|
244
506
|
new_book = Workbook.open(@simple_file1)
|
245
|
-
new_book.sheet(1)[1,1].
|
507
|
+
new_book.sheet(1)[1,1].should_not == @old_value
|
246
508
|
end
|
247
509
|
|
248
510
|
it "should unobtrusively open and and not close the workbook" do
|
@@ -251,16 +513,16 @@ describe Workbook do
|
|
251
513
|
book.saved.should be true
|
252
514
|
book.visible.should be true
|
253
515
|
book.writable.should be true
|
254
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
516
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
255
517
|
end
|
256
518
|
@book.should be_alive
|
257
519
|
@book.saved.should be true
|
258
520
|
@book.visible.should be true
|
259
521
|
@book.writable.should be true
|
260
|
-
@book.sheet(1)[1,1].
|
522
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
261
523
|
@book.close
|
262
524
|
new_book = Workbook.open(@simple_file1)
|
263
|
-
new_book.sheet(1)[1,1].
|
525
|
+
new_book.sheet(1)[1,1].should_not == @old_value
|
264
526
|
end
|
265
527
|
|
266
528
|
end
|
@@ -274,7 +536,7 @@ describe Workbook do
|
|
274
536
|
Workbook.unobtrusively(@simple_file) do |book|
|
275
537
|
book.should be_a Workbook
|
276
538
|
sheet = book.sheet(1)
|
277
|
-
sheet[1,1] = sheet[1,1]
|
539
|
+
sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
|
278
540
|
book.should be_alive
|
279
541
|
book.Saved.should be false
|
280
542
|
end
|
@@ -326,7 +588,7 @@ describe Workbook do
|
|
326
588
|
it "should connect" do
|
327
589
|
Workbook.unobtrusively(@simple_file1) do |book|
|
328
590
|
book.excel.Workbooks.Count.should == 1
|
329
|
-
Excel.
|
591
|
+
Excel.instance_count.should == 1
|
330
592
|
book.FullName.should == General.absolute_path(@simple_file1)
|
331
593
|
book.saved.should be true
|
332
594
|
book.visible.should be false
|
@@ -383,8 +645,8 @@ describe Workbook do
|
|
383
645
|
book.saved.should be true
|
384
646
|
book.visible.should be false
|
385
647
|
book.writable.should be true
|
386
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
387
|
-
@new_value = book.sheet(1)[1,1]
|
648
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
649
|
+
@new_value = book.sheet(1)[1,1]
|
388
650
|
book.Saved.should be false
|
389
651
|
end
|
390
652
|
ole_wb = WIN32OLE.connect(@abs_filename)
|
@@ -393,8 +655,8 @@ describe Workbook do
|
|
393
655
|
ole_wb.ReadOnly.should be false
|
394
656
|
ole_wb.Close
|
395
657
|
book2 = Workbook.open(@simple_file1)
|
396
|
-
book2.sheet(1)[1,1].
|
397
|
-
book2.sheet(1)[1,1].
|
658
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
659
|
+
book2.sheet(1)[1,1].should == @new_value
|
398
660
|
end
|
399
661
|
|
400
662
|
it "should modify and remain saved-status and not save the new value when writable => false" do
|
@@ -402,8 +664,8 @@ describe Workbook do
|
|
402
664
|
book.saved.should be true
|
403
665
|
book.visible.should be false
|
404
666
|
book.writable.should be true
|
405
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
406
|
-
@new_value = book.sheet(1)[1,1]
|
667
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
668
|
+
@new_value = book.sheet(1)[1,1]
|
407
669
|
book.Saved.should be false
|
408
670
|
end
|
409
671
|
ole_wb = WIN32OLE.connect(@abs_filename)
|
@@ -412,8 +674,8 @@ describe Workbook do
|
|
412
674
|
ole_wb.ReadOnly.should be false
|
413
675
|
ole_wb.Close
|
414
676
|
book2 = Workbook.open(@simple_file1)
|
415
|
-
book2.sheet(1)[1,1].
|
416
|
-
book2.sheet(1)[1,1].
|
677
|
+
book2.sheet(1)[1,1].should == @old_value
|
678
|
+
book2.sheet(1)[1,1].should_not == @new_value
|
417
679
|
end
|
418
680
|
|
419
681
|
end
|
@@ -464,9 +726,9 @@ describe Workbook do
|
|
464
726
|
@ole_wb = ws.Open(@abs_filename)
|
465
727
|
@ole_e1.Visible = true
|
466
728
|
@ole_wb.Windows(@ole_wb.Name).Visible = true
|
467
|
-
@old_value = @ole_wb.Worksheets.Item(1).Cells.Item(1,1)
|
729
|
+
@old_value = @ole_wb.Worksheets.Item(1).Cells.Item(1,1)
|
468
730
|
@ole_wb.Worksheets.Item(1).Cells.Item(1,1).Value = @old_value = "foo" #== "foo" ? "bar" : "foo"
|
469
|
-
@new_value = @ole_wb.Worksheets.Item(1).Cells.Item(1,1)
|
731
|
+
@new_value = @ole_wb.Worksheets.Item(1).Cells.Item(1,1)
|
470
732
|
@ole_wb.Saved.should be false
|
471
733
|
end
|
472
734
|
|
@@ -506,8 +768,8 @@ describe Workbook do
|
|
506
768
|
|
507
769
|
it "should remain unsaved when modifying" do
|
508
770
|
Workbook.unobtrusively(@simple_file1) do |book|
|
509
|
-
book.sheet(1)[1,1] = "bar" #book.sheet(1)[1,1]
|
510
|
-
@new_value = book.sheet(1)[1,1]
|
771
|
+
book.sheet(1)[1,1] = "bar" #book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
772
|
+
@new_value = book.sheet(1)[1,1]
|
511
773
|
book.saved.should be false
|
512
774
|
book.visible.should be true
|
513
775
|
book.writable.should be true
|
@@ -518,8 +780,8 @@ describe Workbook do
|
|
518
780
|
ole_wb.ReadOnly.should be false
|
519
781
|
Excel.kill_all
|
520
782
|
book2 = Workbook.open(@simple_file1)
|
521
|
-
book2.sheet(1)[1,1].
|
522
|
-
book2.sheet(1)[1,1].
|
783
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
784
|
+
book2.sheet(1)[1,1].should == @new_value
|
523
785
|
end
|
524
786
|
|
525
787
|
it "should not write with :writable => false" do
|
@@ -527,8 +789,8 @@ describe Workbook do
|
|
527
789
|
@ole_wb.Save
|
528
790
|
@ole_wb.Worksheets.Item(1).Cells.Item(1,1).Value = @old_value = "foo"
|
529
791
|
Workbook.unobtrusively(@simple_file1, :writable => false) do |book|
|
530
|
-
book.sheet(1)[1,1] = "bar" #book.sheet(1)[1,1]
|
531
|
-
@new_value = book.sheet(1)[1,1]
|
792
|
+
book.sheet(1)[1,1] = "bar" #book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
793
|
+
@new_value = book.sheet(1)[1,1]
|
532
794
|
book.saved.should be false
|
533
795
|
book.visible.should be true
|
534
796
|
book.writable.should be true
|
@@ -539,8 +801,8 @@ describe Workbook do
|
|
539
801
|
ole_wb.ReadOnly.should be false
|
540
802
|
Excel.kill_all
|
541
803
|
book2 = Workbook.open(@simple_file1)
|
542
|
-
book2.sheet(1)[1,1].
|
543
|
-
book2.sheet(1)[1,1].
|
804
|
+
book2.sheet(1)[1,1].should == @old_value
|
805
|
+
book2.sheet(1)[1,1].should_not == @new_value
|
544
806
|
end
|
545
807
|
|
546
808
|
end
|
@@ -584,8 +846,8 @@ describe Workbook do
|
|
584
846
|
|
585
847
|
it "should remain read-only when modifying" do
|
586
848
|
Workbook.unobtrusively(@simple_file1) do |book|
|
587
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
588
|
-
@new_value = book.sheet(1)[1,1]
|
849
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
850
|
+
@new_value = book.sheet(1)[1,1]
|
589
851
|
book.saved.should be false
|
590
852
|
book.visible.should be true
|
591
853
|
book.writable.should be false
|
@@ -596,14 +858,14 @@ describe Workbook do
|
|
596
858
|
ole_wb.ReadOnly.should be true
|
597
859
|
ole_wb.Close
|
598
860
|
book2 = Workbook.open(@simple_file1)
|
599
|
-
book2.sheet(1)[1,1].
|
600
|
-
book2.sheet(1)[1,1].
|
861
|
+
book2.sheet(1)[1,1].should == @old_value
|
862
|
+
book2.sheet(1)[1,1].should_not == @new_value
|
601
863
|
end
|
602
864
|
|
603
865
|
it "should remain read-only when modifying" do
|
604
866
|
Workbook.unobtrusively(@simple_file1, :read_only => false) do |book|
|
605
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
606
|
-
@new_value = book.sheet(1)[1,1]
|
867
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
868
|
+
@new_value = book.sheet(1)[1,1]
|
607
869
|
book.saved.should be false
|
608
870
|
book.visible.should be true
|
609
871
|
book.writable.should be true
|
@@ -614,14 +876,14 @@ describe Workbook do
|
|
614
876
|
ole_wb.ReadOnly.should be true
|
615
877
|
ole_wb.Close
|
616
878
|
book2 = Workbook.open(@simple_file1)
|
617
|
-
book2.sheet(1)[1,1].
|
618
|
-
book2.sheet(1)[1,1].
|
879
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
880
|
+
book2.sheet(1)[1,1].should == @new_value
|
619
881
|
end
|
620
882
|
|
621
883
|
it "should remain read-only when modifying" do
|
622
884
|
Workbook.unobtrusively(@simple_file1, :read_only => false, :writable => true) do |book|
|
623
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
624
|
-
@new_value = book.sheet(1)[1,1]
|
885
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
886
|
+
@new_value = book.sheet(1)[1,1]
|
625
887
|
book.saved.should be false
|
626
888
|
book.visible.should be true
|
627
889
|
book.writable.should be true
|
@@ -632,14 +894,14 @@ describe Workbook do
|
|
632
894
|
ole_wb.ReadOnly.should be true
|
633
895
|
ole_wb.Close
|
634
896
|
book2 = Workbook.open(@simple_file1)
|
635
|
-
book2.sheet(1)[1,1].
|
636
|
-
book2.sheet(1)[1,1].
|
897
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
898
|
+
book2.sheet(1)[1,1].should == @new_value
|
637
899
|
end
|
638
900
|
|
639
901
|
it "should remain read-only when modifying and not save changes, when :writable => false" do
|
640
902
|
Workbook.unobtrusively(@simple_file1, :writable => false, :read_only => false) do |book|
|
641
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
642
|
-
@new_value = book.sheet(1)[1,1]
|
903
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
904
|
+
@new_value = book.sheet(1)[1,1]
|
643
905
|
book.saved.should be false
|
644
906
|
book.visible.should be true
|
645
907
|
book.writable.should be true
|
@@ -650,14 +912,14 @@ describe Workbook do
|
|
650
912
|
ole_wb.ReadOnly.should be true
|
651
913
|
ole_wb.Close
|
652
914
|
book2 = Workbook.open(@simple_file1)
|
653
|
-
book2.sheet(1)[1,1].
|
654
|
-
book2.sheet(1)[1,1].
|
915
|
+
book2.sheet(1)[1,1].should == @old_value
|
916
|
+
book2.sheet(1)[1,1].should_not == @new_value
|
655
917
|
end
|
656
918
|
|
657
919
|
it "should remain read-only when modifying and not save changes, when :writable => false" do
|
658
920
|
Workbook.unobtrusively(@simple_file1, :read_only => false, :writable => false) do |book|
|
659
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
660
|
-
@new_value = book.sheet(1)[1,1]
|
921
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
922
|
+
@new_value = book.sheet(1)[1,1]
|
661
923
|
book.saved.should be false
|
662
924
|
book.visible.should be true
|
663
925
|
book.writable.should be true
|
@@ -668,15 +930,15 @@ describe Workbook do
|
|
668
930
|
ole_wb.ReadOnly.should be true
|
669
931
|
ole_wb.Close
|
670
932
|
book2 = Workbook.open(@simple_file1)
|
671
|
-
book2.sheet(1)[1,1].
|
672
|
-
book2.sheet(1)[1,1].
|
933
|
+
book2.sheet(1)[1,1].should == @old_value
|
934
|
+
book2.sheet(1)[1,1].should_not == @new_value
|
673
935
|
end
|
674
936
|
|
675
937
|
|
676
938
|
it "should remain read-only when modifying and not save changes, when :writable => false" do
|
677
939
|
Workbook.unobtrusively(@simple_file1, :writable => false, :read_only => false) do |book|
|
678
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
679
|
-
@new_value = book.sheet(1)[1,1]
|
940
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
941
|
+
@new_value = book.sheet(1)[1,1]
|
680
942
|
book.saved.should be false
|
681
943
|
book.visible.should be true
|
682
944
|
book.writable.should be true
|
@@ -687,14 +949,14 @@ describe Workbook do
|
|
687
949
|
ole_wb.ReadOnly.should be true
|
688
950
|
ole_wb.Close
|
689
951
|
book2 = Workbook.open(@simple_file1)
|
690
|
-
book2.sheet(1)[1,1].
|
691
|
-
book2.sheet(1)[1,1].
|
952
|
+
book2.sheet(1)[1,1].should == @old_value
|
953
|
+
book2.sheet(1)[1,1].should_not == @new_value
|
692
954
|
end
|
693
955
|
|
694
956
|
it "should remain read-only when modifying and not save changes, even if :writable => true" do
|
695
957
|
Workbook.unobtrusively(@simple_file1, :writable => true) do |book|
|
696
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
697
|
-
@new_value = book.sheet(1)[1,1]
|
958
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
959
|
+
@new_value = book.sheet(1)[1,1]
|
698
960
|
book.saved.should be false
|
699
961
|
book.visible.should be true
|
700
962
|
book.writable.should be false
|
@@ -705,14 +967,14 @@ describe Workbook do
|
|
705
967
|
ole_wb.ReadOnly.should be true
|
706
968
|
ole_wb.Close
|
707
969
|
book2 = Workbook.open(@simple_file1)
|
708
|
-
book2.sheet(1)[1,1].
|
709
|
-
book2.sheet(1)[1,1].
|
970
|
+
book2.sheet(1)[1,1].should == @old_value
|
971
|
+
book2.sheet(1)[1,1].should_not == @new_value
|
710
972
|
end
|
711
973
|
|
712
974
|
it "should remain read-only when modifying and not save changes, when :writable => false" do
|
713
975
|
Workbook.unobtrusively(@simple_file1, :writable => false) do |book|
|
714
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
715
|
-
@new_value = book.sheet(1)[1,1]
|
976
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
977
|
+
@new_value = book.sheet(1)[1,1]
|
716
978
|
book.saved.should be false
|
717
979
|
book.visible.should be true
|
718
980
|
book.writable.should be false
|
@@ -723,8 +985,8 @@ describe Workbook do
|
|
723
985
|
ole_wb.ReadOnly.should be true
|
724
986
|
Excel.kill_all
|
725
987
|
book2 = Workbook.open(@simple_file1)
|
726
|
-
book2.sheet(1)[1,1].
|
727
|
-
book2.sheet(1)[1,1].
|
988
|
+
book2.sheet(1)[1,1].should == @old_value
|
989
|
+
book2.sheet(1)[1,1].should_not == @new_value
|
728
990
|
end
|
729
991
|
|
730
992
|
|
@@ -736,7 +998,7 @@ describe Workbook do
|
|
736
998
|
|
737
999
|
it "should open one excel instance and workbook should be closed" do
|
738
1000
|
Workbook.unobtrusively(@simple_file1){ |book| nil }
|
739
|
-
Excel.
|
1001
|
+
Excel.instance_count.should == 1
|
740
1002
|
end
|
741
1003
|
|
742
1004
|
end
|
@@ -757,97 +1019,97 @@ describe Workbook do
|
|
757
1019
|
it "should open read-write" do
|
758
1020
|
Workbook.unobtrusively(@simple_file1) do |book|
|
759
1021
|
book.ReadOnly.should be false
|
760
|
-
@old_value = book.sheet(1)[1,1]
|
761
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1022
|
+
@old_value = book.sheet(1)[1,1]
|
1023
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
762
1024
|
book.Saved.should be false
|
763
1025
|
end
|
764
1026
|
Excel.current.Workbooks.Count.should == 0
|
765
1027
|
b1 = Workbook.open(@simple_file1)
|
766
|
-
b1.sheet(1)[1,1].
|
1028
|
+
b1.sheet(1)[1,1].should_not == @old_value
|
767
1029
|
end
|
768
1030
|
|
769
1031
|
it "should open as read-write" do
|
770
1032
|
Workbook.unobtrusively(@simple_file, :read_only => false) do |book|
|
771
1033
|
book.ReadOnly.should be false
|
772
|
-
@old_value = book.sheet(1)[1,1]
|
773
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1034
|
+
@old_value = book.sheet(1)[1,1]
|
1035
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
774
1036
|
book.Saved.should be false
|
775
1037
|
end
|
776
1038
|
Excel.current.Workbooks.Count.should == 0
|
777
1039
|
b1 = Workbook.open(@simple_file1)
|
778
|
-
b1.sheet(1)[1,1].
|
1040
|
+
b1.sheet(1)[1,1].should_not == @old_value
|
779
1041
|
end
|
780
1042
|
|
781
|
-
it "should open as read-write" do
|
1043
|
+
it "should open as read-write but not save changes" do
|
782
1044
|
Workbook.unobtrusively(@simple_file, :read_only => false, :writable => false) do |book|
|
783
1045
|
book.ReadOnly.should be false
|
784
|
-
@old_value = book.sheet(1)[1,1]
|
785
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1046
|
+
@old_value = book.sheet(1)[1,1]
|
1047
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
786
1048
|
book.Saved.should be false
|
787
1049
|
end
|
788
1050
|
Excel.current.Workbooks.Count.should == 0
|
789
1051
|
b1 = Workbook.open(@simple_file1)
|
790
|
-
b1.sheet(1)[1,1].
|
1052
|
+
b1.sheet(1)[1,1].should == @old_value
|
791
1053
|
end
|
792
1054
|
|
793
1055
|
it "should open as read-write" do
|
794
1056
|
Workbook.unobtrusively(@simple_file, :writable => true) do |book|
|
795
1057
|
book.ReadOnly.should be false
|
796
|
-
@old_value = book.sheet(1)[1,1]
|
797
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1058
|
+
@old_value = book.sheet(1)[1,1]
|
1059
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
798
1060
|
book.Saved.should be false
|
799
1061
|
end
|
800
1062
|
Excel.current.Workbooks.Count.should == 0
|
801
1063
|
b1 = Workbook.open(@simple_file1)
|
802
|
-
b1.sheet(1)[1,1].
|
1064
|
+
b1.sheet(1)[1,1].should_not == @old_value
|
803
1065
|
end
|
804
1066
|
|
805
1067
|
it "should open as read-write" do
|
806
1068
|
Workbook.unobtrusively(@simple_file, :writable => true, :read_only => false) do |book|
|
807
1069
|
book.ReadOnly.should be false
|
808
|
-
@old_value = book.sheet(1)[1,1]
|
809
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1070
|
+
@old_value = book.sheet(1)[1,1]
|
1071
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
810
1072
|
book.Saved.should be false
|
811
1073
|
end
|
812
1074
|
Excel.current.Workbooks.Count.should == 0
|
813
1075
|
b1 = Workbook.open(@simple_file1)
|
814
|
-
b1.sheet(1)[1,1].
|
1076
|
+
b1.sheet(1)[1,1].should_not == @old_value
|
815
1077
|
end
|
816
1078
|
|
817
1079
|
it "should open read-only" do
|
818
1080
|
Workbook.unobtrusively(@simple_file, :read_only => true) do |book|
|
819
1081
|
book.ReadOnly.should be true
|
820
|
-
@old_value = book.sheet(1)[1,1]
|
821
|
-
#book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1082
|
+
@old_value = book.sheet(1)[1,1]
|
1083
|
+
#book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
822
1084
|
#book.Saved.should be false
|
823
1085
|
end
|
824
1086
|
Excel.current.Workbooks.Count.should == 0
|
825
1087
|
b1 = Workbook.open(@simple_file1)
|
826
|
-
b1.sheet(1)[1,1].
|
1088
|
+
b1.sheet(1)[1,1].should == @old_value
|
827
1089
|
end
|
828
1090
|
|
829
1091
|
it "should open read-only" do
|
830
1092
|
Workbook.unobtrusively(@simple_file, :read_only => true, :writable => false) do |book|
|
831
1093
|
book.ReadOnly.should be true
|
832
|
-
@old_value = book.sheet(1)[1,1]
|
833
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1094
|
+
@old_value = book.sheet(1)[1,1]
|
1095
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
834
1096
|
book.Saved.should be false
|
835
1097
|
end
|
836
1098
|
Excel.current.Workbooks.Count.should == 0
|
837
1099
|
b1 = Workbook.open(@simple_file1)
|
838
|
-
b1.sheet(1)[1,1].
|
1100
|
+
b1.sheet(1)[1,1].should == @old_value
|
839
1101
|
end
|
840
1102
|
|
841
|
-
it "should open not writable" do
|
1103
|
+
it "should open not writable and read-only" do
|
842
1104
|
Workbook.unobtrusively(@simple_file, :writable => false) do |book|
|
843
|
-
|
844
|
-
@old_value = book.sheet(1)[1,1]
|
845
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1105
|
+
book.ReadOnly.should be true
|
1106
|
+
@old_value = book.sheet(1)[1,1]
|
1107
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
846
1108
|
book.Saved.should be false
|
847
1109
|
end
|
848
1110
|
Excel.current.Workbooks.Count.should == 0
|
849
1111
|
b1 = Workbook.open(@simple_file1)
|
850
|
-
b1.sheet(1)[1,1].
|
1112
|
+
b1.sheet(1)[1,1].should == @old_value
|
851
1113
|
end
|
852
1114
|
|
853
1115
|
it "should raise error if both options are true" do
|
@@ -861,7 +1123,7 @@ describe Workbook do
|
|
861
1123
|
|
862
1124
|
before do
|
863
1125
|
@book = Workbook.open(@simple_file1)
|
864
|
-
@old_value = @book.sheet(1)[1,1]
|
1126
|
+
@old_value = @book.sheet(1)[1,1]
|
865
1127
|
end
|
866
1128
|
|
867
1129
|
it "should open as read-write by default" do
|
@@ -870,11 +1132,11 @@ describe Workbook do
|
|
870
1132
|
book.should == @book
|
871
1133
|
book.filename.should == @book.filename
|
872
1134
|
book.excel.should == @book.excel
|
873
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1135
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
874
1136
|
end
|
875
1137
|
@book.close
|
876
1138
|
book2 = Workbook.open(@simple_file1)
|
877
|
-
book2.sheet(1)[1,1].
|
1139
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
878
1140
|
end
|
879
1141
|
|
880
1142
|
it "should open as read-write" do
|
@@ -883,11 +1145,11 @@ describe Workbook do
|
|
883
1145
|
book.should == @book
|
884
1146
|
book.filename.should == @book.filename
|
885
1147
|
book.excel.should == @book.excel
|
886
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1148
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
887
1149
|
end
|
888
1150
|
@book.close
|
889
1151
|
book2 = Workbook.open(@simple_file1)
|
890
|
-
book2.sheet(1)[1,1].
|
1152
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
891
1153
|
end
|
892
1154
|
|
893
1155
|
it "should open as read-write" do
|
@@ -896,11 +1158,11 @@ describe Workbook do
|
|
896
1158
|
book.should == @book
|
897
1159
|
book.filename.should == @book.filename
|
898
1160
|
book.excel.should == @book.excel
|
899
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1161
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
900
1162
|
end
|
901
1163
|
@book.close
|
902
1164
|
book2 = Workbook.open(@simple_file1)
|
903
|
-
book2.sheet(1)[1,1].
|
1165
|
+
book2.sheet(1)[1,1].should == @old_value
|
904
1166
|
end
|
905
1167
|
|
906
1168
|
it "should open as read-write" do
|
@@ -909,11 +1171,11 @@ describe Workbook do
|
|
909
1171
|
book.should == @book
|
910
1172
|
book.filename.should == @book.filename
|
911
1173
|
book.excel.should == @book.excel
|
912
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1174
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
913
1175
|
end
|
914
1176
|
@book.close
|
915
1177
|
book2 = Workbook.open(@simple_file1)
|
916
|
-
book2.sheet(1)[1,1].
|
1178
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
917
1179
|
end
|
918
1180
|
|
919
1181
|
it "should open as read-write" do
|
@@ -922,11 +1184,11 @@ describe Workbook do
|
|
922
1184
|
book.should == @book
|
923
1185
|
book.filename.should == @book.filename
|
924
1186
|
book.excel.should == @book.excel
|
925
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1187
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
926
1188
|
end
|
927
1189
|
@book.close
|
928
1190
|
book2 = Workbook.open(@simple_file1)
|
929
|
-
book2.sheet(1)[1,1].
|
1191
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
930
1192
|
end
|
931
1193
|
|
932
1194
|
it "should force to read-only" do
|
@@ -935,8 +1197,8 @@ describe Workbook do
|
|
935
1197
|
book.ReadOnly.should be true
|
936
1198
|
book.should == @book
|
937
1199
|
book.filename.should == @book.filename
|
938
|
-
book.excel.
|
939
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1200
|
+
book.excel.should == @book.excel
|
1201
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
940
1202
|
end
|
941
1203
|
}.to raise_error(WorkbookReadOnly)
|
942
1204
|
end
|
@@ -950,11 +1212,11 @@ describe Workbook do
|
|
950
1212
|
book.should == @book
|
951
1213
|
book.filename.should == @book.filename
|
952
1214
|
book.excel.should == @book.excel
|
953
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1215
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
954
1216
|
end
|
955
1217
|
@book.close
|
956
1218
|
book2 = Workbook.open(@simple_file1)
|
957
|
-
book2.sheet(1)[1,1].
|
1219
|
+
book2.sheet(1)[1,1].should == @old_value
|
958
1220
|
end
|
959
1221
|
|
960
1222
|
it "should open not writable" do
|
@@ -963,11 +1225,11 @@ describe Workbook do
|
|
963
1225
|
book.should == @book
|
964
1226
|
book.filename.should == @book.filename
|
965
1227
|
book.excel.should == @book.excel
|
966
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1228
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
967
1229
|
end
|
968
1230
|
@book.close
|
969
1231
|
book2 = Workbook.open(@simple_file1)
|
970
|
-
book2.sheet(1)[1,1].
|
1232
|
+
book2.sheet(1)[1,1].should == @old_value
|
971
1233
|
end
|
972
1234
|
end
|
973
1235
|
|
@@ -975,23 +1237,23 @@ describe Workbook do
|
|
975
1237
|
|
976
1238
|
before do
|
977
1239
|
@book = Workbook.open(@simple_file1, :read_only => true)
|
978
|
-
@old_value = @book.sheet(1)[1,1]
|
1240
|
+
@old_value = @book.sheet(1)[1,1]
|
979
1241
|
end
|
980
1242
|
|
981
1243
|
it "should not write" do
|
982
1244
|
Workbook.unobtrusively(@simple_file1, :writable => false) do |book|
|
983
1245
|
book.Readonly.should be true
|
984
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
985
|
-
book.sheet(1)[1,1].
|
1246
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1247
|
+
book.sheet(1)[1,1].should_not == @old_value
|
986
1248
|
end
|
987
1249
|
@book.ReadOnly.should be true
|
988
1250
|
@book.close
|
989
1251
|
Workbook.unobtrusively(@simple_file1, :writable => false) do |book|
|
990
|
-
book.sheet(1)[1,1].
|
1252
|
+
book.sheet(1)[1,1].should == @old_value
|
991
1253
|
end
|
992
1254
|
#@book.close
|
993
1255
|
#book2 = Workbook.open(@simple_file1)
|
994
|
-
#book2.sheet(1)[1,1].
|
1256
|
+
#book2.sheet(1)[1,1].should == @old_value
|
995
1257
|
end
|
996
1258
|
|
997
1259
|
it "should not change the read_only mode" do
|
@@ -1000,12 +1262,12 @@ describe Workbook do
|
|
1000
1262
|
book.should == @book
|
1001
1263
|
book.filename.should == @book.filename
|
1002
1264
|
book.excel.should == @book.excel
|
1003
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1265
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1004
1266
|
end
|
1005
1267
|
@book.ReadOnly.should be true
|
1006
1268
|
@book.close
|
1007
1269
|
book2 = Workbook.open(@simple_file1)
|
1008
|
-
book2.sheet(1)[1,1].
|
1270
|
+
book2.sheet(1)[1,1].should == @old_value
|
1009
1271
|
end
|
1010
1272
|
|
1011
1273
|
it "should open as read-write" do
|
@@ -1013,12 +1275,12 @@ describe Workbook do
|
|
1013
1275
|
book.Readonly.should be false
|
1014
1276
|
book.should == @book
|
1015
1277
|
book.filename.should == @book.filename
|
1016
|
-
book.excel.
|
1017
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1278
|
+
book.excel.should == @book.excel
|
1279
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1018
1280
|
end
|
1019
1281
|
@book.close
|
1020
1282
|
book2 = Workbook.open(@simple_file1)
|
1021
|
-
book2.sheet(1)[1,1].
|
1283
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1022
1284
|
end
|
1023
1285
|
|
1024
1286
|
it "should open as read-write" do
|
@@ -1026,12 +1288,12 @@ describe Workbook do
|
|
1026
1288
|
book.Readonly.should be false
|
1027
1289
|
book.should == @book
|
1028
1290
|
book.filename.should == @book.filename
|
1029
|
-
book.excel.
|
1030
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1291
|
+
book.excel.should == @book.excel
|
1292
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1031
1293
|
end
|
1032
1294
|
@book.close
|
1033
1295
|
book2 = Workbook.open(@simple_file1)
|
1034
|
-
book2.sheet(1)[1,1].
|
1296
|
+
book2.sheet(1)[1,1].should == @old_value
|
1035
1297
|
end
|
1036
1298
|
|
1037
1299
|
it "should remain read-only even if writeble => true" do
|
@@ -1040,11 +1302,11 @@ describe Workbook do
|
|
1040
1302
|
book.should == @book
|
1041
1303
|
book.filename.should == @book.filename
|
1042
1304
|
book.excel.should == @book.excel
|
1043
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1305
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1044
1306
|
end
|
1045
1307
|
@book.close
|
1046
1308
|
book2 = Workbook.open(@simple_file1)
|
1047
|
-
book2.sheet(1)[1,1].
|
1309
|
+
book2.sheet(1)[1,1].should == @old_value
|
1048
1310
|
end
|
1049
1311
|
|
1050
1312
|
it "should force to read-write" do
|
@@ -1053,11 +1315,11 @@ describe Workbook do
|
|
1053
1315
|
book.should == @book
|
1054
1316
|
book.filename.should == @book.filename
|
1055
1317
|
book.excel.should == @book.excel
|
1056
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1318
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1057
1319
|
end
|
1058
1320
|
@book.close
|
1059
1321
|
book2 = Workbook.open(@simple_file1)
|
1060
|
-
book2.sheet(1)[1,1].
|
1322
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1061
1323
|
end
|
1062
1324
|
|
1063
1325
|
=begin
|
@@ -1067,11 +1329,11 @@ describe Workbook do
|
|
1067
1329
|
book.Readonly.should be false
|
1068
1330
|
book.filename.should == @book.filename
|
1069
1331
|
book.excel.should == e1
|
1070
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1332
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1071
1333
|
end
|
1072
1334
|
@book.close
|
1073
1335
|
book2 = Workbook.open(@simple_file1)
|
1074
|
-
book2.sheet(1)[1,1].
|
1336
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1075
1337
|
end
|
1076
1338
|
|
1077
1339
|
it "should force to read-write" do
|
@@ -1080,11 +1342,11 @@ describe Workbook do
|
|
1080
1342
|
book.should == @book
|
1081
1343
|
book.filename.should == @book.filename
|
1082
1344
|
book.excel.should == @book.excel
|
1083
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1345
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1084
1346
|
end
|
1085
1347
|
@book.close
|
1086
1348
|
book2 = Workbook.open(@simple_file1)
|
1087
|
-
book2.sheet(1)[1,1].
|
1349
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1088
1350
|
end
|
1089
1351
|
|
1090
1352
|
it "should force to read-write" do
|
@@ -1092,11 +1354,11 @@ describe Workbook do
|
|
1092
1354
|
book.Readonly.should be false
|
1093
1355
|
book.filename.should == @book.filename
|
1094
1356
|
book.excel.should_not == @book.excel
|
1095
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1357
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1096
1358
|
end
|
1097
1359
|
@book.close
|
1098
1360
|
book2 = Workbook.open(@simple_file1)
|
1099
|
-
book2.sheet(1)[1,1].
|
1361
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1100
1362
|
end
|
1101
1363
|
=end
|
1102
1364
|
|
@@ -1106,11 +1368,11 @@ describe Workbook do
|
|
1106
1368
|
book.should == @book
|
1107
1369
|
book.filename.should == @book.filename
|
1108
1370
|
book.excel.should == @book.excel
|
1109
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1371
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1110
1372
|
end
|
1111
1373
|
@book.close
|
1112
1374
|
book2 = Workbook.open(@simple_file1)
|
1113
|
-
book2.sheet(1)[1,1].
|
1375
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1114
1376
|
end
|
1115
1377
|
|
1116
1378
|
it "should force to read-only" do
|
@@ -1119,11 +1381,11 @@ describe Workbook do
|
|
1119
1381
|
book.should == @book
|
1120
1382
|
book.filename.should == @book.filename
|
1121
1383
|
book.excel.should == @book.excel
|
1122
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1384
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1123
1385
|
end
|
1124
1386
|
@book.close
|
1125
1387
|
book2 = Workbook.open(@simple_file1)
|
1126
|
-
book2.sheet(1)[1,1].
|
1388
|
+
book2.sheet(1)[1,1].should == @old_value
|
1127
1389
|
end
|
1128
1390
|
|
1129
1391
|
it "should force to read-only" do
|
@@ -1132,11 +1394,11 @@ describe Workbook do
|
|
1132
1394
|
book.should == @book
|
1133
1395
|
book.filename.should == @book.filename
|
1134
1396
|
book.excel.should == @book.excel
|
1135
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1397
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1136
1398
|
end
|
1137
1399
|
@book.close
|
1138
1400
|
book2 = Workbook.open(@simple_file1)
|
1139
|
-
book2.sheet(1)[1,1].
|
1401
|
+
book2.sheet(1)[1,1].should == @old_value
|
1140
1402
|
end
|
1141
1403
|
|
1142
1404
|
it "should open not writable" do
|
@@ -1145,11 +1407,11 @@ describe Workbook do
|
|
1145
1407
|
book.should == @book
|
1146
1408
|
book.filename.should == @book.filename
|
1147
1409
|
book.excel.should == @book.excel
|
1148
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1410
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1149
1411
|
end
|
1150
1412
|
@book.close
|
1151
1413
|
book2 = Workbook.open(@simple_file1)
|
1152
|
-
book2.sheet(1)[1,1].
|
1414
|
+
book2.sheet(1)[1,1].should == @old_value
|
1153
1415
|
end
|
1154
1416
|
end
|
1155
1417
|
|
@@ -1157,8 +1419,8 @@ describe Workbook do
|
|
1157
1419
|
|
1158
1420
|
before do
|
1159
1421
|
@book = Workbook.open(@simple_file1)
|
1160
|
-
@book.sheet(1)[1,1] = @book.sheet(1)[1,1]
|
1161
|
-
@old_value = @book.sheet(1)[1,1]
|
1422
|
+
@book.sheet(1)[1,1] = @book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1423
|
+
@old_value = @book.sheet(1)[1,1]
|
1162
1424
|
end
|
1163
1425
|
|
1164
1426
|
it "should open as read-write by default" do
|
@@ -1167,10 +1429,10 @@ describe Workbook do
|
|
1167
1429
|
book.should == @book
|
1168
1430
|
book.filename.should == @book.filename
|
1169
1431
|
book.excel.should == @book.excel
|
1170
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1432
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1171
1433
|
end
|
1172
1434
|
@book.Saved.should be false
|
1173
|
-
@book.sheet(1)[1,1].
|
1435
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
1174
1436
|
end
|
1175
1437
|
|
1176
1438
|
it "should open as read-write" do
|
@@ -1179,10 +1441,10 @@ describe Workbook do
|
|
1179
1441
|
book.should == @book
|
1180
1442
|
book.filename.should == @book.filename
|
1181
1443
|
book.excel.should == @book.excel
|
1182
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1444
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1183
1445
|
end
|
1184
1446
|
@book.Saved.should be false
|
1185
|
-
@book.sheet(1)[1,1].
|
1447
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
1186
1448
|
end
|
1187
1449
|
|
1188
1450
|
it "should open as read-write" do
|
@@ -1191,10 +1453,10 @@ describe Workbook do
|
|
1191
1453
|
book.should == @book
|
1192
1454
|
book.filename.should == @book.filename
|
1193
1455
|
book.excel.should == @book.excel
|
1194
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1456
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1195
1457
|
end
|
1196
1458
|
@book.Saved.should be false
|
1197
|
-
@book.sheet(1)[1,1].
|
1459
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
1198
1460
|
end
|
1199
1461
|
|
1200
1462
|
it "should force to read-write" do
|
@@ -1203,10 +1465,10 @@ describe Workbook do
|
|
1203
1465
|
book.should == @book
|
1204
1466
|
book.filename.should == @book.filename
|
1205
1467
|
book.excel.should == @book.excel
|
1206
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1468
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1207
1469
|
end
|
1208
1470
|
@book.Saved.should be false
|
1209
|
-
@book.sheet(1)[1,1].
|
1471
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
1210
1472
|
end
|
1211
1473
|
|
1212
1474
|
it "should force to read-write" do
|
@@ -1215,10 +1477,10 @@ describe Workbook do
|
|
1215
1477
|
book.should == @book
|
1216
1478
|
book.filename.should == @book.filename
|
1217
1479
|
book.excel.should == @book.excel
|
1218
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1480
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1219
1481
|
end
|
1220
1482
|
@book.Saved.should be false
|
1221
|
-
@book.sheet(1)[1,1].
|
1483
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
1222
1484
|
end
|
1223
1485
|
|
1224
1486
|
it "should force to read-only" do
|
@@ -1227,7 +1489,7 @@ describe Workbook do
|
|
1227
1489
|
end
|
1228
1490
|
@book.Saved.should be false
|
1229
1491
|
@book.ReadOnly.should be false
|
1230
|
-
@book.sheet(1)[1,1].
|
1492
|
+
@book.sheet(1)[1,1].should == @old_value
|
1231
1493
|
end
|
1232
1494
|
|
1233
1495
|
it "should force to read-only with writable false" do
|
@@ -1236,7 +1498,7 @@ describe Workbook do
|
|
1236
1498
|
end
|
1237
1499
|
@book.Saved.should be false
|
1238
1500
|
@book.ReadOnly.should be false
|
1239
|
-
@book.sheet(1)[1,1].
|
1501
|
+
@book.sheet(1)[1,1].should == @old_value
|
1240
1502
|
end
|
1241
1503
|
|
1242
1504
|
it "should open not writable" do
|
@@ -1245,13 +1507,13 @@ describe Workbook do
|
|
1245
1507
|
book.should == @book
|
1246
1508
|
book.filename.should == @book.filename
|
1247
1509
|
book.excel.should == @book.excel
|
1248
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1510
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1249
1511
|
end
|
1250
1512
|
@book.Saved.should be false
|
1251
|
-
@book.sheet(1)[1,1].
|
1513
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
1252
1514
|
@book.close(:if_unsaved => :forget)
|
1253
1515
|
book2 = Workbook.open(@simple_file1)
|
1254
|
-
book2.sheet(1)[1,1].
|
1516
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1255
1517
|
end
|
1256
1518
|
end
|
1257
1519
|
|
@@ -1259,8 +1521,8 @@ describe Workbook do
|
|
1259
1521
|
|
1260
1522
|
before do
|
1261
1523
|
@book = Workbook.open(@simple_file1, :read_only => true)
|
1262
|
-
@book.sheet(1)[1,1] = @book.sheet(1)[1,1]
|
1263
|
-
@old_value = @book.sheet(1)[1,1]
|
1524
|
+
@book.sheet(1)[1,1] = @book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1525
|
+
@old_value = @book.sheet(1)[1,1]
|
1264
1526
|
end
|
1265
1527
|
|
1266
1528
|
it "should open as read-only by default" do
|
@@ -1269,14 +1531,14 @@ describe Workbook do
|
|
1269
1531
|
book.should == @book
|
1270
1532
|
book.filename.should == @book.filename
|
1271
1533
|
book.excel.should == @book.excel
|
1272
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1534
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1273
1535
|
end
|
1274
1536
|
@book.Saved.should be false
|
1275
1537
|
@book.ReadOnly.should be true
|
1276
|
-
@book.sheet(1)[1,1].
|
1538
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
1277
1539
|
@book.close
|
1278
1540
|
book2 = Workbook.open(@simple_file1)
|
1279
|
-
book2.sheet(1)[1,1].
|
1541
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1280
1542
|
end
|
1281
1543
|
|
1282
1544
|
it "should open as read-only" do
|
@@ -1289,13 +1551,13 @@ describe Workbook do
|
|
1289
1551
|
Workbook.unobtrusively(@simple_file1, :writable => true) do |book|
|
1290
1552
|
book.Readonly.should be true
|
1291
1553
|
book.Saved.should be false
|
1292
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1554
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1293
1555
|
end
|
1294
1556
|
@book.ReadOnly.should be true
|
1295
|
-
@book.sheet(1)[1,1].
|
1557
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
1296
1558
|
@book.close
|
1297
1559
|
book2 = Workbook.open(@simple_file1)
|
1298
|
-
book2.sheet(1)[1,1].
|
1560
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1299
1561
|
end
|
1300
1562
|
|
1301
1563
|
it "should force to read-only" do
|
@@ -1304,14 +1566,14 @@ describe Workbook do
|
|
1304
1566
|
book.should == @book
|
1305
1567
|
book.filename.should == @book.filename
|
1306
1568
|
book.excel.should == @book.excel
|
1307
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1569
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1308
1570
|
end
|
1309
1571
|
@book.Saved.should be false
|
1310
1572
|
@book.ReadOnly.should be true
|
1311
|
-
@book.sheet(1)[1,1].
|
1573
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
1312
1574
|
@book.close
|
1313
1575
|
book2 = Workbook.open(@simple_file1)
|
1314
|
-
book2.sheet(1)[1,1].
|
1576
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1315
1577
|
end
|
1316
1578
|
|
1317
1579
|
it "should force to read-only" do
|
@@ -1320,14 +1582,14 @@ describe Workbook do
|
|
1320
1582
|
book.should == @book
|
1321
1583
|
book.filename.should == @book.filename
|
1322
1584
|
book.excel.should == @book.excel
|
1323
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1585
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1324
1586
|
end
|
1325
1587
|
@book.Saved.should be false
|
1326
1588
|
@book.ReadOnly.should be true
|
1327
|
-
@book.sheet(1)[1,1].
|
1589
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
1328
1590
|
@book.close
|
1329
1591
|
book2 = Workbook.open(@simple_file1)
|
1330
|
-
book2.sheet(1)[1,1].
|
1592
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1331
1593
|
end
|
1332
1594
|
|
1333
1595
|
it "should open not writable" do
|
@@ -1336,14 +1598,14 @@ describe Workbook do
|
|
1336
1598
|
book.should == @book
|
1337
1599
|
book.filename.should == @book.filename
|
1338
1600
|
book.excel.should == @book.excel
|
1339
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1601
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1340
1602
|
end
|
1341
1603
|
@book.Saved.should be false
|
1342
1604
|
@book.ReadOnly.should be true
|
1343
|
-
@book.sheet(1)[1,1].
|
1605
|
+
@book.sheet(1)[1,1].should_not == @old_value
|
1344
1606
|
@book.close
|
1345
1607
|
book2 = Workbook.open(@simple_file1)
|
1346
|
-
book2.sheet(1)[1,1].
|
1608
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1347
1609
|
end
|
1348
1610
|
end
|
1349
1611
|
|
@@ -1377,94 +1639,94 @@ describe Workbook do
|
|
1377
1639
|
|
1378
1640
|
it "should write in the outer and inner block" do
|
1379
1641
|
Workbook.unobtrusively(@simple_file1) do |book|
|
1380
|
-
@old_value = book.sheet(1)[1,1]
|
1642
|
+
@old_value = book.sheet(1)[1,1]
|
1381
1643
|
book.ReadOnly.should be false
|
1382
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1644
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1383
1645
|
book.Saved.should be false
|
1384
|
-
book.sheet(1)[1,1].
|
1646
|
+
book.sheet(1)[1,1].should_not == @old_value
|
1385
1647
|
Workbook.unobtrusively(@simple_file1) do |book2|
|
1386
1648
|
book2.should == book
|
1387
1649
|
book2.ReadOnly.should be false
|
1388
1650
|
book2.Saved.should be false
|
1389
|
-
book2.sheet(1)[1,1].
|
1390
|
-
book2.sheet(1)[1,1] = book2.sheet(1)[1,1]
|
1391
|
-
book2.sheet(1)[1,1].
|
1651
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1652
|
+
book2.sheet(1)[1,1] = book2.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1653
|
+
book2.sheet(1)[1,1].should == @old_value
|
1392
1654
|
end
|
1393
1655
|
book.should be_alive
|
1394
1656
|
book.Saved.should be false
|
1395
|
-
book.sheet(1)[1,1].
|
1657
|
+
book.sheet(1)[1,1].should == @old_value
|
1396
1658
|
end
|
1397
1659
|
book = Workbook.open(@simple_file1)
|
1398
|
-
book.sheet(1)[1,1].
|
1660
|
+
book.sheet(1)[1,1].should == @old_value
|
1399
1661
|
end
|
1400
1662
|
=begin
|
1401
1663
|
it "should write in the outer and not in the inner block" do
|
1402
1664
|
Workbook.unobtrusively(@simple_file1, :if_unsaved => :forget) do |book|
|
1403
|
-
@old_value = book.sheet(1)[1,1]
|
1665
|
+
@old_value = book.sheet(1)[1,1]
|
1404
1666
|
book.ReadOnly.should be false
|
1405
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1667
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1406
1668
|
book.Saved.should be false
|
1407
|
-
book.sheet(1)[1,1].
|
1669
|
+
book.sheet(1)[1,1].should_not == @old_value
|
1408
1670
|
Workbook.unobtrusively(@simple_file1, :if_unsaved => :forget, :read_only => true) do |book2|
|
1409
1671
|
book2.should == book
|
1410
1672
|
book2.ReadOnly.should be true
|
1411
1673
|
book2.Saved.should be true
|
1412
|
-
book2.sheet(1)[1,1] = book2.sheet(1)[1,1]
|
1413
|
-
#book2.sheet(1)[1,1].
|
1674
|
+
book2.sheet(1)[1,1] = book2.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1675
|
+
#book2.sheet(1)[1,1].should_not == @old_value
|
1414
1676
|
end
|
1415
1677
|
book.should be_alive
|
1416
1678
|
book.Saved.should be false
|
1417
|
-
book.sheet(1)[1,1].
|
1679
|
+
book.sheet(1)[1,1].should_not == @old_value
|
1418
1680
|
end
|
1419
1681
|
book = Workbook.open(@simple_file1)
|
1420
|
-
book.sheet(1)[1,1].
|
1682
|
+
book.sheet(1)[1,1].should_not == @old_value
|
1421
1683
|
end
|
1422
1684
|
=end
|
1423
1685
|
it "should write in the outer and not in the inner block" do
|
1424
1686
|
Workbook.unobtrusively(@simple_file1) do |book|
|
1425
|
-
@old_value = book.sheet(1)[1,1]
|
1687
|
+
@old_value = book.sheet(1)[1,1]
|
1426
1688
|
book.ReadOnly.should be false
|
1427
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1689
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1428
1690
|
book.Saved.should be false
|
1429
|
-
book.sheet(1)[1,1].
|
1691
|
+
book.sheet(1)[1,1].should_not == @old_value
|
1430
1692
|
Workbook.unobtrusively(@simple_file1, :writable => false) do |book2|
|
1431
1693
|
book2.should == book
|
1432
1694
|
book2.ReadOnly.should be false
|
1433
1695
|
book2.Saved.should be false
|
1434
|
-
book2.sheet(1)[1,1].
|
1435
|
-
book2.sheet(1)[1,1] = book2.sheet(1)[1,1]
|
1436
|
-
book2.sheet(1)[1,1].
|
1696
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1697
|
+
book2.sheet(1)[1,1] = book2.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1698
|
+
book2.sheet(1)[1,1].should == @old_value
|
1437
1699
|
end
|
1438
1700
|
book.should be_alive
|
1439
1701
|
book.Saved.should be false
|
1440
|
-
book.sheet(1)[1,1].
|
1702
|
+
book.sheet(1)[1,1].should == @old_value
|
1441
1703
|
end
|
1442
1704
|
book = Workbook.open(@simple_file1)
|
1443
|
-
book.sheet(1)[1,1].
|
1705
|
+
book.sheet(1)[1,1].should == @old_value
|
1444
1706
|
end
|
1445
1707
|
=begin
|
1446
1708
|
it "should be read-only in the outer and write in the inner block" do
|
1447
1709
|
Workbook.unobtrusively(@simple_file1, :read_only => true, :if_unsaved => :save) do |book|
|
1448
|
-
@old_value = book.sheet(1)[1,1]
|
1710
|
+
@old_value = book.sheet(1)[1,1]
|
1449
1711
|
book.ReadOnly.should be true
|
1450
|
-
book.sheet(1)[1,1] = book.sheet(1)[1,1]
|
1712
|
+
book.sheet(1)[1,1] = book.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1451
1713
|
book.Saved.should be false
|
1452
|
-
book.sheet(1)[1,1].
|
1714
|
+
book.sheet(1)[1,1].should_not == @old_value
|
1453
1715
|
Workbook.unobtrusively(@simple_file1, :if_unsaved => :save) do |book2|
|
1454
1716
|
book2.should == book
|
1455
1717
|
book2.ReadOnly.should be true
|
1456
1718
|
book2.Saved.should be false
|
1457
|
-
book2.sheet(1)[1,1].
|
1458
|
-
book2.sheet(1)[1,1] = book2.sheet(1)[1,1]
|
1459
|
-
book2.sheet(1)[1,1].
|
1719
|
+
book2.sheet(1)[1,1].should_not == @old_value
|
1720
|
+
book2.sheet(1)[1,1] = book2.sheet(1)[1,1] == "foo" ? "bar" : "foo"
|
1721
|
+
book2.sheet(1)[1,1].should == @old_value
|
1460
1722
|
end
|
1461
1723
|
book.should be_alive
|
1462
1724
|
book.Saved.should be false
|
1463
1725
|
book.ReadOnly.should be true
|
1464
|
-
book.sheet(1)[1,1].
|
1726
|
+
book.sheet(1)[1,1].should == @old_value
|
1465
1727
|
end
|
1466
1728
|
book = Workbook.open(@simple_file1)
|
1467
|
-
book.sheet(1)[1,1].
|
1729
|
+
book.sheet(1)[1,1].should == @old_value
|
1468
1730
|
end
|
1469
1731
|
=end
|
1470
1732
|
end
|
@@ -1510,31 +1772,31 @@ describe Workbook do
|
|
1510
1772
|
|
1511
1773
|
it "should write and remain read_only and open the workbook in another Excel" do
|
1512
1774
|
book1 = Workbook.open(@simple_file1, :read_only => true)
|
1513
|
-
old_value = book1.sheet(1)[1,1]
|
1775
|
+
old_value = book1.sheet(1)[1,1]
|
1514
1776
|
Workbook.unobtrusively(@simple_file1) do |book|
|
1515
1777
|
sheet = book.sheet(1)
|
1516
|
-
sheet[1,1] = sheet[1,1]
|
1778
|
+
sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
|
1517
1779
|
book.excel.should == book1.excel
|
1518
1780
|
end
|
1519
1781
|
book1.ReadOnly.should be true
|
1520
1782
|
book1.close
|
1521
1783
|
book2 = Workbook.open(@simple_file1)
|
1522
|
-
book2.sheet(1)[1,1].
|
1784
|
+
book2.sheet(1)[1,1].should == old_value
|
1523
1785
|
end
|
1524
1786
|
|
1525
1787
|
it "should write and remain read_only and open the workbook in the same Excel" do
|
1526
1788
|
book1 = Workbook.open(@simple_file1, :read_only => true)
|
1527
|
-
old_value = book1.sheet(1)[1,1]
|
1789
|
+
old_value = book1.sheet(1)[1,1]
|
1528
1790
|
Workbook.unobtrusively(@simple_file1, :writable => true) do |book|
|
1529
1791
|
book.ReadOnly.should be true
|
1530
1792
|
sheet = book.sheet(1)
|
1531
|
-
sheet[1,1] = sheet[1,1]
|
1793
|
+
sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
|
1532
1794
|
book.excel.should == book1.excel
|
1533
1795
|
end
|
1534
1796
|
book1.ReadOnly.should be true
|
1535
1797
|
book1.close
|
1536
1798
|
book2 = Workbook.open(@simple_file1)
|
1537
|
-
book2.sheet(1)[1,1].
|
1799
|
+
book2.sheet(1)[1,1].should == old_value
|
1538
1800
|
end
|
1539
1801
|
|
1540
1802
|
end
|
@@ -1733,18 +1995,18 @@ describe Workbook do
|
|
1733
1995
|
@book.Saved.should be true
|
1734
1996
|
@book.should be_alive
|
1735
1997
|
sheet = @book.sheet(1)
|
1736
|
-
old_cell_value = sheet[1,1]
|
1998
|
+
old_cell_value = sheet[1,1]
|
1737
1999
|
unobtrusively_ok?
|
1738
2000
|
@book.Saved.should be true
|
1739
2001
|
@book.should be_alive
|
1740
2002
|
sheet = @book.sheet(1)
|
1741
|
-
sheet[1,1].
|
2003
|
+
sheet[1,1].should_not == old_cell_value
|
1742
2004
|
end
|
1743
2005
|
|
1744
2006
|
it "should let the unsaved book unsaved" do
|
1745
2007
|
sheet = @book.sheet(1)
|
1746
|
-
sheet[1,1] = sheet[1,1]
|
1747
|
-
old_cell_value = sheet[1,1]
|
2008
|
+
sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
|
2009
|
+
old_cell_value = sheet[1,1]
|
1748
2010
|
@book.Saved.should be false
|
1749
2011
|
unobtrusively_ok?
|
1750
2012
|
@book.should be_alive
|
@@ -1752,7 +2014,7 @@ describe Workbook do
|
|
1752
2014
|
@book.close(:if_unsaved => :forget)
|
1753
2015
|
@book2 = Workbook.open(@simple_file1)
|
1754
2016
|
sheet2 = @book2.sheet(1)
|
1755
|
-
sheet2[1,1].
|
2017
|
+
sheet2[1,1].should_not == old_cell_value
|
1756
2018
|
end
|
1757
2019
|
|
1758
2020
|
it "should modify unobtrusively the second, writable book" do
|
@@ -1760,8 +2022,8 @@ describe Workbook do
|
|
1760
2022
|
@book.ReadOnly.should be false
|
1761
2023
|
@book2.ReadOnly.should be true
|
1762
2024
|
sheet = @book2.sheet(1)
|
1763
|
-
old_cell_value = sheet[1,1]
|
1764
|
-
sheet[1,1] = sheet[1,1]
|
2025
|
+
old_cell_value = sheet[1,1]
|
2026
|
+
sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
|
1765
2027
|
unobtrusively_ok?
|
1766
2028
|
@book2.should be_alive
|
1767
2029
|
@book2.Saved.should be false
|
@@ -1769,7 +2031,7 @@ describe Workbook do
|
|
1769
2031
|
@book.close
|
1770
2032
|
new_book = Workbook.open(@simple_file1)
|
1771
2033
|
sheet2 = new_book.sheet(1)
|
1772
|
-
sheet2[1,1].
|
2034
|
+
sheet2[1,1].should_not == old_cell_value
|
1773
2035
|
end
|
1774
2036
|
end
|
1775
2037
|
|
@@ -1786,21 +2048,21 @@ describe Workbook do
|
|
1786
2048
|
|
1787
2049
|
it "should let the closed book closed by default" do
|
1788
2050
|
sheet = @book.sheet(1)
|
1789
|
-
old_cell_value = sheet[1,1]
|
2051
|
+
old_cell_value = sheet[1,1]
|
1790
2052
|
@book.close
|
1791
2053
|
@book.should_not be_alive
|
1792
2054
|
unobtrusively_ok?
|
1793
2055
|
@book.should_not be_alive
|
1794
2056
|
new_book = Workbook.open(@simple_file1)
|
1795
2057
|
sheet = new_book.sheet(1)
|
1796
|
-
sheet[1,1].
|
2058
|
+
sheet[1,1].should_not == old_cell_value
|
1797
2059
|
end
|
1798
2060
|
|
1799
2061
|
# The bold reanimation of the @book
|
1800
2062
|
it "should use the excel of the book and keep open the book" do
|
1801
2063
|
excel = Excel.new(:reuse => false)
|
1802
2064
|
sheet = @book.sheet(1)
|
1803
|
-
old_cell_value = sheet[1,1]
|
2065
|
+
old_cell_value = sheet[1,1]
|
1804
2066
|
@book.close
|
1805
2067
|
@book.should_not be_alive
|
1806
2068
|
Workbook.unobtrusively(@simple_file, :keep_open => true) do |book|
|
@@ -1809,21 +2071,21 @@ describe Workbook do
|
|
1809
2071
|
book.excel.should_not == excel
|
1810
2072
|
sheet = book.sheet(1)
|
1811
2073
|
cell = sheet[1,1]
|
1812
|
-
sheet[1,1] = cell
|
2074
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
1813
2075
|
book.Saved.should be false
|
1814
2076
|
end
|
1815
2077
|
@book.should be_alive
|
1816
2078
|
@book.close
|
1817
2079
|
new_book = Workbook.open(@simple_file1)
|
1818
2080
|
sheet = new_book.sheet(1)
|
1819
|
-
sheet[1,1].
|
2081
|
+
sheet[1,1].should_not == old_cell_value
|
1820
2082
|
end
|
1821
2083
|
|
1822
2084
|
# book shall be reanimated
|
1823
2085
|
it "should use the excel of the book and keep open the book" do
|
1824
2086
|
excel = Excel.new(:reuse => false)
|
1825
2087
|
sheet = @book.sheet(1)
|
1826
|
-
old_cell_value = sheet[1,1]
|
2088
|
+
old_cell_value = sheet[1,1]
|
1827
2089
|
@book.close
|
1828
2090
|
@book.should_not be_alive
|
1829
2091
|
Workbook.unobtrusively(@simple_file, :if_closed => :new) do |book|
|
@@ -1833,38 +2095,38 @@ describe Workbook do
|
|
1833
2095
|
book.excel.should_not == excel
|
1834
2096
|
sheet = book.sheet(1)
|
1835
2097
|
cell = sheet[1,1]
|
1836
|
-
sheet[1,1] = cell
|
2098
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
1837
2099
|
book.Saved.should be false
|
1838
2100
|
end
|
1839
2101
|
@book.should_not be_alive
|
1840
2102
|
new_book = Workbook.open(@simple_file1)
|
1841
2103
|
sheet = new_book.sheet(1)
|
1842
|
-
sheet[1,1].
|
2104
|
+
sheet[1,1].should_not == old_cell_value
|
1843
2105
|
end
|
1844
2106
|
|
1845
2107
|
it "should use another excel if the Excels are closed" do
|
1846
2108
|
sheet = @book.sheet(1)
|
1847
|
-
old_cell_value = sheet[1,1]
|
2109
|
+
old_cell_value = sheet[1,1]
|
1848
2110
|
@book.close
|
1849
2111
|
@book.should_not be_alive
|
1850
2112
|
Workbook.unobtrusively(@simple_file, :keep_open => true) do |book|
|
1851
2113
|
book.should be_a Workbook
|
1852
2114
|
sheet = book.sheet(1)
|
1853
2115
|
cell = sheet[1,1]
|
1854
|
-
sheet[1,1] = cell
|
2116
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
1855
2117
|
book.Saved.should be false
|
1856
2118
|
end
|
1857
2119
|
@book.should be_alive
|
1858
2120
|
@book.close
|
1859
2121
|
new_book = Workbook.open(@simple_file1)
|
1860
2122
|
sheet = new_book.sheet(1)
|
1861
|
-
sheet[1,1].
|
2123
|
+
sheet[1,1].should_not == old_cell_value
|
1862
2124
|
end
|
1863
2125
|
|
1864
2126
|
it "should use another excel if the Excels are closed" do
|
1865
2127
|
excel = Excel.new(:reuse => false)
|
1866
2128
|
sheet = @book.sheet(1)
|
1867
|
-
old_cell_value = sheet[1,1]
|
2129
|
+
old_cell_value = sheet[1,1]
|
1868
2130
|
@book.close
|
1869
2131
|
@book.should_not be_alive
|
1870
2132
|
Excel.kill_all
|
@@ -1874,33 +2136,33 @@ describe Workbook do
|
|
1874
2136
|
book.excel.should_not == excel
|
1875
2137
|
sheet = book.sheet(1)
|
1876
2138
|
cell = sheet[1,1]
|
1877
|
-
sheet[1,1] = cell
|
2139
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
1878
2140
|
book.Saved.should be false
|
1879
2141
|
end
|
1880
2142
|
@book.should_not be_alive
|
1881
2143
|
new_book = Workbook.open(@simple_file1)
|
1882
2144
|
sheet = new_book.sheet(1)
|
1883
|
-
sheet[1,1].
|
2145
|
+
sheet[1,1].should_not == old_cell_value
|
1884
2146
|
end
|
1885
2147
|
|
1886
2148
|
it "should modify unobtrusively the copied file" do
|
1887
2149
|
sheet = @book.sheet(1)
|
1888
|
-
old_cell_value = sheet[1,1]
|
2150
|
+
old_cell_value = sheet[1,1]
|
1889
2151
|
File.delete simple_save_file rescue nil
|
1890
2152
|
@book.save_as(@simple_save_file)
|
1891
2153
|
@book.close
|
1892
2154
|
Workbook.unobtrusively(@simple_save_file) do |book|
|
1893
2155
|
sheet = book.sheet(1)
|
1894
2156
|
cell = sheet[1,1]
|
1895
|
-
sheet[1,1] = cell
|
2157
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
1896
2158
|
end
|
1897
2159
|
old_book = Workbook.open(@simple_file1)
|
1898
2160
|
old_sheet = old_book.sheet(1)
|
1899
|
-
old_sheet[1,1].
|
2161
|
+
old_sheet[1,1].should == old_cell_value
|
1900
2162
|
old_book.close
|
1901
2163
|
new_book = Workbook.open(@simple_save_file)
|
1902
2164
|
new_sheet = new_book.sheet(1)
|
1903
|
-
new_sheet[1,1].
|
2165
|
+
new_sheet[1,1].should_not == old_cell_value
|
1904
2166
|
new_book.close
|
1905
2167
|
end
|
1906
2168
|
end
|
@@ -1997,7 +2259,7 @@ describe Workbook do
|
|
1997
2259
|
@book.ReadOnly.should be true
|
1998
2260
|
@book.Saved.should be true
|
1999
2261
|
sheet = @book.sheet(1)
|
2000
|
-
old_cell_value = sheet[1,1]
|
2262
|
+
old_cell_value = sheet[1,1]
|
2001
2263
|
unobtrusively_ok?
|
2002
2264
|
@book.should be_alive
|
2003
2265
|
@book.Saved.should be true
|
@@ -2005,20 +2267,20 @@ describe Workbook do
|
|
2005
2267
|
@book.close
|
2006
2268
|
book2 = Workbook.open(@simple_file1)
|
2007
2269
|
sheet2 = book2.sheet(1)
|
2008
|
-
sheet2[1,1].
|
2270
|
+
sheet2[1,1].should == old_cell_value
|
2009
2271
|
end
|
2010
2272
|
|
2011
2273
|
it "should let the unsaved book unsaved" do
|
2012
2274
|
@book.ReadOnly.should be true
|
2013
2275
|
sheet = @book.sheet(1)
|
2014
|
-
sheet[1,1] = sheet[1,1]
|
2276
|
+
sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
|
2015
2277
|
@book.Saved.should be false
|
2016
2278
|
@book.should be_alive
|
2017
2279
|
Workbook.unobtrusively(@simple_file1) do |book|
|
2018
2280
|
book.should be_a Workbook
|
2019
2281
|
sheet = book.sheet(1)
|
2020
|
-
sheet[1,1] = sheet[1,1]
|
2021
|
-
@cell_value = sheet[1,1]
|
2282
|
+
sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
|
2283
|
+
@cell_value = sheet[1,1]
|
2022
2284
|
book.should be_alive
|
2023
2285
|
book.Saved.should be false
|
2024
2286
|
end
|
@@ -2029,7 +2291,7 @@ describe Workbook do
|
|
2029
2291
|
book2 = Workbook.open(@simple_file1)
|
2030
2292
|
sheet2 = book2.sheet(1)
|
2031
2293
|
# modifies unobtrusively the saved version, not the unsaved version
|
2032
|
-
sheet2[1,1].
|
2294
|
+
sheet2[1,1].should == @cell_value
|
2033
2295
|
end
|
2034
2296
|
|
2035
2297
|
it "should open unobtrusively by default the writable book" do
|
@@ -2037,13 +2299,13 @@ describe Workbook do
|
|
2037
2299
|
@book.ReadOnly.should be true
|
2038
2300
|
book2.Readonly.should be false
|
2039
2301
|
sheet = @book.sheet(1)
|
2040
|
-
cell_value = sheet[1,1]
|
2302
|
+
cell_value = sheet[1,1]
|
2041
2303
|
Workbook.unobtrusively(@simple_file1, :if_closed => :new) do |book|
|
2042
2304
|
book.should be_a Workbook
|
2043
2305
|
book.excel.should == book2.excel
|
2044
2306
|
book.excel.should_not == @book.excel
|
2045
2307
|
sheet = book.sheet(1)
|
2046
|
-
sheet[1,1] = sheet[1,1]
|
2308
|
+
sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
|
2047
2309
|
book.should be_alive
|
2048
2310
|
book.Saved.should be false
|
2049
2311
|
end
|
@@ -2053,7 +2315,7 @@ describe Workbook do
|
|
2053
2315
|
book2.close
|
2054
2316
|
book3 = Workbook.open(@simple_file1)
|
2055
2317
|
new_sheet = book3.sheet(1)
|
2056
|
-
new_sheet[1,1].
|
2318
|
+
new_sheet[1,1].should_not == cell_value
|
2057
2319
|
book3.close
|
2058
2320
|
end
|
2059
2321
|
|
@@ -2065,7 +2327,7 @@ describe Workbook do
|
|
2065
2327
|
@book.ReadOnly.should be true
|
2066
2328
|
book2.Readonly.should be true
|
2067
2329
|
sheet = @book.sheet(1)
|
2068
|
-
cell_value = sheet[1,1]
|
2330
|
+
cell_value = sheet[1,1]
|
2069
2331
|
Workbook.unobtrusively(@simple_file1, :writable => true, :if_closed => :new, :rw_change_excel => :new) do |book|
|
2070
2332
|
book.should be_a Workbook
|
2071
2333
|
book.ReadOnly.should be false
|
@@ -2074,7 +2336,7 @@ describe Workbook do
|
|
2074
2336
|
book.excel.should_not == excel1
|
2075
2337
|
book.excel.should_not == excel2
|
2076
2338
|
sheet = book.sheet(1)
|
2077
|
-
sheet[1,1] = sheet[1,1]
|
2339
|
+
sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
|
2078
2340
|
book.should be_alive
|
2079
2341
|
book.Saved.should be false
|
2080
2342
|
end
|
@@ -2084,7 +2346,7 @@ describe Workbook do
|
|
2084
2346
|
book2.close
|
2085
2347
|
book3 = Workbook.open(@simple_file1)
|
2086
2348
|
new_sheet = book3.sheet(1)
|
2087
|
-
new_sheet[1,1].
|
2349
|
+
new_sheet[1,1].should_not == cell_value
|
2088
2350
|
book3.close
|
2089
2351
|
end
|
2090
2352
|
|
@@ -2095,13 +2357,13 @@ describe Workbook do
|
|
2095
2357
|
@book.ReadOnly.should be true
|
2096
2358
|
book2.Readonly.should be true
|
2097
2359
|
sheet = @book.sheet(1)
|
2098
|
-
cell_value = sheet[1,1]
|
2360
|
+
cell_value = sheet[1,1]
|
2099
2361
|
Workbook.unobtrusively(@simple_file1, :writable => true, :if_closed => :new, :rw_change_excel => :current) do |book|
|
2100
2362
|
book.should be_a Workbook
|
2101
2363
|
book.excel.should == book2.excel
|
2102
2364
|
book.ReadOnly.should be false
|
2103
2365
|
sheet = book.sheet(1)
|
2104
|
-
sheet[1,1] = sheet[1,1]
|
2366
|
+
sheet[1,1] = sheet[1,1] == "foo" ? "bar" : "foo"
|
2105
2367
|
book.should be_alive
|
2106
2368
|
book.Saved.should be false
|
2107
2369
|
end
|
@@ -2111,7 +2373,7 @@ describe Workbook do
|
|
2111
2373
|
book2.close
|
2112
2374
|
book3 = Workbook.open(@simple_file1)
|
2113
2375
|
new_sheet = book3.sheet(1)
|
2114
|
-
new_sheet[1,1].
|
2376
|
+
new_sheet[1,1].should_not == cell_value
|
2115
2377
|
book3.close
|
2116
2378
|
end
|
2117
2379
|
=end
|
@@ -2121,7 +2383,7 @@ describe Workbook do
|
|
2121
2383
|
@book.ReadOnly.should be true
|
2122
2384
|
book2.Readonly.should be true
|
2123
2385
|
sheet = @book.sheet(1)
|
2124
|
-
cell_value = sheet[1,1]
|
2386
|
+
cell_value = sheet[1,1]
|
2125
2387
|
Workbook.unobtrusively(@simple_file1, :if_closed => :new, :read_only => true) do |book|
|
2126
2388
|
book.should be_a Workbook
|
2127
2389
|
book.excel.should == book2.excel
|
@@ -2177,7 +2439,7 @@ describe Workbook do
|
|
2177
2439
|
book.Saved.should be true
|
2178
2440
|
sheet = book.sheet(1)
|
2179
2441
|
cell = sheet[1,1]
|
2180
|
-
sheet[1,1] = cell
|
2442
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
2181
2443
|
@book1.Saved.should be false
|
2182
2444
|
book.Saved.should be false
|
2183
2445
|
sleep 1
|
@@ -2225,11 +2487,11 @@ describe Workbook do
|
|
2225
2487
|
|
2226
2488
|
it "should yield the block result with an unmodified book" do
|
2227
2489
|
sheet1 = @book1.sheet(1)
|
2228
|
-
cell1 = sheet1[1,1]
|
2490
|
+
cell1 = sheet1[1,1]
|
2229
2491
|
result =
|
2230
2492
|
Workbook.unobtrusively(@simple_file1) do |book|
|
2231
2493
|
sheet = book.sheet(1)
|
2232
|
-
cell = sheet[1,1]
|
2494
|
+
cell = sheet[1,1]
|
2233
2495
|
end
|
2234
2496
|
result.should == cell1
|
2235
2497
|
end
|
@@ -2257,7 +2519,7 @@ describe Workbook do
|
|
2257
2519
|
@book1.Readonly.should == false
|
2258
2520
|
@book2.Readonly.should == true
|
2259
2521
|
old_sheet = @book1.sheet(1)
|
2260
|
-
@old_cell_value = old_sheet[1,1]
|
2522
|
+
@old_cell_value = old_sheet[1,1]
|
2261
2523
|
@book1.close
|
2262
2524
|
@book2.close
|
2263
2525
|
@book1.should_not be_alive
|
@@ -2271,12 +2533,12 @@ describe Workbook do
|
|
2271
2533
|
book.ReadOnly.should == false
|
2272
2534
|
sheet = book.sheet(1)
|
2273
2535
|
cell = sheet[1,1]
|
2274
|
-
sheet[1,1] = cell
|
2536
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
2275
2537
|
book.Saved.should be false
|
2276
2538
|
end
|
2277
2539
|
new_book = Workbook.open(@simple_file1)
|
2278
2540
|
sheet = new_book.sheet(1)
|
2279
|
-
sheet[1,1].
|
2541
|
+
sheet[1,1].should_not == @old_cell_value
|
2280
2542
|
end
|
2281
2543
|
|
2282
2544
|
it "should open unobtrusively the closed book in the new Excel" do
|
@@ -2286,12 +2548,12 @@ describe Workbook do
|
|
2286
2548
|
book.ReadOnly.should == false
|
2287
2549
|
sheet = book.sheet(1)
|
2288
2550
|
cell = sheet[1,1]
|
2289
|
-
sheet[1,1] = cell
|
2551
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
2290
2552
|
book.Saved.should be false
|
2291
2553
|
end
|
2292
2554
|
new_book = Workbook.open(@simple_file1)
|
2293
2555
|
sheet = new_book.sheet(1)
|
2294
|
-
sheet[1,1].
|
2556
|
+
sheet[1,1].should_not == @old_cell_value
|
2295
2557
|
end
|
2296
2558
|
|
2297
2559
|
it "should open unobtrusively the closed book in a new Excel if the Excel is not alive anymore" do
|
@@ -2302,12 +2564,12 @@ describe Workbook do
|
|
2302
2564
|
book.excel.should_not == @book2.excel
|
2303
2565
|
sheet = book.sheet(1)
|
2304
2566
|
cell = sheet[1,1]
|
2305
|
-
sheet[1,1] = cell
|
2567
|
+
sheet[1,1] = cell == "foo" ? "bar" : "foo"
|
2306
2568
|
book.Saved.should be false
|
2307
2569
|
end
|
2308
2570
|
new_book = Workbook.open(@simple_file1)
|
2309
2571
|
sheet = new_book.sheet(1)
|
2310
|
-
sheet[1,1].
|
2572
|
+
sheet[1,1].should_not == @old_cell_value
|
2311
2573
|
end
|
2312
2574
|
end
|
2313
2575
|
end
|
@@ -2336,108 +2598,4 @@ describe Workbook do
|
|
2336
2598
|
|
2337
2599
|
end
|
2338
2600
|
|
2339
|
-
describe "for_reading, for_modifying" do
|
2340
|
-
|
2341
|
-
context "open unobtrusively for reading and modifying" do
|
2342
|
-
|
2343
|
-
before do
|
2344
|
-
@book = Workbook.open(@simple_file1)
|
2345
|
-
sheet = @book.sheet(1)
|
2346
|
-
@old_cell_value = sheet[1,1].Value
|
2347
|
-
@book.close
|
2348
|
-
end
|
2349
|
-
|
2350
|
-
it "should not change the value" do
|
2351
|
-
Workbook.for_reading(@simple_file1) do |book|
|
2352
|
-
book.should be_a Workbook
|
2353
|
-
book.should be_alive
|
2354
|
-
book.Saved.should be true
|
2355
|
-
sheet = book.sheet(1)
|
2356
|
-
cell = sheet[1,1]
|
2357
|
-
sheet[1,1] = cell.Value == "foo" ? "bar" : "foo"
|
2358
|
-
book.Saved.should be false
|
2359
|
-
book.excel.should == @book.excel
|
2360
|
-
end
|
2361
|
-
Excel.kill_all
|
2362
|
-
new_book = Workbook.open(@simple_file1)
|
2363
|
-
sheet = new_book.sheet(1)
|
2364
|
-
sheet[1,1].Value.should == @old_cell_value
|
2365
|
-
end
|
2366
|
-
|
2367
|
-
it "should not change the value and use a given Excel" do
|
2368
|
-
new_excel = Excel.new(:reuse => false)
|
2369
|
-
another_excel = Excel.new(:reuse => false)
|
2370
|
-
Workbook.for_reading(@simple_file1, :if_closed => another_excel) do |book|
|
2371
|
-
sheet = book.sheet(1)
|
2372
|
-
cell = sheet[1,1]
|
2373
|
-
sheet[1,1] = cell.Value == "foo" ? "bar" : "foo"
|
2374
|
-
book.excel.should == another_excel
|
2375
|
-
end
|
2376
|
-
Excel.kill_all
|
2377
|
-
new_book = Workbook.open(@simple_file1)
|
2378
|
-
sheet = new_book.sheet(1)
|
2379
|
-
sheet[1,1].Value.should == @old_cell_value
|
2380
|
-
end
|
2381
|
-
|
2382
|
-
it "should not change the value and use the new Excel instance" do
|
2383
|
-
new_excel = Excel.new(:reuse => false)
|
2384
|
-
Workbook.for_reading(@simple_file1, :if_closed => :new) do |book|
|
2385
|
-
sheet = book.sheet(1)
|
2386
|
-
cell = sheet[1,1]
|
2387
|
-
sheet[1,1] = cell.Value == "foo" ? "bar" : "foo"
|
2388
|
-
book.excel.should_not == @book.excel
|
2389
|
-
book.excel.should_not == new_excel
|
2390
|
-
book.excel.properties[:visible].should be false
|
2391
|
-
book.excel.properties[:displayalerts].should == :if_visible
|
2392
|
-
end
|
2393
|
-
Excel.kill_all
|
2394
|
-
new_book = Workbook.open(@simple_file1)
|
2395
|
-
sheet = new_book.sheet(1)
|
2396
|
-
sheet[1,1].Value.should == @old_cell_value
|
2397
|
-
end
|
2398
|
-
|
2399
|
-
it "should change the value" do
|
2400
|
-
Workbook.for_modifying(@simple_file1) do |book|
|
2401
|
-
sheet = book.sheet(1)
|
2402
|
-
cell = sheet[1,1]
|
2403
|
-
sheet[1,1] = cell.Value == "foo" ? "bar" : "foo"
|
2404
|
-
book.excel.should == @book.excel
|
2405
|
-
end
|
2406
|
-
new_book = Workbook.open(@simple_file, :visible => true)
|
2407
|
-
sheet = new_book.sheet(1)
|
2408
|
-
sheet[1,1].Value.should_not == @old_cell_value
|
2409
|
-
end
|
2410
|
-
|
2411
|
-
it "should change the value and use a given Excel" do
|
2412
|
-
new_excel = Excel.new(:reuse => false)
|
2413
|
-
another_excel = Excel.new(:reuse => false)
|
2414
|
-
Workbook.for_modifying(@simple_file1, :if_closed => another_excel) do |book|
|
2415
|
-
sheet = book.sheet(1)
|
2416
|
-
cell = sheet[1,1]
|
2417
|
-
sheet[1,1] = cell.Value == "foo" ? "bar" : "foo"
|
2418
|
-
book.excel.should == another_excel
|
2419
|
-
end
|
2420
|
-
new_book = Workbook.open(@simple_file1, :visible => true)
|
2421
|
-
sheet = new_book.sheet(1)
|
2422
|
-
sheet[1,1].Value.should_not == @old_cell_value
|
2423
|
-
end
|
2424
|
-
|
2425
|
-
it "should change the value and use the new Excel instance" do
|
2426
|
-
new_excel = Excel.new(:reuse => false)
|
2427
|
-
Workbook.for_modifying(@simple_file1, :if_closed => :new) do |book|
|
2428
|
-
sheet = book.sheet(1)
|
2429
|
-
cell = sheet[1,1]
|
2430
|
-
sheet[1,1] = cell.Value == "foo" ? "bar" : "foo"
|
2431
|
-
book.excel.should_not == @book.excel
|
2432
|
-
book.excel.should_not == new_excel
|
2433
|
-
book.excel.properties[:visible].should be false
|
2434
|
-
book.excel.properties[:displayalerts].should == :if_visible
|
2435
|
-
end
|
2436
|
-
new_book = Workbook.open(@simple_file1, :visible => true)
|
2437
|
-
sheet = new_book.sheet(1)
|
2438
|
-
sheet[1,1].Value.should_not == @old_cell_value
|
2439
|
-
end
|
2440
|
-
end
|
2441
|
-
end
|
2442
|
-
|
2443
2601
|
end
|