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
data/spec/worksheet_spec.rb
CHANGED
@@ -295,6 +295,40 @@ describe Worksheet do
|
|
295
295
|
|
296
296
|
end
|
297
297
|
|
298
|
+
describe "#each_value" do
|
299
|
+
|
300
|
+
it "should yield arrays" do
|
301
|
+
@sheet.each_value do |row_value|
|
302
|
+
row_value.should be_kind_of Array
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should read the rows" do
|
307
|
+
i = 0
|
308
|
+
@sheet.each_value do |row_values|
|
309
|
+
case i
|
310
|
+
when 0
|
311
|
+
row_values.should == ['foo', 'workbook', 'sheet1']
|
312
|
+
when 1
|
313
|
+
row_values.should == ['foo', nil, 'foobaaa']
|
314
|
+
end
|
315
|
+
i += 1
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
it "should read the rows with index" do
|
320
|
+
@sheet.each_value_with_index do |row_values, i|
|
321
|
+
case i
|
322
|
+
when 0
|
323
|
+
row_values.should == ['foo', 'workbook', 'sheet1']
|
324
|
+
when 1
|
325
|
+
row_values.should == ['foo', nil, 'foobaaa']
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
end
|
331
|
+
|
298
332
|
describe "#each_row" do
|
299
333
|
it "items should RobustExcelOle::Range" do
|
300
334
|
@sheet.each_row do |rows|
|
@@ -627,8 +661,7 @@ describe Worksheet do
|
|
627
661
|
it "should color the cell" do
|
628
662
|
@sheet1.set_namevalue_glob("new", "bar")
|
629
663
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == -4142
|
630
|
-
@
|
631
|
-
@sheet1.set_namevalue_glob("new", "bar")
|
664
|
+
@sheet1.set_namevalue_glob("new", "bar", :color => 4)
|
632
665
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == 4
|
633
666
|
end
|
634
667
|
|
@@ -720,8 +753,7 @@ describe Worksheet do
|
|
720
753
|
it "should color the cell" do
|
721
754
|
@sheet1.set_namevalue("new", "bar")
|
722
755
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == -4142
|
723
|
-
@
|
724
|
-
@sheet1.set_namevalue("new", "bar")
|
756
|
+
@sheet1.set_namevalue("new", "bar", :color => 4)
|
725
757
|
@book1.Names.Item("new").RefersToRange.Interior.ColorIndex.should == 4
|
726
758
|
end
|
727
759
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: robust_excel_ole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.18'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- traths
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -34,7 +34,8 @@ description: "RobustExcelOle helps controlling Excel. \n This
|
|
34
34
|
email:
|
35
35
|
- Thomas.Raths@gmx.net
|
36
36
|
executables: []
|
37
|
-
extensions:
|
37
|
+
extensions:
|
38
|
+
- extconf.rb
|
38
39
|
extra_rdoc_files:
|
39
40
|
- README.rdoc
|
40
41
|
- LICENSE
|
@@ -49,11 +50,13 @@ files:
|
|
49
50
|
- README.rdoc
|
50
51
|
- Rakefile
|
51
52
|
- TodoList.md
|
53
|
+
- ___dummy_workbook.xls
|
52
54
|
- docs/README_excel.rdoc
|
53
55
|
- docs/README_open.rdoc
|
54
56
|
- docs/README_ranges.rdoc
|
55
57
|
- docs/README_save_close.rdoc
|
56
58
|
- docs/README_sheet.rdoc
|
59
|
+
- examples/example_ruby_library.rb
|
57
60
|
- examples/introductory_examples/example_introductory.rb
|
58
61
|
- examples/introductory_examples/example_open.rb
|
59
62
|
- examples/introductory_examples/example_range.rb
|
@@ -80,11 +83,13 @@ files:
|
|
80
83
|
- examples/open_save_close/example_reuse.rb
|
81
84
|
- examples/open_save_close/example_simple.rb
|
82
85
|
- examples/open_save_close/example_unobtrusively.rb
|
86
|
+
- extconf.rb
|
83
87
|
- jreo.bat
|
84
88
|
- lib/jreo_console.rb
|
85
89
|
- lib/reo_console.rb
|
86
90
|
- lib/robust_excel_ole.rb
|
87
|
-
- lib/robust_excel_ole/
|
91
|
+
- lib/robust_excel_ole/address_tool.rb
|
92
|
+
- lib/robust_excel_ole/base.rb
|
88
93
|
- lib/robust_excel_ole/bookstore.rb
|
89
94
|
- lib/robust_excel_ole/cell.rb
|
90
95
|
- lib/robust_excel_ole/cygwin.rb
|
@@ -92,16 +97,17 @@ files:
|
|
92
97
|
- lib/robust_excel_ole/general.rb
|
93
98
|
- lib/robust_excel_ole/range.rb
|
94
99
|
- lib/robust_excel_ole/range_owners.rb
|
95
|
-
- lib/robust_excel_ole/reo_common.rb
|
96
100
|
- lib/robust_excel_ole/robustexcelole.sublime-project
|
97
101
|
- lib/robust_excel_ole/robustexcelole.sublime-workspace
|
102
|
+
- lib/robust_excel_ole/vba_objects.rb
|
98
103
|
- lib/robust_excel_ole/version.rb
|
99
104
|
- lib/robust_excel_ole/workbook.rb
|
100
105
|
- lib/robust_excel_ole/worksheet.rb
|
101
106
|
- lib/spec_helper.rb
|
102
107
|
- reo.bat
|
103
108
|
- robust_excel_ole.gemspec
|
104
|
-
- spec/
|
109
|
+
- spec/address_tool_spec.rb
|
110
|
+
- spec/base_spec.rb
|
105
111
|
- spec/bookstore_spec.rb
|
106
112
|
- spec/cell_spec.rb
|
107
113
|
- spec/cygwin_spec.rb
|
@@ -125,7 +131,6 @@ files:
|
|
125
131
|
- spec/helpers/create_temporary_dir.rb
|
126
132
|
- spec/helpers/key_sender.rb
|
127
133
|
- spec/range_spec.rb
|
128
|
-
- spec/reo_common_spec.rb
|
129
134
|
- spec/spec_helper.rb
|
130
135
|
- spec/workbook_spec.rb
|
131
136
|
- spec/workbook_specs/workbook_all_spec.rb
|
data/spec/address_spec.rb
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), './spec_helper')
|
4
|
-
require File.expand_path( '../../lib/robust_excel_ole/reo_common', __FILE__)
|
5
|
-
|
6
|
-
$VERBOSE = nil
|
7
|
-
|
8
|
-
include General
|
9
|
-
include RobustExcelOle
|
10
|
-
|
11
|
-
module RobustExcelOle
|
12
|
-
|
13
|
-
describe Address 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
|
-
@book = Workbook.open(@simple_file)
|
23
|
-
end
|
24
|
-
|
25
|
-
after(:all) do
|
26
|
-
@book.close
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should transform relative r1c1-reference into r1c1-format" do
|
30
|
-
Address.r1c1("Z1S[2]:Z[-1]S4").should == "Z1S(2):Z(-1)S4"
|
31
|
-
Address.r1c1("Z[1]S2:Z3S[4]").should == "Z(1)S2:Z3S(4)"
|
32
|
-
Address.r1c1("Z1S[2]").should == "Z1S(2)"
|
33
|
-
Address.r1c1("Z[-1]S4").should == "Z(-1)S4"
|
34
|
-
Address.r1c1("Z[3]").should == "Z(3)"
|
35
|
-
Address.r1c1("S[-2]").should == "S(-2)"
|
36
|
-
end
|
37
|
-
|
38
|
-
# test for 1.8.6
|
39
|
-
it "should transform relative int_range-reference into r1c1-format" do
|
40
|
-
Address.r1c1([1..2,[3]..4]).should == "Z1S(3):Z2S4"
|
41
|
-
Address.r1c1([[1]..2,3..4]).should == "Z(1)S3:Z2S4"
|
42
|
-
Address.r1c1([[1]..2,nil]).should == "Z(1):Z2"
|
43
|
-
Address.r1c1([nil,[1]..2]).should == "S(1):S2"
|
44
|
-
Address.r1c1([nil,[1]]).should == "S(1):S(1)"
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should transform relative int_range-reference into r1c1-format" do
|
48
|
-
Address.r1c1([1..[-2],[3]..4]).should == "Z1S(3):Z(-2)S4"
|
49
|
-
Address.r1c1([[1]..2,3..[4]]).should == "Z(1)S3:Z2S(4)"
|
50
|
-
Address.r1c1([1..[-2],nil]).should == "Z1:Z(-2)"
|
51
|
-
Address.r1c1([nil,[-1]..2]).should == "S(-1):S2"
|
52
|
-
Address.r1c1([[3]..[3],nil]).should == "Z(3):Z(3)"
|
53
|
-
Address.r1c1([nil,[-2]..[-2]]).should == "S(-2):S(-2)"
|
54
|
-
Address.r1c1([[3],nil]).should == "Z(3):Z(3)"
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should transform relative r1c1-reference into r1c1-format" do
|
58
|
-
Address.int_range("Z1S[2]:Z[3]S4").should == [1..[3],[2]..4]
|
59
|
-
Address.int_range("Z[1]S2:Z3S[4]").should == [[1]..3,2..[4]]
|
60
|
-
Address.int_range("Z1S[2]").should == [1..1,[2]..[2]]
|
61
|
-
Address.int_range("Z[3]S4").should == [[3]..[3],4..4]
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should transform a1-format" do
|
65
|
-
Address.a1("A2").should == "A2"
|
66
|
-
Address.r1c1("A2").should == "Z2S1:Z2S1"
|
67
|
-
Address.int_range("A2").should == [2..2,1..1]
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should transform several-letter-a1-format" do
|
71
|
-
Address.a1("ABO15").should == "ABO15"
|
72
|
-
Address.r1c1("ABO15").should == "Z15S743:Z15S743"
|
73
|
-
Address.int_range("ABO15").should == [15..15,743..743]
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should transform complex a1-format" do
|
77
|
-
Address.a1("A2:B3").should == "A2:B3"
|
78
|
-
Address.r1c1("A2:B3").should == "Z2S1:Z3S2"
|
79
|
-
Address.int_range("A2:B3").should == [2..3,1..2]
|
80
|
-
Address.a1("S1:DP2").should == "S1:DP2"
|
81
|
-
Address.r1c1("S1:DP2").should == "Z1S19:Z2S120"
|
82
|
-
Address.int_range("S1:DP2").should == [1..2,19..120]
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should transform infinite a1-format" do
|
86
|
-
Address.a1("A:B").should == "A:B"
|
87
|
-
Address.r1c1("A:B").should == "S1:S2"
|
88
|
-
Address.int_range("A:B").should == [nil,1..2]
|
89
|
-
Address.a1("1:3").should == "1:3"
|
90
|
-
Address.r1c1("1:3").should == "Z1:Z3"
|
91
|
-
Address.int_range("1:3").should == [1..3,nil]
|
92
|
-
Address.a1("B").should == "B"
|
93
|
-
Address.r1c1("B").should == "S2:S2"
|
94
|
-
Address.int_range("B").should == [nil,2..2]
|
95
|
-
Address.a1("3").should == "3"
|
96
|
-
Address.r1c1("3").should == "Z3:Z3"
|
97
|
-
Address.int_range("3").should == [3..3,nil]
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should transform r1c1-format" do
|
101
|
-
Address.r1c1("Z2S1").should == "Z2S1"
|
102
|
-
Address.int_range("Z2S1").should == [2..2,1..1]
|
103
|
-
expect{
|
104
|
-
Address.a1("Z2S1")
|
105
|
-
}.to raise_error(NotImplementedREOError)
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should transform complex r1c1-format" do
|
109
|
-
Address.r1c1("Z2S1:Z3S2").should == "Z2S1:Z3S2"
|
110
|
-
Address.int_range("Z2S1:Z3S2").should == [2..3,1..2]
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should transform int_range format" do
|
114
|
-
Address.int_range([2..2,1..1]).should == [2..2,1..1]
|
115
|
-
Address.r1c1([2..2,1..1]).should == "Z2S1:Z2S1"
|
116
|
-
expect{
|
117
|
-
Address.a1([2..2,1..1])
|
118
|
-
}.to raise_error(NotImplementedREOError)
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should transform simple int_range format" do
|
122
|
-
Address.int_range([2,1]).should == [2..2,1..1]
|
123
|
-
Address.r1c1([2,1]).should == "Z2S1:Z2S1"
|
124
|
-
end
|
125
|
-
|
126
|
-
it "should transform complex int_range format" do
|
127
|
-
Address.int_range([2,"A"]).should == [2..2,1..1]
|
128
|
-
Address.r1c1([2,"A"]).should == "Z2S1:Z2S1"
|
129
|
-
Address.int_range([2,"A".."B"]).should == [2..2,1..2]
|
130
|
-
Address.r1c1([2,"A".."B"]).should == "Z2S1:Z2S2"
|
131
|
-
Address.int_range([1..2,"C"]).should == [1..2,3..3]
|
132
|
-
Address.r1c1([1..2,"C"]).should == "Z1S3:Z2S3"
|
133
|
-
Address.int_range([1..2,"C".."E"]).should == [1..2,3..5]
|
134
|
-
Address.r1c1([1..2,"C".."E"]).should == "Z1S3:Z2S5"
|
135
|
-
Address.int_range([2,3..5]).should == [2..2,3..5]
|
136
|
-
Address.r1c1([2,3..5]).should == "Z2S3:Z2S5"
|
137
|
-
Address.int_range([1..2,3..5]).should == [1..2,3..5]
|
138
|
-
Address.r1c1([1..2,3..5]).should == "Z1S3:Z2S5"
|
139
|
-
end
|
140
|
-
|
141
|
-
it "should transform infinite int_range format" do
|
142
|
-
Address.int_range([nil,1..2]).should == [nil,1..2]
|
143
|
-
Address.r1c1([nil,1..2]).should == "S1:S2"
|
144
|
-
Address.int_range([1..3,nil]).should == [1..3,nil]
|
145
|
-
Address.r1c1([1..3,nil]).should == "Z1:Z3"
|
146
|
-
Address.int_range([nil,2]).should == [nil,2..2]
|
147
|
-
Address.r1c1([nil,2]).should == "S2:S2"
|
148
|
-
Address.int_range([3,nil]).should == [3..3,nil]
|
149
|
-
Address.r1c1([3,nil]).should == "Z3:Z3"
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should raise an error" do
|
153
|
-
expect{
|
154
|
-
Address.a1("1A")
|
155
|
-
}.to raise_error(AddressInvalid, /format not correct/)
|
156
|
-
expect{
|
157
|
-
Address.r1c1("A1B")
|
158
|
-
}.to raise_error(AddressInvalid, /format not correct/)
|
159
|
-
#expect{
|
160
|
-
# Address.int_range(["A".."B","C".."D"])
|
161
|
-
#}.to raise_error(AddressInvalid, /format not correct/)
|
162
|
-
#expect{
|
163
|
-
# Address.int_range(["A".."B",1..2])
|
164
|
-
#}.to raise_error(AddressInvalid, /format not correct/)
|
165
|
-
#expect{
|
166
|
-
# Address.int_range(["A".."B",nil])
|
167
|
-
#}.to raise_error(AddressInvalid, /format not correct/)
|
168
|
-
expect{
|
169
|
-
Address.int_range(["A",1,2])
|
170
|
-
}.to raise_error(AddressInvalid, /more than two components/)
|
171
|
-
end
|
172
|
-
|
173
|
-
end
|
174
|
-
end
|