fionbarr has asked for the wisdom of the Perl Monks concerning the following question:

I am looking for a way to keep trailing zeroes my data = (for example) '6.00' or '123.10' These are shown in the resulting spreadsheet as '6' and '123.1'. Although the data is a string I am trying to convert it to a number so the write_number function will print it with trailing zeroes.
$right = $workbook->add_format( size => 9, align => 'right', ); $table->write_number( $row, $col++, ($fields[0]+0), $right )

Replies are listed 'Best First'.
Re: trailing zeroes with EXCEL::Writer::XLSX
by Bethany (Scribe) on Aug 08, 2014 at 14:17 UTC

    In cases like this you should ask yourself, "How would I do this if I were working in Excel/OpenOffice/etc.?" You'd use the spreadsheet software's cell formatting, right? Time to hit your module's docs and see how it lets you assign a cell format.

    P.S.: If you aren't sure how to write a format, start your spreadsheet program and experiment. That way you'll know for certain when your format string is right.

      the answer is:
      $right = $workbook->add_format( size => 9, align => 'right', num_format => '#,##0.00', );

        There ya go! *thumbs up*

Re: trailing zeroes with EXCEL::Writer::XLSX
by ww (Archbishop) on Aug 08, 2014 at 18:21 UTC

      In this particular case, the fact that you found the answer on your own within half an hour, with nothing but some motivation from Bethany, puts the post in the grey area of whether it was worth posting the question or not.

      In this thread and your last thread, you only asserted that you've done prior research after ww complained, and we still don't know what the results of that research were. If you show your effort, you're likely to get more help.

      I do research my questions before I post them; if I do not find an answer am I precluded from posting the question? I am not trying to offend those to whom the answer is easy.