Hello Monks,
I want to comma format some very large numbers(tens of millions) in an excel file which is made from a database query. For some reason, I can get all of the cells in my desired column (column B) to format except for the first cell. Here is my code that uses strict,warnings, DBI and Spreadsheet::WriteExcel.
# query prepared and executed here... my $xWB = Spreadsheet::WriteExcel->new('spreadsheet.xls'); my $xWS2 = $xWB->add_worksheet('Report'); my $big_num_format = $xWB->add_format(); $big_num_format->set_num_format('##,###,##0'); my $row = 0; my $col = 0; $xWS2->write($row,$col++, $_) for @{$sth2->{NAME}}; while (my $array_ref = $sth2->fetchrow_arrayref) { ++$row; $col = 0; $xWS2->write($row, $col++, $_) for @$array_ref; if ($col == 1) { $xWS2->write_number( 0, 1, $_, $big_num_form +at) for @$array_ref; $xWS2->write_number( 1, 1, $_, $big_num_format) for @$array_r +ef; } }

I also tried manually formatting that cell(1,1) in the if statement. Any suggestions as to how I can fix this would be greatly appreciated.
Thanks,
PerlSufi

In reply to big number excel formatting by PerlSufi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.