如何在php中向excel中用作列标题的数据添加分隔符

如何在php中向excel中用作列标题的数据添加分隔符,php,excel,codeigniter,Php,Excel,Codeigniter,如何在php中向excel中用作列标题的数据添加分隔符。我有来自php的excel表格,在其中我必须为列添加标题。我可以做到这一点,但问题是数据更多,我需要它作为一行,然后我们如何才能打破它在excel表使用php 有人能帮我吗?谢谢 $this->excel->getActiveSheet()->setCellValue('A2', 'a.Please include the legends in the bottom of the table, like in the o

如何在php中向excel中用作列标题的数据添加分隔符。我有来自php的excel表格,在其中我必须为列添加标题。我可以做到这一点,但问题是数据更多,我需要它作为一行,然后我们如何才能打破它在excel表使用php

有人能帮我吗?谢谢

 $this->excel->getActiveSheet()->setCellValue('A2', 'a.Please include the legends in the bottom of the table, like in the online version:<br>
 f – Based on "Actual Final Budget or Actual Spending"
 a – Based on "Actual Spending"
 p – Based on "Provisional Budget"
');
$this->excel->getActiveSheet()->setCellValue('A2','a)。请在表格底部包括图例,如在线版本:
f–基于“实际最终预算或实际支出” a–基于“实际支出” p–基于“临时预算” ');
这是标题,目前我只得到f的数据


请有人帮帮我。

在每个语句后添加半列

使用“\n”字符而不是html中断标记:PHPExcel使用MS Excel格式,而不是html标记

您可能还希望将单元格设置为“换行”,并将行设置为“自动调整”

$str = 'a.Please include the legends in the bottom of the table, like in the online version:'."\r\n";
$str .= 'f – Based on "Actual Final Budget or Actual Spending"'."\r\n";
$str .= 'a – Based on "Actual Spending"'."\r\n";
$str .= 'p – Based on "Provisional Budget"'."\r\n";
$this->excel->getActiveSheet()->setCellValue('A2', $str);

试试这个,应该可以用。

我试过另一种方法,它可以用,我的mergin细胞有问题。我给出了如下信息,它显示错误$this->excel->getActiveSheet()->getStyle('B'.$i)->getAlignment()->setWrapText(true);$this->excel->getActiveSheet()->getStyle('B'.$i)->getFont()->setSize(12);$this->excel->getActiveSheet()->getStyle('B'.$i)->getFont()->setBold(true);$this->excel->getActiveSheet()->mergeCells('B'.$i:'E'.$i);在最后一行中,边距如下:$this->excel->getActiveSheet()$保证金=1$pageMargins->setTop($margin)$pageMargins->setBottom($margin)$pageMargins->setLeft($margin)$页边距->设置权限($margin);