Question

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?

Was it helpful?

Solution 2

Ok figured it out. I was trying to do it like this:

$format_caption =& $workbook->addFormat(array('size' => 11, 'fontFamily' => 'Calibri', 'numformat' => '@', 'bold' => 1, 'left' => 1, 'top' => 1, 'bottom' => 1, 'right' => 1, 'vAlign' => 'vcenter', 'align' => 'center', 'fgcolor' => 50, 'textWrap' => 1));

But setting 'textWrap' => 1 didn't work.

So I changed it a bit:

$format_caption =& $workbook->addFormat(array('size' => 11, 'fontFamily' => 'Calibri', 'numformat' => '@', 'bold' => 1, 'left' => 1, 'top' => 1, 'bottom' => 1, 'right' => 1, 'vAlign' => 'vcenter', 'align' => 'center', 'fgcolor' => 50));
$format_caption -> setTextWrap();

And that solved my issue.

OTHER TIPS

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

textWrap not working bacause you set ROW height, ex:

$worksheet -> setRow($numRow, 17);

Remove this line, and height of row will be calculating automaticly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top