$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
In reply to spreadsheet formula issue by PerlSufi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |