Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hello monks, I am having a problem getting my script to write formulas for subtraction. Here is my code:
$sth = $dbh->prepare($query); $sth->execute(); # create new excel file with 2 worksheets my $xWB = Spreadsheet::WriteExcel->new('trusmart_billing_201302.xls'); my $xWS = $xWB->add_worksheet('Summary'); #set formats my $format = $xWB->add_format(); $format->set_bold(); $xWS->set_column('A:A', 20); $xWS->set_column('E:E', 20, $format); $xWS->set_column('C:C', 20, $format); $xWS->set_column('B:B', 20, $format); my $xWS2 = $xWB->add_worksheet('Details'); #set columns A through D $xWS2->set_column('A:D', 20); # Add column headers for first worksheet my $R=0; my $C=0; $xWS->write($R, $C++, $_) for @{$sth->{NAME}}; # Read the query results and write them into the spreadsheet while (my $ar=$sth->fetchrow_arrayref) { ++$R; $C=0; $xWS->write($R, $C++, $_) for @$ar; } $xWS->write(0,5, 'Additional Images'); $xWS->write_formula('E2', '=(D2-B2)'); $xWS->write_formula('E3', '=(D3-B3)'); $xWS->write_formula('E4', '=(D4-B4)'); $xWS->write_formula('E5', '=(D5-B5)'); $xWS->write_formula('E6', '=1+5'); # as a test, this also did not work

It is writing 0 as the results in the E column cells. why? Thank you for your input

In reply to spreadsheet formula issue by PerlSufi

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (5)
    As of 2018-04-27 09:03 GMT
    Find Nodes?
      Voting Booth?