简体   繁体   中英

Excel::Writer::XLSX adds an unexpected @ in formula (part 2)

This question follows a first question : Excel::Writer::XLSX adds an unexpected @ in formula

I am writing a formula to an xlsx file using Excel::Writer::XLSX

While I am using _xlfn , I do not have the expected result when I try to write a complex formula. Here is a code showing the issue:

use Excel::Writer::XLSX;
my $workbook  = Excel::Writer::XLSX->new( "test.xlsx" );
my $worksheet = $workbook->add_worksheet();
$worksheet->write( 'B1', "5");
$worksheet->write( 'A1', "4");
$worksheet->write( 'A2', "5");
$worksheet->write( 'A3', "3");
$worksheet->write( 'A4', "4");
$worksheet->write( 'A5', "6");
$worksheet->write( 'A7', "=_xlfn.STDEV.P(IF((A1:A5<B1),A1:A5))");
$workbook ->close();

Then the cell A7 contains: =STDEV.P(IF((@A1:A5<B1),A1:A5))

And because of the @ , the cell shows #NAME? instead of the result of the formula.

Does anybody know how to remove this unexpected @ ?

Thanks JvdV, the solution is indeed to use {}

use Excel::Writer::XLSX;
my $workbook  = Excel::Writer::XLSX->new( "test.xlsx" );
my $worksheet = $workbook->add_worksheet();
$worksheet->write( 'B1', "5");
$worksheet->write( 'A1', "4");
$worksheet->write( 'A2', "5");
$worksheet->write( 'A3', "3");
$worksheet->write( 'A4', "4");
$worksheet->write( 'A5', "6");
$worksheet->write( 'A7', "{=_xlfn.STDEV.P(IF((A1:A5<B1),A1:A5))}");
$workbook ->close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM