ruby-on-railsrubyexcelroo-gem

Roo getting number instead of text


I am using roo to parse out an excel sheet like this

worksheet.parse(
        :partNo => "PM_PartNo",
        :salePartNo => "PM_SalesPartNo",
        :appSearchInclude => "PM_AppSearchInclude",
        :desc => "PM_WebApp_Description",
        :brand => "PM_Brand",
        :appSegment => "PM_ApplicationSegment",
        :group => "PM_ProductGroup",
        :design => "PM_ProductDesign",
        :material => "PM_Material",
        :line => "PM_ProdLine",
        :baseSeries => "PM_BaseSeries",
        :colorCode => "PM_ColorCode",
        :series => "PM_Series",
        :weightType => "PM_oz_gram",
        :appRim => "PM_ApplicationRim",
        :coating => "PM_Coating",
        :pcs => "PM_PCSconversion",
        :clean => true
    )  do |hash|

However, Roo keeps giving me a number 200275577.0 for the PM_PartNo column. In the excel sheet, this column has all cells formatted as text. What is should return in the parse is "200275577" as text, not 200275577.0 as a number. Is there a way to ensure it adheres to the excel formatting?


Solution

  • This is an open issue with roo. There is a general workaround contributed by a user in the issue, or you can just convert the value yourself with .to_i.to_s.