I'm having difficulty with Spreadsheet :: WriteExcel and formulas using VLOOKUP . The following test script fills the worksheet with some data and tries to create a VLOOKUP formula. When I open the resulting Excel file, the formula results are displayed as #VALUE! . If I manually edit any cell containing the formulas (press F2 and then just ENTER without changing anything), I can get Excel to evaluate the formula correctly. Any idea what goes wrong?
What is it worth, if I open the same file in OpenOffice, the formulas work fine.
use strict; use warnings; use Spreadsheet::WriteExcel; my $wb = Spreadsheet::WriteExcel->new('foo.xls'); my $ws = $wb->add_worksheet; for my $r (0 .. 9){ for my $c (0 .. 4){ $ws->write($r, $c, $r * 10 + $c); } $ws->write($r, 10, $r * 10); my $formula = sprintf('=VLOOKUP(K%s, A1:B10, 2, FALSE)', $r + 1); $ws->write( $r, 11, $formula );
Version Information:
- Excel 2007 SP2.
- Table: WriteExcel: tried both 2.25 and 2.37.
source share