Skip to content

Commit 107d827

Browse files
committed
added able return integer value if cell has int and float if cell has float number for xls and xlsx
1 parent 7adcdf8 commit 107d827

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/roo/excel.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def set_cell_values(sheet,row,col,i,v,vt,formula,tr,font)
323323

324324
case vt # @cell_type[sheet][key]
325325
when :float
326-
@cell[sheet][key] = v.to_f
326+
@cell[sheet][key] = Integer(v) rescue Float(v)
327327
when :string
328328
@cell[sheet][key] = v
329329
when :date

lib/roo/excelx.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def set_cell_values(sheet,x,y,i,v,vt,formula,tr,str_v,
326326
@cell[sheet] = {} unless @cell[sheet]
327327
case @cell_type[sheet][key]
328328
when :float
329-
@cell[sheet][key] = v.to_f
329+
@cell[sheet][key] = Integer(v) rescue Float(v)
330330
when :string
331331
@cell[sheet][key] = str_v
332332
when :date

0 commit comments

Comments
 (0)