在PHPExcel中设置自动高度不起作用

时间:2016-09-05 09:52:47

标签: php yii yii2 phpexcel

我使用PHPExcel生成Excel。

所有代码都很好。但是自动高度代码不起作用。

我尝试过以下代码。

在特定行上应用行高

$objPHPExcel->getActiveSheet()->getRowDimension('7')->setRowHeight(-1); 

为所有行

应用行高
$objPHPExcel->getActiveSheet()->getDefaultRowDimension(1)->setRowHeight(-1);

我也尝试过自动换行属性。

$objPHPExcel->getActiveSheet()
    ->getStyle('B7')
    ->getAlignment()
    ->setWrapText(true);

但它给我的结果如下:

enter image description here

  

注意:在MS办公室工作,不在Apache中工作打开Office和   LibreOffice的

2 个答案:

答案 0 :(得分:7)

刚刚将以下内容添加到01simple.php示例

select * from Workers
where
(
ISNLL(@name ,'') <>'' and name = @name
)
AND
(ISNLL(@lastname ,'') <>'' and LastName = @Lastname)
AND
(ISNLL(@city ,'') <>'' and city = @city)

这将为Excel2007和Excel5 Writer

创建正确包装的输出

答案 1 :(得分:1)

这似乎是Libre Office中的一个已知错误。详细讨论如下:

  

https://phpexcel.codeplex.com/discussions/429322