roo 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
+ == 1.1.0 2008-07-26
2
+ * 2 major enhancements
3
+ * Excel: speed improvements
4
+ * Changed the behaviour of reading files with the false type
5
+ * 2 bugfixex
6
+ * Excel: last_row in Excel class did not work properly under some circumstances
7
+ * all: fixed a bug in #to_xml if there is an empty sheet
1
8
  == 1.0.2 2008-07-04
2
9
  * 2 bugfixes
3
10
  * Excelx: fixed a bug when there are .xml.rels files in the XLSX archive
@@ -21,6 +21,7 @@ test/false_encoding.xls
21
21
  test/Bibelbund1.ods
22
22
  test/Bibelbund.ods
23
23
  test/Bibelbund.xls
24
+ test/Bibelbund.xlsx
24
25
  test/Bibelbund.csv
25
26
  test/bbu.xls
26
27
  test/bbu.xlsx
@@ -55,6 +56,8 @@ test/bode-v1.xls.zip
55
56
  test/bode-v1.ods.zip
56
57
  test/ric.ods
57
58
  test/bug-row-column-fixnum-float.xls
59
+ test/emptysheets.ods
60
+ test/emptysheets.xls
58
61
  website/index.html
59
62
  website/index.txt
60
63
  website/javascripts/rounded_corners_lite.inc.js
data/Rakefile CHANGED
@@ -106,8 +106,22 @@ end
106
106
  desc 'Generate and upload website files'
107
107
  task :website => [:website_generate, :website_upload]
108
108
 
109
+ #-- prey: BEGIN
110
+ require 'fileutils'
111
+ include FileUtils::Verbose
112
+ desc 'Test the local installation'
113
+ task :test_local_installation do
114
+ # gehe nach $GEM_PATH und starte dort rake test
115
+ # cd(ENV['GEM_PATH']+"roo-1.1.0") do
116
+ cd("/usr/lib/ruby/gems/1.8/gems/roo-1.1.0") do
117
+ sh %{sudo rake test}
118
+ end
119
+ puts 'local installation test done'
120
+ end
121
+ #-- prey: END
122
+
109
123
  desc 'Release the website and new gem version'
110
- task :deploy => [:check_log_params, :check_version, :website, :release ] do
124
+ task :deploy => [:check_log_params, :check_version, :test_local_installation, :website, :release ] do
111
125
  puts "Remember to create SVN tag:"
112
126
  puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
113
127
  "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
@@ -20,16 +20,20 @@ class Excel < GenericSpreadsheet
20
20
 
21
21
  # Creates a new Excel spreadsheet object.
22
22
  # Parameter packed: :zip - File is a zip-file
23
- def initialize(filename, packed = nil)
23
+ def initialize(filename, packed = nil, file_warning = :error)
24
+ super()
25
+ @file_warning = file_warning
24
26
  @tmpdir = "oo_"+$$.to_s
25
27
  unless File.exists?(@tmpdir)
26
28
  FileUtils::mkdir(@tmpdir)
27
29
  end
28
30
  filename = open_from_uri(filename) if filename[0,7] == "http://"
29
31
  filename = unzip(filename) if packed and packed == :zip
30
- if File.extname(filename) != ".xls"
31
- warn "are you sure, this is an excel file?"
32
- end
32
+ #if File.extname(filename).downcase != ".xls"
33
+ # warn "are you sure, this is an excel file?"
34
+ #end
35
+ #@file_warning = :error
36
+ file_type_check(filename,'.xls','an Excel')
33
37
  @filename = filename
34
38
  begin
35
39
  unless File.file?(@filename)
@@ -45,12 +49,16 @@ class Excel < GenericSpreadsheet
45
49
  #if ENV["roo_local"] != "thomas-p"
46
50
  ensure
47
51
  FileUtils::rm_r(@tmpdir)
48
- #end
52
+ #end
49
53
  end
54
+ @cell = Hash.new
55
+ @cell_type = Hash.new
56
+ @formula = Hash.new
50
57
  @first_row = Hash.new
51
58
  @last_row = Hash.new
52
59
  @first_column = Hash.new
53
60
  @last_column = Hash.new
61
+ @header_line = 1
54
62
  @cells_read = Hash.new
55
63
  end
56
64
 
@@ -68,18 +76,7 @@ class Excel < GenericSpreadsheet
68
76
  @workbook.worksheet(i).name
69
77
  )
70
78
  else
71
- # result << platform_specific_iconv(inject_null_characters(@workbook.worksheet(i).name))
72
79
  result << platform_specific_iconv(@workbook.worksheet(i).name)
