robust_excel_ole 1.13 → 1.18
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 +47 -4
- data/README.rdoc +52 -47
- data/___dummy_workbook.xls +0 -0
- data/docs/README_excel.rdoc +9 -3
- data/docs/README_open.rdoc +86 -44
- data/docs/README_ranges.rdoc +90 -81
- data/docs/README_save_close.rdoc +9 -9
- data/docs/README_sheet.rdoc +17 -17
- data/examples/example_ruby_library.rb +27 -0
- data/extconf.rb +7 -0
- data/lib/robust_excel_ole.rb +7 -4
- data/lib/robust_excel_ole/{address.rb → address_tool.rb} +23 -22
- data/lib/robust_excel_ole/{reo_common.rb → base.rb} +3 -92
- 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 +138 -92
- data/lib/robust_excel_ole/general.rb +40 -15
- 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 +320 -319
- data/lib/robust_excel_ole/worksheet.rb +51 -25
- data/robust_excel_ole.gemspec +1 -0
- data/spec/address_tool_spec.rb +175 -0
- data/spec/{reo_common_spec.rb → base_spec.rb} +19 -34
- 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 +137 -369
- data/spec/general_spec.rb +21 -27
- data/spec/range_spec.rb +57 -3
- data/spec/workbook_spec.rb +11 -79
- data/spec/workbook_specs/workbook_misc_spec.rb +29 -40
- data/spec/workbook_specs/workbook_open_spec.rb +599 -31
- data/spec/workbook_specs/workbook_unobtr_spec.rb +760 -93
- data/spec/worksheet_spec.rb +36 -4
- metadata +12 -7
- data/spec/address_spec.rb +0 -174
@@ -12,6 +12,7 @@ module RobustExcelOle
|
|
12
12
|
class Worksheet < RangeOwners
|
13
13
|
|
14
14
|
attr_reader :ole_worksheet
|
15
|
+
attr_reader :workbook
|
15
16
|
|
16
17
|
def initialize(win32_worksheet)
|
17
18
|
@ole_worksheet = win32_worksheet
|
@@ -27,12 +28,18 @@ module RobustExcelOle
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def workbook
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
@workbook ||= begin
|
32
|
+
ole_workbook = self.Parent
|
33
|
+
saved_status = ole_workbook.Saved
|
34
|
+
ole_workbook.Saved = true unless saved_status
|
35
|
+
@workbook = workbook_class.new(ole_workbook)
|
36
|
+
ole_workbook.Saved = saved_status
|
37
|
+
@workbook
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def excel
|
42
|
+
workbook.excel
|
36
43
|
end
|
37
44
|
|
38
45
|
# sheet name
|
@@ -40,7 +47,7 @@ module RobustExcelOle
|
|
40
47
|
def name
|
41
48
|
@ole_worksheet.Name
|
42
49
|
rescue
|
43
|
-
raise WorksheetREOError, "name
|
50
|
+
raise WorksheetREOError, "name could not be determined"
|
44
51
|
end
|
45
52
|
|
46
53
|
# sets sheet name
|
@@ -64,7 +71,7 @@ module RobustExcelOle
|
|
64
71
|
xy = "#{x}_#{y}"
|
65
72
|
@cells = { }
|
66
73
|
begin
|
67
|
-
@cells[xy] = RobustExcelOle::Cell.new(@ole_worksheet.Cells.Item(x, y))
|
74
|
+
@cells[xy] = RobustExcelOle::Cell.new(@ole_worksheet.Cells.Item(x, y), @worksheet)
|
68
75
|
rescue
|
69
76
|
raise RangeNotEvaluatable, "cannot read cell (#{x.inspect},#{y.inspect})"
|
70
77
|
end
|
@@ -87,10 +94,7 @@ module RobustExcelOle
|
|
87
94
|
else
|
88
95
|
name, value = p1, p2
|
89
96
|
begin
|
90
|
-
|
91
|
-
workbook.color_if_modified = 42 # aqua-marin
|
92
|
-
set_namevalue_glob(name, value)
|
93
|
-
workbook.color_if_modified = old_color_if_modified
|
97
|
+
set_namevalue_glob(name, value, :color => 42)
|
94
98
|
rescue REOError
|
95
99
|
begin
|
96
100
|
workbook.set_namevalue_glob(name, value)
|
@@ -104,24 +108,34 @@ module RobustExcelOle
|
|
104
108
|
# value of a cell, if row and column are given
|
105
109
|
# @params row and column
|
106
110
|
# @returns value of the cell
|
111
|
+
def cellval(x,y)
|
112
|
+
xy = "#{x}_#{y}"
|
113
|
+
begin
|
114
|
+
@ole_worksheet.Cells.Item(x, y).Value
|
115
|
+
rescue
|
116
|
+
raise RangeNotEvaluatable, "cannot read cell (#{p1.inspect},#{p2.inspect})"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
=begin
|
107
121
|
def cellval(x,y)
|
108
122
|
xy = "#{x}_#{y}"
|
109
123
|
@cells = { }
|
110
124
|
begin
|
111
|
-
@cells[xy] = RobustExcelOle::Cell.new(@ole_worksheet.Cells.Item(x, y))
|
125
|
+
@cells[xy] = RobustExcelOle::Cell.new(@ole_worksheet.Cells.Item(x, y), @worksheet)
|
112
126
|
@cells[xy].Value
|
113
127
|
rescue
|
114
128
|
raise RangeNotEvaluatable, "cannot read cell (#{p1.inspect},#{p2.inspect})"
|
115
129
|
end
|
116
130
|
end
|
131
|
+
=end
|
117
132
|
|
118
133
|
# sets the value of a cell, if row, column and color of the cell are given
|
119
134
|
# @params [Integer] x,y row and column
|
120
135
|
# @option opts [Symbol] :color the color of the cell when set
|
121
136
|
def set_cellval(x,y,value, opts = { }) # option opts is deprecated
|
122
137
|
cell = @ole_worksheet.Cells.Item(x, y)
|
123
|
-
|
124
|
-
cell.Interior.ColorIndex = workbook.color_if_modified unless workbook.color_if_modified.nil?
|
138
|
+
cell.Interior.ColorIndex = opts[:color] unless opts[:color].nil?
|
125
139
|
cell.Value = value
|
126
140
|
rescue # WIN32OLERuntimeError, Java::OrgRacobCom::ComFailException
|
127
141
|
raise RangeNotEvaluatable, "cannot assign value #{value.inspect} to cell (#{y.inspect},#{x.inspect})"
|
@@ -145,17 +159,31 @@ module RobustExcelOle
|
|
145
159
|
end
|
146
160
|
end
|
147
161
|
|
162
|
+
def each_value
|
163
|
+
@ole_worksheet.UsedRange.Value.each do |row_values|
|
164
|
+
yield row_values
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def each_value_with_index(offset = 0)
|
169
|
+
i = offset
|
170
|
+
@ole_worksheet.UsedRange.Value.each do |row_values|
|
171
|
+
yield row_values, i
|
172
|
+
i += 1
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
148
176
|
def each_row(offset = 0)
|
149
177
|
offset += 1
|
150
178
|
1.upto(@end_row) do |row|
|
151
179
|
next if row < offset
|
152
|
-
yield RobustExcelOle::Range.new(@ole_worksheet.Range(@ole_worksheet.Cells(row, 1), @ole_worksheet.Cells(row, @end_column)))
|
180
|
+
yield RobustExcelOle::Range.new(@ole_worksheet.Range(@ole_worksheet.Cells(row, 1), @ole_worksheet.Cells(row, @end_column)), self)
|
153
181
|
end
|
154
182
|
end
|
155
183
|
|
156
184
|
def each_row_with_index(offset = 0)
|
157
185
|
each_row(offset) do |row_range|
|
158
|
-
yield RobustExcelOle::Range.new(row_range), (row_range.Row - 1 - offset)
|
186
|
+
yield RobustExcelOle::Range.new(row_range, self), (row_range.Row - 1 - offset)
|
159
187
|
end
|
160
188
|
end
|
161
189
|
|
@@ -163,24 +191,24 @@ module RobustExcelOle
|
|
163
191
|
offset += 1
|
164
192
|
1.upto(@end_column) do |column|
|
165
193
|
next if column < offset
|
166
|
-
yield RobustExcelOle::Range.new(@ole_worksheet.Range(@ole_worksheet.Cells(1, column), @ole_worksheet.Cells(@end_row, column)))
|
194
|
+
yield RobustExcelOle::Range.new(@ole_worksheet.Range(@ole_worksheet.Cells(1, column), @ole_worksheet.Cells(@end_row, column)), self)
|
167
195
|
end
|
168
196
|
end
|
169
197
|
|
170
198
|
def each_column_with_index(offset = 0)
|
171
199
|
each_column(offset) do |column_range|
|
172
|
-
yield RobustExcelOle::Range.new(column_range), (column_range.Column - 1 - offset)
|
200
|
+
yield RobustExcelOle::Range.new(column_range, self), (column_range.Column - 1 - offset)
|
173
201
|
end
|
174
202
|
end
|
175
203
|
|
176
204
|
def row_range(row, integer_range = nil)
|
177
205
|
integer_range ||= 1..@end_column
|
178
|
-
RobustExcelOle::Range.new(@ole_worksheet.Range(@ole_worksheet.Cells(row, integer_range.min), @ole_worksheet.Cells(row, integer_range.max)))
|
206
|
+
RobustExcelOle::Range.new(@ole_worksheet.Range(@ole_worksheet.Cells(row, integer_range.min), @ole_worksheet.Cells(row, integer_range.max)), self)
|
179
207
|
end
|
180
208
|
|
181
209
|
def col_range(col, integer_range = nil)
|
182
210
|
integer_range ||= 1..@end_row
|
183
|
-
RobustExcelOle::Range.new(@ole_worksheet.Range(@ole_worksheet.Cells(integer_range.min, col), @ole_worksheet.Cells(integer_range.max, col)))
|
211
|
+
RobustExcelOle::Range.new(@ole_worksheet.Range(@ole_worksheet.Cells(integer_range.min, col), @ole_worksheet.Cells(integer_range.max, col)), self)
|
184
212
|
end
|
185
213
|
|
186
214
|
def == other_worksheet
|
@@ -206,8 +234,7 @@ module RobustExcelOle
|
|
206
234
|
|
207
235
|
# @private
|
208
236
|
def to_s
|
209
|
-
'#<Worksheet: ' + name.to_s + ">"
|
210
|
-
#'#<Worksheet: ' + ('not alive ' unless workbook.alive?).to_s + name.to_s + " #{File.basename(workbook.stored_filename)} >"
|
237
|
+
'#<Worksheet: ' + (workbook.nil? ? 'not alive ' : (name + ' ' + File.basename(workbook.stored_filename)).to_s) + ">"
|
211
238
|
end
|
212
239
|
|
213
240
|
# @private
|
@@ -217,10 +244,9 @@ module RobustExcelOle
|
|
217
244
|
|
218
245
|
private
|
219
246
|
|
220
|
-
# @private
|
221
247
|
def method_missing(name, *args)
|
222
248
|
if name.to_s[0,1] =~ /[A-Z]/
|
223
|
-
if
|
249
|
+
if ::ERRORMESSAGE_JRUBY_BUG
|
224
250
|
begin
|
225
251
|
@ole_worksheet.send(name, *args)
|
226
252
|
rescue Java::OrgRacobCom::ComFailException
|
data/robust_excel_ole.gemspec
CHANGED
@@ -0,0 +1,175 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), './spec_helper')
|
4
|
+
require File.expand_path( '../../lib/robust_excel_ole/base', __FILE__)
|
5
|
+
|
6
|
+
$VERBOSE = nil
|
7
|
+
|
8
|
+
include General
|
9
|
+
include RobustExcelOle
|
10
|
+
|
11
|
+
module RobustExcelOle
|
12
|
+
|
13
|
+
describe AddressTool do
|
14
|
+
|
15
|
+
before(:all) do
|
16
|
+
excel = Excel.new(:reuse => true)
|
17
|
+
open_books = excel == nil ? 0 : excel.Workbooks.Count
|
18
|
+
puts "*** open books *** : #{open_books}" if open_books > 0
|
19
|
+
Excel.kill_all
|
20
|
+
@dir = create_tmpdir
|
21
|
+
@simple_file = @dir + '/workbook.xls'
|
22
|
+
@workbook = Workbook.open(@simple_file)
|
23
|
+
@address_tool = @workbook.excel.address_tool
|
24
|
+
end
|
25
|
+
|
26
|
+
after(:all) do
|
27
|
+
@workbook.close
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should transform relative r1c1-reference into r1c1-format" do
|
31
|
+
@address_tool.as_r1c1("Z1S[2]:Z[-1]S4").should == "Z1S(2):Z(-1)S4"
|
32
|
+
@address_tool.as_r1c1("Z[1]S2:Z3S[4]").should == "Z(1)S2:Z3S(4)"
|
33
|
+
@address_tool.as_r1c1("Z1S[2]").should == "Z1S(2)"
|
34
|
+
@address_tool.as_r1c1("Z[-1]S4").should == "Z(-1)S4"
|
35
|
+
@address_tool.as_r1c1("Z[3]").should == "Z(3)"
|
36
|
+
@address_tool.as_r1c1("S[-2]").should == "S(-2)"
|
37
|
+
end
|
38
|
+
|
39
|
+
# test for 1.8.6
|
40
|
+
it "should transform relative integer_ranges-format into r1c1-format" do
|
41
|
+
@address_tool.as_r1c1([1..2,[3]..4]).should == "Z1S(3):Z2S4"
|
42
|
+
@address_tool.as_r1c1([[1]..2,3..4]).should == "Z(1)S3:Z2S4"
|
43
|
+
@address_tool.as_r1c1([[1]..2,nil]).should == "Z(1):Z2"
|
44
|
+
@address_tool.as_r1c1([nil,[1]..2]).should == "S(1):S2"
|
45
|
+
@address_tool.as_r1c1([nil,[1]]).should == "S(1):S(1)"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should transform relative integer_ranges-format into r1c1-format" do
|
49
|
+
@address_tool.as_r1c1([1..[-2],[3]..4]).should == "Z1S(3):Z(-2)S4"
|
50
|
+
@address_tool.as_r1c1([[1]..2,3..[4]]).should == "Z(1)S3:Z2S(4)"
|
51
|
+
@address_tool.as_r1c1([1..[-2],nil]).should == "Z1:Z(-2)"
|
52
|
+
@address_tool.as_r1c1([nil,[-1]..2]).should == "S(-1):S2"
|
53
|
+
@address_tool.as_r1c1([[3]..[3],nil]).should == "Z(3):Z(3)"
|
54
|
+
@address_tool.as_r1c1([nil,[-2]..[-2]]).should == "S(-2):S(-2)"
|
55
|
+
@address_tool.as_r1c1([[3],nil]).should == "Z(3):Z(3)"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should transform relative r1c1-format into r1c1-format" do
|
59
|
+
@address_tool.as_integer_ranges("Z1S[2]:Z[3]S4").should == [1..[3],[2]..4]
|
60
|
+
@address_tool.as_integer_ranges("Z[1]S2:Z3S[4]").should == [[1]..3,2..[4]]
|
61
|
+
@address_tool.as_integer_ranges("Z1S[2]").should == [1..1,[2]..[2]]
|
62
|
+
@address_tool.as_integer_ranges("Z[3]S4").should == [[3]..[3],4..4]
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should transform a1-format" do
|
66
|
+
@address_tool.as_a1("A2").should == "A2"
|
67
|
+
@address_tool.as_r1c1("A2").should == "Z2S1:Z2S1"
|
68
|
+
@address_tool.as_integer_ranges("A2").should == [2..2,1..1]
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should transform several-letter-a1-format" do
|
72
|
+
@address_tool.as_a1("ABO15").should == "ABO15"
|
73
|
+
@address_tool.as_r1c1("ABO15").should == "Z15S743:Z15S743"
|
74
|
+
@address_tool.as_integer_ranges("ABO15").should == [15..15,743..743]
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should transform complex a1-format" do
|
78
|
+
@address_tool.as_a1("A2:B3").should == "A2:B3"
|
79
|
+
@address_tool.as_r1c1("A2:B3").should == "Z2S1:Z3S2"
|
80
|
+
@address_tool.as_integer_ranges("A2:B3").should == [2..3,1..2]
|
81
|
+
@address_tool.as_a1("S1:DP2").should == "S1:DP2"
|
82
|
+
@address_tool.as_r1c1("S1:DP2").should == "Z1S19:Z2S120"
|
83
|
+
@address_tool.as_integer_ranges("S1:DP2").should == [1..2,19..120]
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should transform infinite a1-format" do
|
87
|
+
@address_tool.as_a1("A:B").should == "A:B"
|
88
|
+
@address_tool.as_r1c1("A:B").should == "S1:S2"
|
89
|
+
@address_tool.as_integer_ranges("A:B").should == [nil,1..2]
|
90
|
+
@address_tool.as_a1("1:3").should == "1:3"
|
91
|
+
@address_tool.as_r1c1("1:3").should == "Z1:Z3"
|
92
|
+
@address_tool.as_integer_ranges("1:3").should == [1..3,nil]
|
93
|
+
@address_tool.as_a1("B").should == "B"
|
94
|
+
@address_tool.as_r1c1("B").should == "S2:S2"
|
95
|
+
@address_tool.as_integer_ranges("B").should == [nil,2..2]
|
96
|
+
@address_tool.as_a1("3").should == "3"
|
97
|
+
@address_tool.as_r1c1("3").should == "Z3:Z3"
|
98
|
+
@address_tool.as_integer_ranges("3").should == [3..3,nil]
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should transform r1c1-format" do
|
102
|
+
@address_tool.as_r1c1("Z2S1").should == "Z2S1"
|
103
|
+
@address_tool.as_integer_ranges("Z2S1").should == [2..2,1..1]
|
104
|
+
expect{
|
105
|
+
@address_tool.as_a1("Z2S1")
|
106
|
+
}.to raise_error(NotImplementedREOError)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should transform complex r1c1-format" do
|
110
|
+
@address_tool.as_r1c1("Z2S1:Z3S2").should == "Z2S1:Z3S2"
|
111
|
+
@address_tool.as_integer_ranges("Z2S1:Z3S2").should == [2..3,1..2]
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should transform as_integer_ranges format" do
|
115
|
+
@address_tool.as_integer_ranges([2..2,1..1]).should == [2..2,1..1]
|
116
|
+
@address_tool.as_r1c1([2..2,1..1]).should == "Z2S1:Z2S1"
|
117
|
+
expect{
|
118
|
+
@address_tool.as_a1([2..2,1..1])
|
119
|
+
}.to raise_error(NotImplementedREOError)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should transform simple as_integer_ranges format" do
|
123
|
+
@address_tool.as_integer_ranges([2,1]).should == [2..2,1..1]
|
124
|
+
@address_tool.as_r1c1([2,1]).should == "Z2S1:Z2S1"
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should transform complex as_integer_ranges format" do
|
128
|
+
@address_tool.as_integer_ranges([2,"A"]).should == [2..2,1..1]
|
129
|
+
@address_tool.as_r1c1([2,"A"]).should == "Z2S1:Z2S1"
|
130
|
+
@address_tool.as_integer_ranges([2,"A".."B"]).should == [2..2,1..2]
|
131
|
+
@address_tool.as_r1c1([2,"A".."B"]).should == "Z2S1:Z2S2"
|
132
|
+
@address_tool.as_integer_ranges([1..2,"C"]).should == [1..2,3..3]
|
133
|
+
@address_tool.as_r1c1([1..2,"C"]).should == "Z1S3:Z2S3"
|
134
|
+
@address_tool.as_integer_ranges([1..2,"C".."E"]).should == [1..2,3..5]
|
135
|
+
@address_tool.as_r1c1([1..2,"C".."E"]).should == "Z1S3:Z2S5"
|
136
|
+
@address_tool.as_integer_ranges([2,3..5]).should == [2..2,3..5]
|
137
|
+
@address_tool.as_r1c1([2,3..5]).should == "Z2S3:Z2S5"
|
138
|
+
@address_tool.as_integer_ranges([1..2,3..5]).should == [1..2,3..5]
|
139
|
+
@address_tool.as_r1c1([1..2,3..5]).should == "Z1S3:Z2S5"
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should transform infinite as_integer_ranges format" do
|
143
|
+
@address_tool.as_integer_ranges([nil,1..2]).should == [nil,1..2]
|
144
|
+
@address_tool.as_r1c1([nil,1..2]).should == "S1:S2"
|
145
|
+
@address_tool.as_integer_ranges([1..3,nil]).should == [1..3,nil]
|
146
|
+
@address_tool.as_r1c1([1..3,nil]).should == "Z1:Z3"
|
147
|
+
@address_tool.as_integer_ranges([nil,2]).should == [nil,2..2]
|
148
|
+
@address_tool.as_r1c1([nil,2]).should == "S2:S2"
|
149
|
+
@address_tool.as_integer_ranges([3,nil]).should == [3..3,nil]
|
150
|
+
@address_tool.as_r1c1([3,nil]).should == "Z3:Z3"
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should raise an error" do
|
154
|
+
expect{
|
155
|
+
@address_tool.as_a1("1A")
|
156
|
+
}.to raise_error(AddressInvalid, /format not correct/)
|
157
|
+
expect{
|
158
|
+
@address_tool.as_r1c1("A1B")
|
159
|
+
}.to raise_error(AddressInvalid, /format not correct/)
|
160
|
+
#expect{
|
161
|
+
# @address_tool.as_integer_ranges(["A".."B","C".."D"])
|
162
|
+
#}.to raise_error(AddressInvalid, /format not correct/)
|
163
|
+
#expect{
|
164
|
+
# @address_tool.as_integer_ranges(["A".."B",1..2])
|
165
|
+
#}.to raise_error(AddressInvalid, /format not correct/)
|
166
|
+
#expect{
|
167
|
+
# @address_tool.as_integer_ranges(["A".."B",nil])
|
168
|
+
#}.to raise_error(AddressInvalid, /format not correct/)
|
169
|
+
expect{
|
170
|
+
@address_tool.as_integer_ranges(["A",1,2])
|
171
|
+
}.to raise_error(AddressInvalid, /more than two components/)
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), './spec_helper')
|
4
|
-
require File.expand_path( '../../lib/robust_excel_ole/
|
4
|
+
require File.expand_path( '../../lib/robust_excel_ole/base', __FILE__)
|
5
5
|
|
6
6
|
$VERBOSE = nil
|
7
7
|
|
@@ -10,7 +10,7 @@ include RobustExcelOle
|
|
10
10
|
|
11
11
|
module RobustExcelOle
|
12
12
|
|
13
|
-
describe
|
13
|
+
describe Base do
|
14
14
|
|
15
15
|
before(:all) do
|
16
16
|
excel = Excel.new(:reuse => true)
|
@@ -40,12 +40,12 @@ module RobustExcelOle
|
|
40
40
|
|
41
41
|
it "should put some number" do
|
42
42
|
a = 4
|
43
|
-
|
43
|
+
Base::trace "some text #{a}"
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should put another text" do
|
47
47
|
b = Workbook.open(@simple_file)
|
48
|
-
|
48
|
+
Base::trace "book: #{b}"
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -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
|
@@ -82,43 +82,28 @@ module RobustExcelOle
|
|
82
82
|
|
83
83
|
end
|
84
84
|
|
85
|
-
describe "
|
86
|
-
|
87
|
-
before do
|
88
|
-
@book = Workbook.open(@simple_file)
|
89
|
-
@sheet = @book.sheet(1)
|
90
|
-
end
|
91
|
-
|
92
|
-
before do
|
93
|
-
@book.close
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should raise an error when asking excel of a sheet" do
|
97
|
-
expect{
|
98
|
-
@sheet.excel
|
99
|
-
}.to raise_error(TypeREOError, "receiver instance is neither an Excel nor a Workbook")
|
100
|
-
end
|
85
|
+
describe "misc" do
|
101
86
|
|
102
|
-
|
87
|
+
it "should" do
|
103
88
|
|
104
|
-
|
89
|
+
LOG_TO_STDOUT = true
|
90
|
+
Base::trace "foo"
|
105
91
|
|
106
|
-
|
107
|
-
|
92
|
+
LOG_TO_STDOUT = false
|
93
|
+
Base::trace "foo"
|
108
94
|
|
109
|
-
|
110
|
-
|
95
|
+
REO_LOG_DIR = ""
|
96
|
+
Base::trace "foo"
|
111
97
|
|
112
|
-
|
113
|
-
|
98
|
+
#REO_LOG_DIR = "C:"
|
99
|
+
#Base::trace "foo"
|
114
100
|
|
115
|
-
|
116
|
-
REOCommon::trace "foo"
|
101
|
+
Base::tr1 "foo"
|
117
102
|
|
118
|
-
|
103
|
+
h = {:a => {:c => 4}, :b => 2}
|
104
|
+
Base::puts_hash(h)
|
119
105
|
|
120
|
-
|
121
|
-
REOCommon::puts_hash(h)
|
106
|
+
end
|
122
107
|
|
123
108
|
end
|
124
109
|
end
|