文件错误:提供超链接时数据可能已经丢失 [英] File Error:data may have been lost while giving hyperlinks
问题描述
我正在编写代码以使用Spreadsheet :: WriteExcel生成excel. 我想将数据写入单元格并为其提供超链接. 我做到了但是在打开文件时,它显示警告说文件数据可能已丢失.
I am writing a code to generate excel using Spreadsheet::WriteExcel. I want to write the data into cells and give the hyperlink to it. I did that. But while opening the file it shows warning saying file data may have been lost.
$Log_Sheet->write(12,0,'AA',$ERR_DESCR_Format );
$Log_Sheet->write_url(12, 0, 'internal:sheet3!A1' );
我想写内容并提供链接而不会得到警告.怎么做?
I want to write the content and provide link without getting warning. How to do it?
推荐答案
Spreadsheet :: WriteExcel,虽然很棒,但是已经好几年没有更新了,据我所知,它仅支持Office 2007之前的扩展.xls.我真的建议您升级到Excel :: Writer :: XLSX,这是McNamara对开放XML标准格式(xlsx)的出色更新.
Spreadsheet::WriteExcel, greatness though it is, hasn't been updated for several years, and to my knowledge it only supports the pre-Office 2007 extension of .xls. I'd really recommend you upgrade to Excel::Writer::XLSX, which is McNamara's fabulous update to the open XML standard format (xlsx).
所以我不能肯定地说,因为在Excel :: Writer :: XLSX上不会发生此错误,但是我的最初理论是您正在将两个不同的值写入相同的单元格(12,0),所以一个实质上是在破坏另一个-因此是警告.
So, I can't say for sure because this error does not happen on Excel::Writer::XLSX, but my initial theory is you are writing two different values to the exact same cell (12, 0), so the one is essentially clobbering the other -- hence the warning.
如果确实要升级到Excel-Writer,则警告应消失.更重要的是,如果您想要超链接,则可以在同一调用中包含链接和友好描述:
If you do upgrade to Excel-Writer, the warning should disappear. More importantly, if you want a hyperlink, you include the link and the friendly description all in the same call:
$worksheet->write_url(12, 0, 'internal:Sheet3!A1', 'Click Here!');
对于它的价值,我认为write
方法也可以正确地将其解释为链接:
For what it's worth, I think the write
method will also correctly interpret this as a link:
$worksheet->write(12, 0, 'internal:Sheet3!A1', 'Click Here!');
-编辑12/21/2018-
-- EDIT 12/21/2018 --
如果要在合并的单元格上创建超链接,一种方法是使用Excel的超链接功能:
If want to do a hyperlink on a merged cell, one way to do it is to use Excel's hyperlink function:
my $merged = $workbook->add_format();
$worksheet->merge_range("A10:A11",
qq{=hyperlink("#'Sheet3'!A1","Click Here!")},
$merged);
这篇关于文件错误:提供超链接时数据可能已经丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!