如何设置自动换行符PhpExcel? [英] How to set auto-line break PhpExcel?

查看:473
本文介绍了如何设置自动换行符PhpExcel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PHPExcel生成一些excel导出. Excel具有自动换行符功能.我该如何激活它?

I'm using PHPExcel to generate some excel export. Excel has an autoline break feature. How can i activate this ?

我的客户仅使用Microsoft Excel,因此不必支持其他程序.

My customer use only Microsoft Excel, so it don't have to support others programs.

有什么想法吗?

我可能会使用类似这样的内容:如何使用phpexcel在单元格中换行.但这不是真正的解决方案,更是一种黑客手段.

I may use something like this : how to make New lines in a cell using phpexcel But that's more a kind of hack, than a real solution.

更新: 请参阅,一旦合并了列,自动换行文本就会失败.我尝试在合并的每一列上添加自动换行文本,但这不会影响结果.

UPDATE : See, once columns are merged, wrap text fail. I tryied to add wrap text upon every column merged, but it don't affect result.

更新2:

合并单元格,然后添加自动换行文本,然后添加文本.

The cells are merged, then i add wrap text, then i add text.

推荐答案

将列设置为固定宽度;为单元格设置setWrapText(true),看看会发生什么.

Set the column to a fixed width; setWrapText(true) for the cells, and see what happens.

以/Tests/05featuredemo.php中创建的第二张纸为例.

Look at the second sheet created in /Tests/05featuredemo.php for an example.

仅在要精确控制换行的位置时才需要使用\ n

You only need to use \n if you want to control exactly where a line wraps

这篇关于如何设置自动换行符PhpExcel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