我正在使用PHPExcel生成Excel.
所有代码工作正常.但是自动高度代码不起作用.
我试过以下代码.
在特定行上应用行高
$objPHPExcel->getActiveSheet()->getRowDimension('7')->setRowHeight(-1);
为所有行应用行高
$objPHPExcel->getActiveSheet()->getDefaultRowDimension(1)->setRowHeight(-1);
我也尝试过自动换行属性.
$objPHPExcel->getActiveSheet()
->getStyle('B7')
->getAlignment()
->setWrapText(true);
但它给我的结果如下:
Note : Working in MS office,Not Working in Apache open Office and
LibreOffice
解决方法:
刚刚将以下内容添加到01simple.php示例中
$value = "To be or not to be-that is the question: whether 'tis nobler in the mind to suffer the slings and arrows of outrageous fortune, or to take arms against a sea of troubles, and, by opposing, end them.";
$objPHPExcel->getActiveSheet()->setCellValue('A12', $value);
$objPHPExcel->getActiveSheet()->getRowDimension(12)->setRowHeight(-1);
$objPHPExcel->getActiveSheet()->getStyle('A12')->getAlignment()->setWrapText(true);
这为Excel2007和Excel5 Writer创建了正确的包装输出