PHPExcel and Text Wrapping

PHPExcel is a library for working with Microsoft Excel files in PHP. It provides a set of classes for reading, writing, and manipulating Excel files. To wrap text within a cell in PHPExcel, you can use the following method:

$objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setWrapText(true);

Where "A1" is the cell in which you want to wrap the text and "setWrapText(true)" enables text wrapping for that cell.

Watch a course Learn object oriented PHP

You can also set the width of the column to autofit the text by using the following method:

$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);

Where "A" is the column you want to autofit.