Excel::Writer::XLSX 在公式中添加了意外的@

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

我正在使用 Excel::Writer::XLSX

将公式写入 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))");

但是当我打开 Excel sheet 时,我可以在单元格中看到

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

@从哪里来?

而不是-

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

使用以下方法:

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

查看 the documentation for formulas for Excel 2010 and later

完整脚本:

#!/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();

输出: