php 如何在phpexcel中设置自动高度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6054444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:13:37  来源:igfitidea点击:

How to set auto height in phpexcel?

phpphpexcel

提问by bungdito

I am using phpexcelto generate excel document with PHP.

the question is, how to make auto height row using phpexcel? many thanks :)

我正在使用phpexcel用 PHP 生成 excel 文档。

问题是,如何使用phpexcel制作自动高度行?非常感谢 :)

回答by pkavanagh

$excel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1);

Should set the row height to 'auto' for row 1.

应将第 1 行的行高设置为“自动”。

回答by Dhaval

$excel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(-1);

回答by Kamil Szot

To change height of all rows to auto you can do:

要将所有行的高度更改为自动,您可以执行以下操作:

foreach($xls->getActiveSheet()->getRowDimensions() as $rd) { 
    $rd->setRowHeight(-1); 
}

回答by Vivek Parmar

You can set it by using following code,

您可以使用以下代码进行设置,

$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1);
$objPHPExcel->getActiveSheet()->getStyle('E')->getAlignment()->setWrapText(true);