如果我加载模板 - 甚至是直接文档作为模板,并且除了保存它之外什么都不做,它会删除表格/单元格边框。
这是我的代码:
$this->word = new PhpWord\PhpWord;
$this->template = $this->word->loadTemplate('path/to/template.dotx'); // this could be a .docx - same results
$templatefilepath = $this->template->save();
$word = \PhpOffice\PhpWord\IOFactory::load($templatefilepath);
$writer = PhpWord\IOFactory::createWriter($word, 'Word2007');
$writer->save('/path/to/worddoc.docx');
// Output all necessary headers...
echo File::get('/path/to/worddoc.docx'); // (Lumen)
这会将模板另存为 Word Doc,但会去除所有表格/单元格边框。