【问题标题】:PHPExcel setWrapText(true) not workingPHPExcel setWrapText(true)不起作用
【发布时间】:2014-10-08 12:49:34
【问题描述】:

我在通过 PHPExcel 进行文本换行时遇到了严重问题。我有一列,其中包含新行中的文本。它在 LibreOffice 中进行换行。在 MS Office 中,它显示在一行中。在这两个查看器中,它只进行换行,当我双击一个单元格然后单击该单元格时。我有以下代码:

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);

他们似乎没有工作。难道我做错了什么?我用谷歌搜索了它,但没有一个解决方案对我有用。

【问题讨论】:

  • 你用的是什么作家?
  • $letter肯定是L
  • 是的,$letterL

标签: php phpexcel word-wrap


【解决方案1】:

我只需要设置行的高度。

$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        
}

【讨论】:

    猜你喜欢
    • 2014-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多