Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPExcel row autoheight on merged cells w/ wrapText

Tags:

php

phpexcel

Is there a good way to set row autoheight in PHP Excel? So far I have seen that you can use a fixed height where you specify before hand how tall you want the row. I have also seen that you can use autoheight if you are not using merged cells.

PHPExcel - dynamic row height for merged cells

How to set auto height in phpexcel?

These two other questions ask similar questions but neither is answered. One solution I've considered is to count the number of words in the cell and wrap based on that and the column span. This could open a can of worms however.

like image 689
aaron-bond Avatar asked Nov 30 '12 11:11

aaron-bond


1 Answers

You can also do it like this

  1. Merge cells you want, for example: A7:C7
  2. Copy context of it to one cell for instance Z7
  3. Set the width of the merged cells to Z7
  4. Apply Wrap Text to the Z7
  5. Make Z7 not visible
like image 137
Maria Avatar answered Sep 21 '22 07:09

Maria