roo 1.3.6 → 1.3.8
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.
- data/lib/roo.rb +1 -1
- data/lib/roo/excel.rb +34 -8
- data/lib/roo/version.rb +1 -1
- data/test/formula_parse_error.xls +0 -0
- data/test/test_roo.rb +12 -3
- metadata +4 -3
data/lib/roo.rb
CHANGED
data/lib/roo/excel.rb
CHANGED
@@ -12,16 +12,42 @@ end
|
|
12
12
|
module Spreadsheet
|
13
13
|
module Excel
|
14
14
|
class Row < Spreadsheet::Row
|
15
|
-
|
16
|
-
return data if data.is_a?(Date)
|
17
|
-
date = @worksheet.date_base + data.to_i
|
18
|
-
if LEAP_ERROR > @worksheet.date_base
|
19
|
-
date -= 1
|
20
|
-
end
|
21
|
-
date
|
22
|
-
end
|
15
|
+
public :_date
|
23
16
|
public :_datetime
|
24
17
|
end
|
18
|
+
# patch for ruby-spreadsheet parsing formulas
|
19
|
+
class Reader
|
20
|
+
def read_formula worksheet, addr, work
|
21
|
+
row, column, xf, rtype, rval, rcheck, opts = work.unpack 'v3CxCx3v2'
|
22
|
+
formula = Formula.new
|
23
|
+
formula.shared = (opts & 0x08) > 0
|
24
|
+
formula.data = work[20..-1]
|
25
|
+
if rcheck != 0xffff || rtype > 3
|
26
|
+
value, = work.unpack 'x6E'
|
27
|
+
unless value
|
28
|
+
# on architectures where sizeof(double) > 8
|
29
|
+
value, = work.unpack 'x6e'
|
30
|
+
end
|
31
|
+
formula.value = value
|
32
|
+
elsif rtype == 0
|
33
|
+
pos, op, len, work = get_next_chunk
|
34
|
+
if op == :string
|
35
|
+
formula.value = client read_string(work, 2), @workbook.encoding
|
36
|
+
else
|
37
|
+
# This seems to work but I don't know why :). It at least
|
38
|
+
# seems to correct the case we saw but doubtful it's the right fix
|
39
|
+
formula.value = client read_string(work[10..-1], 2), @workbook.encoding
|
40
|
+
end
|
41
|
+
elsif rtype == 1
|
42
|
+
formula.value = rval > 0
|
43
|
+
elsif rtype == 2
|
44
|
+
formula.value = Error.new rval
|
45
|
+
else
|
46
|
+
# leave the Formula value blank
|
47
|
+
end
|
48
|
+
set_cell worksheet, row, column, xf, formula
|
49
|
+
end
|
50
|
+
end
|
25
51
|
end
|
26
52
|
end
|
27
53
|
|
data/lib/roo/version.rb
CHANGED
Binary file
|
data/test/test_roo.rb
CHANGED
@@ -130,7 +130,7 @@ class TestRoo < Test::Unit::TestCase
|
|
130
130
|
|
131
131
|
OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
|
132
132
|
EXCEL = true # do Excel Tests?
|
133
|
-
GOOGLE =
|
133
|
+
GOOGLE = false # do Google-Spreadsheet Tests?
|
134
134
|
EXCELX = true # do Excel-X Tests? (.xlsx-files)
|
135
135
|
|
136
136
|
ONLINE = true
|
@@ -1756,18 +1756,27 @@ Sheet 3:
|
|
1756
1756
|
end
|
1757
1757
|
end
|
1758
1758
|
|
1759
|
+
|
1760
|
+
def test_ruby_spreadsheet_formula_bug
|
1761
|
+
with_each_spreadsheet(:name=>'formula_parse_error', :format=>:excel) do |oo|
|
1762
|
+
assert_equal '5026', oo.cell(2,3)
|
1763
|
+
assert_equal '5026', oo.cell(3,3)
|
1764
|
+
end
|
1765
|
+
end
|
1766
|
+
|
1767
|
+
|
1759
1768
|
# Excel has two base date formats one from 1900 and the other from 1904.
|
1760
1769
|
# There's a MS bug that 1900 base dates include an extra day due to erroneously
|
1761
1770
|
# including 1900 as a leap yar.
|
1762
1771
|
def test_base_dates_in_excel
|
1763
1772
|
with_each_spreadsheet(:name=>'1900_base', :format=>:excel) do |oo|
|
1764
1773
|
assert_equal Date.new(2009,06,15), oo.cell(1,1)
|
1765
|
-
assert_equal Date.new(
|
1774
|
+
assert_equal Date.new(2009,06,28), oo.cell(2,1) #formula for TODAY(), last calculated on 06.28
|
1766
1775
|
assert_equal :date, oo.celltype(1,1)
|
1767
1776
|
end
|
1768
1777
|
with_each_spreadsheet(:name=>'1904_base', :format=>:excel) do |oo|
|
1769
1778
|
assert_equal Date.new(2009,06,15), oo.cell(1,1)
|
1770
|
-
assert_equal Date.new(
|
1779
|
+
assert_equal Date.new(2009,06,28), oo.cell(2,1) #formula for TODAY(), last calculated on 06.28
|
1771
1780
|
assert_equal :date, oo.celltype(1,1)
|
1772
1781
|
end
|
1773
1782
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hugh McGowan
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-07-18 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 0.6.
|
24
|
+
version: 0.6.4
|
25
25
|
version:
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rubyzip
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- test/formula.ods
|
111
111
|
- test/formula.xls
|
112
112
|
- test/formula.xlsx
|
113
|
+
- test/formula_parse_error.xls
|
113
114
|
- test/html-escape.ods
|
114
115
|
- test/no_spreadsheet_file.txt
|
115
116
|
- test/numbers1.csv
|