robust_excel_ole 1.3 → 1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog +6 -0
- data/README.rdoc +1 -1
- data/docs/README_open.rdoc +1 -1
- data/docs/README_ranges.rdoc +60 -57
- data/docs/README_sheet.rdoc +1 -1
- data/examples/introducing_examples/example_introducing.rb +42 -0
- data/examples/introducing_examples/example_open.rb +49 -0
- data/examples/introducing_examples/example_range.rb +67 -0
- data/examples/{edit_sheets → modifying_sheets}/example_access_sheets_and_cells.rb +0 -0
- data/examples/{edit_sheets → modifying_sheets}/example_adding_sheets.rb +0 -0
- data/examples/{edit_sheets → modifying_sheets}/example_concating.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_copying.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_expanding.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_naming.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_ranges.rb +1 -1
- data/examples/{edit_sheets → modifying_sheets}/example_saving.rb +1 -1
- data/examples/open_save_close/example_control_to_excel.rb +2 -2
- data/examples/open_save_close/example_if_obstructed_save.rb +2 -2
- data/examples/open_save_close/example_if_unsaved_accept.rb +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_rename_cells.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 +2 -2
- data/lib/robust_excel_ole/bookstore.rb +1 -1
- data/lib/robust_excel_ole/cell.rb +15 -2
- data/lib/robust_excel_ole/excel.rb +14 -12
- data/lib/robust_excel_ole/general.rb +12 -0
- data/lib/robust_excel_ole/range.rb +37 -20
- data/lib/robust_excel_ole/reo_common.rb +63 -37
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/{book.rb → workbook.rb} +35 -33
- data/lib/robust_excel_ole/{sheet.rb → worksheet.rb} +22 -22
- data/spec/bookstore_spec.rb +38 -38
- data/spec/cell_spec.rb +10 -10
- data/spec/data/another_workbook.xls +0 -0
- data/spec/data/workbook.xls +0 -0
- data/spec/excel_spec.rb +113 -105
- data/spec/general_spec.rb +37 -5
- data/spec/range_spec.rb +34 -19
- data/spec/reo_common_spec.rb +58 -48
- data/spec/{book_spec.rb → workbook_spec.rb} +198 -198
- data/spec/workbook_specs/workbook_all_spec.rb +33 -0
- data/spec/{book_specs/book_close_spec.rb → workbook_specs/workbook_close_spec.rb} +10 -10
- data/spec/{book_specs/book_misc_spec.rb → workbook_specs/workbook_misc_spec.rb} +148 -128
- data/spec/{book_specs/book_open_spec.rb → workbook_specs/workbook_open_spec.rb} +427 -427
- data/spec/{book_specs/book_save_spec.rb → workbook_specs/workbook_save_spec.rb} +44 -44
- data/spec/{book_specs/book_sheet_spec.rb → workbook_specs/workbook_sheet_spec.rb} +19 -19
- data/spec/{book_specs/book_subclass_spec.rb → workbook_specs/workbook_subclass_spec.rb} +5 -6
- data/spec/{book_specs/book_unobtr_spec.rb → workbook_specs/workbook_unobtr_spec.rb} +339 -344
- data/spec/{sheet_spec.rb → worksheet_spec.rb} +85 -55
- metadata +25 -22
- data/spec/book_specs/book_all_spec.rb +0 -22
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), './../spec_helper')
|
4
|
+
|
5
|
+
$VERBOSE = nil
|
6
|
+
|
7
|
+
require File.expand_path("workbook_open_spec", File.dirname(__FILE__))
|
8
|
+
require File.expand_path("workbook_close_spec", File.dirname(__FILE__))
|
9
|
+
require File.expand_path("workbook_save_spec", File.dirname(__FILE__))
|
10
|
+
require File.expand_path("workbook_misc_spec", File.dirname(__FILE__))
|
11
|
+
require File.expand_path("workbook_sheet_spec", File.dirname(__FILE__))
|
12
|
+
require File.expand_path("workbook_unobtr_spec", File.dirname(__FILE__))
|
13
|
+
require File.expand_path("workbook_subclass_spec", File.dirname(__FILE__))
|
14
|
+
|
15
|
+
=begin
|
16
|
+
$VERBOSE = nil
|
17
|
+
|
18
|
+
include General
|
19
|
+
|
20
|
+
unless Object.method_defined?(:require_relative)
|
21
|
+
def require_relative path
|
22
|
+
require File.expand_path(path, File.dirname(__FILE__))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require_relative "workbook_open_spec"
|
27
|
+
require_relative "workbook_close_spec"
|
28
|
+
require_relative "workbook_save_spec"
|
29
|
+
require_relative "workbook_misc_spec"
|
30
|
+
require_relative "workbook_sheet_spec"
|
31
|
+
require_relative "workbook_unobtr_spec"
|
32
|
+
require_relative "workbook_subclass_spec"
|
33
|
+
=end
|
@@ -9,7 +9,7 @@ $VERBOSE = nil
|
|
9
9
|
include RobustExcelOle
|
10
10
|
include General
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe Workbook do
|
13
13
|
|
14
14
|
before(:all) do
|
15
15
|
excel = Excel.new(:reuse => true)
|
@@ -40,7 +40,7 @@ describe Book do
|
|
40
40
|
|
41
41
|
context "with saved book" do
|
42
42
|
before do
|
43
|
-
@book =
|
43
|
+
@book = Workbook.open(@simple_file)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should close book" do
|
@@ -53,7 +53,7 @@ describe Book do
|
|
53
53
|
|
54
54
|
context "with unsaved read_only book" do
|
55
55
|
before do
|
56
|
-
@book =
|
56
|
+
@book = Workbook.open(@simple_file1, :read_only => true)
|
57
57
|
@sheet_count = @book.ole_workbook.Worksheets.Count
|
58
58
|
@book.add_sheet(@sheet, :as => 'a_name')
|
59
59
|
end
|
@@ -62,7 +62,7 @@ describe Book do
|
|
62
62
|
expect{
|
63
63
|
@book.close
|
64
64
|
}.to_not raise_error
|
65
|
-
new_book =
|
65
|
+
new_book = Workbook.open(@simple_file1)
|
66
66
|
|
67
67
|
new_book.ole_workbook.Worksheets.Count.should == @sheet_count
|
68
68
|
new_book.close
|
@@ -71,7 +71,7 @@ describe Book do
|
|
71
71
|
|
72
72
|
context "with unsaved book" do
|
73
73
|
before do
|
74
|
-
@book =
|
74
|
+
@book = Workbook.open(@simple_file1)
|
75
75
|
@sheet_count = @book.ole_workbook.Worksheets.Count
|
76
76
|
@book.add_sheet(@sheet, :as => 'a_name')
|
77
77
|
@sheet = @book.sheet(1)
|
@@ -112,7 +112,7 @@ describe Book do
|
|
112
112
|
@book.should_not be_alive
|
113
113
|
#expect{
|
114
114
|
# ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
|
115
|
-
new_book =
|
115
|
+
new_book = Workbook.open(@simple_file1)
|
116
116
|
begin
|
117
117
|
new_book.ole_workbook.Worksheets.Count.should == @sheet_count
|
118
118
|
ensure
|
@@ -131,7 +131,7 @@ describe Book do
|
|
131
131
|
@book.should_not be_alive
|
132
132
|
#expect{
|
133
133
|
# ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
|
134
|
-
new_book =
|
134
|
+
new_book = Workbook.open(@simple_file1)
|
135
135
|
begin
|
136
136
|
new_book.ole_workbook.Worksheets.Count.should == @sheet_count
|
137
137
|
ensure
|
@@ -156,7 +156,7 @@ describe Book do
|
|
156
156
|
@book.should_not be_alive
|
157
157
|
#expect{
|
158
158
|
# ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
|
159
|
-
new_book =
|
159
|
+
new_book = Workbook.open(@simple_file1)
|
160
160
|
begin
|
161
161
|
new_book.ole_workbook.Worksheets.Count.should == @sheet_count + 1
|
162
162
|
ensure
|
@@ -196,7 +196,7 @@ describe Book do
|
|
196
196
|
@book.should_not be_alive
|
197
197
|
# expect{ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
|
198
198
|
end
|
199
|
-
new_book =
|
199
|
+
new_book = Workbook.open(@simple_file1, :if_unsaved => :forget)
|
200
200
|
begin
|
201
201
|
new_book.ole_workbook.Worksheets.Count.should == @sheet_count + (answer==:yes ? 1 : 0)
|
202
202
|
new_book.excel.DisplayAlerts.should == displayalert_value
|
@@ -239,7 +239,7 @@ describe Book do
|
|
239
239
|
@book.should_not be_alive
|
240
240
|
#expect{ole_workbook.Name}.to raise_error(WIN32OLERuntimeError)
|
241
241
|
end
|
242
|
-
new_book =
|
242
|
+
new_book = Workbook.open(@simple_file1, :if_unsaved => :forget)
|
243
243
|
begin
|
244
244
|
new_book.ole_workbook.Worksheets.Count.should == @sheet_count + (answer==:yes ? 1 : 0)
|
245
245
|
new_book.excel.DisplayAlerts.should == displayalert_value
|
@@ -8,7 +8,7 @@ $VERBOSE = nil
|
|
8
8
|
include RobustExcelOle
|
9
9
|
include General
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe Workbook do
|
12
12
|
|
13
13
|
before(:all) do
|
14
14
|
excel = Excel.new(:reuse => true)
|
@@ -39,9 +39,9 @@ describe Book do
|
|
39
39
|
context "with standard" do
|
40
40
|
it "open an existing file" do
|
41
41
|
expect {
|
42
|
-
@book =
|
42
|
+
@book = Workbook.new(@simple_file)
|
43
43
|
}.to_not raise_error
|
44
|
-
@book.should be_a
|
44
|
+
@book.should be_a Workbook
|
45
45
|
@book.close
|
46
46
|
end
|
47
47
|
end
|
@@ -50,7 +50,7 @@ describe Book do
|
|
50
50
|
describe "for_this_workbook" do
|
51
51
|
|
52
52
|
before do
|
53
|
-
@book =
|
53
|
+
@book = Workbook.open(@simple_file)
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should set options" do
|
@@ -90,13 +90,13 @@ describe Book do
|
|
90
90
|
@book.visible.should be false
|
91
91
|
@book.ReadOnly.should be true
|
92
92
|
@book.CheckCompatibility.should be false
|
93
|
-
@book.for_this_workbook(:calculation => true)
|
94
93
|
@book.excel.Visible.should be true
|
95
94
|
@book.Windows(@book.Name).Visible.should be false
|
96
95
|
@book.visible.should be false
|
97
96
|
@book.ReadOnly.should be true
|
98
97
|
@book.CheckCompatibility.should be false
|
99
|
-
|
98
|
+
#@book.for_this_workbook(:calculation => true)
|
99
|
+
#@book.excel.calculation.should be true
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should set options" do
|
@@ -109,7 +109,7 @@ describe Book do
|
|
109
109
|
describe "excel_of" do
|
110
110
|
|
111
111
|
before do
|
112
|
-
@book =
|
112
|
+
@book = Workbook.open(@simple_file)
|
113
113
|
end
|
114
114
|
|
115
115
|
after do
|
@@ -118,19 +118,19 @@ describe Book do
|
|
118
118
|
|
119
119
|
it "should access the excel" do
|
120
120
|
workbook = @book.ole_workbook
|
121
|
-
excel =
|
121
|
+
excel = Workbook.excel_of(workbook)
|
122
122
|
excel.should be_a Excel
|
123
123
|
excel.should == @book.excel
|
124
124
|
end
|
125
125
|
|
126
126
|
it "should access the Excel of the ole_excel" do
|
127
|
-
excel =
|
127
|
+
excel = Workbook.excel_of(@book.excel.ole_excel)
|
128
128
|
excel.should be_a Excel
|
129
129
|
excel.should == @book.excel
|
130
130
|
end
|
131
131
|
|
132
|
-
it "should access the Excel of a
|
133
|
-
excel =
|
132
|
+
it "should access the Excel of a Workbook" do
|
133
|
+
excel = Workbook.excel_of(@book)
|
134
134
|
excel.should be_a Excel
|
135
135
|
excel.should == @book.excel
|
136
136
|
end
|
@@ -140,7 +140,7 @@ describe Book do
|
|
140
140
|
describe "with retain_saved" do
|
141
141
|
|
142
142
|
before do
|
143
|
-
@book =
|
143
|
+
@book = Workbook.open(@simple_file)
|
144
144
|
end
|
145
145
|
|
146
146
|
after do
|
@@ -166,7 +166,7 @@ describe Book do
|
|
166
166
|
|
167
167
|
it "should keep the save state 'unsaved'" do
|
168
168
|
sheet = @book.sheet(1)
|
169
|
-
sheet[1,1] = sheet[1,1].
|
169
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
170
170
|
@book.Saved.should be false
|
171
171
|
@book.retain_saved do
|
172
172
|
sheet = @book.sheet(1)
|
@@ -180,7 +180,7 @@ describe Book do
|
|
180
180
|
@book.Saved.should be true
|
181
181
|
@book.retain_saved do
|
182
182
|
sheet = @book.sheet(1)
|
183
|
-
sheet[1,1] = sheet[1,1].
|
183
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
184
184
|
@book.Saved.should be false
|
185
185
|
end
|
186
186
|
@book.Saved.should be true
|
@@ -188,7 +188,7 @@ describe Book do
|
|
188
188
|
|
189
189
|
it "should keep the save state 'unsaved' even when the workbook was saved before" do
|
190
190
|
sheet = @book.sheet(1)
|
191
|
-
sheet[1,1] = sheet[1,1].
|
191
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
192
192
|
@book.Saved.should be false
|
193
193
|
@book.retain_saved do
|
194
194
|
@book.save
|
@@ -201,16 +201,16 @@ describe Book do
|
|
201
201
|
describe "default-visible" do
|
202
202
|
|
203
203
|
it "should keep the visibility of the open workbook" do
|
204
|
-
book1 =
|
204
|
+
book1 = Workbook.open(@simple_file1)
|
205
205
|
book1.excel.Visible.should be false
|
206
206
|
book1.Windows(book1.Name).Visible.should be true
|
207
207
|
book1.visible.should be false
|
208
|
-
book2 =
|
208
|
+
book2 = Workbook.open(@simple_file1, :default => {:visible => true})
|
209
209
|
book2.visible.should be false
|
210
210
|
book2.excel.Visible.should be false
|
211
211
|
book2.Windows(book2.Name).Visible.should be true
|
212
212
|
book1.visible.should be false
|
213
|
-
book2 =
|
213
|
+
book2 = Workbook.open(@simple_file1, :default => {:visible => false})
|
214
214
|
book2.visible.should be false
|
215
215
|
book2.excel.Visible.should be false
|
216
216
|
book2.Windows(book2.Name).Visible.should be true
|
@@ -218,11 +218,11 @@ describe Book do
|
|
218
218
|
end
|
219
219
|
|
220
220
|
it "should keep the visibility of the open workbook per default" do
|
221
|
-
book1 =
|
221
|
+
book1 = Workbook.open(@simple_file1)
|
222
222
|
book1.excel.Visible.should be false
|
223
223
|
book1.Windows(book1.Name).Visible.should be true
|
224
224
|
book1.visible.should be false
|
225
|
-
book2 =
|
225
|
+
book2 = Workbook.open(@simple_file1)
|
226
226
|
book2.visible.should be false
|
227
227
|
book2.excel.Visible.should be false
|
228
228
|
book2.Windows(book2.Name).Visible.should be true
|
@@ -230,11 +230,11 @@ describe Book do
|
|
230
230
|
end
|
231
231
|
|
232
232
|
it "should keep the found Excel instance invisible" do
|
233
|
-
book1 =
|
233
|
+
book1 = Workbook.open(@simple_file1)
|
234
234
|
excel1 = book1.excel
|
235
235
|
excel1.Visible.should be false
|
236
236
|
book1.close
|
237
|
-
book2 =
|
237
|
+
book2 = Workbook.open(@simple_file1, :default => {:visible => true})
|
238
238
|
excel2 = book2.excel
|
239
239
|
excel2.should == excel1
|
240
240
|
excel2.Visible.should be false
|
@@ -242,11 +242,11 @@ describe Book do
|
|
242
242
|
end
|
243
243
|
|
244
244
|
it "should keep the found Excel instance invisible with default invisible" do
|
245
|
-
book1 =
|
245
|
+
book1 = Workbook.open(@simple_file1)
|
246
246
|
excel1 = book1.excel
|
247
247
|
excel1.Visible.should be false
|
248
248
|
book1.close
|
249
|
-
book2 =
|
249
|
+
book2 = Workbook.open(@simple_file1, :default => {:visible => false})
|
250
250
|
excel2 = book1.excel
|
251
251
|
excel2.should == excel1
|
252
252
|
excel2.Visible.should be false
|
@@ -254,12 +254,12 @@ describe Book do
|
|
254
254
|
end
|
255
255
|
|
256
256
|
it "should keep the found Excel instance visible" do
|
257
|
-
book1 =
|
257
|
+
book1 = Workbook.open(@simple_file1, :visible => true)
|
258
258
|
excel1 = book1.excel
|
259
259
|
book1.Windows(book1.Name).Visible.should be true
|
260
260
|
excel1.Visible.should be true
|
261
261
|
book1.close
|
262
|
-
book2 =
|
262
|
+
book2 = Workbook.open(@simple_file1, :default => {:visible => false})
|
263
263
|
excel2 = book1.excel
|
264
264
|
excel2.should == excel1
|
265
265
|
excel2.Visible.should be true
|
@@ -267,12 +267,12 @@ describe Book do
|
|
267
267
|
end
|
268
268
|
|
269
269
|
it "should keep the found Excel instance visible with default visible true" do
|
270
|
-
book1 =
|
270
|
+
book1 = Workbook.open(@simple_file1, :visible => true)
|
271
271
|
excel1 = book1.excel
|
272
272
|
book1.Windows(book1.Name).Visible.should be true
|
273
273
|
excel1.Visible.should be true
|
274
274
|
book1.close
|
275
|
-
book2 =
|
275
|
+
book2 = Workbook.open(@simple_file1, :default => {:visible => true})
|
276
276
|
excel2 = book1.excel
|
277
277
|
excel2.should == excel1
|
278
278
|
excel2.Visible.should be true
|
@@ -280,11 +280,11 @@ describe Book do
|
|
280
280
|
end
|
281
281
|
|
282
282
|
it "should keep the found Excel instance invisible per default" do
|
283
|
-
book1 =
|
283
|
+
book1 = Workbook.open(@simple_file1)
|
284
284
|
excel1 = book1.excel
|
285
285
|
excel1.Visible.should be false
|
286
286
|
book1.close
|
287
|
-
book2 =
|
287
|
+
book2 = Workbook.open(@simple_file1)
|
288
288
|
excel2 = book1.excel
|
289
289
|
excel2.should == excel1
|
290
290
|
excel2.Visible.should be false
|
@@ -292,35 +292,35 @@ describe Book do
|
|
292
292
|
end
|
293
293
|
|
294
294
|
it "should open the workbook visible if the workbook is new" do
|
295
|
-
book1 =
|
295
|
+
book1 = Workbook.open(@simple_file1, :default => {:visible => true})
|
296
296
|
book1.visible.should be true
|
297
297
|
book1.excel.Visible.should be true
|
298
298
|
book1.Windows(book1.Name).Visible.should be true
|
299
299
|
end
|
300
300
|
|
301
301
|
it "should open the workbook invisible if the workbook is new" do
|
302
|
-
book1 =
|
302
|
+
book1 = Workbook.open(@simple_file1, :default => {:visible => false})
|
303
303
|
book1.visible.should be false
|
304
304
|
book1.excel.Visible.should be false
|
305
305
|
book1.Windows(book1.Name).Visible.should be false
|
306
306
|
end
|
307
307
|
|
308
308
|
it "should open the workbook invisible per default if the workbook is new" do
|
309
|
-
book1 =
|
309
|
+
book1 = Workbook.open(@simple_file1)
|
310
310
|
book1.visible.should be false
|
311
311
|
book1.excel.Visible.should be false
|
312
312
|
book1.Windows(book1.Name).Visible.should be true
|
313
313
|
end
|
314
314
|
|
315
315
|
it "should open the workbook visible if the old Excel is closed" do
|
316
|
-
book1 =
|
316
|
+
book1 = Workbook.open(@simple_file1)
|
317
317
|
book1.visible.should be false
|
318
318
|
excel1 = book1.excel
|
319
319
|
excel1.Visible.should be false
|
320
320
|
book1.Windows(book1.Name).Visible.should be true
|
321
321
|
book1.close
|
322
322
|
excel1.close
|
323
|
-
book2 =
|
323
|
+
book2 = Workbook.open(@simple_file1, :default => {:visible => true})
|
324
324
|
excel2 = book2.excel
|
325
325
|
book2.visible.should be true
|
326
326
|
excel2.Visible.should be true
|
@@ -328,14 +328,14 @@ describe Book do
|
|
328
328
|
end
|
329
329
|
|
330
330
|
it "should open the workbook invisible if the old Excel is closed" do
|
331
|
-
book1 =
|
331
|
+
book1 = Workbook.open(@simple_file1, :default => {:visible => true})
|
332
332
|
book1.visible.should be true
|
333
333
|
excel1 = book1.excel
|
334
334
|
excel1.Visible.should be true
|
335
335
|
book1.Windows(book1.Name).Visible.should be true
|
336
336
|
book1.close
|
337
337
|
excel1.close
|
338
|
-
book2 =
|
338
|
+
book2 = Workbook.open(@simple_file1, :default => {:visible => false})
|
339
339
|
excel2 = book2.excel
|
340
340
|
book2.visible.should be false
|
341
341
|
excel2.Visible.should be false
|
@@ -347,16 +347,16 @@ describe Book do
|
|
347
347
|
describe "force-visible" do
|
348
348
|
|
349
349
|
it "should change the visibility of the workbooks" do
|
350
|
-
book1 =
|
350
|
+
book1 = Workbook.open(@simple_file)
|
351
351
|
book1.excel.Visible.should be false
|
352
352
|
book1.Windows(book1.Name).Visible.should be true
|
353
353
|
book1.visible.should be false
|
354
|
-
book2 =
|
354
|
+
book2 = Workbook.open(@simple_file, :visible => true)
|
355
355
|
book2.visible.should be true
|
356
356
|
book2.excel.Visible.should be true
|
357
357
|
book2.Windows(book2.Name).Visible.should be true
|
358
358
|
book1.visible.should be true
|
359
|
-
book2 =
|
359
|
+
book2 = Workbook.open(@simple_file, :visible => false)
|
360
360
|
book2.visible.should be false
|
361
361
|
book2.excel.Visible.should be true
|
362
362
|
book2.Windows(book2.Name).Visible.should be false
|
@@ -370,28 +370,28 @@ describe Book do
|
|
370
370
|
it "should adapt its default value at the visible value of the Excel" do
|
371
371
|
excel1 = Excel.create
|
372
372
|
excel1.visible = true
|
373
|
-
book1 =
|
373
|
+
book1 = Workbook.open(@simple_file)
|
374
374
|
excel1.Visible.should be true
|
375
375
|
excel1.visible.should be true
|
376
376
|
book1.visible.should be true
|
377
377
|
end
|
378
378
|
|
379
379
|
it "should preserve :visible if it is not set" do
|
380
|
-
book1 =
|
380
|
+
book1 = Workbook.open(@simple_file)
|
381
381
|
book1.excel.Visible.should be false
|
382
382
|
book1.Windows(book1.Name).Visible.should be true
|
383
383
|
book1.visible.should be false
|
384
384
|
end
|
385
385
|
|
386
386
|
it "should set :visible to false" do
|
387
|
-
book1 =
|
387
|
+
book1 = Workbook.open(@simple_file, :visible => false)
|
388
388
|
book1.excel.Visible.should be false
|
389
389
|
book1.Windows(book1.Name).Visible.should be false
|
390
390
|
book1.visible.should be false
|
391
391
|
end
|
392
392
|
|
393
393
|
it "should set :visible to true" do
|
394
|
-
book1 =
|
394
|
+
book1 = Workbook.open(@simple_file, :visible => true)
|
395
395
|
book1.excel.Visible.should be true
|
396
396
|
book1.Windows(book1.Name).Visible.should be true
|
397
397
|
book1.visible.should be true
|
@@ -399,7 +399,7 @@ describe Book do
|
|
399
399
|
|
400
400
|
it "should preserve :visible if they are set to visible" do
|
401
401
|
excel1 = Excel.create(:visible => true)
|
402
|
-
book1 =
|
402
|
+
book1 = Workbook.open(@simple_file)
|
403
403
|
book1.excel.Visible.should be true
|
404
404
|
book1.Windows(book1.Name).Visible.should be true
|
405
405
|
book1.visible.should be true
|
@@ -407,7 +407,7 @@ describe Book do
|
|
407
407
|
|
408
408
|
it "should preserve :visible" do
|
409
409
|
excel1 = Excel.create
|
410
|
-
book1 =
|
410
|
+
book1 = Workbook.open(@simple_file)
|
411
411
|
book1.excel.Visible.should be false
|
412
412
|
book1.Windows(book1.Name).Visible.should be true
|
413
413
|
book1.visible.should be false
|
@@ -416,7 +416,7 @@ describe Book do
|
|
416
416
|
|
417
417
|
it "should preserve :visible if it is set to false" do
|
418
418
|
excel1 = Excel.create
|
419
|
-
book1 =
|
419
|
+
book1 = Workbook.open(@simple_file, :visible => false)
|
420
420
|
book1.excel.Visible.should be false
|
421
421
|
book1.Windows(book1.Name).Visible.should be false
|
422
422
|
book1.visible.should be false
|
@@ -424,7 +424,7 @@ describe Book do
|
|
424
424
|
|
425
425
|
it "should preserve :visible if it is not set" do
|
426
426
|
excel1 = Excel.create
|
427
|
-
book1 =
|
427
|
+
book1 = Workbook.open(@simple_file)
|
428
428
|
book1.excel.Visible.should be false
|
429
429
|
book1.Windows(book1.Name).Visible.should be true
|
430
430
|
book1.visible.should be false
|
@@ -432,7 +432,7 @@ describe Book do
|
|
432
432
|
|
433
433
|
it "should overwrite :visible to false" do
|
434
434
|
excel1 = Excel.create(:visible => true)
|
435
|
-
book1 =
|
435
|
+
book1 = Workbook.open(@simple_file, :visible => false)
|
436
436
|
book1.excel.Visible.should be true
|
437
437
|
book1.Windows(book1.Name).Visible.should be false
|
438
438
|
book1.visible.should be false
|
@@ -440,7 +440,7 @@ describe Book do
|
|
440
440
|
|
441
441
|
it "should overwrite :visible to true" do
|
442
442
|
excel1 = Excel.create(:visible => false)
|
443
|
-
book1 =
|
443
|
+
book1 = Workbook.open(@simple_file, :visible => true)
|
444
444
|
book1.excel.Visible.should be true
|
445
445
|
book1.Windows(book1.Name).Visible.should be true
|
446
446
|
book1.visible.should be true
|
@@ -448,8 +448,8 @@ describe Book do
|
|
448
448
|
|
449
449
|
it "should preserve :visible if it is not set with default_excel" do
|
450
450
|
excel1 = Excel.create(:visible => true)
|
451
|
-
book1 =
|
452
|
-
book2 =
|
451
|
+
book1 = Workbook.open(@simple_file)
|
452
|
+
book2 = Workbook.open(@different_file, :default_excel => :new)
|
453
453
|
book2.excel.Visible.should be false
|
454
454
|
book2.Windows(book2.Name).Visible.should be true
|
455
455
|
book2.visible.should be false
|
@@ -457,8 +457,8 @@ describe Book do
|
|
457
457
|
|
458
458
|
it "should set :visible to true with default_excel" do
|
459
459
|
excel1 = Excel.create(:visible => true)
|
460
|
-
book1 =
|
461
|
-
book2 =
|
460
|
+
book1 = Workbook.open(@simple_file)
|
461
|
+
book2 = Workbook.open(@different_file, :default_excel => :new, :visible => true)
|
462
462
|
book2.excel.Visible.should be true
|
463
463
|
book2.Windows(book2.Name).Visible.should be true
|
464
464
|
book2.visible.should be true
|
@@ -466,8 +466,8 @@ describe Book do
|
|
466
466
|
|
467
467
|
it "should set :visible to false with default_excel" do
|
468
468
|
excel1 = Excel.create(:visible => true)
|
469
|
-
book1 =
|
470
|
-
book2 =
|
469
|
+
book1 = Workbook.open(@simple_file)
|
470
|
+
book2 = Workbook.open(@different_file, :default_excel => :new, :visible => false)
|
471
471
|
book2.excel.Visible.should be false
|
472
472
|
book2.Windows(book2.Name).Visible.should be false
|
473
473
|
book2.visible.should be false
|
@@ -476,7 +476,7 @@ describe Book do
|
|
476
476
|
it "should preserve :visible if it is set to true with default_excel" do
|
477
477
|
excel1 = Excel.create(:visible => true)
|
478
478
|
excel2 = Excel.create(:visible => true)
|
479
|
-
book1 =
|
479
|
+
book1 = Workbook.open(@different_file, :default_excel => excel2)
|
480
480
|
book1.excel.Visible.should be true
|
481
481
|
book1.Windows(book1.Name).Visible.should be true
|
482
482
|
book1.visible.should be true
|
@@ -485,7 +485,7 @@ describe Book do
|
|
485
485
|
it "should overwrite :visible to false with default_excel" do
|
486
486
|
excel1 = Excel.create(:visible => true)
|
487
487
|
excel2 = Excel.create(:visible => true)
|
488
|
-
book1 =
|
488
|
+
book1 = Workbook.open(@different_file, :default_excel => excel2, :visible => false)
|
489
489
|
book1.excel.Visible.should be true
|
490
490
|
book1.Windows(book1.Name).Visible.should be false
|
491
491
|
book1.visible.should be false
|
@@ -493,7 +493,7 @@ describe Book do
|
|
493
493
|
|
494
494
|
it "should preserve :visible if it is not set with force_excel => new" do
|
495
495
|
excel1 = Excel.create(:visible => true)
|
496
|
-
book1 =
|
496
|
+
book1 = Workbook.open(@different_file, :force_excel => :new)
|
497
497
|
book1.excel.Visible.should be false
|
498
498
|
book1.Windows(book1.Name).Visible.should be true
|
499
499
|
book1.visible.should be false
|
@@ -501,7 +501,7 @@ describe Book do
|
|
501
501
|
|
502
502
|
it "should set :visible to true with force_excel" do
|
503
503
|
excel1 = Excel.create(:visible => true)
|
504
|
-
book1 =
|
504
|
+
book1 = Workbook.open(@different_file, :force_excel => :new, :visible => true)
|
505
505
|
book1.excel.Visible.should be true
|
506
506
|
book1.Windows(book1.Name).Visible.should be true
|
507
507
|
book1.visible.should be true
|
@@ -510,7 +510,7 @@ describe Book do
|
|
510
510
|
it "should preserve :visible if it is not set with force_excel => excel" do
|
511
511
|
excel1 = Excel.create(:visible => true)
|
512
512
|
excel2 = Excel.create(:visible => true)
|
513
|
-
book1 =
|
513
|
+
book1 = Workbook.open(@different_file, :force_excel => excel2)
|
514
514
|
book1.excel.Visible.should be true
|
515
515
|
book1.Windows(book1.Name).Visible.should be true
|
516
516
|
book1.visible.should be true
|
@@ -519,7 +519,7 @@ describe Book do
|
|
519
519
|
it "should set visible to false with force_excel => excel" do
|
520
520
|
excel1 = Excel.create(:visible => true)
|
521
521
|
excel2 = Excel.create(:visible => true)
|
522
|
-
book1 =
|
522
|
+
book1 = Workbook.open(@different_file, :force_excel => excel2, :visible => false)
|
523
523
|
book1.excel.Visible.should be true
|
524
524
|
book1.Windows(book1.Name).Visible.should be false
|
525
525
|
book1.visible.should be false
|
@@ -528,7 +528,7 @@ describe Book do
|
|
528
528
|
it "should set visible to true with force_excel => excel" do
|
529
529
|
excel1 = Excel.create(:visible => true)
|
530
530
|
excel2 = Excel.create(:visible => true)
|
531
|
-
book1 =
|
531
|
+
book1 = Workbook.open(@different_file, :force_excel => excel2, :visible => true)
|
532
532
|
book1.excel.Visible.should be true
|
533
533
|
book1.Windows(book1.Name).Visible.should be true
|
534
534
|
book1.visible.should be true
|
@@ -536,7 +536,7 @@ describe Book do
|
|
536
536
|
|
537
537
|
it "should preserve :visible if it is set to true with force_excel => current" do
|
538
538
|
excel1 = Excel.create(:visible => true)
|
539
|
-
book1 =
|
539
|
+
book1 = Workbook.open(@different_file, :force_excel => :current)
|
540
540
|
book1.excel.Visible.should be true
|
541
541
|
book1.Windows(book1.Name).Visible.should be true
|
542
542
|
book1.visible.should be true
|
@@ -544,7 +544,7 @@ describe Book do
|
|
544
544
|
|
545
545
|
it "should set :visible to false with force_excel => current" do
|
546
546
|
excel1 = Excel.create(:visible => true)
|
547
|
-
book1 =
|
547
|
+
book1 = Workbook.open(@different_file, :force_excel => :current, :visible => false)
|
548
548
|
book1.excel.Visible.should be true
|
549
549
|
book1.Windows(book1.Name).Visible.should be false
|
550
550
|
book1.visible.should be false
|
@@ -552,7 +552,7 @@ describe Book do
|
|
552
552
|
|
553
553
|
it "should preserve :visible if it is set to false with force_excel => current" do
|
554
554
|
excel1 = Excel.create(:visible => false)
|
555
|
-
book1 =
|
555
|
+
book1 = Workbook.open(@simple_file, :force_excel => :current)
|
556
556
|
book1.excel.Visible.should be false
|
557
557
|
book1.Windows(book1.Name).Visible.should be true
|
558
558
|
book1.visible.should be false
|
@@ -560,34 +560,34 @@ describe Book do
|
|
560
560
|
|
561
561
|
it "should set :visible to false with force_excel => current" do
|
562
562
|
excel1 = Excel.create(:visible => false)
|
563
|
-
book1 =
|
563
|
+
book1 = Workbook.open(@simple_file, :force_excel => :current, :visible => true)
|
564
564
|
book1.excel.Visible.should be true
|
565
565
|
book1.Windows(book1.Name).Visible.should be true
|
566
566
|
book1.visible.should be true
|
567
567
|
end
|
568
568
|
|
569
|
-
it "should let an open
|
570
|
-
@book =
|
571
|
-
|
572
|
-
book.should be_a
|
569
|
+
it "should let an open Workbook open" do
|
570
|
+
@book = Workbook.open(@simple_file1, :visible => true)
|
571
|
+
Workbook.unobtrusively(@simple_file1) do |book|
|
572
|
+
book.should be_a Workbook
|
573
573
|
book.should be_alive
|
574
574
|
book.excel.should == @book.excel
|
575
575
|
book.excel.Visible.should be true
|
576
576
|
end
|
577
577
|
@book.should be_alive
|
578
|
-
@book.should be_a
|
578
|
+
@book.should be_a Workbook
|
579
579
|
@book.excel.Visible.should be true
|
580
580
|
@book.close(:if_unsaved => :forget)
|
581
581
|
@book2.close(:if_unsaved => :forget) rescue nil
|
582
582
|
end
|
583
583
|
|
584
584
|
it "should set visible and displayalerts if displayalerts => :if_visible" do
|
585
|
-
book1 =
|
585
|
+
book1 = Workbook.open(@simple_file)
|
586
586
|
book1.excel.Visible.should be false
|
587
587
|
book1.excel.displayalerts.should == :if_visible
|
588
588
|
book1.Windows(book1.Name).Visible.should be true
|
589
589
|
book1.visible.should be false
|
590
|
-
book2 =
|
590
|
+
book2 = Workbook.open(@different_file)
|
591
591
|
book2.excel.Visible.should be false
|
592
592
|
book2.Windows(book2.Name).Visible.should be true
|
593
593
|
book2.visible.should be false
|
@@ -597,12 +597,12 @@ describe Book do
|
|
597
597
|
end
|
598
598
|
|
599
599
|
it "should set visible and displayalerts if displayalerts => :if_visible" do
|
600
|
-
book1 =
|
600
|
+
book1 = Workbook.open(@simple_file)
|
601
601
|
book1.excel.Visible.should be false
|
602
602
|
book1.excel.displayalerts.should == :if_visible
|
603
603
|
book1.Windows(book1.Name).Visible.should be true
|
604
604
|
book1.visible.should be false
|
605
|
-
book2 =
|
605
|
+
book2 = Workbook.open(@different_file, :visible => true)
|
606
606
|
book2.excel.Visible.should be true
|
607
607
|
book2.Windows(book2.Name).Visible.should be true
|
608
608
|
book2.visible.should be true
|
@@ -616,7 +616,7 @@ describe Book do
|
|
616
616
|
|
617
617
|
context "with standard" do
|
618
618
|
before do
|
619
|
-
@book =
|
619
|
+
@book = Workbook.open(@simple_file)
|
620
620
|
end
|
621
621
|
|
622
622
|
after do
|
@@ -650,7 +650,7 @@ describe Book do
|
|
650
650
|
context "with some open book" do
|
651
651
|
|
652
652
|
before do
|
653
|
-
@book =
|
653
|
+
@book = Workbook.open(@simple_file1)
|
654
654
|
end
|
655
655
|
|
656
656
|
after do
|
@@ -658,7 +658,7 @@ describe Book do
|
|
658
658
|
end
|
659
659
|
|
660
660
|
it "should create and use a hidden Excel instance" do
|
661
|
-
book2 =
|
661
|
+
book2 = Workbook.open(@simple_file1, :force_excel => @book.bookstore.hidden_excel)
|
662
662
|
book2.excel.should_not == @book.excel
|
663
663
|
book2.excel.visible.should be false
|
664
664
|
book2.excel.displayalerts.should == :if_visible
|
@@ -670,7 +670,7 @@ describe Book do
|
|
670
670
|
describe "nameval, set_nameval, [], []=" do
|
671
671
|
|
672
672
|
before do
|
673
|
-
@book1 =
|
673
|
+
@book1 = Workbook.open(@another_simple_file)
|
674
674
|
end
|
675
675
|
|
676
676
|
after do
|
@@ -719,28 +719,28 @@ describe Book do
|
|
719
719
|
}.to_not raise_error
|
720
720
|
expect {
|
721
721
|
@book1.namevalue_glob("foo", :default => :__not_provided)
|
722
|
-
}.to raise_error(NameNotFound, /name "foo" not in #<
|
722
|
+
}.to raise_error(NameNotFound, /name "foo" not in #<Workbook: another_workbook/)
|
723
723
|
expect {
|
724
724
|
@book1.namevalue_glob("foo")
|
725
|
-
}.to raise_error(NameNotFound, /name "foo" not in #<
|
725
|
+
}.to raise_error(NameNotFound, /name "foo" not in #<Workbook: another_workbook/)
|
726
726
|
@book1.namevalue_glob("foo", :default => nil).should be_nil
|
727
727
|
@book1.namevalue_glob("foo", :default => 1).should == 1
|
728
728
|
expect {
|
729
729
|
@book1.set_namevalue_glob("foo","bar")
|
730
|
-
}.to raise_error(NameNotFound, /name "foo" not in #<
|
730
|
+
}.to raise_error(NameNotFound, /name "foo" not in #<Workbook: another_workbook/)
|
731
731
|
expect {
|
732
732
|
@book1["foo"] = "bar"
|
733
|
-
}.to raise_error(NameNotFound, /name "foo" not in #<
|
733
|
+
}.to raise_error(NameNotFound, /name "foo" not in #<Workbook: another_workbook/)
|
734
734
|
@book1.namevalue_glob("empty", :default => 1).should be_nil
|
735
735
|
end
|
736
736
|
|
737
737
|
it "should raise an error if name was defined but contents is calcuated" do
|
738
738
|
expect {
|
739
739
|
@book1.set_namevalue_glob("named_formula","bar")
|
740
|
-
}.to raise_error(RangeNotEvaluatable, /cannot assign value to range named "named_formula" in #<
|
740
|
+
}.to raise_error(RangeNotEvaluatable, /cannot assign value to range named "named_formula" in #<Workbook: another_workbook/)
|
741
741
|
expect {
|
742
742
|
@book1["named_formula"] = "bar"
|
743
|
-
}.to raise_error(RangeNotEvaluatable, /cannot assign value to range named "named_formula" in #<
|
743
|
+
}.to raise_error(RangeNotEvaluatable, /cannot assign value to range named "named_formula" in #<Workbook: another_workbook/)
|
744
744
|
end
|
745
745
|
|
746
746
|
# Excel Bug: for local names without uqifier: takes the first sheet as default even if another sheet is activated
|
@@ -764,7 +764,7 @@ describe Book do
|
|
764
764
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == 42
|
765
765
|
@book1.save
|
766
766
|
@book1.close
|
767
|
-
#book2 =
|
767
|
+
#book2 = Workbook.open(@simple_file1, :visible => true)
|
768
768
|
#book2.Names.Item("new").RefersToRange.Interior.ColorIndex.should == 42
|
769
769
|
end
|
770
770
|
|
@@ -773,7 +773,7 @@ describe Book do
|
|
773
773
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == 4
|
774
774
|
@book1.save(:discoloring => true)
|
775
775
|
@book1.close
|
776
|
-
#book2 =
|
776
|
+
#book2 = Workbook.open(@simple_file1, :visible => true)
|
777
777
|
#book2.Names.Item("new").RefersToRange.Interior.ColorIndex.should == 0
|
778
778
|
end
|
779
779
|
|
@@ -782,7 +782,7 @@ describe Book do
|
|
782
782
|
describe "rename_range" do
|
783
783
|
|
784
784
|
before do
|
785
|
-
@book1 =
|
785
|
+
@book1 = Workbook.open(@another_simple_file)
|
786
786
|
end
|
787
787
|
|
788
788
|
after do
|
@@ -803,7 +803,7 @@ describe Book do
|
|
803
803
|
context "with alive?" do
|
804
804
|
|
805
805
|
before do
|
806
|
-
@book =
|
806
|
+
@book = Workbook.open(@simple_file)
|
807
807
|
end
|
808
808
|
|
809
809
|
after do
|
@@ -824,7 +824,7 @@ describe Book do
|
|
824
824
|
context "with filename" do
|
825
825
|
|
826
826
|
before do
|
827
|
-
@book =
|
827
|
+
@book = Workbook.open(@simple_file)
|
828
828
|
end
|
829
829
|
|
830
830
|
after do
|
@@ -845,7 +845,7 @@ describe Book do
|
|
845
845
|
context "with ==" do
|
846
846
|
|
847
847
|
before do
|
848
|
-
@book =
|
848
|
+
@book = Workbook.open(@simple_file1)
|
849
849
|
end
|
850
850
|
|
851
851
|
after do
|
@@ -854,26 +854,26 @@ describe Book do
|
|
854
854
|
end
|
855
855
|
|
856
856
|
it "should be true with two identical books" do
|
857
|
-
@new_book =
|
857
|
+
@new_book = Workbook.open(@simple_file1)
|
858
858
|
@new_book.should == @book
|
859
859
|
end
|
860
860
|
|
861
861
|
it "should be false with two different books" do
|
862
|
-
@new_book =
|
862
|
+
@new_book = Workbook.new(@different_file)
|
863
863
|
@new_book.should_not == @book
|
864
864
|
end
|
865
865
|
|
866
866
|
it "should be false with same book names but different paths" do
|
867
|
-
@new_book =
|
867
|
+
@new_book = Workbook.new(@simple_file_other_path, :force_excel => :new)
|
868
868
|
@new_book.should_not == @book
|
869
869
|
end
|
870
870
|
|
871
871
|
it "should be false with same book names but different excel instances" do
|
872
|
-
@new_book =
|
872
|
+
@new_book = Workbook.new(@simple_file, :force_excel => :new)
|
873
873
|
@new_book.should_not == @book
|
874
874
|
end
|
875
875
|
|
876
|
-
it "should be false with non-
|
876
|
+
it "should be false with non-Workbooks" do
|
877
877
|
@book.should_not == "hallo"
|
878
878
|
@book.should_not == 7
|
879
879
|
@book.should_not == nil
|
@@ -883,7 +883,7 @@ describe Book do
|
|
883
883
|
context "with saved" do
|
884
884
|
|
885
885
|
before do
|
886
|
-
@book =
|
886
|
+
@book = Workbook.open(@simple_file)
|
887
887
|
end
|
888
888
|
|
889
889
|
after do
|
@@ -896,7 +896,7 @@ describe Book do
|
|
896
896
|
|
897
897
|
it "should yield false for an unsaved book" do
|
898
898
|
sheet = @book.sheet(1)
|
899
|
-
sheet[1,1] = sheet[1,1].
|
899
|
+
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
900
900
|
@book.saved.should be false
|
901
901
|
end
|
902
902
|
end
|
@@ -906,7 +906,7 @@ describe Book do
|
|
906
906
|
|
907
907
|
it "should leave the excel invisible when opening with default option" do
|
908
908
|
excel1 = Excel.new(:reuse => false, :visible => false)
|
909
|
-
book1 =
|
909
|
+
book1 = Workbook.open(@simple_file)
|
910
910
|
excel1.Visible.should be false
|
911
911
|
book1.Windows(book1.Name).Visible.should be true
|
912
912
|
book1.visible.should be false
|
@@ -914,7 +914,7 @@ describe Book do
|
|
914
914
|
|
915
915
|
it "should leave the excel invisible when opening with :visible => false" do
|
916
916
|
excel1 = Excel.new(:reuse => false, :visible => false)
|
917
|
-
book1 =
|
917
|
+
book1 = Workbook.open(@simple_file, :visible => false)
|
918
918
|
excel1.Visible.should be false
|
919
919
|
book1.Windows(book1.Name).Visible.should be false
|
920
920
|
book1.visible.should be false
|
@@ -922,15 +922,15 @@ describe Book do
|
|
922
922
|
|
923
923
|
it "should leave the excel visible" do
|
924
924
|
excel1 = Excel.new(:reuse => false, :visible => false)
|
925
|
-
book1 =
|
925
|
+
book1 = Workbook.open(@simple_file, :visible => true)
|
926
926
|
excel1.Visible.should be true
|
927
927
|
book1.Windows(book1.Name).Visible.should be true
|
928
928
|
book1.visible.should be true
|
929
|
-
book2 =
|
929
|
+
book2 = Workbook.open(@another_simple_file)
|
930
930
|
excel1.Visible.should be true
|
931
931
|
book2.Windows(book2.Name).Visible.should be true
|
932
932
|
book2.visible.should be true
|
933
|
-
book3 =
|
933
|
+
book3 = Workbook.open(@different_file, :visible => false)
|
934
934
|
excel1.Visible.should be true
|
935
935
|
book3.Windows(book3.Name).Visible.should be false
|
936
936
|
book3.visible.should be false
|
@@ -938,7 +938,7 @@ describe Book do
|
|
938
938
|
|
939
939
|
it "should leave the excel visible when opening with default option" do
|
940
940
|
excel1 = Excel.new(:reuse => false, :visible => true)
|
941
|
-
book1 =
|
941
|
+
book1 = Workbook.open(@simple_file)
|
942
942
|
excel1.Visible.should be true
|
943
943
|
book1.Windows(book1.Name).Visible.should be true
|
944
944
|
book1.visible.should be true
|
@@ -946,11 +946,11 @@ describe Book do
|
|
946
946
|
|
947
947
|
it "should leave the excel visible when opening with :visible => false" do
|
948
948
|
excel1 = Excel.new(:reuse => false, :visible => true)
|
949
|
-
book1 =
|
949
|
+
book1 = Workbook.open(@simple_file, :visible => false)
|
950
950
|
excel1.Visible.should be true
|
951
951
|
book1.Windows(book1.Name).Visible.should be false
|
952
952
|
book1.visible.should be false
|
953
|
-
book2 =
|
953
|
+
book2 = Workbook.open(@another_simple_file)
|
954
954
|
excel1.Visible.should be true
|
955
955
|
book2.Windows(book2.Name).Visible.should be true
|
956
956
|
book2.visible.should be true
|
@@ -958,11 +958,11 @@ describe Book do
|
|
958
958
|
|
959
959
|
it "should leave the excel visible" do
|
960
960
|
excel1 = Excel.new(:reuse => false, :visible => true)
|
961
|
-
book1 =
|
961
|
+
book1 = Workbook.open(@simple_file, :visible => true)
|
962
962
|
excel1.Visible.should be true
|
963
963
|
book1.Windows(book1.Name).Visible.should be true
|
964
964
|
book1.visible.should be true
|
965
|
-
book2 =
|
965
|
+
book2 = Workbook.open(@different_file, :visible => false)
|
966
966
|
excel1.Visible.should be true
|
967
967
|
book2.Windows(book2.Name).Visible.should be false
|
968
968
|
book2.visible.should be false
|
@@ -970,12 +970,12 @@ describe Book do
|
|
970
970
|
|
971
971
|
it "should leave the visibility of Excel" do
|
972
972
|
excel1 = Excel.new(:reuse => false, :visible => false)
|
973
|
-
book1 =
|
973
|
+
book1 = Workbook.open(@simple_file, :visible => true)
|
974
974
|
excel1.Visible.should be true
|
975
975
|
book1.Windows(book1.Name).Visible.should be true
|
976
976
|
book1.visible.should be true
|
977
977
|
excel1.visible = false
|
978
|
-
book2 =
|
978
|
+
book2 = Workbook.open(@different_file)
|
979
979
|
excel1.Visible.should be false
|
980
980
|
book2.Windows(book2.Name).Visible.should be true
|
981
981
|
book2.visible.should be false
|
@@ -983,12 +983,12 @@ describe Book do
|
|
983
983
|
|
984
984
|
it "should leave the visibility of Excel" do
|
985
985
|
excel1 = Excel.new(:reuse => false, :visible => false)
|
986
|
-
book1 =
|
986
|
+
book1 = Workbook.open(@simple_file, :visible => false)
|
987
987
|
excel1.Visible.should be false
|
988
988
|
book1.Windows(book1.Name).Visible.should be false
|
989
989
|
book1.visible.should be false
|
990
990
|
excel1.visible = true
|
991
|
-
book2 =
|
991
|
+
book2 = Workbook.open(@different_file)
|
992
992
|
excel1.Visible.should be true
|
993
993
|
book2.Windows(book2.Name).Visible.should be true
|
994
994
|
book2.visible.should be true
|
@@ -998,8 +998,8 @@ describe Book do
|
|
998
998
|
context "with visible, visible=" do
|
999
999
|
|
1000
1000
|
before do
|
1001
|
-
@book1 =
|
1002
|
-
@book2 =
|
1001
|
+
@book1 = Workbook.open(@simple_file)
|
1002
|
+
@book2 = Workbook.open(@different_file, :force_excel => :new, :visible => true)
|
1003
1003
|
end
|
1004
1004
|
|
1005
1005
|
after do
|
@@ -1045,9 +1045,9 @@ describe Book do
|
|
1045
1045
|
|
1046
1046
|
before do
|
1047
1047
|
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '../helpers/key_sender.rb') + '" "Microsoft Excel" ' , "w"
|
1048
|
-
@book =
|
1048
|
+
@book = Workbook.open(@simple_file, :visible => true)
|
1049
1049
|
@book.excel.displayalerts = false
|
1050
|
-
@book2 =
|
1050
|
+
@book2 = Workbook.open(@another_simple_file, :visible => true)
|
1051
1051
|
@book2.excel.displayalerts = false
|
1052
1052
|
end
|
1053
1053
|
|
@@ -1078,10 +1078,25 @@ describe Book do
|
|
1078
1078
|
end
|
1079
1079
|
end
|
1080
1080
|
|
1081
|
+
context "name2range" do
|
1082
|
+
|
1083
|
+
before do
|
1084
|
+
@book1 = Workbook.open(@dir + '/another_workbook.xls', :read_only => true, :visible => true)
|
1085
|
+
@book1.excel.displayalerts = false
|
1086
|
+
end
|
1087
|
+
|
1088
|
+
it "should create a range from the name" do
|
1089
|
+
@book1.add_name("foo",[1..3,1..4])
|
1090
|
+
range = @book1.name2range("foo")
|
1091
|
+
range.Address.should == "$A$1:$D$3"
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
end
|
1095
|
+
|
1081
1096
|
context "adding and deleting the name of a range" do
|
1082
1097
|
|
1083
1098
|
before do
|
1084
|
-
@book1 =
|
1099
|
+
@book1 = Workbook.open(@dir + '/another_workbook.xls', :read_only => true, :visible => true)
|
1085
1100
|
@book1.excel.displayalerts = false
|
1086
1101
|
end
|
1087
1102
|
|
@@ -1090,25 +1105,25 @@ describe Book do
|
|
1090
1105
|
end
|
1091
1106
|
|
1092
1107
|
it "should name an unnamed range with a giving address" do
|
1093
|
-
@book1.add_name("foo",1,2)
|
1108
|
+
@book1.add_name("foo",[1,2])
|
1094
1109
|
@book1.Names.Item("foo").Name.should == "foo"
|
1095
|
-
@book1.Names.Item("foo").Value.should == "=Sheet1!$B$1"
|
1110
|
+
@book1.Names.Item("foo").Value.should == "=Sheet1!$B$1:$B$1"
|
1096
1111
|
end
|
1097
1112
|
|
1098
1113
|
it "should rename an already named range with a giving address" do
|
1099
|
-
@book1.add_name("foo",1,1)
|
1114
|
+
@book1.add_name("foo",[1,1])
|
1100
1115
|
@book1.Names.Item("foo").Name.should == "foo"
|
1101
|
-
@book1.Names.Item("foo").Value.should == "=Sheet1!$A$1"
|
1116
|
+
@book1.Names.Item("foo").Value.should == "=Sheet1!$A$1:$A$1"
|
1102
1117
|
end
|
1103
1118
|
|
1104
1119
|
it "should raise an error" do
|
1105
1120
|
expect{
|
1106
|
-
@book1.add_name("foo", -2, 1)
|
1107
|
-
}.to raise_error(RangeNotEvaluatable, /cannot add name "foo" to
|
1121
|
+
@book1.add_name("foo", [-2, 1])
|
1122
|
+
}.to raise_error(RangeNotEvaluatable, /cannot add name "foo" to range/)
|
1108
1123
|
end
|
1109
1124
|
|
1110
1125
|
it "should delete a name of a range" do
|
1111
|
-
@book1.add_name("foo",1,1)
|
1126
|
+
@book1.add_name("foo",[1,1])
|
1112
1127
|
@book1.delete_name("foo")
|
1113
1128
|
expect{
|
1114
1129
|
@book1.namevalue_glob("foo")
|
@@ -1116,7 +1131,12 @@ describe Book do
|
|
1116
1131
|
end
|
1117
1132
|
|
1118
1133
|
it "should add a name of a rectangular range" do
|
1119
|
-
@book1.add_name("foo",1,1
|
1134
|
+
@book1.add_name("foo",[1..3,1..4])
|
1135
|
+
@book1["foo"].should == [["foo", "workbook", "sheet1", nil], ["foo", 1.0, 2.0, 4.0], ["matz", 3.0, 4.0, 4.0]]
|
1136
|
+
end
|
1137
|
+
|
1138
|
+
it "should accept the old interface" do
|
1139
|
+
@book1.add_name("foo",1..3,1..4)
|
1120
1140
|
@book1["foo"].should == [["foo", "workbook", "sheet1", nil], ["foo", 1.0, 2.0, 4.0], ["matz", 3.0, 4.0, 4.0]]
|
1121
1141
|
end
|
1122
1142
|
|
@@ -1125,12 +1145,12 @@ describe Book do
|
|
1125
1145
|
context "with compatibility" do
|
1126
1146
|
|
1127
1147
|
it "should open with checking compatibility" do
|
1128
|
-
book =
|
1148
|
+
book = Workbook.open(@simple_file, :visible => true, :check_compatibility => true)
|
1129
1149
|
book.CheckCompatibility.should be true
|
1130
1150
|
end
|
1131
1151
|
|
1132
1152
|
it "should open without checking compatibility" do
|
1133
|
-
book =
|
1153
|
+
book = Workbook.open(@simple_file, :visible => true, :check_compatibility => false)
|
1134
1154
|
book.CheckCompatibility.should be false
|
1135
1155
|
end
|
1136
1156
|
end
|