workbook 0.1.6.1 → 0.1.6.2
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/workbook/readers/xlsx_reader.rb +45 -14
- data/test/artifacts/native_xlsx.xlsx +0 -0
- data/test/test_readers_xlsx_reader.rb +1 -1
- data/workbook.gemspec +1 -1
- metadata +2 -2
@@ -62,20 +62,54 @@ module RubyXL
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
# end monkey patch submitted
|
65
|
-
|
66
|
-
# other monkey patch
|
67
65
|
module RubyXL
|
68
|
-
class
|
69
|
-
def
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
66
|
+
class Workbook
|
67
|
+
def num_fmts_by_id
|
68
|
+
return @num_fmts_hash unless @num_fmts_hash.nil?
|
69
|
+
@num_fmts_hash={1=>{:attributes=>{:formatCode=>'0'}},
|
70
|
+
2=>{:attributes=>{:formatCode=>'0.00'}},
|
71
|
+
3=>{:attributes=>{:formatCode=>'#, ##0'}},
|
72
|
+
4=>{:attributes=>{:formatCode=>'#, ##0.00'}},
|
73
|
+
5=>{:attributes=>{:formatCode=>'$#, ##0_);($#, ##0)'}},
|
74
|
+
6=>{:attributes=>{:formatCode=>'$#, ##0_);[Red]($#, ##0)'}},
|
75
|
+
7=>{:attributes=>{:formatCode=>'$#, ##0.00_);($#, ##0.00)'}},
|
76
|
+
8=>{:attributes=>{:formatCode=>'$#, ##0.00_);[Red]($#, ##0.00)'}},
|
77
|
+
9=>{:attributes=>{:formatCode=>'0%'}},
|
78
|
+
10=>{:attributes=>{:formatCode=>'0.00%'}},
|
79
|
+
11=>{:attributes=>{:formatCode=>'0.00E+00'}},
|
80
|
+
12=>{:attributes=>{:formatCode=>'# ?/?'}},
|
81
|
+
13=>{:attributes=>{:formatCode=>'# ??/??'}},
|
82
|
+
14=>{:attributes=>{:formatCode=>'m/d/yyyy'}},
|
83
|
+
15=>{:attributes=>{:formatCode=>'d-mmm-yy'}},
|
84
|
+
16=>{:attributes=>{:formatCode=>'d-mmm'}},
|
85
|
+
17=>{:attributes=>{:formatCode=>'mmm-yy'}},
|
86
|
+
18=>{:attributes=>{:formatCode=>'h:mm AM/PM'}},
|
87
|
+
19=>{:attributes=>{:formatCode=>'h:mm:ss AM/PM'}},
|
88
|
+
20=>{:attributes=>{:formatCode=>'h:mm'}},
|
89
|
+
21=>{:attributes=>{:formatCode=>'h:mm:ss'}},
|
90
|
+
22=>{:attributes=>{:formatCode=>'m/d/yyyy h:mm'}},
|
91
|
+
37=>{:attributes=>{:formatCode=>'#, ##0_);(#, ##0)'}},
|
92
|
+
38=>{:attributes=>{:formatCode=>'#, ##0_);[Red](#, ##0)'}},
|
93
|
+
39=>{:attributes=>{:formatCode=>'#, ##0.00_);(#, ##0.00)'}},
|
94
|
+
40=>{:attributes=>{:formatCode=>'#, ##0.00_);[Red](#, ##0.00)'}},
|
95
|
+
45=>{:attributes=>{:formatCode=>'mm:ss'}},
|
96
|
+
46=>{:attributes=>{:formatCode=>'[h]:mm:ss'}},
|
97
|
+
47=>{:attributes=>{:formatCode=>'mm:ss.0'}},
|
98
|
+
48=>{:attributes=>{:formatCode=>'##0.0E+0'}},
|
99
|
+
49=>{:attributes=>{:formatCode=>'@'}}}
|
100
|
+
if num_fmts and num_fmts[:numFmt]
|
101
|
+
num_fmts[:numFmt].each do |num_fmt|
|
102
|
+
@num_fmts_hash[num_fmt[:attributes][:numFmtId]]=num_fmt
|
75
103
|
end
|
76
104
|
end
|
105
|
+
return @num_fmts_hash
|
77
106
|
end
|
78
|
-
|
107
|
+
end
|
108
|
+
end
|
109
|
+
# other monkey patch
|
110
|
+
module RubyXL
|
111
|
+
class Cell
|
112
|
+
def number_format
|
79
113
|
if !@value.is_a?(String)
|
80
114
|
if @workbook.num_fmts_by_id
|
81
115
|
num_fmt_id = xf_id()[:numFmtId]
|
@@ -84,7 +118,6 @@ module RubyXL
|
|
84
118
|
end
|
85
119
|
end
|
86
120
|
end
|
87
|
-
|
88
121
|
end
|
89
122
|
end
|
90
123
|
# end of monkey patch
|
@@ -112,10 +145,8 @@ module Workbook
|
|
112
145
|
if cell.nil?
|
113
146
|
r[ci] = Workbook::Cell.new nil
|
114
147
|
else
|
115
|
-
r[ci] = Workbook::Cell.new cell.value
|
116
|
-
|
148
|
+
r[ci] = Workbook::Cell.new cell.value
|
117
149
|
r[ci].parse!
|
118
|
-
|
119
150
|
xls_format = cell.style_index
|
120
151
|
col_width = nil
|
121
152
|
|
Binary file
|
@@ -20,8 +20,8 @@ module Readers
|
|
20
20
|
|
21
21
|
assert_equal("Callnr.",w.sheet.table[0][:callnr].value)
|
22
22
|
assert_equal("2475617.00",w.sheet.table[3][:callnr].value)
|
23
|
-
assert_equal("2012-12-03T09:48:59+00:00",w.sheet.table[6][:datum_gemeld].value.to_s)
|
24
23
|
assert_equal("2012-12-03T12:30:00+00:00",w.sheet.table[7][:datum_gemeld].value.to_s)
|
24
|
+
assert_equal("2012-12-03T09:48:59+00:00",w.sheet.table[6][:datum_gemeld].value.to_s)
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
data/workbook.gemspec
CHANGED
@@ -5,7 +5,7 @@ require "workbook"
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'workbook'
|
7
7
|
s.rubyforge_project = 'workbook'
|
8
|
-
s.version = '0.1.6.
|
8
|
+
s.version = '0.1.6.2'
|
9
9
|
s.date = '2012-12-11'
|
10
10
|
s.summary = "Workbook is a datastructure to contain books of tables (an anlogy used in e.g. Excel)"
|
11
11
|
s.description = "Workbook contains workbooks, as in a table, contains rows, contains cells, reads/writes excels and csv's and tab separated, and offers basic diffing and sorting capabilities."
|