roo 1.12.2 → 1.13.0
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 +7 -0
- data/CHANGELOG +14 -0
- data/VERSION +1 -1
- data/lib/roo/base.rb +1 -1
- data/lib/roo/csv.rb +2 -2
- data/lib/roo/excel.rb +8 -2
- data/lib/roo/excel2003xml.rb +1 -1
- data/lib/roo/excelx.rb +71 -35
- data/lib/roo/openoffice.rb +1 -1
- data/lib/roo/spreadsheet.rb +2 -2
- data/roo.gemspec +7 -5
- data/spec/lib/roo/spreadsheet_spec.rb +36 -2
- data/test/files/link.xls +0 -0
- data/test/files/link.xlsx +0 -0
- data/test/test_roo.rb +25 -0
- metadata +24 -37
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c041c89a52bab18a4a8c0f3ca606323c2a74dcf4
|
4
|
+
data.tar.gz: 73837bdf2ff5a36f18f70c0353f2535ca128c511
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 802f2af75523ef329aeaeca290702eba0d0a87f866e07db3ad75efcf1191f252e9f1a9856eb5580d93446e64b95f05143132fbace981e4b2e522af96df916547
|
7
|
+
data.tar.gz: 9d28e8f7980756a1a9f8f9f7a5c3c47af33aaf53f3bf0fda6ebacf951d19cccb0e79467619f458436b0e1d322b04ec93138d0eddceace90987c344a67a49dc52
|
data/CHANGELOG
CHANGED
@@ -1,7 +1,21 @@
|
|
1
|
+
== 1.13.0 2013-12-05
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Support extracting link data from Excel and Excelx spreadsheets,
|
5
|
+
via Excel#read_cell(_content) and Excelx#hyperlink(?). #47
|
6
|
+
* Support setting the Excel Spreadsheet mode via the :mode option. #88
|
7
|
+
* Support Spreadsheet.open with a declared :extension that includes a leading '.'. #73
|
8
|
+
* Enable file type detection for URI's with parameters / anchors. #51
|
9
|
+
|
10
|
+
* bugfixes
|
11
|
+
* Fix that CSV#each_row could overwrite the filename when run against a uri. #77
|
12
|
+
* Fix that #to_matrix wasn't respecting the sheet argument. #87
|
13
|
+
|
1
14
|
== 1.12.2 2013-09-11
|
2
15
|
|
3
16
|
* 1 enhancement
|
4
17
|
* Support rubyzip >= 1.0.0. #65
|
18
|
+
* Fix typo in deprecation notices. #63
|
5
19
|
|
6
20
|
== 1.12.1 2013-08-18
|
7
21
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.13.0
|
data/lib/roo/base.rb
CHANGED
@@ -208,7 +208,7 @@ class Roo::Base
|
|
208
208
|
|
209
209
|
Matrix.rows((from_row||first_row(sheet)).upto(to_row||last_row(sheet)).map do |row|
|
210
210
|
(from_column||first_column(sheet)).upto(to_column||last_column(sheet)).map do |col|
|
211
|
-
cell(row,col)
|
211
|
+
cell(row,col,sheet)
|
212
212
|
end
|
213
213
|
end)
|
214
214
|
end
|
data/lib/roo/csv.rb
CHANGED
@@ -60,8 +60,8 @@ class Roo::CSV < Roo::Base
|
|
60
60
|
def each_row(options, &block)
|
61
61
|
if uri?(filename)
|
62
62
|
make_tmpdir do |tmpdir|
|
63
|
-
|
64
|
-
CSV.foreach(
|
63
|
+
tmp_filename = download_uri(filename, tmpdir)
|
64
|
+
CSV.foreach(tmp_filename, options, &block)
|
65
65
|
end
|
66
66
|
else
|
67
67
|
CSV.foreach(filename, options, &block)
|
data/lib/roo/excel.rb
CHANGED
@@ -19,9 +19,11 @@ class Roo::Excel < Roo::Base
|
|
19
19
|
if Hash === options
|
20
20
|
packed = options[:packed]
|
21
21
|
file_warning = options[:file_warning] || :error
|
22
|
+
mode = options[:mode] || "rb+"
|
22
23
|
else
|
23
|
-
warn 'Supplying `packed` or `file_warning` as separate arguments to `Roo::Excel.new` is
|
24
|
+
warn 'Supplying `packed` or `file_warning` as separate arguments to `Roo::Excel.new` is deprecated. Use an options hash instead.'
|
24
25
|
packed = options
|
26
|
+
mode = "rb+"
|
25
27
|
file_warning = deprecated_file_warning
|
26
28
|
end
|
27
29
|
|
@@ -35,7 +37,7 @@ class Roo::Excel < Roo::Base
|
|
35
37
|
unless File.file?(@filename)
|
36
38
|
raise IOError, "file #{@filename} does not exist"
|
37
39
|
end
|
38
|
-
@workbook = Spreadsheet.open(filename)
|
40
|
+
@workbook = Spreadsheet.open(filename, mode)
|
39
41
|
end
|
40
42
|
super(filename, options)
|
41
43
|
@formula = Hash.new
|
@@ -274,6 +276,7 @@ class Roo::Excel < Roo::Base
|
|
274
276
|
# way formula stores the value
|
275
277
|
def read_cell_content(row, idx)
|
276
278
|
cell = row.at(idx)
|
279
|
+
cell = row[idx] if row[idx].class == Spreadsheet::Link
|
277
280
|
cell = cell.value if cell.class == Spreadsheet::Formula
|
278
281
|
cell
|
279
282
|
end
|
@@ -336,6 +339,9 @@ class Roo::Excel < Roo::Base
|
|
336
339
|
when Float, Integer, Fixnum, Bignum
|
337
340
|
value_type = :float
|
338
341
|
value = cell.to_f
|
342
|
+
when Spreadsheet::Link
|
343
|
+
value_type = :link
|
344
|
+
value = cell
|
339
345
|
when String, TrueClass, FalseClass
|
340
346
|
value_type = :string
|
341
347
|
value = cell.to_s
|
data/lib/roo/excel2003xml.rb
CHANGED
@@ -11,7 +11,7 @@ class Roo::Excel2003XML < Roo::Base
|
|
11
11
|
packed = options[:packed]
|
12
12
|
file_warning = options[:file_warning] || :error
|
13
13
|
else
|
14
|
-
warn 'Supplying `packed` or `file_warning` as separate arguments to `Roo::Excel2003XML.new` is
|
14
|
+
warn 'Supplying `packed` or `file_warning` as separate arguments to `Roo::Excel2003XML.new` is deprecated. Use an options hash instead.'
|
15
15
|
packed = options
|
16
16
|
file_warning = deprecated_file_warning
|
17
17
|
end
|
data/lib/roo/excelx.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'date'
|
2
2
|
require 'nokogiri'
|
3
|
+
require 'spreadsheet'
|
3
4
|
|
4
5
|
class Roo::Excelx < Roo::Base
|
5
6
|
module Format
|
@@ -70,7 +71,7 @@ class Roo::Excelx < Roo::Base
|
|
70
71
|
packed = options[:packed]
|
71
72
|
file_warning = options[:file_warning] || :error
|
72
73
|
else
|
73
|
-
warn 'Supplying `packed` or `file_warning` as separate arguments to `Roo::Excelx.new` is
|
74
|
+
warn 'Supplying `packed` or `file_warning` as separate arguments to `Roo::Excelx.new` is deprecated. Use an options hash instead.'
|
74
75
|
packed = options
|
75
76
|
file_warning = deprecated_file_warning
|
76
77
|
end
|
@@ -84,6 +85,7 @@ class Roo::Excelx < Roo::Base
|
|
84
85
|
raise IOError, "file #{@filename} does not exist"
|
85
86
|
end
|
86
87
|
@comments_files = Array.new
|
88
|
+
@rels_files = Array.new
|
87
89
|
extract_content(tmpdir, @filename)
|
88
90
|
@workbook_doc = load_xml(File.join(tmpdir, "roo_workbook.xml"))
|
89
91
|
@shared_table = []
|
@@ -103,6 +105,9 @@ class Roo::Excelx < Roo::Base
|
|
103
105
|
@comments_doc = @comments_files.compact.map do |item|
|
104
106
|
load_xml(item)
|
105
107
|
end
|
108
|
+
@rels_doc = @rels_files.map do |item|
|
109
|
+
load_xml(item)
|
110
|
+
end
|
106
111
|
end
|
107
112
|
super(filename, options)
|
108
113
|
@formula = Hash.new
|
@@ -111,6 +116,8 @@ class Roo::Excelx < Roo::Base
|
|
111
116
|
@s_attribute = Hash.new # TODO: ggf. wieder entfernen nur lokal benoetigt
|
112
117
|
@comment = Hash.new
|
113
118
|
@comments_read = Hash.new
|
119
|
+
@hyperlink = Hash.new
|
120
|
+
@hyperlinks_read = Hash.new
|
114
121
|
end
|
115
122
|
|
116
123
|
def method_missing(m,*args)
|
@@ -290,6 +297,20 @@ class Roo::Excelx < Roo::Base
|
|
290
297
|
end
|
291
298
|
end
|
292
299
|
|
300
|
+
def hyperlink?(row,col,sheet=nil)
|
301
|
+
hyperlink(row, col, sheet) != nil
|
302
|
+
end
|
303
|
+
|
304
|
+
# returns the hyperlink at (row/col)
|
305
|
+
# nil if there is no hyperlink
|
306
|
+
def hyperlink(row,col,sheet=nil)
|
307
|
+
sheet ||= @default_sheet
|
308
|
+
read_hyperlinks(sheet) unless @hyperlinks_read[sheet]
|
309
|
+
row,col = normalize(row,col)
|
310
|
+
return nil unless @hyperlink[sheet]
|
311
|
+
@hyperlink[sheet][[row,col]]
|
312
|
+
end
|
313
|
+
|
293
314
|
# returns the comment at (row/col)
|
294
315
|
# nil if there is no comment
|
295
316
|
def comment(row,col,sheet=nil)
|
@@ -354,6 +375,8 @@ class Roo::Excelx < Roo::Base
|
|
354
375
|
else
|
355
376
|
v
|
356
377
|
end
|
378
|
+
|
379
|
+
@cell[sheet][key] = Spreadsheet::Link.new(@hyperlink[sheet][key], @cell[sheet][key]) if hyperlink?(y,x+i)
|
357
380
|
@excelx_type[sheet] ||= {}
|
358
381
|
@excelx_type[sheet][key] = excelx_type
|
359
382
|
@excelx_value[sheet] ||= {}
|
@@ -509,6 +532,26 @@ Datei xl/comments1.xml
|
|
509
532
|
@comments_read[sheet] = true
|
510
533
|
end
|
511
534
|
|
535
|
+
# Reads all hyperlinks from a sheet
|
536
|
+
def read_hyperlinks(sheet=nil)
|
537
|
+
sheet ||= @default_sheet
|
538
|
+
validate_sheet!(sheet)
|
539
|
+
n = self.sheets.index(sheet)
|
540
|
+
if rels_doc = @rels_doc[n]
|
541
|
+
rels = Hash[rels_doc.xpath("/xmlns:Relationships/xmlns:Relationship").map do |r|
|
542
|
+
[r.attribute('Id').text, r]
|
543
|
+
end]
|
544
|
+
@sheet_doc[n].xpath("/xmlns:worksheet/xmlns:hyperlinks/xmlns:hyperlink").each do |h|
|
545
|
+
if rel_element = rels[h.attribute('id').text]
|
546
|
+
row,col = Roo::Base.split_coordinate(h.attributes['ref'].to_s)
|
547
|
+
@hyperlink[sheet] ||= {}
|
548
|
+
@hyperlink[sheet][[row,col]] = rel_element.attribute('Target').text
|
549
|
+
end
|
550
|
+
end
|
551
|
+
end
|
552
|
+
@hyperlinks_read[sheet] = true
|
553
|
+
end
|
554
|
+
|
512
555
|
def read_labels
|
513
556
|
@label ||= Hash[@workbook_doc.xpath("//xmlns:definedName").map do |defined_name|
|
514
557
|
# "Sheet1!$C$5"
|
@@ -523,43 +566,36 @@ Datei xl/comments1.xml
|
|
523
566
|
@sheet_files = []
|
524
567
|
Roo::ZipFile.open(zipfilename) {|zf|
|
525
568
|
zf.entries.each {|entry|
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
nr = $1
|
548
|
-
open(tmpdir+'/'+"roo_sheet#{nr}",'wb') {|f|
|
549
|
-
f << zip.read(entry)
|
550
|
-
}
|
551
|
-
@sheet_files[nr.to_i-1] = tmpdir+'/'+"roo_sheet#{nr}"
|
552
|
-
end
|
553
|
-
if entry.to_s.downcase =~ /comments([0-9]+).xml$/
|
554
|
-
nr = $1
|
555
|
-
open(tmpdir+'/'+"roo_comments#{nr}",'wb') {|f|
|
556
|
-
f << zip.read(entry)
|
557
|
-
}
|
558
|
-
@comments_files[nr.to_i-1] = tmpdir+'/'+"roo_comments#{nr}"
|
569
|
+
entry_name = entry.to_s.downcase
|
570
|
+
|
571
|
+
path =
|
572
|
+
if entry_name.end_with?('workbook.xml')
|
573
|
+
"#{tmpdir}/roo_workbook.xml"
|
574
|
+
elsif entry_name.end_with?('sharedstrings.xml')
|
575
|
+
"#{tmpdir}/roo_sharedStrings.xml"
|
576
|
+
elsif entry_name.end_with?('styles.xml')
|
577
|
+
"#{tmpdir}/roo_styles.xml"
|
578
|
+
elsif entry_name =~ /sheet([0-9]+).xml$/
|
579
|
+
nr = $1
|
580
|
+
@sheet_files[nr.to_i-1] = "#{tmpdir}/roo_sheet#{nr}"
|
581
|
+
elsif entry_name =~ /comments([0-9]+).xml$/
|
582
|
+
nr = $1
|
583
|
+
@comments_files[nr.to_i-1] = "#{tmpdir}/roo_comments#{nr}"
|
584
|
+
elsif entry_name =~ /sheet([0-9]+).xml.rels$/
|
585
|
+
nr = $1
|
586
|
+
@rels_files[nr.to_i-1] = "#{tmpdir}/roo_rels#{nr}"
|
587
|
+
end
|
588
|
+
if path
|
589
|
+
extract_file(zip, entry, path)
|
559
590
|
end
|
560
591
|
}
|
561
592
|
}
|
562
|
-
|
593
|
+
end
|
594
|
+
|
595
|
+
def extract_file(source_zip, entry, destination_path)
|
596
|
+
open(destination_path,'wb') {|f|
|
597
|
+
f << source_zip.read(entry)
|
598
|
+
}
|
563
599
|
end
|
564
600
|
|
565
601
|
# extract files from the zip file
|
data/lib/roo/openoffice.rb
CHANGED
@@ -36,7 +36,7 @@ class Roo::OpenOffice < Roo::Base
|
|
36
36
|
file_warning = options[:file_warning] || :error
|
37
37
|
tmpdir_root = options[:tmpdir_root]
|
38
38
|
else
|
39
|
-
warn 'Supplying `packed`, `file_warning`, or `tmpdir_root` as separate arguments to `Roo::OpenOffice.new` is
|
39
|
+
warn 'Supplying `packed`, `file_warning`, or `tmpdir_root` as separate arguments to `Roo::OpenOffice.new` is deprecated. Use an options hash instead.'
|
40
40
|
packed = options
|
41
41
|
file_warning = deprecated_file_warning
|
42
42
|
tmpdir_root = deprecated_tmpdir_root
|
data/lib/roo/spreadsheet.rb
CHANGED
@@ -7,9 +7,9 @@ module Roo
|
|
7
7
|
extension =
|
8
8
|
if options[:extension]
|
9
9
|
options[:file_warning] = :ignore
|
10
|
-
".#{options[:extension]}"
|
10
|
+
".#{options[:extension]}".gsub(/[.]+/, ".")
|
11
11
|
else
|
12
|
-
File.extname(file)
|
12
|
+
File.extname(URI.parse(file).path)
|
13
13
|
end
|
14
14
|
|
15
15
|
case extension.downcase
|
data/roo.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "roo"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.13.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Thomas Preymesser", "Hugh McGowan", "Ben Woosley"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-12-05"
|
13
13
|
s.description = "Roo can access the contents of various spreadsheet files. It can handle\n* OpenOffice\n* Excel\n* Google spreadsheets\n* Excelx\n* LibreOffice\n* CSV"
|
14
14
|
s.email = "ruby.ruby.ruby.roo@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -110,6 +110,8 @@ Gem::Specification.new do |s|
|
|
110
110
|
"test/files/formula_parse_error.xml",
|
111
111
|
"test/files/formula_string_error.xlsx",
|
112
112
|
"test/files/html-escape.ods",
|
113
|
+
"test/files/link.xls",
|
114
|
+
"test/files/link.xlsx",
|
113
115
|
"test/files/matrix.ods",
|
114
116
|
"test/files/matrix.xls",
|
115
117
|
"test/files/named_cells.ods",
|
@@ -173,12 +175,12 @@ Gem::Specification.new do |s|
|
|
173
175
|
s.licenses = ["MIT"]
|
174
176
|
s.require_paths = ["lib"]
|
175
177
|
s.required_ruby_version = Gem::Requirement.new(">= 1.9.0")
|
176
|
-
s.rubygems_version = "
|
178
|
+
s.rubygems_version = "2.0.14"
|
177
179
|
s.summary = "Roo can access the contents of various spreadsheet files."
|
178
|
-
s.test_files = ["spec/fixtures/vcr_cassettes/google_drive.yml", "spec/fixtures/vcr_cassettes/google_drive_access_token.yml", "spec/lib/roo/base_spec.rb", "spec/lib/roo/csv_spec.rb", "spec/lib/roo/excel2003xml_spec.rb", "spec/lib/roo/excel_spec.rb", "spec/lib/roo/excelx/format_spec.rb", "spec/lib/roo/excelx_spec.rb", "spec/lib/roo/google_spec.rb", "spec/lib/roo/libreoffice_spec.rb", "spec/lib/roo/openoffice_spec.rb", "spec/lib/roo/spreadsheet_spec.rb", "spec/spec_helper.rb", "test/all_ss.rb", "test/files/1900_base.xls", "test/files/1900_base.xlsx", "test/files/1904_base.xls", "test/files/1904_base.xlsx", "test/files/Bibelbund.csv", "test/files/Bibelbund.ods", "test/files/Bibelbund.xls", "test/files/Bibelbund.xlsx", "test/files/Bibelbund.xml", "test/files/Bibelbund1.ods", "test/files/Pfand_from_windows_phone.xlsx", "test/files/bad_excel_date.xls", "test/files/bbu.ods", "test/files/bbu.xls", "test/files/bbu.xlsx", "test/files/bbu.xml", "test/files/bode-v1.ods.zip", "test/files/bode-v1.xls.zip", "test/files/boolean.csv", "test/files/boolean.ods", "test/files/boolean.xls", "test/files/boolean.xlsx", "test/files/boolean.xml", "test/files/borders.ods", "test/files/borders.xls", "test/files/borders.xlsx", "test/files/borders.xml", "test/files/bug-numbered-sheet-names.xlsx", "test/files/bug-row-column-fixnum-float.xls", "test/files/bug-row-column-fixnum-float.xml", "test/files/comments.ods", "test/files/comments.xls", "test/files/comments.xlsx", "test/files/csvtypes.csv", "test/files/datetime.ods", "test/files/datetime.xls", "test/files/datetime.xlsx", "test/files/datetime.xml", "test/files/datetime_floatconv.xls", "test/files/datetime_floatconv.xml", "test/files/dreimalvier.ods", "test/files/emptysheets.ods", "test/files/emptysheets.xls", "test/files/emptysheets.xlsx", "test/files/emptysheets.xml", "test/files/excel2003.xml", "test/files/false_encoding.xls", "test/files/false_encoding.xml", "test/files/formula.ods", "test/files/formula.xls", "test/files/formula.xlsx", "test/files/formula.xml", "test/files/formula_parse_error.xls", "test/files/formula_parse_error.xml", "test/files/formula_string_error.xlsx", "test/files/html-escape.ods", "test/files/matrix.ods", "test/files/matrix.xls", "test/files/named_cells.ods", "test/files/named_cells.xls", "test/files/named_cells.xlsx", "test/files/no_spreadsheet_file.txt", "test/files/numbers1.csv", "test/files/numbers1.ods", "test/files/numbers1.xls", "test/files/numbers1.xlsx", "test/files/numbers1.xml", "test/files/only_one_sheet.ods", "test/files/only_one_sheet.xls", "test/files/only_one_sheet.xlsx", "test/files/only_one_sheet.xml", "test/files/paragraph.ods", "test/files/paragraph.xls", "test/files/paragraph.xlsx", "test/files/paragraph.xml", "test/files/prova.xls", "test/files/ric.ods", "test/files/simple_spreadsheet.ods", "test/files/simple_spreadsheet.xls", "test/files/simple_spreadsheet.xlsx", "test/files/simple_spreadsheet.xml", "test/files/simple_spreadsheet_from_italo.ods", "test/files/simple_spreadsheet_from_italo.xls", "test/files/simple_spreadsheet_from_italo.xml", "test/files/so_datetime.csv", "test/files/style.ods", "test/files/style.xls", "test/files/style.xlsx", "test/files/style.xml", "test/files/time-test.csv", "test/files/time-test.ods", "test/files/time-test.xls", "test/files/time-test.xlsx", "test/files/time-test.xml", "test/files/type_excel.ods", "test/files/type_excel.xlsx", "test/files/type_excelx.ods", "test/files/type_excelx.xls", "test/files/type_openoffice.xls", "test/files/type_openoffice.xlsx", "test/files/whitespace.ods", "test/files/whitespace.xls", "test/files/whitespace.xlsx", "test/files/whitespace.xml", "test/rm_sub_test.rb", "test/rm_test.rb", "test/test_generic_spreadsheet.rb", "test/test_helper.rb", "test/test_roo.rb"]
|
180
|
+
s.test_files = ["spec/fixtures/vcr_cassettes/google_drive.yml", "spec/fixtures/vcr_cassettes/google_drive_access_token.yml", "spec/lib/roo/base_spec.rb", "spec/lib/roo/csv_spec.rb", "spec/lib/roo/excel2003xml_spec.rb", "spec/lib/roo/excel_spec.rb", "spec/lib/roo/excelx/format_spec.rb", "spec/lib/roo/excelx_spec.rb", "spec/lib/roo/google_spec.rb", "spec/lib/roo/libreoffice_spec.rb", "spec/lib/roo/openoffice_spec.rb", "spec/lib/roo/spreadsheet_spec.rb", "spec/spec_helper.rb", "test/all_ss.rb", "test/files/1900_base.xls", "test/files/1900_base.xlsx", "test/files/1904_base.xls", "test/files/1904_base.xlsx", "test/files/Bibelbund.csv", "test/files/Bibelbund.ods", "test/files/Bibelbund.xls", "test/files/Bibelbund.xlsx", "test/files/Bibelbund.xml", "test/files/Bibelbund1.ods", "test/files/Pfand_from_windows_phone.xlsx", "test/files/bad_excel_date.xls", "test/files/bbu.ods", "test/files/bbu.xls", "test/files/bbu.xlsx", "test/files/bbu.xml", "test/files/bode-v1.ods.zip", "test/files/bode-v1.xls.zip", "test/files/boolean.csv", "test/files/boolean.ods", "test/files/boolean.xls", "test/files/boolean.xlsx", "test/files/boolean.xml", "test/files/borders.ods", "test/files/borders.xls", "test/files/borders.xlsx", "test/files/borders.xml", "test/files/bug-numbered-sheet-names.xlsx", "test/files/bug-row-column-fixnum-float.xls", "test/files/bug-row-column-fixnum-float.xml", "test/files/comments.ods", "test/files/comments.xls", "test/files/comments.xlsx", "test/files/csvtypes.csv", "test/files/datetime.ods", "test/files/datetime.xls", "test/files/datetime.xlsx", "test/files/datetime.xml", "test/files/datetime_floatconv.xls", "test/files/datetime_floatconv.xml", "test/files/dreimalvier.ods", "test/files/emptysheets.ods", "test/files/emptysheets.xls", "test/files/emptysheets.xlsx", "test/files/emptysheets.xml", "test/files/excel2003.xml", "test/files/false_encoding.xls", "test/files/false_encoding.xml", "test/files/formula.ods", "test/files/formula.xls", "test/files/formula.xlsx", "test/files/formula.xml", "test/files/formula_parse_error.xls", "test/files/formula_parse_error.xml", "test/files/formula_string_error.xlsx", "test/files/html-escape.ods", "test/files/link.xls", "test/files/link.xlsx", "test/files/matrix.ods", "test/files/matrix.xls", "test/files/named_cells.ods", "test/files/named_cells.xls", "test/files/named_cells.xlsx", "test/files/no_spreadsheet_file.txt", "test/files/numbers1.csv", "test/files/numbers1.ods", "test/files/numbers1.xls", "test/files/numbers1.xlsx", "test/files/numbers1.xml", "test/files/only_one_sheet.ods", "test/files/only_one_sheet.xls", "test/files/only_one_sheet.xlsx", "test/files/only_one_sheet.xml", "test/files/paragraph.ods", "test/files/paragraph.xls", "test/files/paragraph.xlsx", "test/files/paragraph.xml", "test/files/prova.xls", "test/files/ric.ods", "test/files/simple_spreadsheet.ods", "test/files/simple_spreadsheet.xls", "test/files/simple_spreadsheet.xlsx", "test/files/simple_spreadsheet.xml", "test/files/simple_spreadsheet_from_italo.ods", "test/files/simple_spreadsheet_from_italo.xls", "test/files/simple_spreadsheet_from_italo.xml", "test/files/so_datetime.csv", "test/files/style.ods", "test/files/style.xls", "test/files/style.xlsx", "test/files/style.xml", "test/files/time-test.csv", "test/files/time-test.ods", "test/files/time-test.xls", "test/files/time-test.xlsx", "test/files/time-test.xml", "test/files/type_excel.ods", "test/files/type_excel.xlsx", "test/files/type_excelx.ods", "test/files/type_excelx.xls", "test/files/type_openoffice.xls", "test/files/type_openoffice.xlsx", "test/files/whitespace.ods", "test/files/whitespace.xls", "test/files/whitespace.xlsx", "test/files/whitespace.xml", "test/rm_sub_test.rb", "test/rm_test.rb", "test/test_generic_spreadsheet.rb", "test/test_helper.rb", "test/test_roo.rb"]
|
179
181
|
|
180
182
|
if s.respond_to? :specification_version then
|
181
|
-
s.specification_version =
|
183
|
+
s.specification_version = 4
|
182
184
|
|
183
185
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
184
186
|
s.add_runtime_dependency(%q<spreadsheet>, ["> 0.6.4"])
|
@@ -6,21 +6,55 @@ describe Roo::Spreadsheet do
|
|
6
6
|
let(:filename) { 'file.XLS' }
|
7
7
|
|
8
8
|
it 'loads the proper type' do
|
9
|
-
Roo::Excel.
|
9
|
+
expect(Roo::Excel).to receive(:new).with(filename, {})
|
10
10
|
Roo::Spreadsheet.open(filename)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
context 'for a url' do
|
15
|
+
context 'that is csv' do
|
16
|
+
let(:filename) { 'http://example.com/file.csv?with=params#and=anchor' }
|
17
|
+
|
18
|
+
it 'treats the url as CSV' do
|
19
|
+
expect(Roo::CSV).to receive(:new).with(filename, {})
|
20
|
+
Roo::Spreadsheet.open(filename)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
14
25
|
context 'for a csv file' do
|
15
26
|
let(:filename) { 'file.csv' }
|
16
27
|
let(:options) { {csv_options: {col_sep: '"'}} }
|
17
28
|
|
18
29
|
context 'with options' do
|
19
30
|
it 'passes the options through' do
|
20
|
-
Roo::CSV.
|
31
|
+
expect(Roo::CSV).to receive(:new).with(filename, options)
|
32
|
+
Roo::Spreadsheet.open(filename, options)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when the file extension' do
|
38
|
+
let(:filename) { 'file.xls' }
|
39
|
+
|
40
|
+
context "is xls" do
|
41
|
+
let(:options) { { extension: "xls" } }
|
42
|
+
|
43
|
+
it 'loads with xls extension options' do
|
44
|
+
expect(Roo::Excel).to receive(:new).with(filename, options)
|
21
45
|
Roo::Spreadsheet.open(filename, options)
|
22
46
|
end
|
23
47
|
end
|
48
|
+
|
49
|
+
context "is .xls" do
|
50
|
+
let(:options) { { extension: ".xls" } }
|
51
|
+
|
52
|
+
it 'loads with .xls extension options' do
|
53
|
+
expect(Roo::Excel).to receive(:new).with(filename, options)
|
54
|
+
Roo::Spreadsheet.open(filename, options)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
24
58
|
end
|
25
59
|
end
|
26
60
|
end
|
data/test/files/link.xls
ADDED
Binary file
|
Binary file
|
data/test/test_roo.rb
CHANGED
@@ -1542,6 +1542,21 @@ Sheet 3:
|
|
1542
1542
|
end
|
1543
1543
|
end
|
1544
1544
|
|
1545
|
+
|
1546
|
+
def test_excel_links
|
1547
|
+
with_each_spreadsheet(:name=>'link', :format=>:excel) do |oo|
|
1548
|
+
assert_equal 'Google', oo.cell(1,1)
|
1549
|
+
assert_equal 'http://www.google.com', oo.cell(1,1).url
|
1550
|
+
end
|
1551
|
+
end
|
1552
|
+
|
1553
|
+
def test_excelx_links
|
1554
|
+
with_each_spreadsheet(:name=>'link', :format=>:excelx) do |oo|
|
1555
|
+
assert_equal 'Google', oo.cell(1,1)
|
1556
|
+
assert_equal 'http://www.google.com', oo.cell(1,1).url
|
1557
|
+
end
|
1558
|
+
end
|
1559
|
+
|
1545
1560
|
# Excel has two base date formats one from 1900 and the other from 1904.
|
1546
1561
|
# There's a MS bug that 1900 base dates include an extra day due to erroneously
|
1547
1562
|
# including 1900 as a leap yar.
|
@@ -1771,6 +1786,16 @@ Sheet 3:
|
|
1771
1786
|
end
|
1772
1787
|
end
|
1773
1788
|
|
1789
|
+
def test_matrix_specifying_sheet
|
1790
|
+
with_each_spreadsheet(:name => 'matrix', :format => [:openoffice, :excel, :google]) do |oo|
|
1791
|
+
oo.default_sheet = oo.sheets.first
|
1792
|
+
assert_equal Matrix[
|
1793
|
+
[1.0, nil, 3.0],
|
1794
|
+
[4.0, 5.0, 6.0],
|
1795
|
+
[7.0, 8.0, nil] ], oo.to_matrix(nil, nil, nil, nil, 'Sheet3')
|
1796
|
+
end
|
1797
|
+
end
|
1798
|
+
|
1774
1799
|
# unter Windows soll es laut Bug-Reports nicht moeglich sein, eine Excel-Datei, die
|
1775
1800
|
# mit Excel.new geoeffnet wurde nach dem Processing anschliessend zu loeschen.
|
1776
1801
|
# Anmerkung: Das Spreadsheet-Gem erlaubt kein explizites Close von Spreadsheet-Dateien,
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.13.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Thomas Preymesser
|
@@ -11,101 +10,86 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date: 2013-
|
13
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: spreadsheet
|
18
17
|
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
18
|
requirements:
|
21
|
-
- -
|
19
|
+
- - '>'
|
22
20
|
- !ruby/object:Gem::Version
|
23
21
|
version: 0.6.4
|
24
22
|
type: :runtime
|
25
23
|
prerelease: false
|
26
24
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
25
|
requirements:
|
29
|
-
- -
|
26
|
+
- - '>'
|
30
27
|
- !ruby/object:Gem::Version
|
31
28
|
version: 0.6.4
|
32
29
|
- !ruby/object:Gem::Dependency
|
33
30
|
name: nokogiri
|
34
31
|
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
32
|
requirements:
|
37
|
-
- -
|
33
|
+
- - '>='
|
38
34
|
- !ruby/object:Gem::Version
|
39
35
|
version: '0'
|
40
36
|
type: :runtime
|
41
37
|
prerelease: false
|
42
38
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
39
|
requirements:
|
45
|
-
- -
|
40
|
+
- - '>='
|
46
41
|
- !ruby/object:Gem::Version
|
47
42
|
version: '0'
|
48
43
|
- !ruby/object:Gem::Dependency
|
49
44
|
name: rubyzip
|
50
45
|
requirement: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
46
|
requirements:
|
53
|
-
- -
|
47
|
+
- - '>='
|
54
48
|
- !ruby/object:Gem::Version
|
55
49
|
version: '0'
|
56
50
|
type: :runtime
|
57
51
|
prerelease: false
|
58
52
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
53
|
requirements:
|
61
|
-
- -
|
54
|
+
- - '>='
|
62
55
|
- !ruby/object:Gem::Version
|
63
56
|
version: '0'
|
64
57
|
- !ruby/object:Gem::Dependency
|
65
58
|
name: google_drive
|
66
59
|
requirement: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
60
|
requirements:
|
69
|
-
- -
|
61
|
+
- - '>='
|
70
62
|
- !ruby/object:Gem::Version
|
71
63
|
version: '0'
|
72
64
|
type: :development
|
73
65
|
prerelease: false
|
74
66
|
version_requirements: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
67
|
requirements:
|
77
|
-
- -
|
68
|
+
- - '>='
|
78
69
|
- !ruby/object:Gem::Version
|
79
70
|
version: '0'
|
80
71
|
- !ruby/object:Gem::Dependency
|
81
72
|
name: jeweler
|
82
73
|
requirement: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
74
|
requirements:
|
85
|
-
- -
|
75
|
+
- - '>='
|
86
76
|
- !ruby/object:Gem::Version
|
87
77
|
version: '0'
|
88
78
|
type: :development
|
89
79
|
prerelease: false
|
90
80
|
version_requirements: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
81
|
requirements:
|
93
|
-
- -
|
82
|
+
- - '>='
|
94
83
|
- !ruby/object:Gem::Version
|
95
84
|
version: '0'
|
96
|
-
description:
|
97
|
-
|
85
|
+
description: |-
|
86
|
+
Roo can access the contents of various spreadsheet files. It can handle
|
98
87
|
* OpenOffice
|
99
|
-
|
100
88
|
* Excel
|
101
|
-
|
102
89
|
* Google spreadsheets
|
103
|
-
|
104
90
|
* Excelx
|
105
|
-
|
106
91
|
* LibreOffice
|
107
|
-
|
108
|
-
* CSV'
|
92
|
+
* CSV
|
109
93
|
email: ruby.ruby.ruby.roo@gmail.com
|
110
94
|
executables: []
|
111
95
|
extensions: []
|
@@ -206,6 +190,8 @@ files:
|
|
206
190
|
- test/files/formula_parse_error.xml
|
207
191
|
- test/files/formula_string_error.xlsx
|
208
192
|
- test/files/html-escape.ods
|
193
|
+
- test/files/link.xls
|
194
|
+
- test/files/link.xlsx
|
209
195
|
- test/files/matrix.ods
|
210
196
|
- test/files/matrix.xls
|
211
197
|
- test/files/named_cells.ods
|
@@ -267,27 +253,26 @@ files:
|
|
267
253
|
homepage: http://github.com/Empact/roo
|
268
254
|
licenses:
|
269
255
|
- MIT
|
256
|
+
metadata: {}
|
270
257
|
post_install_message:
|
271
258
|
rdoc_options: []
|
272
259
|
require_paths:
|
273
260
|
- lib
|
274
261
|
required_ruby_version: !ruby/object:Gem::Requirement
|
275
|
-
none: false
|
276
262
|
requirements:
|
277
|
-
- -
|
263
|
+
- - '>='
|
278
264
|
- !ruby/object:Gem::Version
|
279
265
|
version: 1.9.0
|
280
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
281
|
-
none: false
|
282
267
|
requirements:
|
283
|
-
- -
|
268
|
+
- - '>='
|
284
269
|
- !ruby/object:Gem::Version
|
285
270
|
version: '0'
|
286
271
|
requirements: []
|
287
272
|
rubyforge_project:
|
288
|
-
rubygems_version:
|
273
|
+
rubygems_version: 2.0.14
|
289
274
|
signing_key:
|
290
|
-
specification_version:
|
275
|
+
specification_version: 4
|
291
276
|
summary: Roo can access the contents of various spreadsheet files.
|
292
277
|
test_files:
|
293
278
|
- spec/fixtures/vcr_cassettes/google_drive.yml
|
@@ -360,6 +345,8 @@ test_files:
|
|
360
345
|
- test/files/formula_parse_error.xml
|
361
346
|
- test/files/formula_string_error.xlsx
|
362
347
|
- test/files/html-escape.ods
|
348
|
+
- test/files/link.xls
|
349
|
+
- test/files/link.xlsx
|
363
350
|
- test/files/matrix.ods
|
364
351
|
- test/files/matrix.xls
|
365
352
|
- test/files/named_cells.ods
|