73
- #case RUBY_PLATFORM.downcase
74
- #when /darwin/
75
- # result << Iconv.new('utf-8','utf-8').iconv(
76
- # @workbook.worksheet(i).name
77
- # )
78
- #else
79
- # result << Iconv.new('utf-8','unicode').iconv(
80
- # @workbook.worksheet(i).name
81
- # )
82
- #end # case
83
80
  end
84
81
  end
85
82
  return result
@@ -101,127 +98,31 @@ class Excel < GenericSpreadsheet
101
98
  # returns the content of a cell. The upper left corner is (1,1) or ('A',1)
102
99
  def cell(row,col,sheet=nil)
103
100
  sheet = @default_sheet unless sheet
101
+ read_cells(sheet) unless @cells_read[sheet]
104
102
  row,col = normalize(row,col)
105
- worksheet = @workbook.worksheet(sheet_no(sheet))
106
- skip = 0
107
- line = 1
108
- worksheet.each(skip) { |row_par| #TODO: nicht jedesmal durch alle Zeilen gehen, sonder aus interner Repraesentation holen?
109
- if line == row
110
- if row_par == nil
111
- return nil
112
- end
113
- cell = row_par.at(col-1)
114
- return nil unless cell
115
- case cell.type
116
- when :numeric then return cell.to_f
117
- when :text then return cell.to_s('utf-8')
118
- # when :date then return cell.date
119
- when :date
120
- if cell.to_s.to_f < 1.0
121
- f = cell.to_s.to_f*24.0*60.0*60.0
122
- secs = f.round
123
- h = (secs / 3600.0).floor
124
- secs = secs - 3600*h
125
- m = (secs / 60.0).floor
126
- secs = secs - 60*m
127
- s = secs
128
- return h*3600+m*60+s
129
- else
130
- return cell.date
131
- end
132
- else
133
- return nil # cell.to_s('utf-8')
134
- end
135
- end
136
- line += 1
137
- }
103
+ if celltype(row,col,sheet) == :date
104
+ yyyy,mm,dd = @cell[sheet]["#{row},#{col}"].split('-')
105
+ return Date.new(yyyy.to_i,mm.to_i,dd.to_i)
106
+ end
107
+ return @cell[sheet]["#{row},#{col}"]
138
108
  end
139
109
 
140
- # returns the type of a cell: :float, :string, :date, :time
110
+ # returns the type of a cell:
111
+ # * :float
112
+ # * :string,
113
+ # * :date
114
+ # * :percentage
115
+ # * :formula
116
+ # * :time
141
117
  def celltype(row,col,sheet=nil)
142
118
  sheet = @default_sheet unless sheet
119
+ read_cells(sheet) unless @cells_read[sheet]
143
120
  row,col = normalize(row,col)
144
-
145
- worksheet = @workbook.worksheet(sheet_no(sheet))
146
- skip = 0
147
- line = 1
148
- worksheet.each(skip) { |row_par|
149
- if line == row
150
- return nil unless row_par
151
- cell = row_par.at(col-1)
152
- return nil unless cell
153
- case cell.type
154
- when :numeric
155
- return :float
156
- when :text
157
- return :string
158
- when :date
159
- if cell.to_s.to_f < 1.0
160
- return :time
161
- else
162
- return :date
163
- end
164
- else
165
- return cell.type.to_sym
166
- end
167
- end
168
- line += 1
169
- }
170
- end
171
-
172
- # returns all values in this row as an array
173
- # row numbers are 1,2,3,... like in the spreadsheet
174
- def row(rownumber,sheet=nil)
175
- sheet = @default_sheet unless sheet
176
- worksheet = @workbook.worksheet(sheet_no(sheet))
177
- #therow = worksheet.row(rownumber-1)
178
- result = []
179
- worksheet.row(rownumber-1).each {|cell|
180
- if cell
181
- case cell.type
182
- when :numeric then result << cell.to_f
183
- when :text then result << cell.to_s('utf-8')
184
- when :date then result << cell.date
185
- else
186
- result << cell.to_s('utf-8')
187
- end
188
- else
189
- result << nil
190
- end
191
- }
192
- return result
193
- end
194
-
195
- # returns all values in this column as an array
196
- # column numbers are 1,2,3,... like in the spreadsheet
197
- def column(columnnumber,sheet=nil)
198
- if columnnumber.class == String
199
- columnnumber = Openoffice.letter_to_number(columnnumber)
121
+ if @formula[sheet]["#{row},#{col}"]
122
+ return :formula
123
+ else
124
+ @cell_type[sheet]["#{row},#{col}"]
200
125
  end
