LibreOffice Calc中的自动高度

wit*_*rin 5 phpexcel libreoffice-calc

通常情况下,您可以使用PHPExcel格式化自动高度行,如下所示:

$file = new PHPExcel();
$file->getActiveSheet()->setCellValue('A1', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.');
$file->getActiveSheet()->getRowDimension(1)->setRowHeight(-1);
$file->getActiveSheet()->getStyle('A1')->getAlignment()->setWrapText(true);
$writer = PHPExcel_IOFactory::createWriter($file, 'Excel2007');
$writer->save(str_replace('.php', '.xlsx', __FILE__));
Run Code Online (Sandbox Code Playgroud)

问题是当您使用LibreOffice Calc打开此类文件时,这不起作用.相反,您必须选择单元格,选择Format Cells...并单击OK.

这似乎是一个已知的错误,但不幸的是,通过在第1004行添加以下else块提出的解决方案似乎不起作用:Classes\PHPExcel\Writer\Excel2007\Worksheet.php

else {
    $objWriter->writeAttribute('customHeight', 'false');
    $objWriter->writeAttribute('ht', '0');
}
Run Code Online (Sandbox Code Playgroud)

怎么能修好?

Coo*_*Esh 0

这似乎是 Libre Office 中的一个已知错误。详细讨论在这里:https://phpexcel.codeplex.com/discussions/429322