如何使用phpexcel在单元格中创建新行 [英] how to make New lines in a cell using phpexcel
本文介绍了如何使用phpexcel在单元格中创建新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对php excel有问题,
i have problem with php excel,
我想在一个单元格中换行,但我不能,我尝试使用\ n或< br/>但没有用这是我的代码:
i want to make new line in one cell but i can't, i have tried using \n or <br /> but itsn't work. this my code:
$objPHPExcel->getActiveSheet()->setCellValue('H5', 'Hello\nWorld'); // i need this show in two line
$objPHPExcel->getActiveSheet()->getStyle('H5')->getAlignment()->setWrapText(true);
fyi:我的格式excel是xls而不是xlsx. 非常感谢:)
fyi: my format excel is xls not xlsx. many thanks :)
推荐答案
$objPHPExcel->getActiveSheet()->setCellValue('H5', "Hello\nWorld");
$objPHPExcel->getActiveSheet()->getStyle('H5')->getAlignment()->setWrapText(true);
为我工作...
您应始终使用双引号当您在PHP字符串中添加转义序列时.
You should always use double quotes when you add escape sequences in a PHP string.
这篇关于如何使用phpexcel在单元格中创建新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文