201
- sheet = @default_sheet unless sheet
202
- worksheet = @workbook.worksheet(sheet_no(sheet))
203
- skip = 0
204
- result = []
205
- worksheet.each(skip) { |row_par|
206
- if defined? row_par.at(columnnumber-1)
207
- cell = row_par.at(columnnumber-1)
208
- #if defined? cell = row_par.at(columnnumber-1)
209
- if cell
210
- case cell.type
211
- when :numeric then result << cell.to_f
212
- when :text then result << cell.to_s('utf-8')
213
- when :date then result << cell.date
214
- else
215
- result << cell.to_s('utf-8')
216
- end
217
- else
218
- result << nil
219
- end
220
- else
221
- result << nil
222
- end
223
- }
224
- result
225
126
  end
226
127
 
227
128
  # returns the first non empty column
@@ -304,7 +205,9 @@ class Excel < GenericSpreadsheet
304
205
  # parsexcel liefert (mir unverstaendlich) eine Zeile als letzte Zeile
305
206
  # zurueck, die aber leer ist. Deshalb Korrekturfunktion, die wirklich
306
207
  # die letzte nicht leere Zeile liefert.
307
- while empty_row? row(lr,sheet)
208
+ # 2008-07-23 meine Loesung funtionierte auch noch nicht unter allen
209
+ # Umstaenden row() == nil ergaenzt
210
+ while row(lr,sheet) == nil || empty_row?(row(lr,sheet))
308
211
  lr -= 1
309
212
  end
310
213
  end
@@ -332,9 +235,8 @@ class Excel < GenericSpreadsheet
332
235
 
333
236
  def empty_row?(row)
334
237
  content = false
