robust_excel_ole 0.3.1 → 0.3.2
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.
- data/README.rdoc +69 -56
- data/README_detail.rdoc +44 -34
- data/TodoList.md +8 -6
- data/examples/edit_sheets/example_access_sheets_and_cells.rb +6 -6
- data/examples/edit_sheets/example_adding_sheets.rb +2 -2
- data/examples/edit_sheets/example_ranges.rb +3 -3
- data/examples/open_save_close/example_control_to_excel.rb +2 -2
- data/examples/open_save_close/example_default_excel.rb +2 -2
- data/examples/open_save_close/example_force_excel.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +4 -4
- data/examples/open_save_close/example_if_obstructed_forget.rb +2 -2
- data/examples/open_save_close/example_if_obstructed_save.rb +2 -2
- data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
- data/examples/open_save_close/example_if_unsaved_forget.rb +1 -1
- data/examples/open_save_close/example_if_unsaved_forget_more.rb +1 -1
- data/examples/open_save_close/example_read_only.rb +2 -2
- data/examples/open_save_close/example_rename_cells.rb +1 -1
- data/examples/open_save_close/example_reuse.rb +3 -3
- data/examples/open_save_close/example_simple.rb +2 -2
- data/examples/open_save_close/example_unobtrusively.rb +1 -1
- data/lib/robust_excel_ole/book.rb +97 -128
- data/lib/robust_excel_ole/book_store.rb +23 -23
- data/lib/robust_excel_ole/excel.rb +12 -14
- data/lib/robust_excel_ole/version.rb +1 -1
- data/spec/book_spec.rb +462 -289
- data/spec/book_store_spec.rb +36 -55
- data/spec/data/book_with_blank.xls +0 -0
- data/spec/data/{different_simple.xls → different_workbook.xls} +0 -0
- data/spec/data/merge_cells.xls +0 -0
- data/spec/data/{more_simple.xls → more_workbook.xls} +0 -0
- data/spec/data/protected_sheet.xls +0 -0
- data/spec/data/{simple.xls → workbook.xls} +0 -0
- data/spec/data/{simple.xlsm → workbook.xlsm} +0 -0
- data/spec/data/{simple.xlsx → workbook.xlsx} +0 -0
- data/spec/excel_spec.rb +40 -0
- metadata +9 -9
data/spec/book_store_spec.rb
CHANGED
@@ -47,10 +47,10 @@ describe BookStore do
|
|
47
47
|
before do
|
48
48
|
@bookstore = BookStore.new
|
49
49
|
@dir = create_tmpdir
|
50
|
-
@simple_file = @dir + '/
|
51
|
-
@simple_save_file = @dir + '/
|
52
|
-
@different_file = @dir + '/
|
53
|
-
@simple_file_other_path = @dir + '/more_data/
|
50
|
+
@simple_file = @dir + '/workbook.xls'
|
51
|
+
@simple_save_file = @dir + '/workbook_save.xls'
|
52
|
+
@different_file = @dir + '/different_workbook.xls'
|
53
|
+
@simple_file_other_path = @dir + '/more_data/workbook.xls'
|
54
54
|
end
|
55
55
|
|
56
56
|
after do
|
@@ -273,7 +273,7 @@ describe BookStore do
|
|
273
273
|
@bookstore.store(@book2)
|
274
274
|
@bookstore.store(@book3)
|
275
275
|
sheet = @book3[0]
|
276
|
-
sheet[0,0] = sheet[0,0].
|
276
|
+
sheet[0,0] = sheet[0,0].Value == "simple" ? "complex" : "simple"
|
277
277
|
@book.ReadOnly.should be_true
|
278
278
|
@book2.ReadOnly.should be_false
|
279
279
|
@book3.ReadOnly.should be_true
|
@@ -394,67 +394,48 @@ describe BookStore do
|
|
394
394
|
end
|
395
395
|
end
|
396
396
|
|
397
|
-
describe "
|
398
|
-
|
399
|
-
context "with no books" do
|
400
|
-
|
401
|
-
it "should yield nil" do
|
402
|
-
@bookstore.excel_list.should == {}
|
403
|
-
end
|
397
|
+
describe "hidden_excel" do
|
404
398
|
|
405
|
-
|
399
|
+
context "with some open book" do
|
406
400
|
|
407
|
-
context "with open books" do
|
408
|
-
|
409
401
|
before do
|
410
402
|
@book = Book.open(@simple_file)
|
411
|
-
@bookstore.store(@book)
|
412
403
|
end
|
413
404
|
|
414
405
|
after do
|
415
406
|
@book.close
|
416
407
|
end
|
417
408
|
|
418
|
-
it "should
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
it "should yield two excels and two books" do
|
444
|
-
e = Excel.create
|
445
|
-
book1 = Book.open(@simple_file, :force_excel => :new)
|
409
|
+
it "should create and use a hidden Excel instance" do
|
410
|
+
h_excel0 = @bookstore.try_hidden_excel
|
411
|
+
h_excel0.should == nil
|
412
|
+
h_excel1 = @bookstore.ensure_hidden_excel
|
413
|
+
h_excel1.should == @bookstore.try_hidden_excel
|
414
|
+
h_excel1.should_not == @book.excel
|
415
|
+
h_excel1.Visible.should be_false
|
416
|
+
h_excel1.DisplayAlerts.should be_false
|
417
|
+
book1 = Book.open(@simple_file, :force_excel => @bookstore.ensure_hidden_excel)
|
418
|
+
book1.excel.should === h_excel1
|
419
|
+
book1.excel.should_not === @book.excel
|
420
|
+
Excel.close_all
|
421
|
+
h_excel2 = @bookstore.ensure_hidden_excel
|
422
|
+
h_excel2.should_not == @book.excel
|
423
|
+
h_excel2.should_not == book1.excel
|
424
|
+
h_excel2.Visible.should be_false
|
425
|
+
h_excel2.DisplayAlerts.should be_false
|
426
|
+
book2 = Book.open(@simple_file, :force_excel => @bookstore.ensure_hidden_excel)
|
427
|
+
book2.excel.should === h_excel2
|
428
|
+
book2.excel.should_not === @book.excel
|
429
|
+
book2.excel.should_not === book1.excel
|
430
|
+
end
|
431
|
+
|
432
|
+
it "should exclude hidden excel" do
|
433
|
+
book1 = Book.open(@simple_file, :force_excel => @bookstore.ensure_hidden_excel)
|
446
434
|
@bookstore.store(book1)
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
num = num + 1
|
452
|
-
excel.should be_a Excel
|
453
|
-
workbooks.size.should == 1
|
454
|
-
#workbooks[0].should == @book.workbook if num == 1
|
455
|
-
#workbooks[0].should == book1.workbook if num == 2
|
456
|
-
end
|
457
|
-
end
|
435
|
+
book1.close
|
436
|
+
book2 = @bookstore.fetch(@simple_file)
|
437
|
+
book2.should == nil
|
438
|
+
end
|
458
439
|
end
|
459
440
|
end
|
460
441
|
end
|
Binary file
|
Binary file
|
data/spec/data/merge_cells.xls
CHANGED
Binary file
|
File without changes
|
Binary file
|
Binary file
|
File without changes
|
File without changes
|
data/spec/excel_spec.rb
CHANGED
@@ -8,8 +8,18 @@ module RobustExcelOle
|
|
8
8
|
|
9
9
|
describe Excel do
|
10
10
|
|
11
|
+
before(:all) do
|
12
|
+
Excel.close_all
|
13
|
+
end
|
14
|
+
|
11
15
|
before do
|
16
|
+
@dir = create_tmpdir
|
17
|
+
@simple_file = @dir + '/simple.xls'
|
18
|
+
end
|
19
|
+
|
20
|
+
after do
|
12
21
|
Excel.close_all
|
22
|
+
rm_tmp(@dir)
|
13
23
|
end
|
14
24
|
|
15
25
|
context "excel creation" do
|
@@ -109,6 +119,12 @@ module RobustExcelOle
|
|
109
119
|
@excel1.should_not == nil
|
110
120
|
end
|
111
121
|
|
122
|
+
it "should be false with dead Excel objects" do
|
123
|
+
excel2 = Excel.current
|
124
|
+
Excel.close_all
|
125
|
+
excel2.should_not == @excel1
|
126
|
+
end
|
127
|
+
|
112
128
|
end
|
113
129
|
|
114
130
|
context "with Visible and DisplayAlerts" do
|
@@ -225,6 +241,30 @@ module RobustExcelOle
|
|
225
241
|
excel3.should_not == excel4
|
226
242
|
end
|
227
243
|
end
|
244
|
+
|
245
|
+
describe "generate workbook" do
|
246
|
+
|
247
|
+
context "with standard" do
|
248
|
+
|
249
|
+
before do
|
250
|
+
@excel1 = Excel.create
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should generate a workbook" do
|
254
|
+
excel = Excel.create
|
255
|
+
workbook = excel.generate_workbook(@simple_file)
|
256
|
+
p "workbook: #{workbook}"
|
257
|
+
workbook.should be_a WIN32OLE
|
258
|
+
workbook.Name.should == File.basename(@simple_file)
|
259
|
+
workbook.FullName.should == RobustExcelOle::absolute_path(@simple_file)
|
260
|
+
workbook.Saved.should be_true
|
261
|
+
workbook.ReadOnly.should be_false
|
262
|
+
workbook.Sheets.Count == 1
|
263
|
+
workbooks = excel.Workbooks
|
264
|
+
workbooks.Count.should == 1
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
228
268
|
end
|
229
269
|
|
230
270
|
describe "RobustExcelOle" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: robust_excel_ole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- traths
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2015-
|
18
|
+
date: 2015-06-07 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -89,14 +89,14 @@ files:
|
|
89
89
|
- spec/cell_spec.rb
|
90
90
|
- spec/cygwin_spec.rb
|
91
91
|
- spec/data/book_with_blank.xls
|
92
|
-
- spec/data/
|
92
|
+
- spec/data/different_workbook.xls
|
93
93
|
- spec/data/merge_cells.xls
|
94
94
|
- spec/data/more_data/simple.xls
|
95
|
-
- spec/data/
|
95
|
+
- spec/data/more_workbook.xls
|
96
96
|
- spec/data/protected_sheet.xls
|
97
|
-
- spec/data/
|
98
|
-
- spec/data/
|
99
|
-
- spec/data/
|
97
|
+
- spec/data/workbook.xls
|
98
|
+
- spec/data/workbook.xlsm
|
99
|
+
- spec/data/workbook.xlsx
|
100
100
|
- spec/excel_spec.rb
|
101
101
|
- spec/helpers/create_temporary_dir.rb
|
102
102
|
- spec/helpers/key_sender.rb
|