在 PHPExcel 中设置自动高度不起作用
Set auto height in PHPExcel not working
我正在使用 PHPExcel 生成 Excel。
所有代码工作Fine.But自动高度代码不工作。
我试过下面的代码。
在特定行应用行高
$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 Writers 创建正确包装的输出
我正在使用 PHPExcel 生成 Excel。
所有代码工作Fine.But自动高度代码不工作。
我试过下面的代码。
在特定行应用行高
$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 Writers 创建正确包装的输出