Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Excel Formatting

by CountOrlok (Friar)
on Apr 22, 2013 at 19:10 UTC ( #1029955=note: print w/replies, xml ) Need Help??

in reply to Excel Formatting

For setting the column format, try this:
my $trans_format = $workbook->add_format(); $trans_format->set_num_format('$0.00'); #... $worksheet->set_column('I:I', undef, $trans_format);
For column J, just don't write to the column:
my $row = 2; while (<FH>) { chomp; @keepers = split /,/, $_, 10; pop @keepers; # only get first 9 columns $worksheet->write_row($row, 0, \@keepers, $cell_format); $row++; } $worksheet->write_formula('I1', '=SUM (I3:I262)'); $worksheet->set_column('I:I', undef, $trans_format);
Update: replaced write() with write_row()

Replies are listed 'Best First'.
Re^2: Excel Formatting
by PerlSufi (Friar) on Apr 22, 2013 at 19:42 UTC
    Hi Count, thanks so much for the input! However, I am still getting the column J and not getting my currency format when I try that..?
      You are applying the currency format at the end, after you have written all the data? (before closing the file, of course).
        Yes. I have tried declaring
        my $trans_format = $workbook->add_format(); $trans_format->set_num_format('$0.00');
        where I set my other formats and after the while loop. I have also done $worksheet->set_column('I:I', undef, $trans_format); after the while loop. I can't figure it out..
      UPDATE:Actually replacing that while statement with my previous one worked to remove J column, but I still don't have the currency format.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029955]
[amitkumarj441]: I need to ask a question, where can I post my problem?
[Discipulus]: everyone is me
[Discipulus]: Seekers of Perl Wisdom is the for asking question
[Discipulus]: be sure to use code tags for code and data
[Discipulus]: and to show some effort while asking
[Discipulus]: <code> code and data</code>
[Discipulus]: amitkumarj441 more atention you put asking, more attentio you got in answers
Discipulus 's hoping he needs a oneliner ;=)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2017-04-26 20:23 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (488 votes). Check out past polls.