phpspreadsheet-excel-writer

PHP Excel Writer Wrap text


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?


Solution

  • 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.