robust_excel_ole 1.27 → 1.32
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 +36 -2
- data/README.rdoc +121 -19
- data/___dummy_workbook.xls +0 -0
- data/benchmarking/creek_example.rb +1 -1
- data/benchmarking/reo_example.rb +1 -1
- data/benchmarking/reo_example1.rb +1 -1
- data/benchmarking/reo_example2.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/bin/jreo +19 -0
- data/bin/reo +19 -0
- data/docs/README_excel.rdoc +16 -24
- data/docs/README_listobjects.rdoc +176 -0
- data/docs/README_open.rdoc +20 -16
- data/docs/README_ranges.rdoc +72 -55
- data/docs/README_save_close.rdoc +3 -3
- data/docs/README_sheet.rdoc +19 -20
- data/examples/example_ruby_library.rb +2 -2
- data/examples/introductory_examples/example_open.rb +11 -0
- 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.rb +19 -16
- data/lib/robust_excel_ole/address_tool.rb +54 -44
- data/lib/robust_excel_ole/base.rb +9 -6
- data/lib/robust_excel_ole/bookstore.rb +3 -17
- data/lib/robust_excel_ole/cell.rb +17 -22
- data/lib/robust_excel_ole/cygwin.rb +2 -0
- data/lib/robust_excel_ole/excel.rb +136 -201
- data/lib/robust_excel_ole/general.rb +249 -238
- data/lib/robust_excel_ole/list_object.rb +186 -210
- data/lib/robust_excel_ole/list_row.rb +155 -0
- data/lib/robust_excel_ole/range.rb +130 -94
- data/lib/robust_excel_ole/range_owners.rb +54 -135
- data/lib/robust_excel_ole/version.rb +1 -1
- data/lib/robust_excel_ole/workbook.rb +230 -196
- data/lib/robust_excel_ole/worksheet.rb +254 -133
- data/lib/spec_helper.rb +1 -1
- data/robust_excel_ole.gemspec +4 -3
- data/spec/address_tool_spec.rb +2 -2
- data/spec/base_spec.rb +19 -17
- data/spec/bookstore_spec.rb +3 -4
- data/spec/cell_spec.rb +10 -10
- data/spec/cygwin_spec.rb +1 -1
- data/spec/data/more_data/workbook.xls +0 -0
- data/spec/excel_spec.rb +133 -86
- data/spec/general_spec.rb +79 -18
- data/spec/list_object_spec.rb +259 -81
- data/spec/list_row_spec.rb +218 -0
- data/spec/range_spec.rb +75 -41
- data/spec/spec_helper.rb +16 -2
- data/spec/workbook_spec.rb +87 -46
- data/spec/workbook_specs/workbook_all_spec.rb +9 -28
- data/spec/workbook_specs/workbook_close_spec.rb +1 -1
- data/spec/workbook_specs/workbook_misc_spec.rb +52 -45
- data/spec/workbook_specs/workbook_open_spec.rb +103 -50
- data/spec/workbook_specs/workbook_save_spec.rb +22 -23
- data/spec/workbook_specs/workbook_sheet_spec.rb +4 -4
- data/spec/workbook_specs/workbook_subclass_spec.rb +1 -1
- data/spec/workbook_specs/workbook_unobtr_spec.rb +553 -395
- data/spec/worksheet_spec.rb +544 -308
- metadata +38 -3
- data/lib/reo_console.rb +0 -42
@@ -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
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
|
2
|
+
require_relative 'spec_helper'
|
3
3
|
|
4
4
|
include RobustExcelOle
|
5
5
|
include General
|
@@ -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|
|
@@ -73,17 +93,31 @@ describe RobustExcelOle::Range do
|
|
73
93
|
end
|
74
94
|
end
|
75
95
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
@
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
96
|
+
end
|
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"]]
|
87
121
|
end
|
88
122
|
|
89
123
|
end
|
@@ -175,7 +209,7 @@ describe RobustExcelOle::Range do
|
|
175
209
|
@range[2].v.should eq 'sheet2'
|
176
210
|
end
|
177
211
|
end
|
178
|
-
end
|
212
|
+
end
|
179
213
|
|
180
214
|
describe "#value" do
|
181
215
|
|
@@ -190,16 +224,16 @@ describe RobustExcelOle::Range do
|
|
190
224
|
end
|
191
225
|
|
192
226
|
it "should return value" do
|
193
|
-
@sheet[1,1].
|
227
|
+
@sheet[1,1].should == 'simple'
|
194
228
|
@sheet.range(1..2,3..4).v.should == [["sheet2", nil], [nil, nil]]
|
195
229
|
end
|
196
230
|
|
197
231
|
it "should set value of a cell and return its value" do
|
198
|
-
@sheet1[2,3].
|
199
|
-
@sheet1[2,3].
|
200
|
-
@sheet1[2,3]
|
201
|
-
@sheet1[2,3].
|
202
|
-
@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"
|
203
237
|
end
|
204
238
|
|
205
239
|
it "should set value and return value of a rectangular range" do
|
@@ -222,7 +256,7 @@ describe RobustExcelOle::Range do
|
|
222
256
|
@book1 = Workbook.open(@dir + '/workbook.xls')
|
223
257
|
@sheet1 = @book1.sheet(1)
|
224
258
|
@range1 = @sheet1.range([1..2,1..3])
|
225
|
-
@sheet1[1,1].Interior.ColorIndex = 4
|
259
|
+
@sheet1.range([1,1]).Interior.ColorIndex = 4
|
226
260
|
@book2 = Workbook.open(@dir + '/different_workbook.xls')
|
227
261
|
@sheet2 = @book2.sheet(2)
|
228
262
|
@book3 = Workbook.open(@dir + '/another_workbook.xls', :force => {:excel => :new})
|
@@ -238,61 +272,61 @@ describe RobustExcelOle::Range do
|
|
238
272
|
it "should copy range" do
|
239
273
|
@range1.copy([4,2])
|
240
274
|
@sheet1.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
241
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
275
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
242
276
|
end
|
243
277
|
|
244
278
|
it "should copy range when giving an address" do
|
245
279
|
@range1.copy([4..5,2..4])
|
246
280
|
@sheet1.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
247
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
281
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
248
282
|
end
|
249
283
|
|
250
284
|
it "should copy range to another worksheet of another workbook" do
|
251
285
|
@range1.copy([4,2], @sheet2)
|
252
286
|
@sheet2.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
253
|
-
@sheet2[4,2].Interior.ColorIndex.should == 4
|
287
|
+
@sheet2.range([4,2]).Interior.ColorIndex.should == 4
|
254
288
|
end
|
255
289
|
|
256
290
|
it "should copy range to another worksheet of another workbook of another Excel instance" do
|
257
291
|
@range1.copy([4,2], @sheet3)
|
258
292
|
@sheet3.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
259
|
-
@sheet3[4,2].Interior.ColorIndex.should == 4
|
293
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == 4
|
260
294
|
end
|
261
295
|
|
262
296
|
it "should copy values only" do
|
263
297
|
@range1.copy([4,2], @sheet1, :values_only => true)
|
264
298
|
@sheet1.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
265
|
-
@sheet1[4,2].Interior.ColorIndex.should == -4142
|
299
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == -4142
|
266
300
|
end
|
267
301
|
|
268
302
|
it "should copy values only to another worksheet of another Excel instance" do
|
269
303
|
@range1.copy([4,2], @sheet3, :values_only => true)
|
270
304
|
@sheet3.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
271
|
-
@sheet3[4,2].Interior.ColorIndex.should == -4142
|
305
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == -4142
|
272
306
|
end
|
273
307
|
|
274
308
|
it "should copy and transpose with values only" do
|
275
309
|
@range1.copy([4,2], @sheet1, :values_only => true, :transpose => true)
|
276
310
|
@sheet1.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
277
|
-
@sheet1[4,2].Interior.ColorIndex.should == -4142
|
311
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == -4142
|
278
312
|
end
|
279
313
|
|
280
314
|
it "should copy and transpose with values only into another Excel instance" do
|
281
315
|
@range1.copy([4,2], @sheet3, :values_only => true, :transpose => true)
|
282
316
|
@sheet3.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
283
|
-
@sheet3[4,2].Interior.ColorIndex.should == -4142
|
317
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == -4142
|
284
318
|
end
|
285
319
|
|
286
320
|
it "should copy and transpose" do
|
287
321
|
@range1.copy([4,2], @sheet1, :transpose => true)
|
288
322
|
@sheet1.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
289
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
323
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
290
324
|
end
|
291
325
|
|
292
326
|
it "should copy and transpose into another Excel instance" do
|
293
327
|
@range1.copy([4,2], @sheet3, :transpose => true)
|
294
328
|
@sheet3.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
295
|
-
@sheet3[4,2].Interior.ColorIndex.should == 4
|
329
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == 4
|
296
330
|
end
|
297
331
|
end
|
298
332
|
|
@@ -302,7 +336,7 @@ describe RobustExcelOle::Range do
|
|
302
336
|
@book1 = Workbook.open(@dir + '/workbook.xls')
|
303
337
|
@sheet1 = @book1.sheet(1)
|
304
338
|
@range1 = @sheet1.range([1..2,1..3])
|
305
|
-
@sheet1[1,1].Interior.ColorIndex = 4
|
339
|
+
@sheet1.range([1,1]).Interior.ColorIndex = 4
|
306
340
|
@book2 = Workbook.open(@dir + '/different_workbook.xls')
|
307
341
|
@sheet2 = @book2.sheet(2)
|
308
342
|
@book3 = Workbook.open(@dir + '/another_workbook.xls', :force => {:excel => :new})
|
@@ -318,61 +352,61 @@ describe RobustExcelOle::Range do
|
|
318
352
|
it "should copy range" do
|
319
353
|
@range1.copy(4,2)
|
320
354
|
@sheet1.range(4..5,2..4).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
321
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
355
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
322
356
|
end
|
323
357
|
|
324
358
|
it "should copy range when giving an address" do
|
325
359
|
@range1.copy(4..5,2..4)
|
326
360
|
@sheet1.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
327
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
361
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
328
362
|
end
|
329
363
|
|
330
364
|
it "should copy range to another worksheet of another workbook" do
|
331
365
|
@range1.copy(4,2, @sheet2)
|
332
366
|
@sheet2.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
333
|
-
@sheet2[4,2].Interior.ColorIndex.should == 4
|
367
|
+
@sheet2.range([4,2]).Interior.ColorIndex.should == 4
|
334
368
|
end
|
335
369
|
|
336
370
|
it "should copy range to another worksheet of another workbook of another Excel instance" do
|
337
371
|
@range1.copy(4,2, @sheet3)
|
338
372
|
@sheet3.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
339
|
-
@sheet3[4,2].Interior.ColorIndex.should == 4
|
373
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == 4
|
340
374
|
end
|
341
375
|
|
342
376
|
it "should copy values only" do
|
343
377
|
@range1.copy(4,2, @sheet1, :values_only => true)
|
344
378
|
@sheet1.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
345
|
-
@sheet1[4,2].Interior.ColorIndex.should == -4142
|
379
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == -4142
|
346
380
|
end
|
347
381
|
|
348
382
|
it "should copy values only to another worksheet of another Excel instance" do
|
349
383
|
@range1.copy(4,2, @sheet3, :values_only => true)
|
350
384
|
@sheet3.range([4..5,2..4]).v.should == [["foo", "workbook", "sheet1"],["foo", nil, "foobaaa"]]
|
351
|
-
@sheet3[4,2].Interior.ColorIndex.should == -4142
|
385
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == -4142
|
352
386
|
end
|
353
387
|
|
354
388
|
it "should copy and transpose with values only" do
|
355
389
|
@range1.copy(4,2, @sheet1, :values_only => true, :transpose => true)
|
356
390
|
@sheet1.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
357
|
-
@sheet1[4,2].Interior.ColorIndex.should == -4142
|
391
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == -4142
|
358
392
|
end
|
359
393
|
|
360
394
|
it "should copy and transpose with values only into another Excel instance" do
|
361
395
|
@range1.copy(4,2, @sheet3, :values_only => true, :transpose => true)
|
362
396
|
@sheet3.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
363
|
-
@sheet3[4,2].Interior.ColorIndex.should == -4142
|
397
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == -4142
|
364
398
|
end
|
365
399
|
|
366
400
|
it "should copy and transpose" do
|
367
401
|
@range1.copy(4,2, @sheet1, :transpose => true)
|
368
402
|
@sheet1.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
369
|
-
@sheet1[4,2].Interior.ColorIndex.should == 4
|
403
|
+
@sheet1.range([4,2]).Interior.ColorIndex.should == 4
|
370
404
|
end
|
371
405
|
|
372
406
|
it "should copy and transpose into another Excel instance" do
|
373
407
|
@range1.copy(4,2, @sheet3, :transpose => true)
|
374
408
|
@sheet3.range([4..6,2..3]).v.should == [["foo", "foo"],["workbook", nil],["sheet1","foobaaa"]]
|
375
|
-
@sheet3[4,2].Interior.ColorIndex.should == 4
|
409
|
+
@sheet3.range([4,2]).Interior.ColorIndex.should == 4
|
376
410
|
end
|
377
411
|
|
378
412
|
end
|