Phpspreadsheet how to set autoheight for merged cell?

只谈情不闲聊 提交于 2020-12-06 16:01:54


setWrapText work well for one cell, but not works for merged cell.

Here is the code I use to set autosize for merged cell, but it not works.

$sheet = $spreadsheet->getActiveSheet();

unmerged cell:

merged cell:


Maybe you must set a rowhight by calculation. See this article. You could try


to get the autoheight value.

-1 is the value of auto height. Means the value will calculated automatically. If you need a number of height. I would suggest to calc the height over the value of the cell. You must do following: Find newlines in the content and multiply them with 12.75 pts (standard height).