在phpword中如何在表格中新建行?
16lz
2021-01-22
I want to create a word file .docx
from my data that exist in database. To do this job I am using a phpword 0.12.0 . I need to draw a table to place data inside it. After that I need to fetch every row from table in database to automatically go in cell of new line. I can do this job with
我想从数据库中的数据创建一个word文件。docx。为了完成这项工作,我使用了phpword 0.12.0。我需要画一个表格来放置数据。之后,我需要从数据库中的表中获取每一行,以自动进入新行的单元格。我可以做这项工作
$section->addTextBreak();
but without table, now how can I do this job in cell inside the table? I am using below code, but it doesn't work.
但是没有表格,现在如何在表格的单元格中完成这项工作呢?我正在使用下面的代码,但是它不起作用。
$area=array();
$axis=array();
$topic=array();
$table->addRow(900);
$table->addCell(2000, $styleCell)->addText(htmlspecialchars('test1'), $fontStyle);
$table->addCell(2000, $styleCell)->addText(htmlspecialchars('test2'), $fontStyle);
$table->addCell(2000, $styleCell)->addText(htmlspecialchars('test3'), $fontStyle);
$table->addCell(2000, $styleCell)->addText(htmlspecialchars('test4'), $fontStyle);
for ($i = 0; $i < 4; $i++) {
$table->addRow();
$table->addCell(2000)->addText(htmlspecialchars($topic{$i}),array('name' => 'Segoe UI Semilight'));
$table->addCell(3000)->addText(htmlspecialchars($axis{$i}),array('rtl' => true,'name' => 'Segoe UI Semilight'));
$table->addCell(2000)->addText(htmlspecialchars($area{$i}),array('rtl' => true,'name' => 'Segoe UI Semilight'));
$table->addCell(2000)->addText(htmlspecialchars($i),array('rtl' => true,'name' => 'Segoe UI Semilight'));
}
2 个解决方案
#1
3
You must first create a cell object, and then use addText
您必须首先创建一个单元格对象,然后使用addText
$c1=$table->addCell(2000);
$c1->addText("Cell 1");
$c1->addText("New line");
更多相关文章
- 如何调试UPDATE函数在PHP中无法正常工作的原因?
- jquery ajax在调用之后将无法工作
- 当我将它移动到另一台服务器时,计数器将无法工作
- php会话不在chrome和firefox中工作但在IE中工作
- 当excel表格单元格的格式是日期格式非文本格式的时候,phpexcel 应
- Php DateTime :: setDate()不在第一个DatePeriod迭代上工作
- Codeigniter在localhost中的url上没有index.php但在服务器中没有
- 在mysql shell中显示没有表行的查询结果(非表格输出)
- 格式化mysql表引入Attendace表格格式