Excel::Writer::XSLX 编写嵌入式超链接

Excel::Writer::XSLX write embedded hyperlinks

我有一个带有如下超链接的文本。

Please click <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=pubmed&amp;cmd=Retrieve&amp;dopt=Abstract&amp;list_uids=8395787">here</a> or <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=pubmed&amp;cmd=Retrieve&amp;dopt=Abstract&amp;list_uids=9568930">here</a> for more info.

但是当我使用 Perl 模块的 write() 方法将文本写入单元格时,单元格中的文本显示为纯文本,如上所示。所以我的问题是如何将文本写入单元格,以便它显示为 HTML 文本,超链接可点击,如下所示。

请点击here or here了解更多信息。

这里是一个简单的 Perl 脚本的代码,它创建一个 xlsx 文件,其中包含一个单元格,其中包含带有超链接的文本。谢谢

#!/usr/bin/perl

use strict;
use Excel::Writer::XLSX;

my ($wb, $ws, $format1, $format2, $f_url, $rn);

my $wb = Excel::Writer::XLSX->new('/data/tmp/reference.xlsx');
my $ws = $wb->add_worksheet();
my $format = $wb->add_format(align => 'left');
my $text = 'Please click <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=pubmed&amp;cmd=Retrieve&amp;dopt=Abstract&amp;list_uids=8395787">here</a> or <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=pubmed&amp;cmd=Retrieve&amp;dopt=Abstract&amp;list_uids=9568930" target=_blank>here</a> for more info.';
$ws->write(0, 0, $text, $format);
$wb->close();

exit 0;

不幸的是,这在 Excel 中是不可能的(因此在 Excel::Writer::XLSX 中也不可能)。每个单元格只能有一个超链接。