robust_excel_ole 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -0
- data/examples/edit_sheets/example_access_sheets_and_cells.rb +1 -1
- data/examples/edit_sheets/example_adding_sheets.rb +1 -1
- data/examples/edit_sheets/example_concating.rb +2 -2
- data/examples/edit_sheets/example_copying.rb +2 -2
- data/examples/edit_sheets/example_expanding.rb +2 -2
- data/examples/edit_sheets/example_naming.rb +2 -2
- data/examples/edit_sheets/example_ranges.rb +1 -1
- data/examples/edit_sheets/example_saving.rb +2 -2
- data/examples/open_save_close/example_control_to_excel.rb +1 -1
- data/examples/open_save_close/example_default_excel.rb +1 -1
- data/examples/open_save_close/example_force_excel.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_forget.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_save.rb +1 -1
- 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 +1 -1
- data/examples/open_save_close/example_rename_cells.rb +2 -2
- data/examples/open_save_close/example_reuse.rb +1 -1
- data/examples/open_save_close/example_simple.rb +1 -1
- data/examples/open_save_close/example_unobtrusively.rb +1 -1
- data/lib/reo_console.rb +2 -2
- data/lib/robust_excel_ole.rb +1 -174
- data/lib/robust_excel_ole/book.rb +47 -63
- data/lib/robust_excel_ole/bookstore.rb +4 -4
- data/lib/robust_excel_ole/excel.rb +12 -18
- data/lib/robust_excel_ole/general.rb +188 -0
- data/lib/robust_excel_ole/sheet.rb +1 -1
- data/lib/robust_excel_ole/utilities.rb +1 -1
- data/lib/robust_excel_ole/version.rb +1 -1
- data/spec/{book_specs/book_spec.rb → book_spec.rb} +26 -24
- data/spec/book_specs/book_all_spec.rb +1 -1
- data/spec/book_specs/book_close_spec.rb +16 -15
- data/spec/book_specs/book_misc_spec.rb +4 -3
- data/spec/book_specs/book_open_spec.rb +10 -9
- data/spec/book_specs/book_save_spec.rb +4 -3
- data/spec/book_specs/book_sheet_spec.rb +7 -6
- data/spec/book_specs/book_unobtr_spec.rb +2 -1
- data/spec/data/different_workbook.xls +0 -0
- data/spec/data/workbook.xls +0 -0
- data/spec/excel_spec.rb +9 -11
- data/spec/general_spec.rb +193 -0
- data/spec/range_spec.rb +3 -2
- data/spec/sheet_spec.rb +27 -19
- metadata +8 -6
- data/spec/robust_excel_ole_spec.rb +0 -113
data/spec/range_spec.rb
CHANGED
@@ -14,13 +14,14 @@ describe RobustExcelOle::Range do
|
|
14
14
|
|
15
15
|
before do
|
16
16
|
@dir = create_tmpdir
|
17
|
-
@book = Book.open(@dir + '/workbook.xls')
|
17
|
+
@book = Book.open(@dir + '/workbook.xls', :force_excel => :new)
|
18
18
|
@sheet = @book[1]
|
19
19
|
@range = RobustExcelOle::Range.new(@sheet.worksheet.UsedRange.Rows(1))
|
20
20
|
end
|
21
21
|
|
22
22
|
after do
|
23
23
|
@book.close
|
24
|
+
Excel.kill_all
|
24
25
|
rm_tmp(@dir)
|
25
26
|
end
|
26
27
|
|
@@ -59,7 +60,7 @@ describe RobustExcelOle::Range do
|
|
59
60
|
|
60
61
|
context "read 'merge_cells.xls'" do
|
61
62
|
before do
|
62
|
-
@merge_cells_book = Book.open("#{@dir}/merge_cells.xls")
|
63
|
+
@merge_cells_book = Book.open("#{@dir}/merge_cells.xls", :force_excel => :new)
|
63
64
|
@merge_cells_sheet = @merge_cells_book[0]
|
64
65
|
end
|
65
66
|
|
data/spec/sheet_spec.rb
CHANGED
@@ -1,35 +1,43 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
|
2
3
|
require File.join(File.dirname(__FILE__), './spec_helper')
|
3
4
|
|
5
|
+
$VERBOSE = nil
|
6
|
+
|
4
7
|
include RobustExcelOle
|
8
|
+
include General
|
9
|
+
|
10
|
+
describe Sheet do
|
11
|
+
|
12
|
+
before(:all) do
|
13
|
+
excel = Excel.new(:reuse => true)
|
14
|
+
open_books = excel == nil ? 0 : excel.Workbooks.Count
|
15
|
+
puts "*** open books *** : #{open_books}" if open_books > 0
|
16
|
+
Excel.close_all
|
17
|
+
end
|
5
18
|
|
6
|
-
describe RobustExcelOle::Sheet do
|
7
|
-
|
8
19
|
before do
|
9
20
|
@dir = create_tmpdir
|
10
|
-
@
|
21
|
+
@simple_file = @dir + '/workbook.xls'
|
22
|
+
@protected_file = @dir + '/protected_sheet.xls'
|
23
|
+
@blank_file = @dir + '/book_with_blank.xls'
|
24
|
+
@merge_file = @dir + '/merge_cells.xls'
|
25
|
+
@book = Book.open(@simple_file)
|
11
26
|
@sheet = @book[0]
|
12
27
|
end
|
13
28
|
|
14
29
|
after do
|
15
|
-
@book.close
|
30
|
+
@book.close(:if_unsaved => :forget)
|
31
|
+
Excel.kill_all
|
16
32
|
rm_tmp(@dir)
|
17
33
|
end
|
18
34
|
|
19
|
-
before(:all) do
|
20
|
-
Excel.close_all
|
21
|
-
end
|
22
|
-
|
23
|
-
after(:all) do
|
24
|
-
Excel.kill_all
|
25
|
-
end
|
26
|
-
|
27
35
|
describe ".initialize" do
|
28
36
|
context "when open sheet protected(with password is 'protect')" do
|
29
37
|
before do
|
30
38
|
@key_sender = IO.popen 'ruby "' + File.join(File.dirname(__FILE__), '/helpers/key_sender.rb') + '" "Microsoft Office Excel" ' , "w"
|
39
|
+
@book_protect = Book.open(@protected_file, :visible => true, :read_only => true, :force_excel => :new)
|
31
40
|
@key_sender.puts "{p}{r}{o}{t}{e}{c}{t}{enter}"
|
32
|
-
@book_protect = RobustExcelOle::Book.open(@dir + '/protected_sheet.xls', :visible => true, :read_only => true)
|
33
41
|
@protected_sheet = @book_protect['protect']
|
34
42
|
end
|
35
43
|
|
@@ -51,7 +59,7 @@ describe RobustExcelOle::Sheet do
|
|
51
59
|
|
52
60
|
shared_context "sheet 'open book with blank'" do
|
53
61
|
before do
|
54
|
-
@book_with_blank =
|
62
|
+
@book_with_blank = Book.open(@blank_file, :read_only => true)
|
55
63
|
@sheet_with_blank = @book_with_blank[0]
|
56
64
|
end
|
57
65
|
|
@@ -91,7 +99,7 @@ describe RobustExcelOle::Sheet do
|
|
91
99
|
|
92
100
|
context "access [1,1]" do
|
93
101
|
|
94
|
-
it { @sheet[1, 1].should be_kind_of
|
102
|
+
it { @sheet[1, 1].should be_kind_of Cell }
|
95
103
|
it { @sheet[1, 1].value.should eq 'foo' }
|
96
104
|
end
|
97
105
|
|
@@ -280,7 +288,7 @@ describe RobustExcelOle::Sheet do
|
|
280
288
|
|
281
289
|
context "read sheet which last cell is merged" do
|
282
290
|
before do
|
283
|
-
@book_merge_cells =
|
291
|
+
@book_merge_cells = Book.open(@merge_file)
|
284
292
|
@sheet_merge_cell = @book_merge_cells[0]
|
285
293
|
end
|
286
294
|
|
@@ -385,7 +393,7 @@ describe RobustExcelOle::Sheet do
|
|
385
393
|
context "returning the value of a range" do
|
386
394
|
|
387
395
|
before do
|
388
|
-
@book1 =
|
396
|
+
@book1 = Book.open(@dir + '/another_workbook.xls')
|
389
397
|
@sheet1 = @book1[0]
|
390
398
|
end
|
391
399
|
|
@@ -422,7 +430,7 @@ describe RobustExcelOle::Sheet do
|
|
422
430
|
context "setting the value of a range" do
|
423
431
|
|
424
432
|
before do
|
425
|
-
@book1 =
|
433
|
+
@book1 = Book.open(@dir + '/another_workbook.xls', :read_only => true)
|
426
434
|
@sheet1 = @book1[0]
|
427
435
|
end
|
428
436
|
|
@@ -454,7 +462,7 @@ describe RobustExcelOle::Sheet do
|
|
454
462
|
context "setting the name of a range" do
|
455
463
|
|
456
464
|
before do
|
457
|
-
@book1 =
|
465
|
+
@book1 = Book.open(@dir + '/another_workbook.xls', :read_only => true, :visible => true)
|
458
466
|
@sheet1 = @book1[0]
|
459
467
|
end
|
460
468
|
|
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: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 9
|
10
|
+
version: 0.3.9
|
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: 2016-02
|
18
|
+
date: 2016-03-02 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -46,6 +46,7 @@ extra_rdoc_files:
|
|
46
46
|
- LICENSE
|
47
47
|
files:
|
48
48
|
- .gitignore
|
49
|
+
- .yardopts
|
49
50
|
- Changelog
|
50
51
|
- Gemfile
|
51
52
|
- Guardfile
|
@@ -83,6 +84,7 @@ files:
|
|
83
84
|
- lib/robust_excel_ole/cell.rb
|
84
85
|
- lib/robust_excel_ole/cygwin.rb
|
85
86
|
- lib/robust_excel_ole/excel.rb
|
87
|
+
- lib/robust_excel_ole/general.rb
|
86
88
|
- lib/robust_excel_ole/range.rb
|
87
89
|
- lib/robust_excel_ole/robustexcelole.sublime-project
|
88
90
|
- lib/robust_excel_ole/robustexcelole.sublime-workspace
|
@@ -92,13 +94,13 @@ files:
|
|
92
94
|
- lib/spec_helper.rb
|
93
95
|
- reo.bat
|
94
96
|
- robust_excel_ole.gemspec
|
97
|
+
- spec/book_spec.rb
|
95
98
|
- spec/book_specs/book_all_spec.rb
|
96
99
|
- spec/book_specs/book_close_spec.rb
|
97
100
|
- spec/book_specs/book_misc_spec.rb
|
98
101
|
- spec/book_specs/book_open_spec.rb
|
99
102
|
- spec/book_specs/book_save_spec.rb
|
100
103
|
- spec/book_specs/book_sheet_spec.rb
|
101
|
-
- spec/book_specs/book_spec.rb
|
102
104
|
- spec/book_specs/book_subclass_spec.rb
|
103
105
|
- spec/book_specs/book_unobtr_spec.rb
|
104
106
|
- spec/bookstore_spec.rb
|
@@ -117,10 +119,10 @@ files:
|
|
117
119
|
- spec/data/workbook_linked.xlsm
|
118
120
|
- spec/data/workbook_linked_sub.xlsm
|
119
121
|
- spec/excel_spec.rb
|
122
|
+
- spec/general_spec.rb
|
120
123
|
- spec/helpers/create_temporary_dir.rb
|
121
124
|
- spec/helpers/key_sender.rb
|
122
125
|
- spec/range_spec.rb
|
123
|
-
- spec/robust_excel_ole_spec.rb
|
124
126
|
- spec/sheet_spec.rb
|
125
127
|
- spec/spec_helper.rb
|
126
128
|
- version.rb
|
@@ -1,113 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), './spec_helper')
|
4
|
-
|
5
|
-
$VERBOSE = nil
|
6
|
-
|
7
|
-
include RobustExcelOle
|
8
|
-
|
9
|
-
describe RobustExcelOle do
|
10
|
-
|
11
|
-
before(:all) do
|
12
|
-
excel = Excel.new(:reuse => true)
|
13
|
-
open_books = excel == nil ? 0 : excel.Workbooks.Count
|
14
|
-
puts "*** open books *** : #{open_books}" if open_books > 0
|
15
|
-
Excel.close_all
|
16
|
-
end
|
17
|
-
|
18
|
-
before do
|
19
|
-
@dir = create_tmpdir
|
20
|
-
@simple_file = @dir + '/workbook.xls'
|
21
|
-
end
|
22
|
-
|
23
|
-
after do
|
24
|
-
Excel.kill_all
|
25
|
-
rm_tmp(@dir)
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "t" do
|
29
|
-
|
30
|
-
it "should put some" do
|
31
|
-
a = 4
|
32
|
-
t "some text #{a}"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should put another text" do
|
36
|
-
a = 5
|
37
|
-
t "another text #{a}"
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "#absolute_path" do
|
43
|
-
|
44
|
-
context "with standard" do
|
45
|
-
|
46
|
-
before do
|
47
|
-
@previous_dir = Dir.getwd
|
48
|
-
end
|
49
|
-
|
50
|
-
after do
|
51
|
-
Dir.chdir @previous_dir
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should return the right absolute paths" do
|
55
|
-
absolute_path("C:/abc").should == "C:\\abc"
|
56
|
-
absolute_path("C:\\abc").should == "C:\\abc"
|
57
|
-
Dir.chdir "C:/windows"
|
58
|
-
absolute_path("C:abc").downcase.should == Dir.pwd.gsub("/","\\").downcase + "\\abc"
|
59
|
-
absolute_path("C:abc").upcase.should == File.expand_path("abc").gsub("/","\\").upcase
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should return right absolute path name" do
|
63
|
-
filename = 'C:/Dokumente und Einstellungen/Zauberthomas/Eigene Dateien/robust_excel_ole/spec/book_spec.rb'
|
64
|
-
absolute_path(filename).gsub("\\","/").should == filename
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "canonize" do
|
70
|
-
|
71
|
-
context "with standard" do
|
72
|
-
|
73
|
-
it "should reduce slash at the end" do
|
74
|
-
normalize("hallo/").should == "hallo"
|
75
|
-
normalize("/this/is/the/Path/").should == "/this/is/the/Path"
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should save capital letters" do
|
79
|
-
normalize("HALLO/").should == "HALLO"
|
80
|
-
normalize("/This/IS/tHe/patH/").should == "/This/IS/tHe/patH"
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should reduce multiple shlashes" do
|
84
|
-
normalize("/this/is//the/path").should == "/this/is/the/path"
|
85
|
-
normalize("///this/////////is//the/path/////").should == "/this/is/the/path"
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should reduce dots in the paths" do
|
89
|
-
canonize("/this/is/./the/path").should == "/this/is/the/path"
|
90
|
-
canonize("this/.is/./the/pa.th/").should == "this/.is/the/pa.th"
|
91
|
-
canonize("this//.///.//.is/the/pa.th/").should == "this/.is/the/pa.th"
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should change to the upper directory with two dots" do
|
95
|
-
canonize("/this/is/../the/path").should == "/this/the/path"
|
96
|
-
canonize("this../.i.s/.../..the/..../pa.th/").should == "this../.i.s/.../..the/..../pa.th"
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should downcase" do
|
100
|
-
canonize("/This/IS/tHe/path").should == "/this/is/the/path"
|
101
|
-
canonize("///THIS/.///./////iS//the/../PatH/////").should == "/this/is/path"
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should raise an error for no strings" do
|
105
|
-
expect{
|
106
|
-
canonize(1)
|
107
|
-
}.to raise_error(ExcelError, "No string given to canonize, but 1")
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|