robust_excel_ole 1.15 → 1.18.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.
- checksums.yaml +4 -4
- data/Changelog +27 -0
- data/README.rdoc +18 -1
- data/___dummy_workbook.xls +0 -0
- data/docs/README_excel.rdoc +6 -0
- data/docs/README_open.rdoc +18 -2
- data/docs/README_ranges.rdoc +11 -2
- data/examples/example_ruby_library.rb +27 -0
- data/extconf.rb +13 -0
- data/lib/robust_excel_ole.rb +4 -3
- data/lib/robust_excel_ole/{address.rb → address_tool.rb} +23 -22
- data/lib/robust_excel_ole/{reo_common.rb → base.rb} +2 -90
- data/lib/robust_excel_ole/bookstore.rb +14 -77
- data/lib/robust_excel_ole/cell.rb +30 -18
- data/lib/robust_excel_ole/excel.rb +71 -41
- data/lib/robust_excel_ole/general.rb +39 -14
- data/lib/robust_excel_ole/range.rb +42 -19
- data/lib/robust_excel_ole/range_owners.rb +40 -25
- data/lib/robust_excel_ole/vba_objects.rb +30 -0
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/workbook.rb +241 -235
- data/lib/robust_excel_ole/worksheet.rb +42 -21
- data/lib/rubygems_plugin.rb +3 -0
- data/robust_excel_ole.gemspec +1 -0
- data/spec/address_tool_spec.rb +175 -0
- data/spec/{reo_common_spec.rb → base_spec.rb} +11 -30
- data/spec/bookstore_spec.rb +3 -3
- data/spec/cell_spec.rb +67 -25
- data/spec/data/more_data/workbook.xls +0 -0
- data/spec/excel_spec.rb +41 -275
- data/spec/general_spec.rb +17 -23
- data/spec/range_spec.rb +57 -3
- data/spec/workbook_spec.rb +7 -75
- data/spec/workbook_specs/workbook_misc_spec.rb +11 -21
- data/spec/workbook_specs/workbook_open_spec.rb +570 -30
- data/spec/workbook_specs/workbook_unobtr_spec.rb +33 -33
- data/spec/worksheet_spec.rb +36 -4
- metadata +10 -6
- data/spec/address_spec.rb +0 -174
data/spec/general_spec.rb
CHANGED
@@ -60,9 +60,22 @@ module RobustExcelOle
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should type-lift a range" do
|
63
|
-
range = @book1.sheet(1).range([1,1]).ole_range.to_reo
|
63
|
+
range = @book1.sheet(1).range([1..2,1]).ole_range.to_reo
|
64
64
|
range.should be_kind_of Range
|
65
|
-
range.Value.should == "foo"
|
65
|
+
range.Value.should == [["foo"],["foo"]]
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should type-lift a cell" do
|
69
|
+
cell = @book1.sheet(1).range([1,1]).ole_range.to_reo
|
70
|
+
cell.should be_kind_of Cell
|
71
|
+
cell.Value.should == "foo"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should not do anything with a REO object" do
|
75
|
+
@book1.to_reo.should == @book1
|
76
|
+
@book1.sheet(1).to_reo.should == @book1.sheet(1)
|
77
|
+
@book1.excel.to_reo.should == @book1.excel
|
78
|
+
@book1.sheet(1).range([1,1]).to_reo.should == @book1.sheet(1).range([1,1])
|
66
79
|
end
|
67
80
|
|
68
81
|
end
|
@@ -81,8 +94,7 @@ module RobustExcelOle
|
|
81
94
|
["ActiveCell", "ActiveSheet", "ActiveWorkbook", "Application", "Calculate", "Cells", "Columns",
|
82
95
|
"DisplayAlerts", "Evaluate", "Hwnd", "Name", "Names", "Quit", "Range", "Ready", "Save",
|
83
96
|
"Sheets", "UserName", "Value", "Visible", "Workbooks", "Worksheets"]
|
84
|
-
@excel_methods = ["alive?", "workbook_class", "close", "
|
85
|
-
"with_displayalerts"]
|
97
|
+
@excel_methods = ["alive?", "workbook_class", "close", "properties", "recreate", "with_displayalerts"]
|
86
98
|
@ole_sheet_methods = []
|
87
99
|
# ["Activate", "Calculate", "Copy", "Name", "Select", "Evaluate", "Protect", "Unprotect"]
|
88
100
|
@sheet_methods = ["workbook_class", "col_range", "each", "each_column", "each_column_with_index",
|
@@ -152,9 +164,8 @@ module RobustExcelOle
|
|
152
164
|
|
153
165
|
it "should return the right absolute paths" do
|
154
166
|
absolute_path("C:/abc").should == "C:\\abc"
|
155
|
-
absolute_path("C:\\abc").should == "C:\\abc"
|
167
|
+
#absolute_path("C:\\abc").should == "C:\\abc"
|
156
168
|
Dir.chdir "C:/windows"
|
157
|
-
# does not work under jruby
|
158
169
|
absolute_path("C:abc").downcase.should == Dir.pwd.gsub("/","\\").downcase + "\\abc"
|
159
170
|
absolute_path("C:abc").upcase.should == File.expand_path("abc").gsub("/","\\").upcase
|
160
171
|
end
|
@@ -224,22 +235,5 @@ module RobustExcelOle
|
|
224
235
|
end
|
225
236
|
end
|
226
237
|
|
227
|
-
describe "Object methods" do
|
228
|
-
|
229
|
-
before do
|
230
|
-
@book = Workbook.open(@simple_file)
|
231
|
-
@sheet = @book.sheet(1)
|
232
|
-
end
|
233
|
-
|
234
|
-
before do
|
235
|
-
@book.close
|
236
|
-
end
|
237
|
-
|
238
|
-
it "should raise an error when asking excel of a sheet" do
|
239
|
-
expect{
|
240
|
-
@sheet.excel
|
241
|
-
}.to raise_error(TypeREOError, "receiver instance is neither an Excel nor a Workbook")
|
242
|
-
end
|
243
|
-
end
|
244
238
|
end
|
245
239
|
end
|
data/spec/range_spec.rb
CHANGED
@@ -18,20 +18,74 @@ describe RobustExcelOle::Range do
|
|
18
18
|
@book = Workbook.open(@dir + '/workbook.xls', :force_excel => :new)
|
19
19
|
@sheet = @book.sheet(2)
|
20
20
|
@range = RobustExcelOle::Range.new(@sheet.ole_worksheet.UsedRange.Rows(1))
|
21
|
+
@range2 = @sheet.range([1..2,1..3])
|
21
22
|
end
|
22
23
|
|
23
24
|
after do
|
24
|
-
@book.close
|
25
|
+
@book.close(:if_unsaved => :forget)
|
25
26
|
Excel.kill_all
|
26
27
|
rm_tmp(@dir)
|
27
28
|
end
|
28
29
|
|
30
|
+
describe "#[]" do
|
31
|
+
|
32
|
+
it "should yield a cell" do
|
33
|
+
@range[0].should be_kind_of RobustExcelOle::Cell
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should yield the value of the first cell" do
|
37
|
+
@range2[0].Value.should == 'simple'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should cash the cells in the range" do
|
41
|
+
cell = @range2[0]
|
42
|
+
cell.v.should == 'simple'
|
43
|
+
@range2.Cells.Item(1).Value = 'foo'
|
44
|
+
cell.v.should == 'foo'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
29
48
|
describe "#each" do
|
49
|
+
|
30
50
|
it "items is RobustExcelOle::Cell" do
|
31
|
-
@
|
51
|
+
@range2.each do |cell|
|
32
52
|
cell.should be_kind_of RobustExcelOle::Cell
|
33
53
|
end
|
34
54
|
end
|
55
|
+
|
56
|
+
it "should work with [] doing cashing synchonized, from #[] to #each" do
|
57
|
+
i = 0
|
58
|
+
@range2.each do |cell|
|
59
|
+
cell.v.should == 'simple' if i == 0
|
60
|
+
cell.v.should == 'file' if i == 1
|
61
|
+
cell.v.should == 'sheet2' if i == 2
|
62
|
+
i += 1
|
63
|
+
end
|
64
|
+
@range2[0].Value = 'foo'
|
65
|
+
@range2[1].Value = 'bar'
|
66
|
+
@range2[2].Value = 'simple'
|
67
|
+
i = 0
|
68
|
+
@range2.each do |cell|
|
69
|
+
cell.v.should == 'foo' if i == 0
|
70
|
+
cell.v.should == 'bar' if i == 1
|
71
|
+
cell.v.should == 'simple' if i == 2
|
72
|
+
i += 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should work with [] doing cashing synchonized, from #each to #[]" do
|
77
|
+
@range2[0].Value.should == 'simple'
|
78
|
+
@range2[1].Value.should == 'file'
|
79
|
+
@range2[2].Value.should == 'sheet2'
|
80
|
+
i = 0
|
81
|
+
@range2.each do |cell|
|
82
|
+
cell.Value = 'foo' if i == 0
|
83
|
+
cell.Value = 'bar' if i == 1
|
84
|
+
cell.Value = 'simple' if i == 2
|
85
|
+
i += 1
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
35
89
|
end
|
36
90
|
|
37
91
|
describe "#values" do
|
@@ -335,7 +389,7 @@ describe RobustExcelOle::Range do
|
|
335
389
|
#end
|
336
390
|
|
337
391
|
context "unknown method" do
|
338
|
-
it { expect { @range.hogehogefoo}.to raise_error }
|
392
|
+
it { expect { @range.hogehogefoo}.to raise_error(NoMethodError) }
|
339
393
|
end
|
340
394
|
end
|
341
395
|
end
|
data/spec/workbook_spec.rb
CHANGED
@@ -625,16 +625,16 @@ describe Workbook do
|
|
625
625
|
old_cell_value = sheet[1,1].Value
|
626
626
|
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
627
627
|
book.Saved.should be false
|
628
|
-
new_book = Workbook.open(@simple_file1, :read_only => false, :if_unsaved => :
|
628
|
+
new_book = Workbook.open(@simple_file1, :read_only => false, :if_unsaved => :forget)
|
629
629
|
new_book.ReadOnly.should be false
|
630
630
|
new_book.should be_alive
|
631
|
-
book.
|
632
|
-
new_book.should == book
|
631
|
+
book.should_not be_alive
|
633
632
|
new_sheet = new_book.sheet(1)
|
634
633
|
new_cell_value = new_sheet[1,1].Value
|
635
634
|
new_cell_value.should == old_cell_value
|
636
635
|
end
|
637
636
|
|
637
|
+
|
638
638
|
context "with block" do
|
639
639
|
it 'block parameter should be instance of Workbook' do
|
640
640
|
Workbook.open(@simple_file) do |book|
|
@@ -927,31 +927,6 @@ describe Workbook do
|
|
927
927
|
after do
|
928
928
|
@book.close
|
929
929
|
end
|
930
|
-
|
931
|
-
it "should open unobtrusively the book in a new Excel such that the book is writable" do
|
932
|
-
book2 = Workbook.open(@simple_file1, :force => {:excel => :new}, :read_only => true)
|
933
|
-
@book.ReadOnly.should be true
|
934
|
-
book2.Readonly.should be true
|
935
|
-
sheet = @book.sheet(1)
|
936
|
-
cell_value = sheet[1,1].Value
|
937
|
-
Workbook.unobtrusively(@simple_file1, :rw_change_excel => :new, :if_closed => :current, :writable => true) do |book|
|
938
|
-
book.should be_a Workbook
|
939
|
-
book.excel.should_not == book2.excel
|
940
|
-
book.excel.should_not == @book.excel
|
941
|
-
sheet = book.sheet(1)
|
942
|
-
sheet[1,1] = sheet[1,1].Value == "foo" ? "bar" : "foo"
|
943
|
-
book.should be_alive
|
944
|
-
book.Saved.should be false
|
945
|
-
end
|
946
|
-
@book.Saved.should be true
|
947
|
-
@book.ReadOnly.should be true
|
948
|
-
@book.close
|
949
|
-
book2.close
|
950
|
-
book3 = Workbook.open(@simple_file1)
|
951
|
-
new_sheet = book3.sheet(1)
|
952
|
-
new_sheet[1,1].Value.should_not == cell_value
|
953
|
-
book3.close
|
954
|
-
end
|
955
930
|
end
|
956
931
|
|
957
932
|
context "with a virgin Workbook class" do
|
@@ -1001,7 +976,7 @@ describe Workbook do
|
|
1001
976
|
|
1002
977
|
before do
|
1003
978
|
@book1 = Workbook.open(@simple_file1)
|
1004
|
-
@book2 = Workbook.open(@simple_file1, :
|
979
|
+
@book2 = Workbook.open(@simple_file1, :force_excel => :new)
|
1005
980
|
@book1.Readonly.should == false
|
1006
981
|
@book2.Readonly.should == true
|
1007
982
|
old_sheet = @book1.sheet(1)
|
@@ -1013,9 +988,9 @@ describe Workbook do
|
|
1013
988
|
end
|
1014
989
|
|
1015
990
|
it "should open unobtrusively the closed book in the most recent Excel where it was open before" do
|
1016
|
-
Workbook.unobtrusively(@
|
1017
|
-
book.excel.
|
1018
|
-
book.excel.
|
991
|
+
Workbook.unobtrusively(@simple_file1, :if_closed => :current) do |book|
|
992
|
+
book.excel.should == @book2.excel
|
993
|
+
book.excel.should_not == @book1.excel
|
1019
994
|
book.ReadOnly.should == false
|
1020
995
|
sheet = book.sheet(1)
|
1021
996
|
cell = sheet[1,1]
|
@@ -1027,52 +1002,9 @@ describe Workbook do
|
|
1027
1002
|
sheet[1,1].Value.should_not == @old_cell_value
|
1028
1003
|
end
|
1029
1004
|
|
1030
|
-
it "should open unobtrusively the closed book in the new hidden Excel" do
|
1031
|
-
Workbook.unobtrusively(@simple_file, :if_closed => :current) do |book|
|
1032
|
-
book.excel.should_not == @book2.excel
|
1033
|
-
book.excel.should == @book1.excel
|
1034
|
-
book.ReadOnly.should == false
|
1035
|
-
sheet = book.sheet(1)
|
1036
|
-
cell = sheet[1,1]
|
1037
|
-
sheet[1,1] = cell.Value == "foo" ? "bar" : "foo"
|
1038
|
-
book.Saved.should be false
|
1039
|
-
end
|
1040
|
-
new_book = Workbook.open(@simple_file1)
|
1041
|
-
sheet = new_book.sheet(1)
|
1042
|
-
sheet[1,1].Value.should_not == @old_cell_value
|
1043
|
-
end
|
1044
1005
|
end
|
1045
1006
|
end
|
1046
|
-
|
1047
|
-
=begin
|
1048
|
-
context "with :hidden" do
|
1049
|
-
|
1050
|
-
before do
|
1051
|
-
@book1 = Workbook.open(@simple_file1)
|
1052
|
-
@book1.close
|
1053
|
-
end
|
1054
1007
|
|
1055
|
-
it "should create a new hidden Excel instance and use this afterwards" do
|
1056
|
-
hidden_excel = nil
|
1057
|
-
Workbook.unobtrusively(@simple_file1, :hidden) do |book|
|
1058
|
-
book.should be_a Workbook
|
1059
|
-
book.should be_alive
|
1060
|
-
book.excel.Visible.should be false
|
1061
|
-
book.excel.DisplayAlerts.should be false
|
1062
|
-
hidden_excel = book.excel
|
1063
|
-
end
|
1064
|
-
Workbook.unobtrusively(@different_file, :hidden) do |book|
|
1065
|
-
book.should be_a Workbook
|
1066
|
-
book.should be_alive
|
1067
|
-
book.excel.Visible.should be false
|
1068
|
-
book.excel.DisplayAlerts.should be false
|
1069
|
-
book.excel.should == hidden_excel
|
1070
|
-
end
|
1071
|
-
end
|
1072
|
-
end
|
1073
|
-
end
|
1074
|
-
=end
|
1075
|
-
|
1076
1008
|
describe "for_reading, for_modifying" do
|
1077
1009
|
|
1078
1010
|
context "open unobtrusively for reading and modifying" do
|
@@ -59,25 +59,25 @@ describe Workbook do
|
|
59
59
|
@book.Windows(@book.Name).Visible.should be true
|
60
60
|
@book.visible.should be true
|
61
61
|
@book.ReadOnly.should be false
|
62
|
-
@book.CheckCompatibility.should be
|
62
|
+
@book.CheckCompatibility.should be true
|
63
63
|
@book.for_this_workbook(:visible => false)
|
64
64
|
@book.excel.Visible.should be true
|
65
65
|
@book.Windows(@book.Name).Visible.should be false
|
66
66
|
@book.visible.should be false
|
67
67
|
@book.ReadOnly.should be false
|
68
|
-
@book.CheckCompatibility.should be
|
68
|
+
@book.CheckCompatibility.should be true
|
69
69
|
@book.for_this_workbook(:read_only => true)
|
70
70
|
@book.excel.Visible.should be true
|
71
|
-
@book.Windows(@book.Name).Visible.should be
|
72
|
-
@book.visible.should be
|
71
|
+
@book.Windows(@book.Name).Visible.should be true
|
72
|
+
@book.visible.should be true
|
73
73
|
@book.ReadOnly.should be true
|
74
|
-
@book.CheckCompatibility.should be
|
74
|
+
@book.CheckCompatibility.should be true
|
75
75
|
@book.for_this_workbook(:visible => true)
|
76
76
|
@book.excel.Visible.should be true
|
77
77
|
@book.Windows(@book.Name).Visible.should be true
|
78
78
|
@book.visible.should be true
|
79
79
|
@book.ReadOnly.should be true
|
80
|
-
@book.CheckCompatibility.should be
|
80
|
+
@book.CheckCompatibility.should be true
|
81
81
|
@book.for_this_workbook(:check_compatibility => true)
|
82
82
|
@book.excel.Visible.should be true
|
83
83
|
@book.Windows(@book.Name).Visible.should be true
|
@@ -106,7 +106,7 @@ describe Workbook do
|
|
106
106
|
|
107
107
|
end
|
108
108
|
|
109
|
-
describe "
|
109
|
+
describe "to_reo.excel" do
|
110
110
|
|
111
111
|
before do
|
112
112
|
@book = Workbook.open(@simple_file)
|
@@ -118,19 +118,19 @@ describe Workbook do
|
|
118
118
|
|
119
119
|
it "should access the excel" do
|
120
120
|
workbook = @book.ole_workbook
|
121
|
-
excel =
|
121
|
+
excel = workbook.to_reo.excel
|
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 = @book.excel.ole_excel.to_reo.excel
|
128
128
|
excel.should be_a Excel
|
129
129
|
excel.should == @book.excel
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should access the Excel of a Workbook" do
|
133
|
-
excel =
|
133
|
+
excel = @book.to_reo.excel
|
134
134
|
excel.should be_a Excel
|
135
135
|
excel.should == @book.excel
|
136
136
|
end
|
@@ -773,8 +773,7 @@ describe Workbook do
|
|
773
773
|
it "should color the cell" do
|
774
774
|
@book1.set_namevalue_glob("new", "bar")
|
775
775
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == -4142
|
776
|
-
@book1.
|
777
|
-
@book1.set_namevalue_glob("new", "bar")
|
776
|
+
@book1.set_namevalue_glob("new", "bar", :color => 4)
|
778
777
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == 4
|
779
778
|
@book1["new"].should == "bar"
|
780
779
|
@book1["new"] = "bar"
|
@@ -783,15 +782,6 @@ describe Workbook do
|
|
783
782
|
@book1.close
|
784
783
|
end
|
785
784
|
|
786
|
-
it "should save without color (deprecated)" do
|
787
|
-
@book1.set_namevalue_glob("new", "bar", :color => 4)
|
788
|
-
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == 4
|
789
|
-
@book1.save(:discoloring => true)
|
790
|
-
@book1.close
|
791
|
-
#book2 = Workbook.open(@simple_file1, :visible => true)
|
792
|
-
#book2.Names.Item("new").RefersToRange.Interior.ColorIndex.should == 0
|
793
|
-
end
|
794
|
-
|
795
785
|
end
|
796
786
|
|
797
787
|
describe "rename_range" do
|
@@ -35,7 +35,15 @@ describe Workbook do
|
|
35
35
|
#@simple_file_via_network = File.join('N:/', 'data') + '/workbook.xls'
|
36
36
|
@simple_file_network_path = "N:/data/workbook.xls"
|
37
37
|
@simple_file_hostname_share_path = '//DESKTOP-A3C5CJ6/spec/data/workbook.xls'
|
38
|
-
|
38
|
+
@simple_file_network_path_other_path = "N:/data/more_data/workbook.xls"
|
39
|
+
@simple_file_hostname_share_path_other_path = '//DESKTOP-A3C5CJ6/spec/data/more_data/workbook.xls'
|
40
|
+
@simple_file_network_path1 = @simple_file_network_path
|
41
|
+
@simple_file_hostname_share_path1 = @simple_file_hostname_share_path
|
42
|
+
@simple_file_network_path_other_path1 = @simple_file_network_path_other_path
|
43
|
+
@simple_file_hostname_share_path_other_path1 = @simple_file_hostname_share_path_other_path
|
44
|
+
@simple_file_xlsm1 = @simple_file_xlsm
|
45
|
+
@simple_file_xlsx1 = @simple_file_xlsx
|
46
|
+
@error_message_excel = "provided Excel option value is neither an Excel object nor a valid option"
|
39
47
|
end
|
40
48
|
|
41
49
|
after do
|
@@ -43,6 +51,198 @@ describe Workbook do
|
|
43
51
|
rm_tmp(@dir)
|
44
52
|
end
|
45
53
|
|
54
|
+
describe "basic tests with xlsx-workbooks" do
|
55
|
+
|
56
|
+
context "with simple file" do
|
57
|
+
|
58
|
+
it "should simply create a new workbook given a file" do
|
59
|
+
book = Workbook.new(@simple_file_xlsx1)
|
60
|
+
book.should be_alive
|
61
|
+
book.should be_a Workbook
|
62
|
+
book.filename.should == @simple_file_xlsx1
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
context "with transparency identity" do
|
68
|
+
|
69
|
+
before do
|
70
|
+
@book = Workbook.open(@simple_file_xlsx1)
|
71
|
+
end
|
72
|
+
|
73
|
+
after do
|
74
|
+
@book.close
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should yield identical Workbook objects referring to identical WIN32OLE objects" do
|
78
|
+
book2 = Workbook.new(@book.ole_workbook)
|
79
|
+
book2.equal?(@book).should be true
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
context "with connecting to one unknown workbook" do
|
85
|
+
|
86
|
+
before do
|
87
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
88
|
+
ws = ole_e1.Workbooks
|
89
|
+
abs_filename = General.absolute_path(@simple_file_xlsx1)
|
90
|
+
@ole_wb = ws.Open(abs_filename)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should connect to an unknown workbook" do
|
94
|
+
Workbook.open(@simple_file_xlsx1) do |book|
|
95
|
+
book.filename.should == @simple_file_xlsx1
|
96
|
+
book.should be_alive
|
97
|
+
book.should be_a Workbook
|
98
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
99
|
+
Excel.excels_number.should == 1
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context "with :force => excel" do
|
105
|
+
|
106
|
+
before do
|
107
|
+
@book = Workbook.open(@simple_file_xlsx1)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should open in a new Excel" do
|
111
|
+
book2 = Workbook.open(@simple_file_xlsx1, :force => {:excel => :new})
|
112
|
+
book2.should be_alive
|
113
|
+
book2.should be_a Workbook
|
114
|
+
book2.excel.should_not == @book.excel
|
115
|
+
book2.should_not == @book
|
116
|
+
@book.Readonly.should be false
|
117
|
+
book2.Readonly.should be true
|
118
|
+
book2.close
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
context "with :if_unsaved" do
|
124
|
+
|
125
|
+
before do
|
126
|
+
@book = Workbook.open(@simple_file_xlsx1)
|
127
|
+
@sheet = @book.sheet(1)
|
128
|
+
@book.add_sheet(@sheet, :as => 'a_name')
|
129
|
+
@book.visible = true
|
130
|
+
end
|
131
|
+
|
132
|
+
after do
|
133
|
+
@book.close(:if_unsaved => :forget)
|
134
|
+
@new_book.close rescue nil
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should let the book open, if :if_unsaved is :accept" do
|
138
|
+
expect {
|
139
|
+
@new_book = Workbook.open(@simple_file_xlsx1, :if_unsaved => :accept)
|
140
|
+
}.to_not raise_error
|
141
|
+
@book.should be_alive
|
142
|
+
@new_book.should be_alive
|
143
|
+
@new_book.should == @book
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "basic tests with xlsm-workbooks" do
|
151
|
+
|
152
|
+
context "with simple file" do
|
153
|
+
|
154
|
+
it "should simply create a new workbook given a file" do
|
155
|
+
book = Workbook.new(@simple_file_xlsm1)
|
156
|
+
book.should be_alive
|
157
|
+
book.should be_a Workbook
|
158
|
+
book.filename.should == @simple_file_xlsm1
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
context "with transparency identity" do
|
164
|
+
|
165
|
+
before do
|
166
|
+
@book = Workbook.open(@simple_file_xlsm1)
|
167
|
+
end
|
168
|
+
|
169
|
+
after do
|
170
|
+
@book.close
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should yield identical Workbook objects referring to identical WIN32OLE objects" do
|
174
|
+
book2 = Workbook.new(@book.ole_workbook)
|
175
|
+
book2.equal?(@book).should be true
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
context "connecting to one unknown workbook" do
|
181
|
+
|
182
|
+
before do
|
183
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
184
|
+
ws = ole_e1.Workbooks
|
185
|
+
abs_filename = General.absolute_path(@simple_file_xlsm1)
|
186
|
+
@ole_wb = ws.Open(abs_filename)
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should connect to an unknown workbook" do
|
190
|
+
Workbook.open(@simple_file_xlsm1) do |book|
|
191
|
+
book.filename.should == @simple_file_xlsm1
|
192
|
+
book.should be_alive
|
193
|
+
book.should be_a Workbook
|
194
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
195
|
+
Excel.excels_number.should == 1
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context "with :force => excel" do
|
201
|
+
|
202
|
+
before do
|
203
|
+
@book = Workbook.open(@simple_file_xlsm1)
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should open in a new Excel" do
|
207
|
+
book2 = Workbook.open(@simple_file_xlsm1, :force => {:excel => :new})
|
208
|
+
book2.should be_alive
|
209
|
+
book2.should be_a Workbook
|
210
|
+
book2.excel.should_not == @book.excel
|
211
|
+
book2.should_not == @book
|
212
|
+
@book.Readonly.should be false
|
213
|
+
book2.Readonly.should be true
|
214
|
+
book2.close
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
context "with :if_unsaved" do
|
220
|
+
|
221
|
+
before do
|
222
|
+
@book = Workbook.open(@simple_file_xlsm1)
|
223
|
+
@sheet = @book.sheet(1)
|
224
|
+
@book.add_sheet(@sheet, :as => 'a_name')
|
225
|
+
@book.visible = true
|
226
|
+
end
|
227
|
+
|
228
|
+
after do
|
229
|
+
@book.close(:if_unsaved => :forget)
|
230
|
+
@new_book.close rescue nil
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should let the book open, if :if_unsaved is :accept" do
|
234
|
+
expect {
|
235
|
+
@new_book = Workbook.open(@simple_file_xlsm1, :if_unsaved => :accept)
|
236
|
+
}.to_not raise_error
|
237
|
+
@book.should be_alive
|
238
|
+
@new_book.should be_alive
|
239
|
+
@new_book.should == @book
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
245
|
+
|
46
246
|
describe "open and new" do
|
47
247
|
|
48
248
|
context "with standard" do
|
@@ -67,8 +267,340 @@ describe Workbook do
|
|
67
267
|
|
68
268
|
end
|
69
269
|
|
270
|
+
describe "fetching workbooks with network and hostname share paths" do
|
271
|
+
|
272
|
+
before do
|
273
|
+
bookstore = Bookstore.new
|
274
|
+
end
|
275
|
+
|
276
|
+
it "should fetch a network path file given a hostname share file" do
|
277
|
+
book1 = Workbook.open(@simple_file_hostname_share_path)
|
278
|
+
book2 = Workbook.open(@simple_file_network_path)
|
279
|
+
book2.should === book1
|
280
|
+
book2.Fullname.should == book1.Fullname
|
281
|
+
book1.excel.Workbooks.Count.should == 1
|
282
|
+
end
|
283
|
+
|
284
|
+
it "should fetch a hostname share file given a network path file" do
|
285
|
+
book1 = Workbook.open(@simple_file_network_path)
|
286
|
+
book2 = Workbook.open(@simple_file_hostname_share_path)
|
287
|
+
book2.should === book1
|
288
|
+
book2.Fullname.should == book1.Fullname
|
289
|
+
book1.excel.Workbooks.Count.should == 1
|
290
|
+
end
|
291
|
+
|
292
|
+
it "should raise WorkbookBlocked" do
|
293
|
+
book1 = Workbook.open(@simple_file_hostname_share_path)
|
294
|
+
expect{
|
295
|
+
book2 = Workbook.open(@simple_file)
|
296
|
+
}.to raise_error(WorkbookBlocked)
|
297
|
+
end
|
298
|
+
|
299
|
+
it "should raise an error fetching an hostname share file having opened a local path file" do
|
300
|
+
book1 = Workbook.open(@simple_file)
|
301
|
+
expect{
|
302
|
+
Workbook.open(@simple_file_hostname_share_path)
|
303
|
+
}.to raise_error(WorkbookBlocked)
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should raise an error fetching a local path file having opened a network path file" do
|
307
|
+
book1 = Workbook.open(@simple_file_network_path)
|
308
|
+
expect{
|
309
|
+
Workbook.open(@simple_file)
|
310
|
+
}.to raise_error(WorkbookBlocked)
|
311
|
+
end
|
312
|
+
|
313
|
+
it "should raise an error fetching a network path file having opened a local path file" do
|
314
|
+
book1 = Workbook.open(@simple_file)
|
315
|
+
expect{
|
316
|
+
Workbook.open(@simple_file_network_path)
|
317
|
+
}.to raise_error(WorkbookBlocked)
|
318
|
+
end
|
319
|
+
|
320
|
+
it "should raise an error fetching a local path file having opened a hostname share path file" do
|
321
|
+
book1 = Workbook.open(@simple_file_hostname_share_path)
|
322
|
+
expect{
|
323
|
+
Workbook.open(@simple_file)
|
324
|
+
}.to raise_error(WorkbookBlocked)
|
325
|
+
end
|
326
|
+
|
327
|
+
it "should raise an WorkbookBlockederror" do
|
328
|
+
book1 = Workbook.open(@simple_file_network_path1)
|
329
|
+
expect{
|
330
|
+
Workbook.open(@simple_file_network_path_other_path1)
|
331
|
+
}.to raise_error(WorkbookBlocked)
|
332
|
+
end
|
333
|
+
|
334
|
+
it "should raise an WorkbookBlockederror" do
|
335
|
+
book1 = Workbook.open(@simple_file_network_path_other_path1)
|
336
|
+
expect{
|
337
|
+
Workbook.open(@simple_file_network_path1)
|
338
|
+
}.to raise_error(WorkbookBlocked)
|
339
|
+
end
|
340
|
+
|
341
|
+
it "should raise an WorkbookBlockederror" do
|
342
|
+
book1 = Workbook.open(@simple_file_hostname_share_path1)
|
343
|
+
expect{
|
344
|
+
Workbook.open(@simple_file_hostname_share_path_other_path1)
|
345
|
+
}.to raise_error(WorkbookBlocked)
|
346
|
+
end
|
347
|
+
|
348
|
+
it "should raise an WorkbookBlockederror" do
|
349
|
+
book1 = Workbook.open(@simple_file_hostname_share_path_other_path1)
|
350
|
+
expect{
|
351
|
+
Workbook.open(@simple_file_hostname_share_path1)
|
352
|
+
}.to raise_error(WorkbookBlocked)
|
353
|
+
end
|
354
|
+
|
355
|
+
it "should raise an WorkbookBlockederror" do
|
356
|
+
book1 = Workbook.open(@simple_file_hostname_share_path1)
|
357
|
+
expect{
|
358
|
+
Workbook.open(@simple_file_network_path_other_path1)
|
359
|
+
}.to raise_error(WorkbookBlocked)
|
360
|
+
end
|
361
|
+
|
362
|
+
it "should raise an WorkbookBlockederror" do
|
363
|
+
book1 = Workbook.open(@simple_file_hostname_share_path_other_path1)
|
364
|
+
expect{
|
365
|
+
Workbook.open(@simple_file_network_path1)
|
366
|
+
}.to raise_error(WorkbookBlocked)
|
367
|
+
end
|
368
|
+
|
369
|
+
it "should raise an WorkbookBlockederror" do
|
370
|
+
book1 = Workbook.open(@simple_file_network_path1)
|
371
|
+
expect{
|
372
|
+
Workbook.open(@simple_file_hostname_share_path_other_path1)
|
373
|
+
}.to raise_error(WorkbookBlocked)
|
374
|
+
end
|
375
|
+
|
376
|
+
it "should raise an WorkbookBlockederror" do
|
377
|
+
book1 = Workbook.open(@simple_file_network_path_other_path1)
|
378
|
+
expect{
|
379
|
+
Workbook.open(@simple_file_hostname_share_path1)
|
380
|
+
}.to raise_error(WorkbookBlocked)
|
381
|
+
end
|
382
|
+
|
383
|
+
end
|
384
|
+
|
385
|
+
|
70
386
|
describe "connecting to unknown workbooks" do
|
71
387
|
|
388
|
+
context "with one unknown network path or hostname share file" do
|
389
|
+
|
390
|
+
it "should connect to a network path workbook from a network path file" do
|
391
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
392
|
+
ws = ole_e1.Workbooks
|
393
|
+
abs_filename = General.absolute_path(@simple_file_network_path1)
|
394
|
+
@ole_wb = ws.Open(abs_filename)
|
395
|
+
Workbook.open(@simple_file_network_path1) do |book|
|
396
|
+
book.should be_alive
|
397
|
+
book.should be_a Workbook
|
398
|
+
book.filename.should == @simple_file_network_path1
|
399
|
+
book.Fullname.should == @ole_wb.Fullname
|
400
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
401
|
+
Excel.excels_number.should == 1
|
402
|
+
book.excel.Workbooks.Count.should == 1
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
it "should connect to a hostname share workbook from a network path file" do
|
407
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
408
|
+
ws = ole_e1.Workbooks
|
409
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
|
410
|
+
@ole_wb = ws.Open(abs_filename)
|
411
|
+
Workbook.open(@simple_file_network_path1) do |book|
|
412
|
+
book.should be_alive
|
413
|
+
book.should be_a Workbook
|
414
|
+
book.filename.should == @simple_file_hostname_share_path1.downcase
|
415
|
+
book.Fullname.should == @ole_wb.Fullname
|
416
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
417
|
+
Excel.excels_number.should == 1
|
418
|
+
book.excel.Workbooks.Count.should == 1
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
422
|
+
it "should raise WorkbookBlocked trying to connect to a local path file from a network path file" do
|
423
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
424
|
+
ws = ole_e1.Workbooks
|
425
|
+
abs_filename = General.absolute_path(@simple_file1)
|
426
|
+
@ole_wb = ws.Open(abs_filename)
|
427
|
+
expect{
|
428
|
+
Workbook.open(@simple_file_network_path1)
|
429
|
+
}.to raise_error(WorkbookBlocked)
|
430
|
+
end
|
431
|
+
|
432
|
+
it "should raise WorkbookBlocked trying to connect to a network path file from a local path file" do
|
433
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
434
|
+
ws = ole_e1.Workbooks
|
435
|
+
abs_filename = General.absolute_path(@simple_file_network_path1)
|
436
|
+
@ole_wb = ws.Open(abs_filename)
|
437
|
+
expect{
|
438
|
+
Workbook.open(@simple_file1)
|
439
|
+
}.to raise_error(WorkbookBlocked)
|
440
|
+
end
|
441
|
+
|
442
|
+
it "should raise WorkbookBlocked trying to connect a hostname share file from a local path file" do
|
443
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
444
|
+
ws = ole_e1.Workbooks
|
445
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
|
446
|
+
@ole_wb = ws.Open(abs_filename)
|
447
|
+
expect{
|
448
|
+
Workbook.open(@simple_file1)
|
449
|
+
}.to raise_error(WorkbookBlocked)
|
450
|
+
end
|
451
|
+
|
452
|
+
it "should raise WorkbookBlocked trying to connect to a local path workbook from a hostname share file" do
|
453
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
454
|
+
ws = ole_e1.Workbooks
|
455
|
+
abs_filename = General.absolute_path(@simple_file1)
|
456
|
+
@ole_wb = ws.Open(abs_filename)
|
457
|
+
expect{
|
458
|
+
Workbook.open(@simple_file_hostname_share_path1)
|
459
|
+
}.to raise_error(WorkbookBlocked)
|
460
|
+
end
|
461
|
+
|
462
|
+
it "should connect to a network path workbook from a hostname share file" do
|
463
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
464
|
+
ws = ole_e1.Workbooks
|
465
|
+
abs_filename = General.absolute_path(@simple_file_network_path1)
|
466
|
+
@ole_wb = ws.Open(abs_filename)
|
467
|
+
Workbook.open(@simple_file_hostname_share_path1) do |book|
|
468
|
+
book.should be_alive
|
469
|
+
book.should be_a Workbook
|
470
|
+
book.filename.should == @simple_file_network_path1
|
471
|
+
book.Fullname.should == @ole_wb.Fullname
|
472
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
473
|
+
Excel.excels_number.should == 1
|
474
|
+
book.excel.Workbooks.Count.should == 1
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
it "should connect to a hostname share workbook from a hostname share file" do
|
479
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
480
|
+
ws = ole_e1.Workbooks
|
481
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
|
482
|
+
@ole_wb = ws.Open(abs_filename)
|
483
|
+
Workbook.open(@simple_file_hostname_share_path1) do |book|
|
484
|
+
book.should be_alive
|
485
|
+
book.should be_a Workbook
|
486
|
+
book.filename.should == @simple_file_hostname_share_path1.downcase
|
487
|
+
book.Fullname.should == @ole_wb.Fullname
|
488
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
489
|
+
Excel.excels_number.should == 1
|
490
|
+
book.excel.Workbooks.Count.should == 1
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
it "should raise WorkbookBlocked error" do
|
495
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
496
|
+
ws = ole_e1.Workbooks
|
497
|
+
abs_filename = General.absolute_path(@simple_file_network_path1)
|
498
|
+
@ole_wb = ws.Open(abs_filename)
|
499
|
+
expect{
|
500
|
+
Workbook.open(@simple_file_network_path_other_path1)
|
501
|
+
}.to raise_error(WorkbookBlocked)
|
502
|
+
end
|
503
|
+
|
504
|
+
it "should raise WorkbookBlocked error" do
|
505
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
506
|
+
ws = ole_e1.Workbooks
|
507
|
+
abs_filename = General.absolute_path(@simple_file_network_path_other_path1)
|
508
|
+
@ole_wb = ws.Open(abs_filename)
|
509
|
+
expect{
|
510
|
+
Workbook.open(@simple_file_network_path1)
|
511
|
+
}.to raise_error(WorkbookBlocked)
|
512
|
+
end
|
513
|
+
|
514
|
+
it "should raise WorkbookBlocked error" do
|
515
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
516
|
+
ws = ole_e1.Workbooks
|
517
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
|
518
|
+
@ole_wb = ws.Open(abs_filename)
|
519
|
+
expect{
|
520
|
+
Workbook.open(@simple_file_hostname_share_path_other_path1)
|
521
|
+
}.to raise_error(WorkbookBlocked)
|
522
|
+
end
|
523
|
+
|
524
|
+
it "should raise WorkbookBlocked error" do
|
525
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
526
|
+
ws = ole_e1.Workbooks
|
527
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path_other_path1)
|
528
|
+
@ole_wb = ws.Open(abs_filename)
|
529
|
+
expect{
|
530
|
+
Workbook.open(@simple_file_hostname_share_path1)
|
531
|
+
}.to raise_error(WorkbookBlocked)
|
532
|
+
end
|
533
|
+
|
534
|
+
it "should raise WorkbookBlocked error" do
|
535
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
536
|
+
ws = ole_e1.Workbooks
|
537
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
|
538
|
+
@ole_wb = ws.Open(abs_filename)
|
539
|
+
expect{
|
540
|
+
Workbook.open(@simple_file_network_path_other_path1)
|
541
|
+
}.to raise_error(WorkbookBlocked)
|
542
|
+
end
|
543
|
+
|
544
|
+
it "should raise WorkbookBlocked error" do
|
545
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
546
|
+
ws = ole_e1.Workbooks
|
547
|
+
abs_filename = General.absolute_path(@simple_file_network_path_other_path1)
|
548
|
+
@ole_wb = ws.Open(abs_filename)
|
549
|
+
expect{
|
550
|
+
Workbook.open(@simple_file_hostname_share_path1)
|
551
|
+
}.to raise_error(WorkbookBlocked)
|
552
|
+
end
|
553
|
+
|
554
|
+
it "should raise WorkbookBlocked error" do
|
555
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
556
|
+
ws = ole_e1.Workbooks
|
557
|
+
abs_filename = General.absolute_path(@simple_file_network_path1)
|
558
|
+
@ole_wb = ws.Open(abs_filename)
|
559
|
+
expect{
|
560
|
+
Workbook.open(@simple_file_hostname_share_path_other_path1)
|
561
|
+
}.to raise_error(WorkbookBlocked)
|
562
|
+
end
|
563
|
+
|
564
|
+
it "should raise WorkbookBlocked error" do
|
565
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
566
|
+
ws = ole_e1.Workbooks
|
567
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path_other_path1)
|
568
|
+
@ole_wb = ws.Open(abs_filename)
|
569
|
+
expect{
|
570
|
+
Workbook.open(@simple_file_network_path1)
|
571
|
+
}.to raise_error(WorkbookBlocked)
|
572
|
+
end
|
573
|
+
|
574
|
+
end
|
575
|
+
|
576
|
+
context "with one unknown hostname share path file" do
|
577
|
+
|
578
|
+
before do
|
579
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
580
|
+
ws = ole_e1.Workbooks
|
581
|
+
abs_filename = General.absolute_path( @simple_file_hostname_share_path1)
|
582
|
+
@ole_wb = ws.Open(abs_filename)
|
583
|
+
end
|
584
|
+
|
585
|
+
it "should connect to an unknown hostname share path workbook" do
|
586
|
+
Workbook.open(@simple_file_hostname_share_path1) do |book|
|
587
|
+
book.filename.should == @simple_file_hostname_share_path1.downcase
|
588
|
+
book.should be_alive
|
589
|
+
book.should be_a Workbook
|
590
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
591
|
+
Excel.excels_number.should == 1
|
592
|
+
book.excel.Workbooks.Count.should == 1
|
593
|
+
end
|
594
|
+
end
|
595
|
+
|
596
|
+
it "should raise error because blocking" do
|
597
|
+
expect{
|
598
|
+
Workbook.open(@simple_file1)
|
599
|
+
}.to raise_error(WorkbookBlocked)
|
600
|
+
end
|
601
|
+
|
602
|
+
end
|
603
|
+
|
72
604
|
context "with none workbook" do
|
73
605
|
|
74
606
|
it "should open one new Excel with the worbook" do
|
@@ -78,7 +610,7 @@ describe Workbook do
|
|
78
610
|
Excel.excels_number.should == 1
|
79
611
|
book1.ReadOnly.should be false
|
80
612
|
book1.excel.Visible.should be false
|
81
|
-
book1.CheckCompatibility.should be
|
613
|
+
book1.CheckCompatibility.should be true
|
82
614
|
book1.Saved.should be true
|
83
615
|
end
|
84
616
|
|
@@ -380,7 +912,7 @@ describe Workbook do
|
|
380
912
|
excel1.close
|
381
913
|
expect{
|
382
914
|
book1 = Workbook.open(@simple_file1, :force => {:excel => excel1})
|
383
|
-
}.to raise_error(ExcelREOError, "
|
915
|
+
}.to raise_error(ExcelREOError, "Excel is not alive")
|
384
916
|
end
|
385
917
|
|
386
918
|
it "should open in a provided Excel" do
|
@@ -402,18 +934,7 @@ describe Workbook do
|
|
402
934
|
end
|
403
935
|
|
404
936
|
end
|
405
|
-
|
406
|
-
describe "network paths" do
|
407
|
-
|
408
|
-
it "should open the workbook via network path" do
|
409
|
-
book1 = Workbook.open(@simple_file_hostname_share_path)
|
410
|
-
book2 = Workbook.open(@simple_file_network_path)
|
411
|
-
book1.should === book2
|
412
|
-
book1.Fullname.should == book2.Fullname
|
413
|
-
end
|
414
|
-
|
415
|
-
end
|
416
|
-
|
937
|
+
|
417
938
|
describe "new" do
|
418
939
|
|
419
940
|
context "with transparency identity" do
|
@@ -510,7 +1031,26 @@ describe Workbook do
|
|
510
1031
|
book2.excel.should_not == book.excel
|
511
1032
|
end
|
512
1033
|
|
513
|
-
it "should type-lift an
|
1034
|
+
it "should type-lift an workbook" do
|
1035
|
+
book = Workbook.open(@simple_file)
|
1036
|
+
new_book = Workbook.new(book)
|
1037
|
+
new_book.should == book
|
1038
|
+
new_book.equal?(book).should be true
|
1039
|
+
new_book.Fullname.should == book.Fullname
|
1040
|
+
new_book.excel.should == book.excel
|
1041
|
+
end
|
1042
|
+
|
1043
|
+
it "should type-lift an workbook and supply option" do
|
1044
|
+
book = Workbook.open(@simple_file)
|
1045
|
+
new_book = Workbook.new(book, :visible => true)
|
1046
|
+
new_book.should == book
|
1047
|
+
new_book.equal?(book).should be true
|
1048
|
+
new_book.Fullname.should == book.Fullname
|
1049
|
+
new_book.excel.should == book.excel
|
1050
|
+
new_book.visible.should be true
|
1051
|
+
end
|
1052
|
+
|
1053
|
+
it "should type-lift an open known win32ole workbook" do
|
514
1054
|
book = Workbook.open(@simple_file)
|
515
1055
|
ole_workbook = book.ole_workbook
|
516
1056
|
new_book = Workbook.new(ole_workbook)
|
@@ -520,7 +1060,7 @@ describe Workbook do
|
|
520
1060
|
new_book.excel.should == book.excel
|
521
1061
|
end
|
522
1062
|
|
523
|
-
it "should type-lift an open known workbook and let it be visible" do
|
1063
|
+
it "should type-lift an open known win32ole workbook and let it be visible" do
|
524
1064
|
book = Workbook.open(@simple_file, :visible => true)
|
525
1065
|
ole_workbook = book.ole_workbook
|
526
1066
|
new_book = Workbook.new(ole_workbook)
|
@@ -532,7 +1072,7 @@ describe Workbook do
|
|
532
1072
|
new_book.Windows(new_book.ole_workbook.Name).Visible.should == true
|
533
1073
|
end
|
534
1074
|
|
535
|
-
it "should type-lift an open known workbook and let it be visible and readonly" do
|
1075
|
+
it "should type-lift an open known win32ole workbook and let it be visible and readonly" do
|
536
1076
|
book = Workbook.open(@simple_file, :visible => true, :read_only => true)
|
537
1077
|
ole_workbook = book.ole_workbook
|
538
1078
|
new_book = Workbook.new(ole_workbook)
|
@@ -545,7 +1085,7 @@ describe Workbook do
|
|
545
1085
|
new_book.ReadOnly.should == true
|
546
1086
|
end
|
547
1087
|
|
548
|
-
it "should type-lift an open known workbook and make it visible" do
|
1088
|
+
it "should type-lift an open known win32ole workbook and make it visible" do
|
549
1089
|
book = Workbook.open(@simple_file)
|
550
1090
|
ole_workbook = book.ole_workbook
|
551
1091
|
new_book = Workbook.new(ole_workbook, :visible => true)
|
@@ -557,7 +1097,7 @@ describe Workbook do
|
|
557
1097
|
new_book.Windows(new_book.ole_workbook.Name).Visible.should == true
|
558
1098
|
end
|
559
1099
|
|
560
|
-
it "should type-lift an open unknown workbook" do
|
1100
|
+
it "should type-lift an open unknown win32ole workbook" do
|
561
1101
|
ole_excel = WIN32OLE.new('Excel.Application')
|
562
1102
|
ws = ole_excel.Workbooks
|
563
1103
|
abs_filename = General.absolute_path(@simple_file1)
|
@@ -567,7 +1107,7 @@ describe Workbook do
|
|
567
1107
|
new_book.excel.Hwnd.should == ole_excel.Hwnd
|
568
1108
|
end
|
569
1109
|
|
570
|
-
it "should type-lift an open unknown workbook and make it visible" do
|
1110
|
+
it "should type-lift an open unknown win32ole workbook and make it visible" do
|
571
1111
|
ole_excel = WIN32OLE.new('Excel.Application')
|
572
1112
|
ws = ole_excel.Workbooks
|
573
1113
|
abs_filename = General.absolute_path(@simple_file1)
|
@@ -579,7 +1119,7 @@ describe Workbook do
|
|
579
1119
|
new_book.Windows(new_book.ole_workbook.Name).Visible.should == true
|
580
1120
|
end
|
581
1121
|
|
582
|
-
it "should type-lift an open unknown workbook and make it visible and readonly" do
|
1122
|
+
it "should type-lift an open unknown win32ole workbook and make it visible and readonly" do
|
583
1123
|
ole_excel = WIN32OLE.new('Excel.Application')
|
584
1124
|
ws = ole_excel.Workbooks
|
585
1125
|
abs_filename = General.absolute_path(@simple_file1)
|
@@ -612,20 +1152,20 @@ describe Workbook do
|
|
612
1152
|
|
613
1153
|
it "should not set the default value" do
|
614
1154
|
book1 = Workbook.open(@simple_file)
|
615
|
-
book1.excel.calculation.should == nil
|
1155
|
+
book1.excel.properties[:calculation].should == nil
|
616
1156
|
end
|
617
1157
|
|
618
1158
|
it "should set the calculation mode to automatic" do
|
619
1159
|
book1 = Workbook.open(@simple_file)
|
620
1160
|
book1.excel.calculation = :automatic
|
621
|
-
book1.excel.calculation.should == :automatic
|
1161
|
+
book1.excel.properties[:calculation].should == :automatic
|
622
1162
|
book1.excel.Calculation.should == XlCalculationAutomatic
|
623
1163
|
end
|
624
1164
|
|
625
1165
|
it "should set the calculation mode to manual" do
|
626
1166
|
book1 = Workbook.open(@simple_file)
|
627
1167
|
book1.excel.calculation = :manual
|
628
|
-
book1.excel.calculation.should == :manual
|
1168
|
+
book1.excel.properties[:calculation].should == :manual
|
629
1169
|
book1.excel.Calculation.should == XlCalculationManual
|
630
1170
|
end
|
631
1171
|
|
@@ -1040,7 +1580,7 @@ describe Workbook do
|
|
1040
1580
|
it "should raise an error if no Excel or Workbook is given" do
|
1041
1581
|
expect{
|
1042
1582
|
Workbook.open(@simple_file1, :force => {:excel => :b})
|
1043
|
-
}.to raise_error(TypeREOError,
|
1583
|
+
}.to raise_error(TypeREOError, @error_message_excel)
|
1044
1584
|
end
|
1045
1585
|
|
1046
1586
|
it "should do force_excel even if both force_ and default_excel is given" do
|
@@ -1196,7 +1736,7 @@ describe Workbook do
|
|
1196
1736
|
it "should raise an error if no Excel or Workbook is given" do
|
1197
1737
|
expect{
|
1198
1738
|
Workbook.open(@simple_file1, :excel => :b)
|
1199
|
-
}.to raise_error(TypeREOError,
|
1739
|
+
}.to raise_error(TypeREOError, @error_message_excel)
|
1200
1740
|
end
|
1201
1741
|
|
1202
1742
|
it "should do force_excel even if both force_ and default_excel is given" do
|
@@ -1354,7 +1894,7 @@ describe Workbook do
|
|
1354
1894
|
it "should raise an error if no Excel or Workbook is given" do
|
1355
1895
|
expect{
|
1356
1896
|
Workbook.open(@simple_file1, :force_excel => :b)
|
1357
|
-
}.to raise_error(TypeREOError,
|
1897
|
+
}.to raise_error(TypeREOError, @error_message_excel)
|
1358
1898
|
end
|
1359
1899
|
|
1360
1900
|
it "should do force_excel even if both force_ and default_excel is given" do
|
@@ -1595,7 +2135,7 @@ describe Workbook do
|
|
1595
2135
|
it "should raise an error if no Excel or Workbook is given" do
|
1596
2136
|
expect{
|
1597
2137
|
Workbook.open(@different_file, :default => {:excel => :a})
|
1598
|
-
}.to raise_error(TypeREOError,
|
2138
|
+
}.to raise_error(TypeREOError, @error_message_excel)
|
1599
2139
|
end
|
1600
2140
|
|
1601
2141
|
end
|
@@ -1777,7 +2317,7 @@ describe Workbook do
|
|
1777
2317
|
it "should raise an error if no Excel or Workbook is given" do
|
1778
2318
|
expect{
|
1779
2319
|
Workbook.open(@different_file, :default_excel => :a)
|
1780
|
-
}.to raise_error(TypeREOError,
|
2320
|
+
}.to raise_error(TypeREOError, @error_message_excel)
|
1781
2321
|
end
|
1782
2322
|
|
1783
2323
|
end
|