workbook 0.1.6.1 → 0.1.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 Cell
69
- def number_format
70
- if !@value.is_a?(String)
71
- if @workbook.num_fmts_by_id
72
- num_fmt_id = xf_id()[:numFmtId]
73
- tmp_num_fmt = @workbook.num_fmts_by_id[num_fmt_id]
74
- return (tmp_num_fmt &&tmp_num_fmt[:attributes] && tmp_num_fmt[:attributes][:formatCode]) ? tmp_num_fmt[:attributes][:formatCode] : nil
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
- def fill_color
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.1'
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."
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 1
8
8
  - 6
9
- - 1
10
- version: 0.1.6.1
9
+ - 2
10
+ version: 0.1.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Maarten Brouwers