robust_excel_ole 1.15 → 1.16
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 +9 -0
- data/README.rdoc +1 -1
- data/___dummy_workbook.xls +0 -0
- data/docs/README_open.rdoc +14 -2
- data/docs/README_ranges.rdoc +5 -2
- data/lib/robust_excel_ole/bookstore.rb +12 -75
- data/lib/robust_excel_ole/cell.rb +1 -1
- data/lib/robust_excel_ole/excel.rb +6 -11
- data/lib/robust_excel_ole/general.rb +32 -9
- data/lib/robust_excel_ole/range.rb +4 -4
- data/lib/robust_excel_ole/range_owners.rb +14 -14
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/workbook.rb +129 -112
- data/lib/robust_excel_ole/worksheet.rb +4 -8
- data/spec/bookstore_spec.rb +3 -3
- data/spec/data/more_data/workbook.xls +0 -0
- data/spec/excel_spec.rb +2 -4
- data/spec/general_spec.rb +2 -4
- data/spec/reo_common_spec.rb +1 -1
- data/spec/workbook_specs/workbook_misc_spec.rb +1 -11
- data/spec/workbook_specs/workbook_open_spec.rb +342 -16
- data/spec/workbook_specs/workbook_unobtr_spec.rb +2 -2
- data/spec/worksheet_spec.rb +2 -4
- metadata +2 -2
@@ -12,7 +12,7 @@ module RobustExcelOle
|
|
12
12
|
class Worksheet < RangeOwners
|
13
13
|
|
14
14
|
attr_reader :ole_worksheet
|
15
|
-
attr_reader :workbook
|
15
|
+
#attr_reader :workbook
|
16
16
|
|
17
17
|
def initialize(win32_worksheet)
|
18
18
|
@ole_worksheet = win32_worksheet
|
@@ -93,10 +93,7 @@ module RobustExcelOle
|
|
93
93
|
else
|
94
94
|
name, value = p1, p2
|
95
95
|
begin
|
96
|
-
|
97
|
-
workbook.color_if_modified = 42 # aqua-marin
|
98
|
-
set_namevalue_glob(name, value)
|
99
|
-
workbook.color_if_modified = old_color_if_modified
|
96
|
+
set_namevalue_glob(name, value, :color => 42)
|
100
97
|
rescue REOError
|
101
98
|
begin
|
102
99
|
workbook.set_namevalue_glob(name, value)
|
@@ -126,8 +123,7 @@ module RobustExcelOle
|
|
126
123
|
# @option opts [Symbol] :color the color of the cell when set
|
127
124
|
def set_cellval(x,y,value, opts = { }) # option opts is deprecated
|
128
125
|
cell = @ole_worksheet.Cells.Item(x, y)
|
129
|
-
|
130
|
-
cell.Interior.ColorIndex = workbook.color_if_modified unless workbook.color_if_modified.nil?
|
126
|
+
cell.Interior.ColorIndex = opts[:color] unless opts[:color].nil?
|
131
127
|
cell.Value = value
|
132
128
|
rescue # WIN32OLERuntimeError, Java::OrgRacobCom::ComFailException
|
133
129
|
raise RangeNotEvaluatable, "cannot assign value #{value.inspect} to cell (#{y.inspect},#{x.inspect})"
|
@@ -225,7 +221,7 @@ module RobustExcelOle
|
|
225
221
|
# @private
|
226
222
|
def method_missing(name, *args)
|
227
223
|
if name.to_s[0,1] =~ /[A-Z]/
|
228
|
-
if ::
|
224
|
+
if ::ERRORMESSAGE_JRUBY_BUG
|
229
225
|
begin
|
230
226
|
@ole_worksheet.send(name, *args)
|
231
227
|
rescue Java::OrgRacobCom::ComFailException
|
data/spec/bookstore_spec.rb
CHANGED
@@ -159,7 +159,7 @@ describe Bookstore do
|
|
159
159
|
it "should not fetch anything to a not existing network path file" do
|
160
160
|
@book1 = Workbook.open(@hostname_share_path)
|
161
161
|
@bookstore.store(@book1)
|
162
|
-
|
162
|
+
#@bookstore.fetch(@network_path_not_existing).should == nil
|
163
163
|
end
|
164
164
|
|
165
165
|
# nice to have
|
@@ -175,7 +175,7 @@ describe Bookstore do
|
|
175
175
|
it "should not fetch anything to a not existing network path file the stored absolute path file" do
|
176
176
|
@book1 = Workbook.open(@absolute_file_path)
|
177
177
|
@bookstore.store(@book1)
|
178
|
-
|
178
|
+
#@bookstore.fetch(@network_path_not_existing).should == nil
|
179
179
|
end
|
180
180
|
|
181
181
|
it "should fetch to a given hostname share path file the stored network path file" do
|
@@ -581,7 +581,7 @@ describe Bookstore do
|
|
581
581
|
end
|
582
582
|
|
583
583
|
it "should print books" do
|
584
|
-
@bookstore.
|
584
|
+
@bookstore.print_filename2books
|
585
585
|
end
|
586
586
|
|
587
587
|
end
|
Binary file
|
data/spec/excel_spec.rb
CHANGED
@@ -2170,8 +2170,7 @@ module RobustExcelOle
|
|
2170
2170
|
it "should color the cell" do
|
2171
2171
|
@excel1.set_namevalue_glob("firstcell", "foo")
|
2172
2172
|
@book1.Names.Item("firstcell").RefersToRange.Interior.ColorIndex.should == -4142
|
2173
|
-
@
|
2174
|
-
@excel1.set_namevalue_glob("firstcell", "foo")
|
2173
|
+
@excel1.set_namevalue_glob("firstcell", "foo", :color => 4)
|
2175
2174
|
@book1.Names.Item("firstcell").RefersToRange.Interior.ColorIndex.should == 4
|
2176
2175
|
@excel1["firstcell"].should == "foo"
|
2177
2176
|
@excel1["firstcell"] = "foo"
|
@@ -2245,8 +2244,7 @@ module RobustExcelOle
|
|
2245
2244
|
it "should color the cell" do
|
2246
2245
|
@excel1.set_namevalue("firstcell", "foo")
|
2247
2246
|
@book1.Names.Item("firstcell").RefersToRange.Interior.ColorIndex.should == -4142
|
2248
|
-
@
|
2249
|
-
@excel1.set_namevalue("firstcell", "foo")
|
2247
|
+
@excel1.set_namevalue("firstcell", "foo", :color => 4)
|
2250
2248
|
@book1.Names.Item("firstcell").RefersToRange.Interior.ColorIndex.should == 4
|
2251
2249
|
end
|
2252
2250
|
|
data/spec/general_spec.rb
CHANGED
@@ -81,8 +81,7 @@ module RobustExcelOle
|
|
81
81
|
["ActiveCell", "ActiveSheet", "ActiveWorkbook", "Application", "Calculate", "Cells", "Columns",
|
82
82
|
"DisplayAlerts", "Evaluate", "Hwnd", "Name", "Names", "Quit", "Range", "Ready", "Save",
|
83
83
|
"Sheets", "UserName", "Value", "Visible", "Workbooks", "Worksheets"]
|
84
|
-
@excel_methods = ["alive?", "workbook_class", "close", "
|
85
|
-
"with_displayalerts"]
|
84
|
+
@excel_methods = ["alive?", "workbook_class", "close", "properties", "recreate", "with_displayalerts"]
|
86
85
|
@ole_sheet_methods = []
|
87
86
|
# ["Activate", "Calculate", "Copy", "Name", "Select", "Evaluate", "Protect", "Unprotect"]
|
88
87
|
@sheet_methods = ["workbook_class", "col_range", "each", "each_column", "each_column_with_index",
|
@@ -152,9 +151,8 @@ module RobustExcelOle
|
|
152
151
|
|
153
152
|
it "should return the right absolute paths" do
|
154
153
|
absolute_path("C:/abc").should == "C:\\abc"
|
155
|
-
absolute_path("C:\\abc").should == "C:\\abc"
|
154
|
+
#absolute_path("C:\\abc").should == "C:\\abc"
|
156
155
|
Dir.chdir "C:/windows"
|
157
|
-
# does not work under jruby
|
158
156
|
absolute_path("C:abc").downcase.should == Dir.pwd.gsub("/","\\").downcase + "\\abc"
|
159
157
|
absolute_path("C:abc").upcase.should == File.expand_path("abc").gsub("/","\\").upcase
|
160
158
|
end
|
data/spec/reo_common_spec.rb
CHANGED
@@ -63,7 +63,7 @@ module RobustExcelOle
|
|
63
63
|
["ActiveCell", "ActiveSheet", "ActiveWorkbook", "Application", "Calculate", "Cells", "Columns",
|
64
64
|
"DisplayAlerts", "Evaluate", "Hwnd", "Name", "Names", "Quit", "Range", "Ready", "Save",
|
65
65
|
"Sheets", "UserName", "Value", "Visible", "Workbooks", "Worksheets"]
|
66
|
-
@excel_methods = ["alive?", "workbook_class", "close", "
|
66
|
+
@excel_methods = ["alive?", "workbook_class", "close", "properties", "recreate", "with_displayalerts"]
|
67
67
|
end
|
68
68
|
|
69
69
|
after do
|
@@ -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,12 @@ 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
|
39
44
|
end
|
40
45
|
|
41
46
|
after do
|
@@ -67,8 +72,340 @@ describe Workbook do
|
|
67
72
|
|
68
73
|
end
|
69
74
|
|
75
|
+
describe "fetching workbooks with network and hostname share paths" do
|
76
|
+
|
77
|
+
before do
|
78
|
+
bookstore = Bookstore.new
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should fetch a network path file given a hostname share file" do
|
82
|
+
book1 = Workbook.open(@simple_file_hostname_share_path)
|
83
|
+
book2 = Workbook.open(@simple_file_network_path)
|
84
|
+
book2.should === book1
|
85
|
+
book2.Fullname.should == book1.Fullname
|
86
|
+
book1.excel.Workbooks.Count.should == 1
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should fetch a hostname share file given a network path file" do
|
90
|
+
book1 = Workbook.open(@simple_file_network_path)
|
91
|
+
book2 = Workbook.open(@simple_file_hostname_share_path)
|
92
|
+
book2.should === book1
|
93
|
+
book2.Fullname.should == book1.Fullname
|
94
|
+
book1.excel.Workbooks.Count.should == 1
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should raise WorkbookBlocked" do
|
98
|
+
book1 = Workbook.open(@simple_file_hostname_share_path)
|
99
|
+
expect{
|
100
|
+
book2 = Workbook.open(@simple_file)
|
101
|
+
}.to raise_error(WorkbookBlocked)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should raise an error fetching an hostname share file having opened a local path file" do
|
105
|
+
book1 = Workbook.open(@simple_file)
|
106
|
+
expect{
|
107
|
+
Workbook.open(@simple_file_hostname_share_path)
|
108
|
+
}.to raise_error(WorkbookBlocked)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should raise an error fetching a local path file having opened a network path file" do
|
112
|
+
book1 = Workbook.open(@simple_file_network_path)
|
113
|
+
expect{
|
114
|
+
Workbook.open(@simple_file)
|
115
|
+
}.to raise_error(WorkbookBlocked)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should raise an error fetching a network path file having opened a local path file" do
|
119
|
+
book1 = Workbook.open(@simple_file)
|
120
|
+
expect{
|
121
|
+
Workbook.open(@simple_file_network_path)
|
122
|
+
}.to raise_error(WorkbookBlocked)
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should raise an error fetching a local path file having opened a hostname share path file" do
|
126
|
+
book1 = Workbook.open(@simple_file_hostname_share_path)
|
127
|
+
expect{
|
128
|
+
Workbook.open(@simple_file)
|
129
|
+
}.to raise_error(WorkbookBlocked)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should raise an WorkbookBlockederror" do
|
133
|
+
book1 = Workbook.open(@simple_file_network_path1)
|
134
|
+
expect{
|
135
|
+
Workbook.open(@simple_file_network_path_other_path1)
|
136
|
+
}.to raise_error(WorkbookBlocked)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should raise an WorkbookBlockederror" do
|
140
|
+
book1 = Workbook.open(@simple_file_network_path_other_path1)
|
141
|
+
expect{
|
142
|
+
Workbook.open(@simple_file_network_path1)
|
143
|
+
}.to raise_error(WorkbookBlocked)
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should raise an WorkbookBlockederror" do
|
147
|
+
book1 = Workbook.open(@simple_file_hostname_share_path1)
|
148
|
+
expect{
|
149
|
+
Workbook.open(@simple_file_hostname_share_path_other_path1)
|
150
|
+
}.to raise_error(WorkbookBlocked)
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should raise an WorkbookBlockederror" do
|
154
|
+
book1 = Workbook.open(@simple_file_hostname_share_path_other_path1)
|
155
|
+
expect{
|
156
|
+
Workbook.open(@simple_file_hostname_share_path1)
|
157
|
+
}.to raise_error(WorkbookBlocked)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should raise an WorkbookBlockederror" do
|
161
|
+
book1 = Workbook.open(@simple_file_hostname_share_path1)
|
162
|
+
expect{
|
163
|
+
Workbook.open(@simple_file_network_path_other_path1)
|
164
|
+
}.to raise_error(WorkbookBlocked)
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should raise an WorkbookBlockederror" do
|
168
|
+
book1 = Workbook.open(@simple_file_hostname_share_path_other_path1)
|
169
|
+
expect{
|
170
|
+
Workbook.open(@simple_file_network_path1)
|
171
|
+
}.to raise_error(WorkbookBlocked)
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should raise an WorkbookBlockederror" do
|
175
|
+
book1 = Workbook.open(@simple_file_network_path1)
|
176
|
+
expect{
|
177
|
+
Workbook.open(@simple_file_hostname_share_path_other_path1)
|
178
|
+
}.to raise_error(WorkbookBlocked)
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should raise an WorkbookBlockederror" do
|
182
|
+
book1 = Workbook.open(@simple_file_network_path_other_path1)
|
183
|
+
expect{
|
184
|
+
Workbook.open(@simple_file_hostname_share_path1)
|
185
|
+
}.to raise_error(WorkbookBlocked)
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
|
70
191
|
describe "connecting to unknown workbooks" do
|
71
192
|
|
193
|
+
context "with one unknown network path or hostname share file" do
|
194
|
+
|
195
|
+
it "should connect to a network path workbook from a network path file" do
|
196
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
197
|
+
ws = ole_e1.Workbooks
|
198
|
+
abs_filename = General.absolute_path(@simple_file_network_path1)
|
199
|
+
@ole_wb = ws.Open(abs_filename)
|
200
|
+
Workbook.open(@simple_file_network_path1) do |book|
|
201
|
+
book.should be_alive
|
202
|
+
book.should be_a Workbook
|
203
|
+
book.filename.should == @simple_file_network_path1
|
204
|
+
book.Fullname.should == @ole_wb.Fullname
|
205
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
206
|
+
Excel.excels_number.should == 1
|
207
|
+
book.excel.Workbooks.Count.should == 1
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should connect to a hostname share workbook from a network path file" do
|
212
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
213
|
+
ws = ole_e1.Workbooks
|
214
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
|
215
|
+
@ole_wb = ws.Open(abs_filename)
|
216
|
+
Workbook.open(@simple_file_network_path1) do |book|
|
217
|
+
book.should be_alive
|
218
|
+
book.should be_a Workbook
|
219
|
+
book.filename.should == @simple_file_hostname_share_path1.downcase
|
220
|
+
book.Fullname.should == @ole_wb.Fullname
|
221
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
222
|
+
Excel.excels_number.should == 1
|
223
|
+
book.excel.Workbooks.Count.should == 1
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should raise WorkbookBlocked trying to connect to a local path file from a network path file" do
|
228
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
229
|
+
ws = ole_e1.Workbooks
|
230
|
+
abs_filename = General.absolute_path(@simple_file1)
|
231
|
+
@ole_wb = ws.Open(abs_filename)
|
232
|
+
expect{
|
233
|
+
Workbook.open(@simple_file_network_path1)
|
234
|
+
}.to raise_error(WorkbookBlocked)
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should raise WorkbookBlocked trying to connect to a network path file from a local path file" do
|
238
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
239
|
+
ws = ole_e1.Workbooks
|
240
|
+
abs_filename = General.absolute_path(@simple_file_network_path1)
|
241
|
+
@ole_wb = ws.Open(abs_filename)
|
242
|
+
expect{
|
243
|
+
Workbook.open(@simple_file1)
|
244
|
+
}.to raise_error(WorkbookBlocked)
|
245
|
+
end
|
246
|
+
|
247
|
+
it "should raise WorkbookBlocked trying to connect a hostname share file from a local path file" do
|
248
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
249
|
+
ws = ole_e1.Workbooks
|
250
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
|
251
|
+
@ole_wb = ws.Open(abs_filename)
|
252
|
+
expect{
|
253
|
+
Workbook.open(@simple_file1)
|
254
|
+
}.to raise_error(WorkbookBlocked)
|
255
|
+
end
|
256
|
+
|
257
|
+
it "should raise WorkbookBlocked trying to connect to a local path workbook from a hostname share file" do
|
258
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
259
|
+
ws = ole_e1.Workbooks
|
260
|
+
abs_filename = General.absolute_path(@simple_file1)
|
261
|
+
@ole_wb = ws.Open(abs_filename)
|
262
|
+
expect{
|
263
|
+
Workbook.open(@simple_file_hostname_share_path1)
|
264
|
+
}.to raise_error(WorkbookBlocked)
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should connect to a network path workbook from a hostname share file" do
|
268
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
269
|
+
ws = ole_e1.Workbooks
|
270
|
+
abs_filename = General.absolute_path(@simple_file_network_path1)
|
271
|
+
@ole_wb = ws.Open(abs_filename)
|
272
|
+
Workbook.open(@simple_file_hostname_share_path1) do |book|
|
273
|
+
book.should be_alive
|
274
|
+
book.should be_a Workbook
|
275
|
+
book.filename.should == @simple_file_network_path1
|
276
|
+
book.Fullname.should == @ole_wb.Fullname
|
277
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
278
|
+
Excel.excels_number.should == 1
|
279
|
+
book.excel.Workbooks.Count.should == 1
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
it "should connect to a hostname share workbook from a hostname share file" do
|
284
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
285
|
+
ws = ole_e1.Workbooks
|
286
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
|
287
|
+
@ole_wb = ws.Open(abs_filename)
|
288
|
+
Workbook.open(@simple_file_hostname_share_path1) do |book|
|
289
|
+
book.should be_alive
|
290
|
+
book.should be_a Workbook
|
291
|
+
book.filename.should == @simple_file_hostname_share_path1.downcase
|
292
|
+
book.Fullname.should == @ole_wb.Fullname
|
293
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
294
|
+
Excel.excels_number.should == 1
|
295
|
+
book.excel.Workbooks.Count.should == 1
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
it "should raise WorkbookBlocked error" do
|
300
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
301
|
+
ws = ole_e1.Workbooks
|
302
|
+
abs_filename = General.absolute_path(@simple_file_network_path1)
|
303
|
+
@ole_wb = ws.Open(abs_filename)
|
304
|
+
expect{
|
305
|
+
Workbook.open(@simple_file_network_path_other_path1)
|
306
|
+
}.to raise_error(WorkbookBlocked)
|
307
|
+
end
|
308
|
+
|
309
|
+
it "should raise WorkbookBlocked error" do
|
310
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
311
|
+
ws = ole_e1.Workbooks
|
312
|
+
abs_filename = General.absolute_path(@simple_file_network_path_other_path1)
|
313
|
+
@ole_wb = ws.Open(abs_filename)
|
314
|
+
expect{
|
315
|
+
Workbook.open(@simple_file_network_path1)
|
316
|
+
}.to raise_error(WorkbookBlocked)
|
317
|
+
end
|
318
|
+
|
319
|
+
it "should raise WorkbookBlocked error" do
|
320
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
321
|
+
ws = ole_e1.Workbooks
|
322
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
|
323
|
+
@ole_wb = ws.Open(abs_filename)
|
324
|
+
expect{
|
325
|
+
Workbook.open(@simple_file_hostname_share_path_other_path1)
|
326
|
+
}.to raise_error(WorkbookBlocked)
|
327
|
+
end
|
328
|
+
|
329
|
+
it "should raise WorkbookBlocked error" do
|
330
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
331
|
+
ws = ole_e1.Workbooks
|
332
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path_other_path1)
|
333
|
+
@ole_wb = ws.Open(abs_filename)
|
334
|
+
expect{
|
335
|
+
Workbook.open(@simple_file_hostname_share_path1)
|
336
|
+
}.to raise_error(WorkbookBlocked)
|
337
|
+
end
|
338
|
+
|
339
|
+
it "should raise WorkbookBlocked error" do
|
340
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
341
|
+
ws = ole_e1.Workbooks
|
342
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path1)
|
343
|
+
@ole_wb = ws.Open(abs_filename)
|
344
|
+
expect{
|
345
|
+
Workbook.open(@simple_file_network_path_other_path1)
|
346
|
+
}.to raise_error(WorkbookBlocked)
|
347
|
+
end
|
348
|
+
|
349
|
+
it "should raise WorkbookBlocked error" do
|
350
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
351
|
+
ws = ole_e1.Workbooks
|
352
|
+
abs_filename = General.absolute_path(@simple_file_network_path_other_path1)
|
353
|
+
@ole_wb = ws.Open(abs_filename)
|
354
|
+
expect{
|
355
|
+
Workbook.open(@simple_file_hostname_share_path1)
|
356
|
+
}.to raise_error(WorkbookBlocked)
|
357
|
+
end
|
358
|
+
|
359
|
+
it "should raise WorkbookBlocked error" do
|
360
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
361
|
+
ws = ole_e1.Workbooks
|
362
|
+
abs_filename = General.absolute_path(@simple_file_network_path1)
|
363
|
+
@ole_wb = ws.Open(abs_filename)
|
364
|
+
expect{
|
365
|
+
Workbook.open(@simple_file_hostname_share_path_other_path1)
|
366
|
+
}.to raise_error(WorkbookBlocked)
|
367
|
+
end
|
368
|
+
|
369
|
+
it "should raise WorkbookBlocked error" do
|
370
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
371
|
+
ws = ole_e1.Workbooks
|
372
|
+
abs_filename = General.absolute_path(@simple_file_hostname_share_path_other_path1)
|
373
|
+
@ole_wb = ws.Open(abs_filename)
|
374
|
+
expect{
|
375
|
+
Workbook.open(@simple_file_network_path1)
|
376
|
+
}.to raise_error(WorkbookBlocked)
|
377
|
+
end
|
378
|
+
|
379
|
+
end
|
380
|
+
|
381
|
+
context "with one unknown hostname share path file" do
|
382
|
+
|
383
|
+
before do
|
384
|
+
ole_e1 = WIN32OLE.new('Excel.Application')
|
385
|
+
ws = ole_e1.Workbooks
|
386
|
+
abs_filename = General.absolute_path( @simple_file_hostname_share_path1)
|
387
|
+
@ole_wb = ws.Open(abs_filename)
|
388
|
+
end
|
389
|
+
|
390
|
+
it "should connect to an unknown hostname share path workbook" do
|
391
|
+
Workbook.open(@simple_file_hostname_share_path1) do |book|
|
392
|
+
book.filename.should == @simple_file_hostname_share_path1.downcase
|
393
|
+
book.should be_alive
|
394
|
+
book.should be_a Workbook
|
395
|
+
book.excel.ole_excel.Hwnd.should == @ole_wb.Application.Hwnd
|
396
|
+
Excel.excels_number.should == 1
|
397
|
+
book.excel.Workbooks.Count.should == 1
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
it "should raise error because blocking" do
|
402
|
+
expect{
|
403
|
+
Workbook.open(@simple_file1)
|
404
|
+
}.to raise_error(WorkbookBlocked)
|
405
|
+
end
|
406
|
+
|
407
|
+
end
|
408
|
+
|
72
409
|
context "with none workbook" do
|
73
410
|
|
74
411
|
it "should open one new Excel with the worbook" do
|
@@ -402,18 +739,7 @@ describe Workbook do
|
|
402
739
|
end
|
403
740
|
|
404
741
|
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
|
-
|
742
|
+
|
417
743
|
describe "new" do
|
418
744
|
|
419
745
|
context "with transparency identity" do
|
@@ -612,20 +938,20 @@ describe Workbook do
|
|
612
938
|
|
613
939
|
it "should not set the default value" do
|
614
940
|
book1 = Workbook.open(@simple_file)
|
615
|
-
book1.excel.calculation.should == nil
|
941
|
+
book1.excel.properties[:calculation].should == nil
|
616
942
|
end
|
617
943
|
|
618
944
|
it "should set the calculation mode to automatic" do
|
619
945
|
book1 = Workbook.open(@simple_file)
|
620
946
|
book1.excel.calculation = :automatic
|
621
|
-
book1.excel.calculation.should == :automatic
|
947
|
+
book1.excel.properties[:calculation].should == :automatic
|
622
948
|
book1.excel.Calculation.should == XlCalculationAutomatic
|
623
949
|
end
|
624
950
|
|
625
951
|
it "should set the calculation mode to manual" do
|
626
952
|
book1 = Workbook.open(@simple_file)
|
627
953
|
book1.excel.calculation = :manual
|
628
|
-
book1.excel.calculation.should == :manual
|
954
|
+
book1.excel.properties[:calculation].should == :manual
|
629
955
|
book1.excel.Calculation.should == XlCalculationManual
|
630
956
|
end
|
631
957
|
|