简体   繁体   中英

Excel::Writer::XLSX adds an unexpected @ in formula

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

use Excel::Writer::XLSX;
my $workbook  = Excel::Writer::XLSX->new( "test.xlsx" );
my $worksheet = $workbook->add_worksheet();
$worksheet->write( 'A1', "4");
$worksheet->write( 'A2', "=ERF.PRECISE(A1/SQRT(2))");

But when I open my Excel sheet, I can see in the cell

A2:
=@ERF.PRECISE(A1/SQRT(2))

Where does the @ come from?

Instead of -

$worksheet->write( 'A2', "=ERF.PRECISE(A1/SQRT(2))");

Use below method:

$worksheet->write( 'A2', "=_xlfn.ERF.PRECISE(A1/SQRT(2))");

Look into the documentation for formulas for Excel 2010 and later .

Complete Script:

#!/usr/bin/perl

use strict;
use warnings;

use Excel::Writer::XLSX;

my $workbook  = Excel::Writer::XLSX->new( "test.xlsx" );
my $worksheet = $workbook->add_worksheet();

$worksheet->write( 'A1', "4");
$worksheet->write( 'A2', "=_xlfn.ERF.PRECISE(A1/SQRT(2))");

$workbook->close();

Output: 测试.xlsx

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