roo 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/lib/roo/base.rb +43 -19
- data/lib/roo/excelx.rb +390 -542
- data/lib/roo/excelx/cell.rb +77 -0
- data/lib/roo/excelx/comments.rb +9 -11
- data/lib/roo/excelx/extractor.rb +12 -10
- data/lib/roo/excelx/relationships.rb +13 -14
- data/lib/roo/excelx/shared_strings.rb +19 -22
- data/lib/roo/excelx/sheet.rb +107 -0
- data/lib/roo/excelx/sheet_doc.rb +98 -100
- data/lib/roo/excelx/styles.rb +42 -40
- data/lib/roo/excelx/workbook.rb +36 -36
- data/lib/roo/open_office.rb +4 -1
- data/lib/roo/version.rb +1 -1
- data/spec/lib/roo/excelx_spec.rb +36 -0
- data/spec/lib/roo/openoffice_spec.rb +11 -0
- data/test/test_generic_spreadsheet.rb +104 -78
- data/test/test_roo.rb +22 -1
- metadata +5 -4
- data/scripts/txt2html +0 -67
data/lib/roo/excelx/styles.rb
CHANGED
@@ -2,61 +2,63 @@ require 'roo/font'
|
|
2
2
|
require 'roo/excelx/extractor'
|
3
3
|
|
4
4
|
module Roo
|
5
|
-
class Excelx
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
class Excelx
|
6
|
+
class Styles < Excelx::Extractor
|
7
|
+
# convert internal excelx attribute to a format
|
8
|
+
def style_format(style)
|
9
|
+
id = num_fmt_ids[style.to_i]
|
10
|
+
num_fmts[id] || Excelx::Format::STANDARD_FORMATS[id.to_i]
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def definitions
|
14
|
+
@definitions ||= extract_definitions
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
private
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def num_fmt_ids
|
20
|
+
@num_fmt_ids ||= extract_num_fmt_ids
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
def num_fmts
|
24
|
+
@num_fmts ||= extract_num_fmts
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
def fonts
|
28
|
+
@fonts ||= extract_fonts
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
def extract_definitions
|
32
|
+
doc.xpath('//cellXfs').flat_map do |xfs|
|
33
|
+
xfs.children.map do |xf|
|
34
|
+
fonts[xf['fontId'].to_i]
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
36
|
-
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
def extract_fonts
|
40
|
+
doc.xpath('//fonts/font').map do |font_el|
|
41
|
+
Font.new.tap do |font|
|
42
|
+
font.bold = !font_el.xpath('./b').empty?
|
43
|
+
font.italic = !font_el.xpath('./i').empty?
|
44
|
+
font.underline = !font_el.xpath('./u').empty?
|
45
|
+
end
|
44
46
|
end
|
45
47
|
end
|
46
|
-
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
def extract_num_fmt_ids
|
50
|
+
doc.xpath('//cellXfs').flat_map do |xfs|
|
51
|
+
xfs.children.map do |xf|
|
52
|
+
xf['numFmtId']
|
53
|
+
end
|
52
54
|
end
|
53
55
|
end
|
54
|
-
end
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
def extract_num_fmts
|
58
|
+
Hash[doc.xpath('//numFmt').map do |num_fmt|
|
59
|
+
[num_fmt['numFmtId'], num_fmt['formatCode']]
|
60
|
+
end]
|
61
|
+
end
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
data/lib/roo/excelx/workbook.rb
CHANGED
@@ -1,59 +1,59 @@
|
|
1
1
|
require 'roo/excelx/extractor'
|
2
2
|
|
3
3
|
module Roo
|
4
|
-
class Excelx
|
5
|
-
class
|
6
|
-
|
4
|
+
class Excelx
|
5
|
+
class Workbook < Excelx::Extractor
|
6
|
+
class Label
|
7
|
+
attr_reader :sheet, :row, :col, :name
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
def initialize(name, sheet, row, col)
|
10
|
+
@name = name
|
11
|
+
@sheet = sheet
|
12
|
+
@row = row.to_i
|
13
|
+
@col = ::Roo::Utils.letter_to_number(col)
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def key
|
17
|
+
[@row, @col]
|
18
|
+
end
|
17
19
|
end
|
18
|
-
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
raise ArgumentError, 'missing required workbook file'
|
21
|
+
def initialize(path)
|
22
|
+
super
|
23
|
+
fail ArgumentError, 'missing required workbook file' unless doc_exists?
|
24
24
|
end
|
25
|
-
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
def sheets
|
27
|
+
doc.xpath('//sheet')
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
30
|
+
# aka labels
|
31
|
+
def defined_names
|
32
|
+
Hash[doc.xpath('//definedName').map do |defined_name|
|
33
|
+
# "Sheet1!$C$5"
|
34
|
+
sheet, coordinates = defined_name.text.split('!$', 2)
|
35
|
+
col, row = coordinates.split('$')
|
36
|
+
name = defined_name['name']
|
37
|
+
[name, Label.new(name, sheet, row, col)]
|
38
|
+
end]
|
39
|
+
end
|
41
40
|
|
42
|
-
|
43
|
-
|
41
|
+
def base_date
|
42
|
+
@base_date ||=
|
44
43
|
begin
|
45
44
|
# Default to 1900 (minus one day due to excel quirk) but use 1904 if
|
46
45
|
# it's set in the Workbook's workbookPr
|
47
46
|
# http://msdn.microsoft.com/en-us/library/ff530155(v=office.12).aspx
|
48
|
-
result = Date.new(1899,12,30) # default
|
49
|
-
doc.css(
|
50
|
-
if workbookPr[
|
51
|
-
result = Date.new(1904,01,01)
|
47
|
+
result = Date.new(1899, 12, 30) # default
|
48
|
+
doc.css('workbookPr[date1904]').each do |workbookPr|
|
49
|
+
if workbookPr['date1904'] =~ /true|1/i
|
50
|
+
result = Date.new(1904, 01, 01)
|
52
51
|
break
|
53
52
|
end
|
54
53
|
end
|
55
54
|
result
|
56
55
|
end
|
56
|
+
end
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
data/lib/roo/open_office.rb
CHANGED
@@ -13,7 +13,7 @@ class Roo::OpenOffice < Roo::Base
|
|
13
13
|
|
14
14
|
@only_visible_sheets = options[:only_visible_sheets]
|
15
15
|
file_type_check(filename,'.ods','an Roo::OpenOffice', file_warning, packed)
|
16
|
-
@tmpdir = make_tmpdir(
|
16
|
+
@tmpdir = make_tmpdir(File.basename(filename), options[:tmpdir_root])
|
17
17
|
@filename = local_filename(filename, @tmpdir, packed)
|
18
18
|
#TODO: @cells_read[:default] = false
|
19
19
|
Zip::File.open(@filename) do |zip_file|
|
@@ -38,6 +38,9 @@ class Roo::OpenOffice < Roo::Base
|
|
38
38
|
@font_style_definitions = Hash.new
|
39
39
|
@comment = Hash.new
|
40
40
|
@comments_read = Hash.new
|
41
|
+
rescue => e # clean up any temp files, but only if an error was raised
|
42
|
+
close
|
43
|
+
raise e
|
41
44
|
end
|
42
45
|
|
43
46
|
def method_missing(m,*args)
|
data/lib/roo/version.rb
CHANGED
data/spec/lib/roo/excelx_spec.rb
CHANGED
@@ -36,6 +36,15 @@ describe Roo::Excelx do
|
|
36
36
|
expect(Roo::Excelx.new(path, cell_max: 100)).to be_a(Roo::Excelx)
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
context 'file path is a Pathname' do
|
41
|
+
let(:path) { Pathname.new('test/files/file_item_error.xlsx') }
|
42
|
+
|
43
|
+
it 'creates an instance' do
|
44
|
+
expect(subject).to be_a(Roo::Excelx)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
39
48
|
end
|
40
49
|
|
41
50
|
describe '#cell' do
|
@@ -411,5 +420,32 @@ describe Roo::Excelx do
|
|
411
420
|
expect(index).to eq 4
|
412
421
|
end
|
413
422
|
end
|
423
|
+
|
424
|
+
context 'with offset option' do
|
425
|
+
let(:offset) { 3 }
|
426
|
+
|
427
|
+
it 'returns the expected result' do
|
428
|
+
index = 0
|
429
|
+
subject.each_row_streaming(offset: offset) do |row|
|
430
|
+
expect(row.map(&:value)).to eq expected_rows[index + offset]
|
431
|
+
index += 1
|
432
|
+
end
|
433
|
+
expect(index).to eq 11
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
context 'with offset and max_rows options' do
|
438
|
+
let(:offset) { 3 }
|
439
|
+
let(:max_rows) { 3 }
|
440
|
+
|
441
|
+
it 'returns the expected result' do
|
442
|
+
index = 0
|
443
|
+
subject.each_row_streaming(offset: offset, max_rows: max_rows) do |row|
|
444
|
+
expect(row.map(&:value)).to eq expected_rows[index + offset]
|
445
|
+
index += 1
|
446
|
+
end
|
447
|
+
expect(index).to eq 4
|
448
|
+
end
|
449
|
+
end
|
414
450
|
end
|
415
451
|
end
|
@@ -9,6 +9,17 @@ describe Roo::OpenOffice do
|
|
9
9
|
it 'creates an instance' do
|
10
10
|
expect(subject).to be_a(Roo::OpenOffice)
|
11
11
|
end
|
12
|
+
|
13
|
+
context 'file path is a Pathname' do
|
14
|
+
subject do
|
15
|
+
Roo::OpenOffice.new(Pathname.new('test/files/numbers1.ods'))
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'creates an instance' do
|
19
|
+
expect(subject).to be_a(Roo::OpenOffice)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
12
23
|
end
|
13
24
|
|
14
25
|
# OpenOffice is an alias of LibreOffice. See libreoffice_spec.
|
@@ -2,30 +2,29 @@
|
|
2
2
|
require File.dirname(__FILE__) + '/test_helper'
|
3
3
|
|
4
4
|
class TestBase < Minitest::Test
|
5
|
-
|
6
5
|
def setup
|
7
6
|
@klass = Class.new(Roo::Base) do
|
8
|
-
def initialize(filename='some_file')
|
7
|
+
def initialize(filename = 'some_file')
|
9
8
|
super
|
10
9
|
@filename = filename
|
11
10
|
end
|
12
11
|
|
13
|
-
def read_cells(sheet=nil)
|
12
|
+
def read_cells(sheet = nil)
|
14
13
|
@cells_read[sheet] = true
|
15
14
|
end
|
16
15
|
|
17
|
-
def cell(row, col, sheet=nil)
|
16
|
+
def cell(row, col, sheet = nil)
|
18
17
|
sheet ||= default_sheet
|
19
|
-
@cell[sheet][[row,col]]
|
18
|
+
@cell[sheet][[row, col]]
|
20
19
|
end
|
21
20
|
|
22
|
-
def celltype(row, col, sheet=nil)
|
21
|
+
def celltype(row, col, sheet = nil)
|
23
22
|
sheet ||= default_sheet
|
24
|
-
@cell_type[sheet][[row,col]]
|
23
|
+
@cell_type[sheet][[row, col]]
|
25
24
|
end
|
26
25
|
|
27
26
|
def sheets
|
28
|
-
['my_sheet','blank sheet']
|
27
|
+
['my_sheet', 'blank sheet']
|
29
28
|
end
|
30
29
|
end
|
31
30
|
@oo = @klass.new
|
@@ -33,37 +32,37 @@ class TestBase < Minitest::Test
|
|
33
32
|
end
|
34
33
|
|
35
34
|
context 'private method Roo::Base.uri?(filename)' do
|
36
|
-
should
|
35
|
+
should 'return true when passed a filename starts with http(s)://' do
|
37
36
|
assert_equal true, @oo.send(:uri?, 'http://example.com/')
|
38
37
|
assert_equal true, @oo.send(:uri?, 'https://example.com/')
|
39
38
|
end
|
40
39
|
|
41
|
-
should
|
40
|
+
should 'return false when passed a filename which does not start with http(s)://' do
|
42
41
|
assert_equal false, @oo.send(:uri?, 'example.com')
|
43
42
|
end
|
44
43
|
|
45
|
-
should
|
44
|
+
should 'return false when passed non-String object such as Tempfile' do
|
46
45
|
assert_equal false, @oo.send(:uri?, Tempfile.new('test'))
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
50
49
|
def test_setting_invalid_type_does_not_update_cell
|
51
|
-
@oo.set(1,1,1)
|
52
|
-
assert_raises(ArgumentError){@oo.set(1,1, :invalid_type)}
|
53
|
-
assert_equal 1, @oo.cell(1,1)
|
54
|
-
assert_equal :float, @oo.celltype(1,1)
|
50
|
+
@oo.set(1, 1, 1)
|
51
|
+
assert_raises(ArgumentError) { @oo.set(1, 1, :invalid_type) }
|
52
|
+
assert_equal 1, @oo.cell(1, 1)
|
53
|
+
assert_equal :float, @oo.celltype(1, 1)
|
55
54
|
end
|
56
55
|
|
57
56
|
def test_first_row
|
58
|
-
assert_equal 5
|
57
|
+
assert_equal 5, @oo.first_row
|
59
58
|
end
|
60
59
|
|
61
60
|
def test_last_row
|
62
|
-
assert_equal 16
|
61
|
+
assert_equal 16, @oo.last_row
|
63
62
|
end
|
64
63
|
|
65
64
|
def test_first_column
|
66
|
-
assert_equal 1
|
65
|
+
assert_equal 1, @oo.first_column
|
67
66
|
end
|
68
67
|
|
69
68
|
def test_first_column_as_letter
|
@@ -78,17 +77,16 @@ class TestBase < Minitest::Test
|
|
78
77
|
assert_equal 'G', @oo.last_column_as_letter
|
79
78
|
end
|
80
79
|
|
81
|
-
#TODO: inkonsequente Lieferung Fixnum/Float
|
82
80
|
def test_rows
|
83
|
-
assert_equal [41.0,42.0,43.0,44.0,45.0, nil, nil], @oo.row(12)
|
84
|
-
assert_equal [nil,
|
81
|
+
assert_equal [41.0, 42.0, 43.0, 44.0, 45.0, nil, nil], @oo.row(12)
|
82
|
+
assert_equal [nil, '"Hello world!"', 'dreiundvierzig', 'vierundvierzig', 'fuenfundvierzig', nil, nil], @oo.row(16)
|
85
83
|
end
|
86
84
|
|
87
85
|
def test_empty_eh
|
88
|
-
assert @oo.empty?(1,1)
|
89
|
-
assert !@oo.empty?(8,3)
|
90
|
-
assert @oo.empty?(
|
91
|
-
assert !@oo.empty?(
|
86
|
+
assert @oo.empty?(1, 1)
|
87
|
+
assert !@oo.empty?(8, 3)
|
88
|
+
assert @oo.empty?('A', 11)
|
89
|
+
assert !@oo.empty?('A', 12)
|
92
90
|
end
|
93
91
|
|
94
92
|
def test_reload
|
@@ -96,35 +94,43 @@ class TestBase < Minitest::Test
|
|
96
94
|
assert @oo.instance_variable_get(:@cell).empty?
|
97
95
|
end
|
98
96
|
|
97
|
+
def test_each
|
98
|
+
oo_each = @oo.each
|
99
|
+
assert_instance_of Enumerator, oo_each
|
100
|
+
assert_equal [nil, '"Hello world!"', 'dreiundvierzig', 'vierundvierzig', 'fuenfundvierzig', nil, nil], oo_each.to_a.last
|
101
|
+
end
|
102
|
+
|
99
103
|
def test_to_yaml
|
100
|
-
assert_equal "--- \n"+yaml_entry(5,1,
|
101
|
-
assert_equal "--- \n"+yaml_entry(8,3,
|
102
|
-
assert_equal "--- \n"+yaml_entry(12,3,
|
104
|
+
assert_equal "--- \n" + yaml_entry(5, 1, 'date', '1961-11-21'), @oo.to_yaml({}, 5, 1, 5, 1)
|
105
|
+
assert_equal "--- \n" + yaml_entry(8, 3, 'string', 'thisisc8'), @oo.to_yaml({}, 8, 3, 8, 3)
|
106
|
+
assert_equal "--- \n" + yaml_entry(12, 3, 'float', 43.0), @oo.to_yaml({}, 12, 3, 12, 3)
|
103
107
|
assert_equal \
|
104
|
-
"--- \n"+yaml_entry(12,3,
|
105
|
-
|
106
|
-
|
108
|
+
"--- \n" + yaml_entry(12, 3, 'float', 43.0) +
|
109
|
+
yaml_entry(12, 4, 'float', 44.0) +
|
110
|
+
yaml_entry(12, 5, 'float', 45.0), @oo.to_yaml({}, 12, 3, 12)
|
107
111
|
assert_equal \
|
108
|
-
"--- \n"+yaml_entry(12,3,
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
112
|
+
"--- \n" + yaml_entry(12, 3, 'float', 43.0) +
|
113
|
+
yaml_entry(12, 4, 'float', 44.0) +
|
114
|
+
yaml_entry(12, 5, 'float', 45.0) +
|
115
|
+
yaml_entry(15, 3, 'float', 43.0) +
|
116
|
+
yaml_entry(15, 4, 'float', 44.0) +
|
117
|
+
yaml_entry(15, 5, 'float', 45.0) +
|
118
|
+
yaml_entry(16, 3, 'string', 'dreiundvierzig') +
|
119
|
+
yaml_entry(16, 4, 'string', 'vierundvierzig') +
|
120
|
+
yaml_entry(16, 5, 'string', 'fuenfundvierzig'), @oo.to_yaml({}, 12, 3)
|
117
121
|
end
|
118
122
|
|
119
123
|
def test_to_csv
|
120
|
-
assert_equal expected_csv
|
124
|
+
assert_equal expected_csv, @oo.to_csv
|
121
125
|
end
|
122
126
|
|
123
127
|
def test_to_csv_with_separator
|
124
|
-
assert_equal expected_csv_with_semicolons
|
128
|
+
assert_equal expected_csv_with_semicolons, @oo.to_csv(nil, ';')
|
125
129
|
end
|
126
|
-
|
127
|
-
|
130
|
+
|
131
|
+
protected
|
132
|
+
|
133
|
+
def setup_test_sheet(workbook = nil)
|
128
134
|
workbook ||= @oo
|
129
135
|
set_sheet_values(workbook)
|
130
136
|
set_sheet_types(workbook)
|
@@ -133,68 +139,70 @@ protected
|
|
133
139
|
|
134
140
|
def set_sheet_values(workbook)
|
135
141
|
workbook.instance_variable_get(:@cell)[workbook.default_sheet] = {
|
136
|
-
[5,1] => Date.civil(1961,11,21).to_s,
|
142
|
+
[5, 1] => Date.civil(1961, 11, 21).to_s,
|
137
143
|
|
138
|
-
[8,3] =>
|
139
|
-
[8,7] =>
|
144
|
+
[8, 3] => 'thisisc8',
|
145
|
+
[8, 7] => 'thisisg8',
|
140
146
|
|
141
|
-
[12,1] => 41.0,
|
142
|
-
[12,2] => 42.0,
|
143
|
-
[12,3] => 43.0,
|
144
|
-
[12,4] => 44.0,
|
145
|
-
[12,5] => 45.0,
|
147
|
+
[12, 1] => 41.0,
|
148
|
+
[12, 2] => 42.0,
|
149
|
+
[12, 3] => 43.0,
|
150
|
+
[12, 4] => 44.0,
|
151
|
+
[12, 5] => 45.0,
|
146
152
|
|
147
|
-
[15,3] => 43.0,
|
148
|
-
[15,4] => 44.0,
|
149
|
-
[15,5] => 45.0,
|
153
|
+
[15, 3] => 43.0,
|
154
|
+
[15, 4] => 44.0,
|
155
|
+
[15, 5] => 45.0,
|
150
156
|
|
151
|
-
[16,
|
152
|
-
[16,
|
153
|
-
[16,
|
157
|
+
[16, 2] => '"Hello world!"',
|
158
|
+
[16, 3] => 'dreiundvierzig',
|
159
|
+
[16, 4] => 'vierundvierzig',
|
160
|
+
[16, 5] => 'fuenfundvierzig'
|
154
161
|
}
|
155
162
|
end
|
156
163
|
|
157
164
|
def set_sheet_types(workbook)
|
158
165
|
workbook.instance_variable_get(:@cell_type)[workbook.default_sheet] = {
|
159
|
-
[5,1] => :date,
|
166
|
+
[5, 1] => :date,
|
160
167
|
|
161
|
-
[8,3] => :string,
|
162
|
-
[8,7] => :string,
|
168
|
+
[8, 3] => :string,
|
169
|
+
[8, 7] => :string,
|
163
170
|
|
164
|
-
[12,1] => :float,
|
165
|
-
[12,2] => :float,
|
166
|
-
[12,3] => :float,
|
167
|
-
[12,4] => :float,
|
168
|
-
[12,5] => :float,
|
171
|
+
[12, 1] => :float,
|
172
|
+
[12, 2] => :float,
|
173
|
+
[12, 3] => :float,
|
174
|
+
[12, 4] => :float,
|
175
|
+
[12, 5] => :float,
|
169
176
|
|
170
|
-
[15,3] => :float,
|
171
|
-
[15,4] => :float,
|
172
|
-
[15,5] => :float,
|
177
|
+
[15, 3] => :float,
|
178
|
+
[15, 4] => :float,
|
179
|
+
[15, 5] => :float,
|
173
180
|
|
174
|
-
[16,
|
175
|
-
[16,
|
176
|
-
[16,
|
181
|
+
[16, 2] => :string,
|
182
|
+
[16, 3] => :string,
|
183
|
+
[16, 4] => :string,
|
184
|
+
[16, 5] => :string
|
177
185
|
}
|
178
186
|
end
|
179
187
|
|
180
188
|
def set_first_row(workbook)
|
181
189
|
row_hash = workbook.instance_variable_get(:@first_row)
|
182
|
-
row_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map{|k,
|
190
|
+
row_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map { |k, _v| k[0] }.min
|
183
191
|
end
|
184
192
|
|
185
193
|
def set_last_row(workbook)
|
186
194
|
row_hash = workbook.instance_variable_get(:@last_row)
|
187
|
-
row_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map{|k,
|
195
|
+
row_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map { |k, _v| k[0] }.max
|
188
196
|
end
|
189
197
|
|
190
198
|
def set_first_col(workbook)
|
191
199
|
col_hash = workbook.instance_variable_get(:@first_column)
|
192
|
-
col_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map{|k,
|
200
|
+
col_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map { |k, _v| k[1] }.min
|
193
201
|
end
|
194
202
|
|
195
203
|
def set_last_col(workbook)
|
196
204
|
col_hash = workbook.instance_variable_get(:@last_column)
|
197
|
-
col_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map{|k,
|
205
|
+
col_hash[workbook.default_sheet] = workbook.instance_variable_get(:@cell)[workbook.default_sheet].map { |k, _v| k[1] }.max
|
198
206
|
end
|
199
207
|
|
200
208
|
def set_cells_read(workbook)
|
@@ -203,9 +211,27 @@ protected
|
|
203
211
|
end
|
204
212
|
|
205
213
|
def expected_csv
|
206
|
-
|
214
|
+
<<EOS
|
215
|
+
,,,,,,
|
216
|
+
,,,,,,
|
217
|
+
,,,,,,
|
218
|
+
,,,,,,
|
219
|
+
1961-11-21,,,,,,
|
220
|
+
,,,,,,
|
221
|
+
,,,,,,
|
222
|
+
,,"thisisc8",,,,"thisisg8"
|
223
|
+
,,,,,,
|
224
|
+
,,,,,,
|
225
|
+
,,,,,,
|
226
|
+
41,42,43,44,45,,
|
227
|
+
,,,,,,
|
228
|
+
,,,,,,
|
229
|
+
,,43,44,45,,
|
230
|
+
,"""Hello world!""","dreiundvierzig","vierundvierzig","fuenfundvierzig",,
|
231
|
+
EOS
|
207
232
|
end
|
233
|
+
|
208
234
|
def expected_csv_with_semicolons
|
209
|
-
expected_csv.gsub
|
235
|
+
expected_csv.gsub(/\,/, ';')
|
210
236
|
end
|
211
237
|
end
|