I am using phpexcel to generate excel document with PHP.
the question is, how to make auto height row using phpexcel?
many thanks :)
Asked
Active
Viewed 9.3k times
4 Answers
74
$excel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1);
Should set the row height to 'auto' for row 1.

pkavanagh
- 1,036
- 9
- 4
-
1Any idea how to set it for the entire sheet? – eddy147 Jan 30 '12 at 08:14
-
10@eddy147 - `foreach($xls->getActiveSheet()->getRowDimensions() as $rd) { $rd->setRowHeight(-1); }` – Kamil Szot Jul 03 '12 at 11:15
-
$excel->getActiveSheet()->getRowDimension( 1 )->setRowHeight( 30 ); working in libreoffice calc. – kodmanyagha Jul 16 '17 at 11:22
56
$excel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(-1);
-
4
-
1
-
@Dhaval Maybe you can help me. Look at this : https://stackoverflow.com/questions/56469303/how-do-i-make-automatic-height-row-based-on-content-in-the-maatwebsite-version-3 – moses toh Jun 06 '19 at 02:47
22
To change height of all rows to auto you can do:
foreach($xls->getActiveSheet()->getRowDimensions() as $rd) {
$rd->setRowHeight(-1);
}

Kamil Szot
- 17,436
- 6
- 62
- 65
-
Maybe you can help me. Look at this : https://stackoverflow.com/questions/56469303/how-do-i-make-automatic-height-row-based-on-content-in-the-maatwebsite-version-3 – moses toh Jun 06 '19 at 02:48
5
You can set it by using following code,
$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1);
$objPHPExcel->getActiveSheet()->getStyle('E')->getAlignment()->setWrapText(true);

Vivek Parmar
- 773
- 1
- 10
- 26