A similar problem. As a complement to the Magesh answer , if you donβt know which cells will be integers, you can check:
s.cell(i, j).to_i if s.cell(i,j).is_a?(Float) && s.cell(i,j).denominator == 1
Obviously, you may have false positives, but for the most part it will turn cells that should be integers into integers and save those that should be floating points.
source share