【发布时间】:2017-06-01 08:07:46
【问题描述】:
我使用 PHPword 在我的 Web 应用程序中创建了一个 Word 文档,但我无法实现列表。我使用了以下代码:
$PHPWord = new PHPWord();
$temp = $PHPWord->loadTemplate('temp.docx');
$section = $PHPWord->createSection();
$section->addListItem('List Item 1', 0);
$section->addTextBreak(1);
$temp->setValue('Value1', $section);
$temp->save('list.docx');
此代码不起作用。我设法在新文档中创建了一个列表,但我无法将列表添加到模板中(我无法将列表分配给特定值)。如何添加列表?
【问题讨论】:
-
定义“不工作”。
-
如果我不将 $section 添加到 $temp->setValue ,它将起作用
-
如果我将 $section 添加到 $temp->setValue,它将显示空白页面。(标题不起作用)
-
你在 $section 中的期望值是多少 $temp->setValue('Value1', $section);