对于它的价值,如果我在OpenOffice中打开相同的文件,公式工作正常.
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 ); # $ws->write_formula( $r,$formula ); # Does not help either.}
版本信息:
> Excel 2007 SP2.
> Spreadsheet :: WriteExcel:尝试了2.25和2.37.
这是公式解析器和WriteExcel中的某些公式类型的已知错误.您可以使用store_formula()和repeat_formula()来解决它,如下所示:
use strict;use warnings;use Spreadsheet::WriteExcel;my $wb = Spreadsheet::WriteExcel->new('foo.xls');my $ws = $wb->add_worksheet;my $formula = $ws->store_formula('=VLOOKUP(K1,FALSE)');# Workaround for VLOOKUP BUG in WriteExcel.@$formula = map {s/_ref2d/_ref2dV/;$_} @$formula;for my $r (0 .. 9){ for my $c (0 .. 4){ $ws->write($r,$r * 10); $ws->repeat_formula( $r,$formula,undef,qr/^K1$/,'K' . ($r +1) );}总结
以上是内存溢出为你收集整理的如何让Perl的Spreadsheet :: WriteExcel用VLOOKUP创建公式?全部内容,希望文章能够帮你解决如何让Perl的Spreadsheet :: WriteExcel用VLOOKUP创建公式?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)