335
- row.each {|elem|
238
+ row.compact.each {|elem|
336
239
  if elem != ''
337
- #if elem.class == String and elem.size > 0
338
240
  content = true
339
241
  end
340
242
  }
@@ -380,4 +282,82 @@ class Excel < GenericSpreadsheet
380
282
  result
381
283
  end
382
284
 
285
+ # helper function to set the internal representation of cells
286
+ def set_cell_values(sheet,x,y,i,v,vt,formula,tr,str_v)
287
+ key = "#{y},#{x+i}"
288
+ @cell_type[sheet] = {} unless @cell_type[sheet]
289
+ @cell_type[sheet][key] = vt
290
+ @formula[sheet] = {} unless @formula[sheet]
291
+ @formula[sheet][key] = formula if formula
292
+ @cell[sheet] = {} unless @cell[sheet]
293
+ case @cell_type[sheet][key]
294
+ when :float
295
+ @cell[sheet][key] = v.to_f
296
+ when :string
297
+ @cell[sheet][key] = str_v
298
+ when :date
299
+ @cell[sheet][key] = v
300
+ when :percentage
301
+ @cell[sheet][key] = v.to_f
302
+ when :time
303
+ @cell[sheet][key] = v
304
+ else
305
+ @cell[sheet][key] = v
306
+ end
307
+ end
308
+
309
+ # read all cells in the selected sheet
310
+ def read_cells(sheet=nil)
311
+ sheet = @default_sheet unless sheet
312
+ raise ArgumentError, "Error: sheet '#{sheet||'nil'}' not valid" if @default_sheet == nil and sheet==nil
313
+ raise RangeError unless self.sheets.include? sheet
314
+ worksheet = @workbook.worksheet(sheet_no(sheet))
315
+ skip = 0
316
+ x =1
317
+ y=1
318
+ i=0
319
+ worksheet.each(skip) { |row_par|
320
+ if row_par
321
+ x =1
322
+ row_par.each do # |void|
323
+ cell = row_par.at(x-1)
324
+ if cell
325
+ case cell.type
326
+ when :numeric
327
+ vt = :float
328
+ v = cell.to_f
329
+ when :text
330
+ vt = :string
331
+ str_v = cell.to_s('utf-8')
332
+ when :date
333
+ if cell.to_s.to_f < 1.0
334
+ vt = :time
335
+ f = cell.to_s.to_f*24.0*60.0*60.0
336
+ secs = f.round
337
+ h = (secs / 3600.0).floor
338
+ secs = secs - 3600*h
339
+ m = (secs / 60.0).floor
340
+ secs = secs - 60*m
341
+ s = secs
342
+ v = h*3600+m*60+s
343
+ else
344
+ vt = :date
345
+ v = cell.date
346
+ v = sprintf("%04d-%02d-%02d",v.year,v.month,v.day)
347
+ end
348
+ else
349
+ vt = cell.type.to_sym
350
+ v = nil
351
+ end # case
352
+ formula = tr = nil #TODO:???
353
+ set_cell_values(sheet,x,y,i,v,vt,formula,tr,str_v)
354
+ end # if cell
355
+ x += 1
356
+ end
357
+ end
358
+ y += 1
359
+ }
360
+ @cells_read[sheet] = true
361
+ end
362
+
383
363
  end
@@ -5,7 +5,7 @@ require 'fileutils'
5
5
  require 'zip/zipfilesystem'
6
6
  require 'date'
7
7
  #require 'base64'
8
- require 'logger'
8
+
9
9
  class String
10
10
  def end_with?(str)
11
11
  self[-str.length,str.length] == str
@@ -13,22 +13,24 @@ class String
13
13
  end
14
14
 
15
15
  class Excelx < GenericSpreadsheet
16
- #$log = Logger.new("excelx.log",5,100*1024)
17
- #$log.level = Logger::DEBUG
18
16
  @@nr = 0
19
17
 
20
18
  # initialization and opening of a spreadsheet file
21
19
  # values for packed: :zip
22
- def initialize(filename, packed=nil) #, create = false)
20
+ def initialize(filename, packed=nil, file_warning = :error) #, create = false)
21
+ super()
22
+ @file_warning = file_warning
23
23
  @tmpdir = "oo_"+$$.to_s
24
24
  unless File.exists?(@tmpdir)
25
25
  FileUtils::mkdir(@tmpdir)
26
26
  end
27
27
  filename = open_from_uri(filename) if filename[0,7] == "http://"
28
28
  filename = unzip(filename) if packed and packed == :zip
29
- if File.extname(filename) != ".xlsx"
30
- warn "are you sure, this is an Excel-xlsx file?"
31
- end
29
+ #if File.extname(filename).downcase != ".xlsx"
30
+ # warn "are you sure, this is an Excel-xlsx file?"
31
+ #end
32
+ #@file_warning = :error
33
+ file_type_check(filename,'.xlsx','an Excel-xlsx')
32
34
  @cells_read = Hash.new
33
35
  @filename = filename
34
36
  begin
@@ -72,6 +74,7 @@ class Excelx < GenericSpreadsheet
72
74
  @first_column = Hash.new
73
75
  @last_column = Hash.new
74
76
  @header_line = 1
77
+ @excelx_type = Hash.new
75
78
  end
76
79
 
77
80
  # Returns the content of a spreadsheet-cell.
@@ -106,7 +109,7 @@ class Excelx < GenericSpreadsheet
106
109
  # true, if there is a formula
107
110
  def formula?(row,col,sheet=nil)
108
111
  sheet = @default_sheet unless sheet
109
- read_cells unless @cells_read[sheet]
112
+ read_cells(sheet) unless @cells_read[sheet]
110
113
  row,col = normalize(row,col)
111
114
  formula(row,col) != nil
112
115
  end
@@ -134,17 +137,30 @@ class Excelx < GenericSpreadsheet
134
137
  # * :string,
135
138
  # * :date
136
139
  # * :percentage
140
+ # * :formula
141
+ # * :time
137
142
  def celltype(row,col,sheet=nil)
138
143
  sheet = @default_sheet unless sheet
139
144
  read_cells(sheet) unless @cells_read[sheet]
140
145
  row,col = normalize(row,col)
141
- if @formula and @formula[sheet] and @formula[sheet]["#{row},#{col}"]
146
+ # if @formula and @formula[sheet] and @formula[sheet]["#{row},#{col}"]
147
+ if @formula[sheet]["#{row},#{col}"]
142
148
  return :formula
143
149
  else
144
150
  @cell_type[sheet]["#{row},#{col}"]
145
151
  end
146
152
  end
147
153
 
154
+ # returns the internal type of a excel cell
155
+ # * :numeric_or_formula
156
+ # * :string
157
+ def excelx_type(row,col,sheet=nil)
158
+ sheet = @default_sheet unless sheet
159
+ read_cells(sheet) unless @cells_read[sheet]
160
+ row,col = normalize(row,col)
161
+ :numeric_or_formula
162
+ end
163
+
148
164
  # returns an array of sheet names in the spreadsheet
149
165
  def sheets
150
166
  return_sheets = []
@@ -168,43 +184,6 @@ class Excelx < GenericSpreadsheet
168
184
  @cell[sheet].inspect
169
185
  end
170
186
 
171
- # returns all values in this row as an array
172
- # row numbers are 1,2,3,... like in the spreadsheet
173
- def row(rownumber,sheet=nil)
174
- sheet = @default_sheet unless sheet
175
- read_cells(sheet) unless @cells_read[sheet]
176
- result = []
177
- tmp_arr = []
178
- @cell[sheet].each_pair {|key,value|
179
- y,x = key.split(',')
180
- x = x.to_i
181
- y = y.to_i
182
- if y == rownumber
183
- tmp_arr[x] = value
184
- end
185
- }
186
- result = tmp_arr[1..-1]
187
- while result[-1] == nil
188
- result = result[0..-2]
189
- end
190
- result
191
- end
192
-
193
- # returns all values in this column as an array
194
- # column numbers are 1,2,3,... like in the spreadsheet
195
- def column(columnnumber,sheet=nil)
196
- if columnnumber.class == String
197
- columnnumber = GenericSpreadsheet.letter_to_number(columnnumber)
198
- end
199
- sheet = @default_sheet unless sheet
200
- read_cells(sheet) unless @cells_read[sheet]
201
- result = []
202
- first_row(sheet).upto(last_row(sheet)) do |row|
203
- result << cell(row,columnnumber,sheet)
204
- end
205
- result
206
- end
207
-
208
187
  # returns each formula in the selected sheet as an array of elements
209
188
  # [row, col, formula]
210
189
  def formulas(sheet=nil)
@@ -225,7 +204,7 @@ class Excelx < GenericSpreadsheet
225
204
  private
226
205
 
227
206
  # helper function to set the internal representation of cells
228
- def set_cell_values(sheet,x,y,i,v,vt,formula,tr,str_v)
207
+ def set_cell_values(sheet,x,y,i,v,vt,formula,tr,str_v,excelx_type=nil)
229
208
  key = "#{y},#{x+i}"
230
209
  @cell_type[sheet] = {} unless @cell_type[sheet]
231
210
  @cell_type[sheet][key] = vt
@@ -244,10 +223,12 @@ class Excelx < GenericSpreadsheet
244
223
  when :time
245
224
  #hms = v.split(':')
246
225
  #@cell[sheet][key] = hms[0].to_i*3600 + hms[1].to_i*60 + hms[2].to_i
247
- @cell[sheet][key] = v.to_f*(24*60*60)
226
+ @cell[sheet][key] = v.to_f*(24*60*60)
248
227
  else
249
228
  @cell[sheet][key] = v
250
229
  end
230
+ @excelx_type[sheet] = {} unless @excelx_type[sheet]
231
+ @excelx_type[sheet][key] = excelx_type
251
232
  end
252
233
 
253
234
  def split_coord(s)
@@ -258,7 +239,7 @@ class Excelx < GenericSpreadsheet
258
239
  letter += s[i,1]
259
240
  i+=1
260
241
  end
261
- while i<s.length and "01234567890".include?(s[i,1])
242
+ while i<s.length and "0123456789".include?(s[i,1])
262
243
  number = number*10 + s[i,1].to_i
263
244
  i+=1
264
245
  end
@@ -276,10 +257,11 @@ class Excelx < GenericSpreadsheet
276
257
  end
277
258
 
278
259
  # read all cells in the selected sheet
279
- def read_cells(sheet=nil)
260
+ def ALTER_ANSATZ_read_cells(sheet=nil)
280
261
  sheet = @default_sheet unless sheet
281
262
  sheet_found = false
282
263
  raise ArgumentError, "Error: sheet '#{sheet||'nil'}' not valid" if @default_sheet == nil and sheet==nil
264
+ raise RangeError unless self.sheets.include? sheet
283
265
  n = self.sheets.index(sheet)
284
266
  @sheet_doc[n].each_element do |worksheet|
285
267
  worksheet.each_element do |elem|
@@ -291,8 +273,9 @@ class Excelx < GenericSpreadsheet
291
273
  if row.attributes['t'] == 's'
292
274
  tmp_type = :shared
293
275
  end
294
- if row.attributes['s'] == '2'
295
- tmp_type = :date
276
+ if row.attributes['s'] == '2' #or
277
+ #row.attributes['s'] == '1' # 2008-07-26
278
+ tmp_type = :time
296
279
  elsif row.attributes['s'] == '1' and row.attributes['t'] == nil # and ergaenzt 2008-07-03
297
280
  tmp_type = :formula
298
281
  end
@@ -305,8 +288,17 @@ class Excelx < GenericSpreadsheet
305
288
  end
306
289
  if cell.name == 'v'
307
290
  if tmp_type == :formula and f_element_found == false
291
+ #if cell.text.to_f < 1.0 # 2008-07-26
308
292
  tmp_type = :time
293
+ #else # 2008-07-26
294
+ #tmp_type = :date #2008-07-26
295
+ #end #2008-07-26
309
296
  end
297
+ if tmp_type == :time #2008-07-26
298
+ if cell.text.to_f >= 1.0 # 2008-07-26
299
+ tmp_type = :date # 2008-07-26
300
+ end # 2008-07-26
301
+ end # 2008-07-26
310
302
  if tmp_type == :shared
311
303
  vt = :string
312
304
  str_v = @shared_table[cell.text.to_i]
@@ -326,7 +318,86 @@ class Excelx < GenericSpreadsheet
326
318
  x,y = split_coordinate(row.attributes['r'])
327
319
  tr=nil #TODO: ???s
328
320
  set_cell_values(sheet,x,y,0,v,vt,formula,tr,str_v)
329
- #$log.debug "#{sheet},#{x},#{y},0,#{v},#{vt},#{formula},#{tr},#{str_v})"
321
+ end
322
+ end
323
+ end
324
+ end
325
+ end
326
+ end
327
+ end
328
+ end
329
+ end
330
+ sheet_found = true #TODO:
331
+ if !sheet_found
332
+ raise RangeError
333
+ end
334
+ @cells_read[sheet] = true
335
+ end
336
+
337
+ # read all cells in the selected sheet
338
+ def read_cells(sheet=nil)
339
+ sheet = @default_sheet unless sheet
340
+ sheet_found = false
341
+ raise ArgumentError, "Error: sheet '#{sheet||'nil'}' not valid" if @default_sheet == nil and sheet==nil
342
+ raise RangeError unless self.sheets.include? sheet
343
+ n = self.sheets.index(sheet)
344
+ @sheet_doc[n].each_element do |worksheet|
345
+ worksheet.each_element do |elem|
346
+ if elem.name == 'sheetData'
347
+ elem.each_element do |sheetdata|
348
+ if sheetdata.name == 'row'
349
+ sheetdata.each_element do |row|
350
+ if row.name == 'c'
351
+ if row.attributes['t'] == 's'
352
+ tmp_type = :shared
353
+ end
354
+ if row.attributes['s'] == '2' #or
355
+ #row.attributes['s'] == '1' # 2008-07-26
356
+ tmp_type = :time
357
+ elsif row.attributes['s'] == '1' and row.attributes['t'] == nil # and ergaenzt 2008-07-03
358
+ tmp_type = :formula
359
+ end
360
+ formula = nil
361
+ f_element_found = false
362
+ row.each_element do |cell|
363
+ if cell.name == 'f'
364
+ f_element_found = true
365
+ formula = cell.text
366
+ end
367
+ if cell.name == 'v'
368
+ if tmp_type == :formula and f_element_found == false
369
+ #if cell.text.to_f < 1.0 # 2008-07-26
370
+ tmp_type = :time
371
+ #else # 2008-07-26
372
+ #tmp_type = :date #2008-07-26
373
+ #end #2008-07-26
374
+ end
375
+ if tmp_type == :time #2008-07-26
376
+ if cell.text.to_f >= 1.0 # 2008-07-26
377
+ tmp_type = :date # 2008-07-26
378
+ end # 2008-07-26
379
+ end # 2008-07-26
380
+ excelx_type = :numeric_or_formula
381
+ if tmp_type == :shared
382
+ vt = :string
383
+ str_v = @shared_table[cell.text.to_i]
384
+ excelx_type = :string
385
+ elsif tmp_type == :date
386
+ vt = :date
387
+ v = cell.text
388
+ elsif tmp_type == :time
389
+ vt = :time
390
+ v = cell.text
391
+ elsif tmp_type == :formula
392
+ vt = :formula
393
+ v = cell.text.to_f #TODO: !!!!
394
+ else
395
+ vt = :float
396
+ v = cell.text
397
+ end
398
+ x,y = split_coordinate(row.attributes['r'])
399
+ tr=nil #TODO: ???s
400
+ set_cell_values(sheet,x,y,0,v,vt,formula,tr,str_v,excelx_type)
330
401
  end
331
402
  end
332
403
  end