http://www.perlmonks.org?node_id=1031589

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

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