【发布时间】:2019-10-28 14:27:58
【问题描述】:
我正在尝试使用 PHPSpreadsheet 在 XLSX 工作表中创建评论。一切正常,除了似乎没有办法让评论在默认情况下开始隐藏 - 当我在 LibreOffice 中打开生成的 Excel 文件时,会显示所有 cmets。 Comment 类确实有一个 setVisible 方法,但似乎被忽略了。
我正在通过 Composer 使用 PHPSpreadsheet 1.9.0。
完整示例:
require ('vendor/autoload.php');
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
$excel = new Spreadsheet();
$ws = $excel->getActiveSheet();
$ws->setCellValue('A1', 'Hello');
$ws->getComment('A1')->getText()->createTextRun("This is a comment");
$ws->getComment('A1')->setVisible(false);
$writer = IOFactory::createWriter($excel, 'Xlsx');
$writer->save('test-comments.xlsx');
A1 中的注释应该(理论上)开始隐藏,但默认显示。
编辑 - 一些附加信息。 cmets 确实开始隐藏在 Excel 中,因此这可能表明 LibreOffice 存在一些问题。但是,如果您在 LibreOffice 中隐藏评论,保存回 XLSX 并重新打开,评论确实开始隐藏 - 所以显然 PHPSpreadsheet 写出评论的方式与 LibreOffice 期望的方式之间存在某种不兼容。我已针对 Libreoffice Calc (#128447) 提交了一个错误。
【问题讨论】:
标签: libreoffice libreoffice-calc phpspreadsheet