robust_excel_ole 1.31 → 1.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog +20 -1
- data/README.rdoc +118 -18
- data/___dummy_workbook.xls +0 -0
- data/benchmarking/creek_example.rb +1 -1
- data/benchmarking/roo_example.rb +1 -1
- data/benchmarking/simple_xlsx_reader_example.rb +1 -1
- data/benchmarking/spreadsheet_example.rb +1 -1
- data/docs/README_excel.rdoc +16 -24
- data/docs/README_listobjects.rdoc +176 -0
- data/docs/README_open.rdoc +12 -12
- data/docs/README_ranges.rdoc +72 -55
- data/docs/README_save_close.rdoc +3 -3
- data/docs/README_sheet.rdoc +18 -13
- data/examples/example_ruby_library.rb +2 -2
- data/examples/introductory_examples/example_range.rb +2 -2
- data/examples/modifying_sheets/example_access_sheets_and_cells.rb +6 -6
- data/examples/modifying_sheets/example_add_names.rb +1 -1
- data/examples/modifying_sheets/example_concating.rb +1 -1
- data/examples/modifying_sheets/example_copying.rb +2 -2
- data/examples/modifying_sheets/example_listobjects.rb +86 -0
- data/examples/modifying_sheets/example_naming.rb +1 -1
- data/examples/modifying_sheets/example_ranges.rb +1 -1
- data/examples/open_save_close/example_control_to_excel.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_closeifsaved.rb +1 -1
- data/examples/open_save_close/example_if_obstructed_save.rb +3 -3
- data/examples/open_save_close/example_if_unsaved_accept.rb +1 -1
- data/examples/open_save_close/example_if_unsaved_forget.rb +3 -3
- data/examples/open_save_close/example_if_unsaved_forget_more.rb +4 -4
- data/examples/open_save_close/example_read_only.rb +1 -1
- data/examples/open_save_close/example_simple.rb +1 -1
- data/examples/open_save_close/example_unobtrusively.rb +3 -3
- data/lib/robust_excel_ole/address_tool.rb +54 -44
- data/lib/robust_excel_ole/base.rb +4 -6
- data/lib/robust_excel_ole/bookstore.rb +2 -16
- data/lib/robust_excel_ole/cell.rb +16 -21
- data/lib/robust_excel_ole/excel.rb +131 -186
- data/lib/robust_excel_ole/general.rb +82 -55
- data/lib/robust_excel_ole/list_object.rb +182 -109
- data/lib/robust_excel_ole/list_row.rb +65 -38
- data/lib/robust_excel_ole/range.rb +125 -93
- data/lib/robust_excel_ole/range_owners.rb +52 -66
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/workbook.rb +168 -176
- data/lib/robust_excel_ole/worksheet.rb +177 -141
- data/robust_excel_ole.gemspec +4 -3
- data/spec/bookstore_spec.rb +2 -3
- data/spec/cell_spec.rb +9 -9
- data/spec/data/more_data/workbook.xls +0 -0
- data/spec/excel_spec.rb +132 -85
- data/spec/general_spec.rb +47 -15
- data/spec/list_object_spec.rb +258 -145
- data/spec/list_row_spec.rb +218 -0
- data/spec/range_spec.rb +76 -29
- data/spec/spec_helper.rb +15 -1
- data/spec/workbook_spec.rb +75 -34
- data/spec/workbook_specs/workbook_all_spec.rb +2 -1
- data/spec/workbook_specs/workbook_misc_spec.rb +20 -13
- data/spec/workbook_specs/workbook_open_spec.rb +47 -45
- data/spec/workbook_specs/workbook_save_spec.rb +21 -22
- data/spec/workbook_specs/workbook_sheet_spec.rb +3 -3
- data/spec/workbook_specs/workbook_unobtr_spec.rb +303 -303
- data/spec/worksheet_spec.rb +522 -318
- metadata +37 -2
@@ -0,0 +1,218 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require_relative 'spec_helper'
|
4
|
+
|
5
|
+
$VERBOSE = nil
|
6
|
+
|
7
|
+
include RobustExcelOle
|
8
|
+
include General
|
9
|
+
|
10
|
+
describe ListRow 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.kill_all
|
17
|
+
end
|
18
|
+
|
19
|
+
before do
|
20
|
+
@dir = create_tmpdir
|
21
|
+
@listobject_file = @dir + '/workbook_listobjects.xlsx'
|
22
|
+
@book = Workbook.open(@listobject_file, :visible => true)
|
23
|
+
@sheet = @book.sheet(3)
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
@book.close(:if_unsaved => :forget)
|
28
|
+
Excel.kill_all
|
29
|
+
rm_tmp(@dir)
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "==" do
|
33
|
+
|
34
|
+
before do
|
35
|
+
@table1 = @sheet.table(1)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should yield true" do
|
39
|
+
(@table1[1] == @table1[1]).should be true
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should yield true" do
|
43
|
+
(@table1[1] == @table1[2]).should be false
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "promote" do
|
49
|
+
|
50
|
+
it "should promote a win32ole tablerow" do
|
51
|
+
table1 = @sheet.table(1)
|
52
|
+
ole_tablerow = table1[2].ole_tablerow
|
53
|
+
ListRow.new(ole_tablerow).values.should == [2.0, "Fred", nil, 0.5416666666666666, 40]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "to_a, to_h" do
|
58
|
+
|
59
|
+
before do
|
60
|
+
@table1 = @sheet.table(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should yield values of a row" do
|
64
|
+
@table1[2].to_a.should == [2.0, "Fred", nil, 0.5416666666666666, 40]
|
65
|
+
@table1[2].values.should == [2.0, "Fred", nil, 0.5416666666666666, 40]
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should yield key-value pairs of a row" do
|
69
|
+
@table1[2].to_h.should == {"Number" => 2.0, "Person" => "Fred", "Amount" => nil, "Time" => 0.5416666666666666, "Price" => 40}
|
70
|
+
@table1[2].keys_values.should == {"Number" => 2.0, "Person" => "Fred", "Amount" => nil, "Time" => 0.5416666666666666, "Price" => 40}
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should yield values and key-value pairs of a row with umlauts" do
|
74
|
+
@table1[1].values = [1, "Sören", 20.0, 0.1, 40]
|
75
|
+
@table1[1].values.should == [1.0, "Sören", 20.0, 0.1, 40]
|
76
|
+
@table1[1].to_a.should == [1.0, "Sören", 20.0, 0.1, 40]
|
77
|
+
@table1[1].to_h.should == {"Number" => 1.0, "Person" => "Sören", "Amount" => 20.0, "Time" => 0.1, "Price" => 40}
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "[], []=" do
|
83
|
+
|
84
|
+
before do
|
85
|
+
@table1 = @sheet.table(1)
|
86
|
+
@table_row1 = @table1[1]
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should read value in column" do
|
90
|
+
@table_row1[2].should == "John"
|
91
|
+
@table_row1["Person"].should == "John"
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should read value in column with umlauts" do
|
95
|
+
@table1.add_column("Straße", 1, ["Sören","ö","ü","ß","²","³","g","h","i","j","k","l","m"])
|
96
|
+
table_row2 = @table1[1]
|
97
|
+
@table_row1[1].should == "Sören"
|
98
|
+
@table_row1["Straße"].should == "Sören"
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "getting and setting values" do
|
104
|
+
|
105
|
+
context "with various column names" do
|
106
|
+
|
107
|
+
context "with standard" do
|
108
|
+
|
109
|
+
before do
|
110
|
+
@table = Table.new(@sheet, "table_name", [22,1], 3, ["Person1","Win/Sales", "xiq-Xs", "OrderID", "YEAR", "length in m", "Amo%untSal___es"])
|
111
|
+
@table_row1 = @table[1]
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should read and set values via alternative column names" do
|
115
|
+
@table_row1.person1.should be nil
|
116
|
+
@table_row1.person1 = "John"
|
117
|
+
@table_row1.person1.should == "John"
|
118
|
+
@sheet[23,1].should == "John"
|
119
|
+
@table_row1.Person1 = "Herbert"
|
120
|
+
@table_row1.Person1.should == "Herbert"
|
121
|
+
@sheet[23,1].should == "Herbert"
|
122
|
+
@table_row1.win_sales.should be nil
|
123
|
+
@table_row1.win_sales = 42
|
124
|
+
@table_row1.win_sales.should == 42
|
125
|
+
@sheet[23,2].should == 42
|
126
|
+
@table_row1.Win_Sales = 80
|
127
|
+
@table_row1.Win_Sales.should == 80
|
128
|
+
@sheet[23,2].should == 80
|
129
|
+
@table_row1.xiq_xs.should == nil
|
130
|
+
@table_row1.xiq_xs = 90
|
131
|
+
@table_row1.xiq_xs.should == 90
|
132
|
+
@sheet[23,3].should == 90
|
133
|
+
@table_row1.xiq_Xs = 100
|
134
|
+
@table_row1.xiq_Xs.should == 100
|
135
|
+
@sheet[23,3].should == 100
|
136
|
+
@table_row1.order_id.should == nil
|
137
|
+
@table_row1.order_id = 1
|
138
|
+
@table_row1.order_id.should == 1
|
139
|
+
@sheet[23,4].should == 1
|
140
|
+
@table_row1.OrderID = 2
|
141
|
+
@table_row1.OrderID.should == 2
|
142
|
+
@sheet[23,4].should == 2
|
143
|
+
@table_row1.year = 1984
|
144
|
+
@table_row1.year.should == 1984
|
145
|
+
@sheet[23,5].should == 1984
|
146
|
+
@table_row1.YEAR = 2020
|
147
|
+
@table_row1.YEAR.should == 2020
|
148
|
+
@sheet[23,5].should == 2020
|
149
|
+
@table_row1.length_in_m.should == nil
|
150
|
+
@table_row1.length_in_m = 20
|
151
|
+
@table_row1.length_in_m.should == 20
|
152
|
+
@sheet[23,6].should == 20
|
153
|
+
@table_row1.length_in_m = 40
|
154
|
+
@table_row1.length_in_m.should == 40
|
155
|
+
@sheet[23,6].should == 40
|
156
|
+
@table_row1.amo_unt_sal___es.should == nil
|
157
|
+
@table_row1.amo_unt_sal___es = 80
|
158
|
+
@table_row1.amo_unt_sal___es.should == 80
|
159
|
+
@sheet[23,7].should == 80
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
context "with umlauts" do
|
165
|
+
|
166
|
+
before do
|
167
|
+
@table = Table.new(@sheet, "table_name", [1,1], 3, ["Verkäufer", "Straße", "area in m²"])
|
168
|
+
@table_row1 = @table[1]
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should read and set values via alternative column names" do
|
172
|
+
@table_row1.verkaeufer.should be nil
|
173
|
+
@table_row1.verkaeufer = "John"
|
174
|
+
@table_row1.verkaeufer.should == "John"
|
175
|
+
@sheet[2,1].should == "John"
|
176
|
+
@table_row1.Verkaeufer = "Herbert"
|
177
|
+
@table_row1.Verkaeufer.should == "Herbert"
|
178
|
+
@sheet[2,1].should == "Herbert"
|
179
|
+
@table_row1.strasse.should be nil
|
180
|
+
@table_row1.strasse = 42
|
181
|
+
@table_row1.strasse.should == 42
|
182
|
+
@sheet[2,2].should == 42
|
183
|
+
@table_row1.Strasse = 80
|
184
|
+
@table_row1.Strasse.should == 80
|
185
|
+
@sheet[2,2].should == 80
|
186
|
+
@table_row1.area_in_m2.should be nil
|
187
|
+
@table_row1.area_in_m2 = 10
|
188
|
+
@table_row1.area_in_m2.should == 10
|
189
|
+
@sheet[2,3].should == 10
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
context "with type-lifted ole list object" do
|
197
|
+
|
198
|
+
before do
|
199
|
+
ole_table = @sheet.ListObjects.Item(1)
|
200
|
+
@table = Table.new(ole_table)
|
201
|
+
@table_row1 = @table[1]
|
202
|
+
end
|
203
|
+
|
204
|
+
it "should set and read values" do
|
205
|
+
@table_row1.number.should == 3
|
206
|
+
@table_row1.number = 1
|
207
|
+
@table_row1.number.should == 1
|
208
|
+
@sheet[4,4].should == 1
|
209
|
+
@table_row1.person.should == "John"
|
210
|
+
@table_row1.person = "Herbert"
|
211
|
+
@table_row1.person.should == "Herbert"
|
212
|
+
@sheet[4,5].should == "Herbert"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
data/spec/range_spec.rb
CHANGED
@@ -7,6 +7,7 @@ include General
|
|
7
7
|
describe RobustExcelOle::Range do
|
8
8
|
|
9
9
|
before(:all) do
|
10
|
+
|
10
11
|
excel = Excel.new(:reuse => true)
|
11
12
|
open_books = excel == nil ? 0 : excel.Workbooks.Count
|
12
13
|
puts "*** open books *** : #{open_books}" if open_books > 0
|
@@ -19,6 +20,7 @@ describe RobustExcelOle::Range do
|
|
19
20
|
@sheet = @book.sheet(2)
|
20
21
|
@range = RobustExcelOle::Range.new(@sheet.ole_worksheet.UsedRange.Rows(1))
|
21
22
|
@range2 = @sheet.range([1..2,1..3])
|
23
|
+
@sheet1 = @book.sheet(1)
|
22
24
|
end
|
23
25
|
|
24
26
|
after do
|
@@ -53,6 +55,24 @@ describe RobustExcelOle::Range do
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
58
|
+
it "should access each cell" do
|
59
|
+
cells = []
|
60
|
+
@range2.each do |cell|
|
61
|
+
cells << cell
|
62
|
+
end
|
63
|
+
cells.should == [@range2[0], @range2[1], @range2[2], @range2[3], @range2[4], @range2[5]]
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should map" do
|
67
|
+
@range2.map{|c| c}.should == [@range2[0], @range2[1], @range2[2], @range2[3], @range2[4], @range2[5]]
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should concatenate" do
|
71
|
+
values = []
|
72
|
+
@range2.each.with_index{|c,i| values << [c.v, i]}
|
73
|
+
values.should == [["simple", 0], ["file", 1], ["sheet2", 2], [nil, 3], [nil, 4], [nil, 5]]
|
74
|
+
end
|
75
|
+
|
56
76
|
it "should work with [] doing cashing synchonized, from #[] to #each" do
|
57
77
|
i = 0
|
58
78
|
@range2.each do |cell|
|
@@ -75,6 +95,33 @@ describe RobustExcelOle::Range do
|
|
75
95
|
|
76
96
|
end
|
77
97
|
|
98
|
+
describe "#value" do
|
99
|
+
|
100
|
+
it "should yield the right values" do
|
101
|
+
@sheet1.range([1..2,1..3]).value.should == [["foo", "workbook", "sheet1"], ["foo", nil, "foobaaa"]]
|
102
|
+
@sheet1.range([1,1..3]).value.should == [["foo", "workbook", "sheet1"]]
|
103
|
+
@sheet1.range([1,1..5]).value.should == [["foo", "workbook", "sheet1"]]
|
104
|
+
@sheet1.range([1..5,1..5]).value.should == [["foo", "workbook", "sheet1"], ["foo", nil, "foobaaa"],["matz", "is", "nice"]]
|
105
|
+
@sheet1.range([1..2,1]).value.should == [["foo"], ["foo"]]
|
106
|
+
@sheet1.range([1]).value.should == [["foo", "workbook", "sheet1"]]
|
107
|
+
@sheet1.range([1..2]).value.should == [["foo", "workbook", "sheet1"], ["foo", nil, "foobaaa"]]
|
108
|
+
@sheet1.range([1..60]).value.should == [["foo", "workbook", "sheet1"], ["foo", nil, "foobaaa"], ["matz", "is", "nice"]]
|
109
|
+
@sheet1.range([nil,2..3]).value.should == [["workbook", "sheet1"], [nil, "foobaaa"], ["is", "nice"]]
|
110
|
+
@sheet1.range([1,2]).value.should == "workbook"
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#value=" do
|
116
|
+
|
117
|
+
it "should set value" do
|
118
|
+
@sheet1.range([1..2,1..3]).value.should == [["foo", "workbook", "sheet1"], ["foo", nil, "foobaaa"]]
|
119
|
+
@sheet1.range([1..2,1..3]).value = [["foo", nil, "foobaaa"], ["foo", "workbook", "sheet1"]]
|
120
|
+
@sheet1.range([1..2,1..3]).value.should == [["foo", nil, "foobaaa"], ["foo", "workbook", "sheet1"]]
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
78
125
|
describe "#values" do
|
79
126
|
context "with (0..2)" do
|
80
127
|
it { @range.values(0..2).should eq ['simple', 'file', 'sheet2'] }
|
@@ -162,7 +209,7 @@ describe RobustExcelOle::Range do
|
|
162
209
|
@range[2].v.should eq 'sheet2'
|
163
210
|
end
|
164
211
|
end
|
165
|
-
end
|
212
|
+
end
|
166
213
|
|
167
214
|
describe "#value" do
|
168
215
|
|
@@ -177,16 +224,16 @@ describe RobustExcelOle::Range do
|
|
177
224
|
end
|
178
225
|
|
179
226
|
it "should return value" do
|
180
|
-
@sheet[1,1].
|
227
|
+
@sheet[1,1].should == 'simple'
|
181
228
|
@sheet.range(1..2,3..4).v.should == [["sheet2", nil], [nil, nil]]
|
182
229
|
end
|
183
230
|
|
184
231
|
it "should set value of a cell and return its value" do
|
185
|
-
@sheet1[2,3].
|
186
|
-
@sheet1[2,3].
|
187
|
-
@sheet1[2,3]
|
188
|
-
@sheet1[2,3].
|
189
|
-
@sheet1[2,3].Value.should == "bar"
|
232
|
+
@sheet1[2,3].should == "foobaaa"
|
233
|
+
@sheet1[2,3].should == "foobaaa"
|
234
|
+
@sheet1[2,3] = "bar"
|
235
|
+
@sheet1[2,3].should == "bar"
|
236
|
+
@sheet1.range([2,3]).Value.should == "bar"
|
190
237
|
end
|
191
238
|
|
192
239
|
it "should set value and return value of a rectangular range" do
|
@@ -209,7 +256,7 @@ describe RobustExcelOle::Range do
|
|
209
256
|
@book1 = Workbook.open(@dir + '/workbook.xls')
|
210
257
|
@sheet1 = @book1.sheet(1)
|
211
258
|
@range1 = @sheet1.range([1..2,1..3])
|
212
|
-
@sheet1[1,1].Interior.ColorIndex = 4
|
259
|
+
@sheet1.range([1,1]).Interior.ColorIndex = 4
|
213
260
|
@book2 = Workbook.open(@dir + '/different_workbook.xls')
|
214
261
|
@sheet2 = @book2.sheet(2)
|
215
262
|
@book3 = Workbook.open(@dir + '/another_workbook.xls', :force => {:excel => :new})
|
@@ -225,61 +272,61 @@ describe RobustExcelOle::Range do
|
|
225
272
|
it "should copy range" do
|
226
273
|
@range1.copy([4,2])
|
227
274
|
@sheet1.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
228
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
275
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
229
276
|
end
|
230
277
|
|
231
278
|
it "should copy range when giving an address" do
|
232
279
|
@range1.copy([4..5,2..4])
|
233
280
|
@sheet1.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
234
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
281
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
235
282
|
end
|
236
283
|
|
237
284
|
it "should copy range to another worksheet of another workbook" do
|
238
285
|
@range1.copy([4,2], @sheet2)
|
239
286
|
@sheet2.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
240
|
-
@sheet2[4,2].Interior.ColorIndex.should == 4
|
287
|
+
@sheet2.range([4,2]).Interior.ColorIndex.should == 4
|
241
288
|
end
|
242
289
|
|
243
290
|
it "should copy range to another worksheet of another workbook of another Excel instance" do
|
244
291
|
@range1.copy([4,2], @sheet3)
|
245
292
|
@sheet3.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
246
|
-
@sheet3[4,2].Interior.ColorIndex.should == 4
|
293
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == 4
|
247
294
|
end
|
248
295
|
|
249
296
|
it "should copy values only" do
|
250
297
|
@range1.copy([4,2], @sheet1, :values_only => true)
|
251
298
|
@sheet1.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
252
|
-
@sheet1[4,2].Interior.ColorIndex.should == -4142
|
299
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == -4142
|
253
300
|
end
|
254
301
|
|
255
302
|
it "should copy values only to another worksheet of another Excel instance" do
|
256
303
|
@range1.copy([4,2], @sheet3, :values_only => true)
|
257
304
|
@sheet3.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
258
|
-
@sheet3[4,2].Interior.ColorIndex.should == -4142
|
305
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == -4142
|
259
306
|
end
|
260
307
|
|
261
308
|
it "should copy and transpose with values only" do
|
262
309
|
@range1.copy([4,2], @sheet1, :values_only => true, :transpose => true)
|
263
310
|
@sheet1.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
264
|
-
@sheet1[4,2].Interior.ColorIndex.should == -4142
|
311
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == -4142
|
265
312
|
end
|
266
313
|
|
267
314
|
it "should copy and transpose with values only into another Excel instance" do
|
268
315
|
@range1.copy([4,2], @sheet3, :values_only => true, :transpose => true)
|
269
316
|
@sheet3.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
270
|
-
@sheet3[4,2].Interior.ColorIndex.should == -4142
|
317
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == -4142
|
271
318
|
end
|
272
319
|
|
273
320
|
it "should copy and transpose" do
|
274
321
|
@range1.copy([4,2], @sheet1, :transpose => true)
|
275
322
|
@sheet1.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
276
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
323
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
277
324
|
end
|
278
325
|
|
279
326
|
it "should copy and transpose into another Excel instance" do
|
280
327
|
@range1.copy([4,2], @sheet3, :transpose => true)
|
281
328
|
@sheet3.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
282
|
-
@sheet3[4,2].Interior.ColorIndex.should == 4
|
329
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == 4
|
283
330
|
end
|
284
331
|
end
|
285
332
|
|
@@ -289,7 +336,7 @@ describe RobustExcelOle::Range do
|
|
289
336
|
@book1 = Workbook.open(@dir + '/workbook.xls')
|
290
337
|
@sheet1 = @book1.sheet(1)
|
291
338
|
@range1 = @sheet1.range([1..2,1..3])
|
292
|
-
@sheet1[1,1].Interior.ColorIndex = 4
|
339
|
+
@sheet1.range([1,1]).Interior.ColorIndex = 4
|
293
340
|
@book2 = Workbook.open(@dir + '/different_workbook.xls')
|
294
341
|
@sheet2 = @book2.sheet(2)
|
295
342
|
@book3 = Workbook.open(@dir + '/another_workbook.xls', :force => {:excel => :new})
|
@@ -305,61 +352,61 @@ describe RobustExcelOle::Range do
|
|
305
352
|
it "should copy range" do
|
306
353
|
@range1.copy(4,2)
|
307
354
|
@sheet1.range(4..5,2..4).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
308
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
355
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
309
356
|
end
|
310
357
|
|
311
358
|
it "should copy range when giving an address" do
|
312
359
|
@range1.copy(4..5,2..4)
|
313
360
|
@sheet1.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
314
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
361
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
315
362
|
end
|
316
363
|
|
317
364
|
it "should copy range to another worksheet of another workbook" do
|
318
365
|
@range1.copy(4,2, @sheet2)
|
319
366
|
@sheet2.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
320
|
-
@sheet2[4,2].Interior.ColorIndex.should == 4
|
367
|
+
@sheet2.range([4,2]).Interior.ColorIndex.should == 4
|
321
368
|
end
|
322
369
|
|
323
370
|
it "should copy range to another worksheet of another workbook of another Excel instance" do
|
324
371
|
@range1.copy(4,2, @sheet3)
|
325
372
|
@sheet3.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
326
|
-
@sheet3[4,2].Interior.ColorIndex.should == 4
|
373
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == 4
|
327
374
|
end
|
328
375
|
|
329
376
|
it "should copy values only" do
|
330
377
|
@range1.copy(4,2, @sheet1, :values_only => true)
|
331
378
|
@sheet1.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
332
|
-
@sheet1[4,2].Interior.ColorIndex.should == -4142
|
379
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == -4142
|
333
380
|
end
|
334
381
|
|
335
382
|
it "should copy values only to another worksheet of another Excel instance" do
|
336
383
|
@range1.copy(4,2, @sheet3, :values_only => true)
|
337
384
|
@sheet3.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
338
|
-
@sheet3[4,2].Interior.ColorIndex.should == -4142
|
385
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == -4142
|
339
386
|
end
|
340
387
|
|
341
388
|
it "should copy and transpose with values only" do
|
342
389
|
@range1.copy(4,2, @sheet1, :values_only => true, :transpose => true)
|
343
390
|
@sheet1.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
344
|
-
@sheet1[4,2].Interior.ColorIndex.should == -4142
|
391
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == -4142
|
345
392
|
end
|
346
393
|
|
347
394
|
it "should copy and transpose with values only into another Excel instance" do
|
348
395
|
@range1.copy(4,2, @sheet3, :values_only => true, :transpose => true)
|
349
396
|
@sheet3.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
350
|
-
@sheet3[4,2].Interior.ColorIndex.should == -4142
|
397
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == -4142
|
351
398
|
end
|
352
399
|
|
353
400
|
it "should copy and transpose" do
|
354
401
|
@range1.copy(4,2, @sheet1, :transpose => true)
|
355
402
|
@sheet1.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
356
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
403
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
357
404
|
end
|
358
405
|
|
359
406
|
it "should copy and transpose into another Excel instance" do
|
360
407
|
@range1.copy(4,2, @sheet3, :transpose => true)
|
361
408
|
@sheet3.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
362
|
-
@sheet3[4,2].Interior.ColorIndex.should == 4
|
409
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == 4
|
363
410
|
end
|
364
411
|
|
365
412
|
end
|