Depending on your excel settings you have:
The comma can be the sepator for decimal or it can be de dot in my settings the comma is the separator, the dot is not a number so it is a string:
price dot price comma
2.4 2,4
2.5 2,5
sum price dot #VALUE! sum price comma 4,9
son in my case when I read it with ruby:
require 'spreadsheet'
book = Spreadsheet.open './Workbook1.xls'
sheet1 = book.worksheet 0
column_A = sheet1.column(0)
puts "column A"
column_A.each do |cell|
puts cell.class # this a string
puts cell.gsub(".",",")
end
puts "Colum E"
column_E = sheet1.column(4)
column_E.each do |cell|
puts cell.class #this is a float
cells.to_s.gsub(".",",")
end
the result is:
irb(main):007:0> column A
String
String
String
NilClass
NilClass
Colum E
String
Float
Float
NilClass
NilClass
=> true
In this step you have a string, then if you convert to float .t_f
, the excel will show your default format for float. In ruby is always the dot