PHPExcel setWrapText(true) not working

I have a serious problem with text wrapping via PHPExcel. I have a column, which contains texts in new lines. It does the linebreaks in LibreOffice. In MS Office it is displayed in a single line. In both viewers, it only does the wrap, when I double click into a cell and then click out the cell. I have the following code:

foreach($view->results as $row){
    //...
    foreach($unserialized as $task){
      $value = $field_info['settings']['allowed_values'][$doc['document']];
      $current_tasks .= $value . "\n";          
    }
  $active_sheet->setCellValue($letter.$i, $current_tasks); 
  //...
  //end of main foreach loop
  $active_sheet->getStyle('L' . $i)->getAlignment()->setWrapText(true);
  $i++;
}
//tried this too outside the foreach:
$active_sheet->getStyle('L2:L' . $i)->getAlignment()->setWrapText(true);

They don't seem to be working. Am I doing something wrong? I googled it up and neither of the solutions worked for me.

Upvotes: 1

Views: 4380

Answers (1)

I only needed to set the height of the rows.

$numtasks = 20;
foreach($unserialized as $task){
  $value = $field_info['settings']['allowed_values'][$doc['document']];
  $current_tasks .= $value . "\n";
  $active_sheet->getRowDimension($i)->setRowHeight($numtasks);
  $numtasks += 20;  //20 is for 1 cells height in pixels        
}

Upvotes: 1

Related Questions