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

更多相关文章

  1. 如何调试UPDATE函数在PHP中无法正常工作的原因?
  2. jquery ajax在调用之后将无法工作
  3. 当我将它移动到另一台服务器时,计数器将无法工作
  4. php会话不在chrome和firefox中工作但在IE中工作
  5. 当excel表格单元格的格式是日期格式非文本格式的时候,phpexcel 应
  6. Php DateTime :: setDate()不在第一个DatePeriod迭代上工作
  7. Codeigniter在localhost中的url上没有index.php但在服务器中没有
  8. 在mysql shell中显示没有表行的查询结果(非表格输出)
  9. 格式化mysql表引入Attendace表格格式

随机推荐

  1. 给Activity切换加入动画
  2. 知识储备:Android系统架构
  3. android 1.5 NDK发布
  4. qpython3:安卓上运行Python
  5. Android(安卓)View Attributes
  6. Android启动模式之singleTask解析
  7. TextView使用完全讲解
  8. Android 异步Http框架简介和实现原理
  9. Android中设置控件可见与不可见
  10. 饭后Android 第一餐-NavigationView+Tool