2

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

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

Any ideas ?

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.

enter image description here

UPDATE 2 :

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

Community
  • 1
  • 1
Perello
  • 633
  • 1
  • 7
  • 22

1 Answers1

3

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

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

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

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • It works this way (without column merges). Bu it don't work with my column merges, i'm using them, in order to get an harmonious display. I made a wrapper to php excel, in order to automate many things. And the column merges, make it easy to keep an harmonious rendering across all my exports. Any ideas ? – Perello Oct 26 '12 at 08:16
  • Can you show me exactly what you're doing then? I don't understand how column merges affects word wrap – Mark Baker Oct 26 '12 at 08:21
  • When i unmerged columns, in my excel, line break work correctly. And all the individuals columns have the wrap text checkbox ticked. But they don't autobreak the text. – Perello Oct 26 '12 at 08:38
  • 1
    Ah, this is almost solved. The wrap text works. But it do not auto adjust the line-heigth. – Perello Oct 26 '12 at 08:54
  • I'll look to try and identify the differences over lunchtime: the cell styling is being set correctly, and if the row height is manually adjusted it clearly works.... just need to identify why the line height isn't being set automatically as it is when wrap is set on unmerged cells – Mark Baker Oct 26 '12 at 09:30
  • I did some research, and this is an excel flaw, not a PhpExcel one. I'm calculating a really precise line heigth, so i can resolve my problem. I guess that only the excel team can correct this, in a clean way. – Perello Oct 26 '12 at 11:46