mindreframer-creek 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.rdoc +76 -0
- data/Rakefile +7 -0
- data/creek.gemspec +30 -0
- data/lib/creek/book.rb +38 -0
- data/lib/creek/shared_strings.rb +44 -0
- data/lib/creek/sheet.rb +187 -0
- data/lib/creek/styles/constants.rb +44 -0
- data/lib/creek/styles/converter.rb +116 -0
- data/lib/creek/styles/style_types.rb +85 -0
- data/lib/creek/styles.rb +27 -0
- data/lib/creek/version.rb +3 -0
- data/lib/creek.rb +12 -0
- data/spec/fixtures/invalid.xls +0 -0
- data/spec/fixtures/sample-as-zip.zip +0 -0
- data/spec/fixtures/sample.xlsx +0 -0
- data/spec/fixtures/sheets/sheet1.xml +459 -0
- data/spec/fixtures/sst.xml +78 -0
- data/spec/fixtures/styles/first.xml +208 -0
- data/spec/fixtures/temp_string_io_file_path_with_no_extension +0 -0
- data/spec/shared_string_spec.rb +18 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/styles/converter_spec.rb +16 -0
- data/spec/styles/style_types_spec.rb +15 -0
- data/spec/test_spec.rb +99 -0
- metadata +168 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
2
|
+
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="6" uniqueCount="5">
|
3
|
+
<si>
|
4
|
+
<t>Cell A1</t>
|
5
|
+
</si>
|
6
|
+
<si>
|
7
|
+
<t>Cell B1</t>
|
8
|
+
</si>
|
9
|
+
<si>
|
10
|
+
<t>My Cell</t>
|
11
|
+
</si>
|
12
|
+
<si>
|
13
|
+
<r>
|
14
|
+
<rPr>
|
15
|
+
<sz val="11"/>
|
16
|
+
<color rgb="FFFF0000"/>
|
17
|
+
<rFont val="Calibri"/>
|
18
|
+
<family val="2"/>
|
19
|
+
<scheme val="minor"/>
|
20
|
+
</rPr>
|
21
|
+
<t>Cell</t>
|
22
|
+
</r>
|
23
|
+
<r>
|
24
|
+
<rPr>
|
25
|
+
<sz val="11"/>
|
26
|
+
<color theme="1"/>
|
27
|
+
<rFont val="Calibri"/>
|
28
|
+
<family val="2"/>
|
29
|
+
<scheme val="minor"/>
|
30
|
+
</rPr>
|
31
|
+
<t xml:space="preserve"> </t>
|
32
|
+
</r>
|
33
|
+
<r>
|
34
|
+
<rPr>
|
35
|
+
<b/>
|
36
|
+
<sz val="11"/>
|
37
|
+
<color theme="1"/>
|
38
|
+
<rFont val="Calibri"/>
|
39
|
+
<family val="2"/>
|
40
|
+
<scheme val="minor"/>
|
41
|
+
</rPr>
|
42
|
+
<t>A2</t>
|
43
|
+
</r>
|
44
|
+
</si>
|
45
|
+
<si>
|
46
|
+
<r>
|
47
|
+
<rPr>
|
48
|
+
<sz val="11"/>
|
49
|
+
<color rgb="FF00B0F0"/>
|
50
|
+
<rFont val="Calibri"/>
|
51
|
+
<family val="2"/>
|
52
|
+
<scheme val="minor"/>
|
53
|
+
</rPr>
|
54
|
+
<t>Cell</t>
|
55
|
+
</r>
|
56
|
+
<r>
|
57
|
+
<rPr>
|
58
|
+
<sz val="11"/>
|
59
|
+
<color theme="1"/>
|
60
|
+
<rFont val="Calibri"/>
|
61
|
+
<family val="2"/>
|
62
|
+
<scheme val="minor"/>
|
63
|
+
</rPr>
|
64
|
+
<t xml:space="preserve"> </t>
|
65
|
+
</r>
|
66
|
+
<r>
|
67
|
+
<rPr>
|
68
|
+
<i/>
|
69
|
+
<sz val="11"/>
|
70
|
+
<color theme="1"/>
|
71
|
+
<rFont val="Calibri"/>
|
72
|
+
<family val="2"/>
|
73
|
+
<scheme val="minor"/>
|
74
|
+
</rPr>
|
75
|
+
<t>B2</t>
|
76
|
+
</r>
|
77
|
+
</si>
|
78
|
+
</sst>
|
@@ -0,0 +1,208 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
2
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
3
|
+
<numFmts count="2">
|
4
|
+
<numFmt numFmtId="164" formatCode="GENERAL" />
|
5
|
+
<numFmt numFmtId="165" formatCode="MM/DD/YYYY" />
|
6
|
+
</numFmts>
|
7
|
+
<fonts count="6">
|
8
|
+
<font>
|
9
|
+
<sz val="11" />
|
10
|
+
<color rgb="FF000000" />
|
11
|
+
<name val="Calibri" />
|
12
|
+
<family val="2" />
|
13
|
+
<charset val="1" />
|
14
|
+
</font>
|
15
|
+
<font>
|
16
|
+
<sz val="10" />
|
17
|
+
<name val="Arial" />
|
18
|
+
<family val="0" />
|
19
|
+
</font>
|
20
|
+
<font>
|
21
|
+
<sz val="10" />
|
22
|
+
<name val="Arial" />
|
23
|
+
<family val="0" />
|
24
|
+
</font>
|
25
|
+
<font>
|
26
|
+
<sz val="10" />
|
27
|
+
<name val="Arial" />
|
28
|
+
<family val="0" />
|
29
|
+
</font>
|
30
|
+
<font><b val="true" />
|
31
|
+
<sz val="12" />
|
32
|
+
<color rgb="FFFFFFFF" />
|
33
|
+
<name val="Calibri" />
|
34
|
+
<family val="2" />
|
35
|
+
<charset val="1" />
|
36
|
+
</font>
|
37
|
+
<font><b val="true" />
|
38
|
+
<sz val="11" />
|
39
|
+
<color rgb="FF000000" />
|
40
|
+
<name val="Calibri" />
|
41
|
+
<family val="2" />
|
42
|
+
<charset val="1" />
|
43
|
+
</font>
|
44
|
+
</fonts>
|
45
|
+
<fills count="4">
|
46
|
+
<fill>
|
47
|
+
<patternFill patternType="none" />
|
48
|
+
</fill>
|
49
|
+
<fill>
|
50
|
+
<patternFill patternType="gray125" />
|
51
|
+
</fill>
|
52
|
+
<fill>
|
53
|
+
<patternFill patternType="solid">
|
54
|
+
<fgColor rgb="FF090948" />
|
55
|
+
<bgColor rgb="FF000080" />
|
56
|
+
</patternFill>
|
57
|
+
</fill>
|
58
|
+
<fill>
|
59
|
+
<patternFill patternType="solid">
|
60
|
+
<fgColor rgb="FFDCE6F2" />
|
61
|
+
<bgColor rgb="FFCCFFFF" />
|
62
|
+
</patternFill>
|
63
|
+
</fill>
|
64
|
+
</fills>
|
65
|
+
<borders count="2">
|
66
|
+
<border diagonalUp="false" diagonalDown="false">
|
67
|
+
<left/>
|
68
|
+
<right/>
|
69
|
+
<top/>
|
70
|
+
<bottom/>
|
71
|
+
<diagonal/>
|
72
|
+
</border>
|
73
|
+
<border diagonalUp="false" diagonalDown="false">
|
74
|
+
<left style="thin" />
|
75
|
+
<right style="thin" />
|
76
|
+
<top style="thin" />
|
77
|
+
<bottom style="thin" />
|
78
|
+
<diagonal/>
|
79
|
+
</border>
|
80
|
+
</borders>
|
81
|
+
<cellStyleXfs count="20">
|
82
|
+
<xf numFmtId="164" fontId="0" fillId="0" borderId="0" applyFont="true" applyBorder="true" applyAlignment="true" applyProtection="true">
|
83
|
+
<alignment horizontal="general" vertical="bottom" textRotation="0" wrapText="false" indent="0" shrinkToFit="false" />
|
84
|
+
<protection locked="true" hidden="false" />
|
85
|
+
</xf>
|
86
|
+
<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
87
|
+
<xf numFmtId="0" fontId="1" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
88
|
+
<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
89
|
+
<xf numFmtId="0" fontId="2" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
90
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
91
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
92
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
93
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
94
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
95
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
96
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
97
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
98
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
99
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
100
|
+
<xf numFmtId="43" fontId="1" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
101
|
+
<xf numFmtId="41" fontId="1" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
102
|
+
<xf numFmtId="44" fontId="1" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
103
|
+
<xf numFmtId="42" fontId="1" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
104
|
+
<xf numFmtId="9" fontId="1" fillId="0" borderId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false"></xf>
|
105
|
+
</cellStyleXfs>
|
106
|
+
<cellXfs count="8">
|
107
|
+
<xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyFont="false" applyBorder="false" applyAlignment="false" applyProtection="false">
|
108
|
+
<alignment horizontal="general" vertical="bottom" textRotation="0" wrapText="false" indent="0" shrinkToFit="false" />
|
109
|
+
<protection locked="true" hidden="false" />
|
110
|
+
</xf>
|
111
|
+
<xf numFmtId="164" fontId="4" fillId="2" borderId="1" xfId="0" applyFont="true" applyBorder="true" applyAlignment="true" applyProtection="false">
|
112
|
+
<alignment horizontal="center" vertical="bottom" textRotation="0" wrapText="false" indent="0" shrinkToFit="false" />
|
113
|
+
<protection locked="true" hidden="false" />
|
114
|
+
</xf>
|
115
|
+
<xf numFmtId="164" fontId="4" fillId="2" borderId="0" xfId="0" applyFont="true" applyBorder="true" applyAlignment="true" applyProtection="false">
|
116
|
+
<alignment horizontal="center" vertical="bottom" textRotation="0" wrapText="false" indent="0" shrinkToFit="false" />
|
117
|
+
<protection locked="true" hidden="false" />
|
118
|
+
</xf>
|
119
|
+
<xf numFmtId="165" fontId="4" fillId="2" borderId="0" xfId="0" applyFont="true" applyBorder="true" applyAlignment="true" applyProtection="false">
|
120
|
+
<alignment horizontal="center" vertical="bottom" textRotation="0" wrapText="false" indent="0" shrinkToFit="false" />
|
121
|
+
<protection locked="true" hidden="false" />
|
122
|
+
</xf>
|
123
|
+
<xf numFmtId="164" fontId="5" fillId="3" borderId="0" xfId="0" applyFont="true" applyBorder="true" applyAlignment="true" applyProtection="false">
|
124
|
+
<alignment horizontal="general" vertical="center" textRotation="0" wrapText="true" indent="0" shrinkToFit="false" />
|
125
|
+
<protection locked="true" hidden="false" />
|
126
|
+
</xf>
|
127
|
+
<xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyFont="true" applyBorder="true" applyAlignment="true" applyProtection="false">
|
128
|
+
<alignment horizontal="left" vertical="center" textRotation="0" wrapText="true" indent="0" shrinkToFit="false" />
|
129
|
+
<protection locked="true" hidden="false" />
|
130
|
+
</xf>
|
131
|
+
<xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyFont="true" applyBorder="false" applyAlignment="false" applyProtection="false">
|
132
|
+
<alignment horizontal="general" vertical="bottom" textRotation="0" wrapText="false" indent="0" shrinkToFit="false" />
|
133
|
+
<protection locked="true" hidden="false" />
|
134
|
+
</xf>
|
135
|
+
<xf numFmtId="164" fontId="0" fillId="0" borderId="0" xfId="0" applyFont="false" applyBorder="true" applyAlignment="false" applyProtection="false">
|
136
|
+
<alignment horizontal="general" vertical="bottom" textRotation="0" wrapText="false" indent="0" shrinkToFit="false" />
|
137
|
+
<protection locked="true" hidden="false" />
|
138
|
+
</xf>
|
139
|
+
</cellXfs>
|
140
|
+
<cellStyles count="6">
|
141
|
+
<cellStyle name="Normal" xfId="0" builtinId="0" customBuiltin="false" />
|
142
|
+
<cellStyle name="Comma" xfId="15" builtinId="3" customBuiltin="false" />
|
143
|
+
<cellStyle name="Comma [0]" xfId="16" builtinId="6" customBuiltin="false" />
|
144
|
+
<cellStyle name="Currency" xfId="17" builtinId="4" customBuiltin="false" />
|
145
|
+
<cellStyle name="Currency [0]" xfId="18" builtinId="7" customBuiltin="false" />
|
146
|
+
<cellStyle name="Percent" xfId="19" builtinId="5" customBuiltin="false" />
|
147
|
+
</cellStyles>
|
148
|
+
<colors>
|
149
|
+
<indexedColors>
|
150
|
+
<rgbColor rgb="FF000000" />
|
151
|
+
<rgbColor rgb="FFFFFFFF" />
|
152
|
+
<rgbColor rgb="FFFF0000" />
|
153
|
+
<rgbColor rgb="FF00FF00" />
|
154
|
+
<rgbColor rgb="FF0000FF" />
|
155
|
+
<rgbColor rgb="FFFFFF00" />
|
156
|
+
<rgbColor rgb="FFFF00FF" />
|
157
|
+
<rgbColor rgb="FF00FFFF" />
|
158
|
+
<rgbColor rgb="FF800000" />
|
159
|
+
<rgbColor rgb="FF008000" />
|
160
|
+
<rgbColor rgb="FF090948" />
|
161
|
+
<rgbColor rgb="FF808000" />
|
162
|
+
<rgbColor rgb="FF800080" />
|
163
|
+
<rgbColor rgb="FF008080" />
|
164
|
+
<rgbColor rgb="FFC0C0C0" />
|
165
|
+
<rgbColor rgb="FF808080" />
|
166
|
+
<rgbColor rgb="FF9999FF" />
|
167
|
+
<rgbColor rgb="FF993366" />
|
168
|
+
<rgbColor rgb="FFFFFFCC" />
|
169
|
+
<rgbColor rgb="FFDCE6F2" />
|
170
|
+
<rgbColor rgb="FF660066" />
|
171
|
+
<rgbColor rgb="FFFF8080" />
|
172
|
+
<rgbColor rgb="FF0066CC" />
|
173
|
+
<rgbColor rgb="FFCCCCFF" />
|
174
|
+
<rgbColor rgb="FF000080" />
|
175
|
+
<rgbColor rgb="FFFF00FF" />
|
176
|
+
<rgbColor rgb="FFFFFF00" />
|
177
|
+
<rgbColor rgb="FF00FFFF" />
|
178
|
+
<rgbColor rgb="FF800080" />
|
179
|
+
<rgbColor rgb="FF800000" />
|
180
|
+
<rgbColor rgb="FF008080" />
|
181
|
+
<rgbColor rgb="FF0000FF" />
|
182
|
+
<rgbColor rgb="FF00CCFF" />
|
183
|
+
<rgbColor rgb="FFCCFFFF" />
|
184
|
+
<rgbColor rgb="FFCCFFCC" />
|
185
|
+
<rgbColor rgb="FFFFFF99" />
|
186
|
+
<rgbColor rgb="FF99CCFF" />
|
187
|
+
<rgbColor rgb="FFFF99CC" />
|
188
|
+
<rgbColor rgb="FFCC99FF" />
|
189
|
+
<rgbColor rgb="FFFFCC99" />
|
190
|
+
<rgbColor rgb="FF3366FF" />
|
191
|
+
<rgbColor rgb="FF33CCCC" />
|
192
|
+
<rgbColor rgb="FF99CC00" />
|
193
|
+
<rgbColor rgb="FFFFCC00" />
|
194
|
+
<rgbColor rgb="FFFF9900" />
|
195
|
+
<rgbColor rgb="FFFF6600" />
|
196
|
+
<rgbColor rgb="FF666699" />
|
197
|
+
<rgbColor rgb="FF969696" />
|
198
|
+
<rgbColor rgb="FF003366" />
|
199
|
+
<rgbColor rgb="FF339966" />
|
200
|
+
<rgbColor rgb="FF003300" />
|
201
|
+
<rgbColor rgb="FF333300" />
|
202
|
+
<rgbColor rgb="FF993300" />
|
203
|
+
<rgbColor rgb="FF993366" />
|
204
|
+
<rgbColor rgb="FF333399" />
|
205
|
+
<rgbColor rgb="FF333333" />
|
206
|
+
</indexedColors>
|
207
|
+
</colors>
|
208
|
+
</styleSheet>
|
Binary file
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
|
3
|
+
describe 'shared strings' do
|
4
|
+
|
5
|
+
it 'parses rich text strings correctly' do
|
6
|
+
shared_strings_xml_file = File.open('spec/fixtures/sst.xml')
|
7
|
+
doc = Nokogiri::XML(shared_strings_xml_file)
|
8
|
+
dictionary = Creek::SharedStrings.parse_shared_string_from_document(doc)
|
9
|
+
|
10
|
+
dictionary.keys.size.should == 5
|
11
|
+
dictionary[0].should == 'Cell A1'
|
12
|
+
dictionary[1].should == 'Cell B1'
|
13
|
+
dictionary[2].should == 'My Cell'
|
14
|
+
dictionary[3].should == 'Cell A2'
|
15
|
+
dictionary[4].should == 'Cell B2'
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
|
3
|
+
describe Creek::Styles::Converter do
|
4
|
+
|
5
|
+
describe :call do
|
6
|
+
def convert(value, type, style)
|
7
|
+
Creek::Styles::Converter.call(value, type, style)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe :date_time do
|
11
|
+
it "works" do
|
12
|
+
convert('41275', 'n', :date_time).should == Date.new(2013,01,01)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
|
3
|
+
describe Creek::Styles::StyleTypes do
|
4
|
+
|
5
|
+
describe :call do
|
6
|
+
it "return array of styletypes with mapping to ruby types" do
|
7
|
+
xml_file = File.open('spec/fixtures/styles/first.xml')
|
8
|
+
doc = Nokogiri::XML(xml_file)
|
9
|
+
res = Creek::Styles::StyleTypes.new(doc).call
|
10
|
+
res.size.should == 8
|
11
|
+
res[3].should == :date_time
|
12
|
+
res.should == [:unsupported, :unsupported, :unsupported, :date_time, :unsupported, :unsupported, :unsupported, :unsupported]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/test_spec.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
require './spec/spec_helper'
|
2
|
+
|
3
|
+
describe 'Creek trying to parsing an invalid file.' do
|
4
|
+
it 'Fail to open a legacy xls file.' do
|
5
|
+
lambda { Creek::Book.new 'spec/fixtures/invalid.xls' }.should raise_error 'Not a valid file format.'
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'Ignore file extensions on request.' do
|
9
|
+
path = 'spec/fixtures/sample-as-zip.zip'
|
10
|
+
lambda { Creek::Book.new path, :check_file_extension => false }.should_not raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'Check file extension when requested.' do
|
14
|
+
open_book = lambda { Creek::Book.new 'spec/fixtures/invalid.xls', :check_file_extension => true }
|
15
|
+
open_book.should raise_error 'Not a valid file format.'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'Check file extension of original_filename if passed.' do
|
19
|
+
path = 'spec/fixtures/temp_string_io_file_path_with_no_extension'
|
20
|
+
lambda { Creek::Book.new path, :original_filename => 'invalid.xls' }.should raise_error 'Not a valid file format.'
|
21
|
+
lambda { Creek::Book.new path, :original_filename => 'valid.xlsx' }.should_not raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'Creek parsing a sample XLSX file' do
|
27
|
+
before(:all) do
|
28
|
+
@creek = Creek::Book.new 'spec/fixtures/sample.xlsx'
|
29
|
+
@expected_rows = [{'A1'=>'Content 1', 'B1'=>nil, 'C1'=>'Content 2', 'D1'=>nil, 'E1'=>'Content 3'},
|
30
|
+
{'A2'=>nil, 'B2'=>'Content 4', 'C2'=>nil, 'D2'=>'Content 5', 'E2'=>nil, 'F2'=>'Content 6'},
|
31
|
+
{},
|
32
|
+
{'A4'=>'Content 7', 'B4'=>'Content 8', 'C4'=>'Content 9', 'D4'=>'Content 10', 'E4'=>'Content 11', 'F4'=>'Content 12'},
|
33
|
+
{'A5'=>nil, 'B5'=>nil, 'C5'=>nil, 'D5'=>nil, 'E5'=>nil, 'F5'=>nil, 'G5'=>nil, 'H5'=>nil, 'I5'=>nil, 'J5'=>nil, 'K5'=>nil, 'L5'=>nil, 'M5'=>nil, 'N5'=>nil, 'O5'=>nil, 'P5'=>nil, 'Q5'=>nil, 'R5'=>nil, 'S5'=>nil, 'T5'=>nil, 'U5'=>nil, 'V5'=>nil, 'W5'=>nil, 'X5'=>nil, 'Y5'=>nil, 'Z5'=>'Z Content', 'AA5'=>nil, 'AB5'=>nil, 'AC5'=>nil, 'AD5'=>nil, 'AE5'=>nil, 'AF5'=>nil, 'AG5'=>nil, 'AH5'=>nil, 'AI5'=>nil, 'AJ5'=>nil, 'AK5'=>nil, 'AL5'=>nil, 'AM5'=>nil, 'AN5'=>nil, 'AO5'=>nil, 'AP5'=>nil, 'AQ5'=>nil, 'AR5'=>nil, 'AS5'=>nil, 'AT5'=>nil, 'AU5'=>nil, 'AV5'=>nil, 'AW5'=>nil, 'AX5'=>nil, 'AY5'=>nil, 'AZ5'=>'Content 13'},
|
34
|
+
{'A6'=>'1', 'B6'=>'2', 'C6'=>'3'}, {'A7'=>'Content 15', 'B7'=>'Content 16', 'C7'=>'Content 18', 'D7'=>'Content 19'},
|
35
|
+
{'A8'=>nil, 'B8'=>'Content 20', 'C8'=>nil, 'D8'=>nil, 'E8'=>nil, 'F8'=>'Content 21'}]
|
36
|
+
end
|
37
|
+
|
38
|
+
after(:all) do
|
39
|
+
@creek.close
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'open an XLSX file successfully.' do
|
43
|
+
@creek.should_not be_nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'find sheets successfully.' do
|
47
|
+
@creek.sheets.count.should == 1
|
48
|
+
sheet = @creek.sheets.first
|
49
|
+
sheet.state.should eql nil
|
50
|
+
sheet.name.should eql 'Sheet1'
|
51
|
+
sheet.rid.should eql 'rId1'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'Parse rows with empty cells successfully.' do
|
55
|
+
rows = Array.new
|
56
|
+
row_count = 0
|
57
|
+
@creek.sheets[0].rows.each do |row|
|
58
|
+
rows << row
|
59
|
+
row_count += 1
|
60
|
+
end
|
61
|
+
|
62
|
+
rows[0].should == @expected_rows[0]
|
63
|
+
rows[1].should == @expected_rows[1]
|
64
|
+
rows[2].should == @expected_rows[2]
|
65
|
+
rows[3].should == @expected_rows[3]
|
66
|
+
rows[4].should == @expected_rows[4]
|
67
|
+
rows[5].should == @expected_rows[5]
|
68
|
+
rows[6].should == @expected_rows[6]
|
69
|
+
rows[7].should == @expected_rows[7]
|
70
|
+
row_count.should == 8
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'Parse rows with empty cells and meta data successfully.' do
|
74
|
+
rows = Array.new
|
75
|
+
row_count = 0
|
76
|
+
@creek.sheets[0].rows_with_meta_data.each do |row|
|
77
|
+
rows << row
|
78
|
+
row_count += 1
|
79
|
+
end
|
80
|
+
rows.map{|r| r['cells']}.should == @expected_rows
|
81
|
+
end
|
82
|
+
|
83
|
+
describe 'row_array_generator' do
|
84
|
+
# @expected_rows = [{'A1'=>'Content 1', 'B1'=>nil, 'C1'=>'Content 2', 'D1'=>nil, 'E1'=>'Content 3'},
|
85
|
+
# {'A2'=>nil, 'B2'=>'Content 4', 'C2'=>nil, 'D2'=>'Content 5', 'E2'=>nil, 'F2'=>'Content 6'},
|
86
|
+
# {},
|
87
|
+
# {'A4'=>'Content 7', 'B4'=>'Content 8', 'C4'=>'Content 9', 'D4'=>'Content 10', 'E4'=>'Content 11', 'F4'=>'Content 12'},
|
88
|
+
# {'A5'=>nil, 'B5'=>nil, 'C5'=>nil, 'D5'=>nil, 'E5'=>nil, 'F5'=>nil, 'G5'=>nil, 'H5'=>nil, 'I5'=>nil, 'J5'=>nil, 'K5'=>nil, 'L5'=>nil, 'M5'=>nil, 'N5'=>nil, 'O5'=>nil, 'P5'=>nil, 'Q5'=>nil, 'R5'=>nil, 'S5'=>nil, 'T5'=>nil, 'U5'=>nil, 'V5'=>nil, 'W5'=>nil, 'X5'=>nil, 'Y5'=>nil, 'Z5'=>'Z Content', 'AA5'=>nil, 'AB5'=>nil, 'AC5'=>nil, 'AD5'=>nil, 'AE5'=>nil, 'AF5'=>nil, 'AG5'=>nil, 'AH5'=>nil, 'AI5'=>nil, 'AJ5'=>nil, 'AK5'=>nil, 'AL5'=>nil, 'AM5'=>nil, 'AN5'=>nil, 'AO5'=>nil, 'AP5'=>nil, 'AQ5'=>nil, 'AR5'=>nil, 'AS5'=>nil, 'AT5'=>nil, 'AU5'=>nil, 'AV5'=>nil, 'AW5'=>nil, 'AX5'=>nil, 'AY5'=>nil, 'AZ5'=>'Content 13'},
|
89
|
+
# {'A6'=>'1', 'B6'=>'2', 'C6'=>'3'}, {'A7'=>'Content 15', 'B7'=>'Content 16', 'C7'=>'Content 18', 'D7'=>'Content 19'},
|
90
|
+
# {'A8'=>nil, 'B8'=>'Content 20', 'C8'=>nil, 'D8'=>nil, 'E8'=>nil, 'F8'=>'Content 21'}]
|
91
|
+
it "returns array" do
|
92
|
+
rows = Array.new
|
93
|
+
@creek.sheets[0].rows_array.each do |row|
|
94
|
+
rows << row
|
95
|
+
end
|
96
|
+
rows.last.should == [nil, 'Content 20', nil, nil, nil, 'Content 21']
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|