From: Serguei Cambour Date: 2010-03-10T23:02:21+09:00 Subject: Re: Float in Spreadsheet Lars Christensen wrote: > On Feb 12, 9:26�am, Jim Burgess wrote: >> The program still writes 34 (without the decimal) to the cell. > > Excel treats 34 and 34.00 as the same number (and Ruby treat 34.0 and > 34.00 the same). > > fmt = Spreadsheet::Format.new(:number_format => '0.00') > sheet1.row(1).set_format(1,fmt) For me, te solution: nb_format = Spreadsheet::Format.new :number_format => '0,000' sheet1.row(4).set_format(0, nb_format) works fine. If you want to add decimals, just do nb_format = Spreadsheet::Format.new :number_format => '0,000.00' sheet1.row(4).set_format(0, nb_format) Now the problem is that if a number to be formatted is less than 1000, you'll get a new formatted value like that: 0,518.42 The question - how to avoid "unused" leading zeros? Thanks -- Posted via http://www.ruby-forum.com/.