roo 1.3.8 → 1.3.9
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/excel.rb +55 -29
- data/lib/roo/version.rb +1 -1
- metadata +2 -2
data/lib/roo/excel.rb
CHANGED
@@ -12,42 +12,68 @@ end
|
|
12
12
|
module Spreadsheet
|
13
13
|
module Excel
|
14
14
|
class Row < Spreadsheet::Row
|
15
|
+
def _datetime data # :nodoc:
|
16
|
+
return data if data.is_a?(DateTime)
|
17
|
+
base = @worksheet.date_base
|
18
|
+
date = base + data.to_f
|
19
|
+
hour = (data % 1) * 24
|
20
|
+
min = (hour % 1) * 60
|
21
|
+
sec = ((min % 1) * 60).round
|
22
|
+
min = min.floor
|
23
|
+
hour = hour.floor
|
24
|
+
if sec > 59
|
25
|
+
sec = 0
|
26
|
+
min += 1
|
27
|
+
end
|
28
|
+
if min > 59
|
29
|
+
min = 0
|
30
|
+
hour += 1
|
31
|
+
end
|
32
|
+
if hour > 23
|
33
|
+
hour = 0
|
34
|
+
date += 1
|
35
|
+
end
|
36
|
+
if LEAP_ERROR > base
|
37
|
+
date -= 1
|
38
|
+
end
|
39
|
+
DateTime.new(date.year, date.month, date.day, hour, min, sec)
|
40
|
+
end
|
15
41
|
public :_date
|
16
42
|
public :_datetime
|
17
43
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
44
|
+
# patch for ruby-spreadsheet parsing formulas
|
45
|
+
class Reader
|
46
|
+
def read_formula worksheet, addr, work
|
47
|
+
row, column, xf, rtype, rval, rcheck, opts = work.unpack 'v3CxCx3v2'
|
48
|
+
formula = Formula.new
|
49
|
+
formula.shared = (opts & 0x08) > 0
|
50
|
+
formula.data = work[20..-1]
|
51
|
+
if rcheck != 0xffff || rtype > 3
|
52
|
+
value, = work.unpack 'x6E'
|
53
|
+
unless value
|
54
|
+
# on architectures where sizeof(double) > 8
|
55
|
+
value, = work.unpack 'x6e'
|
56
|
+
end
|
57
|
+
formula.value = value
|
58
|
+
elsif rtype == 0
|
59
|
+
pos, op, len, work = get_next_chunk
|
60
|
+
if op == :string
|
61
|
+
formula.value = client read_string(work, 2), @workbook.encoding
|
45
62
|
else
|
46
|
-
#
|
63
|
+
# This seems to work but I don't know why :). It at least
|
64
|
+
# seems to correct the case we saw but doubtful it's the right fix
|
65
|
+
formula.value = client read_string(work[10..-1], 2), @workbook.encoding
|
47
66
|
end
|
48
|
-
|
67
|
+
elsif rtype == 1
|
68
|
+
formula.value = rval > 0
|
69
|
+
elsif rtype == 2
|
70
|
+
formula.value = Error.new rval
|
71
|
+
else
|
72
|
+
# leave the Formula value blank
|
49
73
|
end
|
74
|
+
set_cell worksheet, row, column, xf, formula
|
50
75
|
end
|
76
|
+
end
|
51
77
|
end
|
52
78
|
end
|
53
79
|
|
data/lib/roo/version.rb
CHANGED
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.9
|
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-07-
|
13
|
+
date: 2009-07-23 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|