2016-10-28 10:22
浏览 261


PHPWord has an excellent template example but I checked its code and it saves the file locally (taken from ../Examples/Template.php):

$document = $PHPWord->loadTemplate('Template.docx');

Compared to one who uses the createWriter method which has an option to auto-download:

$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');

Is auto-download possible for templates? (see PHPWord/Template.php::save)

I do not want it to be saved locally to remove the task of creating a garbage collection when an auto-download option available.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dpz3471 2016-10-31 09:53

    I've used PHPWord's sample Sample_23_TemplateBlock.php to test this solution and it worked:

    // Add HTTP headers to force user's browser save document
    // instead of opening it like an HTML page
    header('Content-Type: application/octet-stream');
    header("Content-Disposition: attachment; filename=template.docx");
    // $templateProcessor->saveAs('results/Sample_23_TemplateBlock.docx');
    解决 无用
    打赏 举报

相关推荐 更多相似问题