PHP Excel Writer Wrap text

Bird87 ZA picture Bird87 ZA · Aug 30, 2012 · Viewed 14.2k times · Source

I'm using this plugin, I know it's not the best, but I don't have time to rewrite all these scripts. I need to know how enable text wrap. The incomplete documentation on the website doesn't help at all.

I have tried using 1 and 'wrap' as the parameter in the array, but no luck.

Has anyone gotten this to work?

Answer

kudis picture kudis · Aug 25, 2016

If You want to use construction addFormat(), name of wrapText property have to be 'wrap'.

You wrote: 'textWrap' => 1

you should: 'wrap' => true or 'wrap' => 1

for example:

$style = array(
    'alignment' => array(
        'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
        'wrap' => true
    )
);
$objPHPExcel->getActiveSheet()->getStyle('A1')->applyFromArray($style);

the result for cell A1 is central alignment whith text wraping