PHPWord 中模板处理器的默认目录是什么?
What is the default directory of Template Processor in PHPWord?
我正在使用 PHPword 生成 word 文档。我想生成多个文档,所以我想使用模板。我在控制器中尝试了这段代码:
$templateProcessor = new TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx');
$templateProcessor->setValue('Name', 'John Doe');
$templateProcessor->setValue(array('City', 'Street'), array('Detroit', '12th Street'));
并显示以下错误:
copy(resources/Sample_07_TemplateCloneRow.docx): failed to open stream: No such
file or directory
在:
// Template file cloning
if (false === copy($documentTemplate, $this->tempDocumentFilename)) {
throw new CopyFileException($documentTemplate, $this->tempDocumentFilename);
}
模板处理器的默认目录是什么?或者我们必须手动提供位置。请帮忙!
PHPversion:7.0
laravel 5.5
PHPWord版本:0.14
这对我有用:
Sample_07_TemplateCloneRow.docx 改为在 /storage 目录中。并使用这一行:
$templateProcessor = new
TemplateProcessor(storage_path('Sample_07_TemplateCloneRow.docx'));
我正在使用 PHPword 生成 word 文档。我想生成多个文档,所以我想使用模板。我在控制器中尝试了这段代码:
$templateProcessor = new TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx');
$templateProcessor->setValue('Name', 'John Doe');
$templateProcessor->setValue(array('City', 'Street'), array('Detroit', '12th Street'));
并显示以下错误:
copy(resources/Sample_07_TemplateCloneRow.docx): failed to open stream: No such
file or directory
在:
// Template file cloning
if (false === copy($documentTemplate, $this->tempDocumentFilename)) {
throw new CopyFileException($documentTemplate, $this->tempDocumentFilename);
}
模板处理器的默认目录是什么?或者我们必须手动提供位置。请帮忙!
PHPversion:7.0 laravel 5.5 PHPWord版本:0.14
这对我有用: Sample_07_TemplateCloneRow.docx 改为在 /storage 目录中。并使用这一行:
$templateProcessor = new
TemplateProcessor(storage_path('Sample_07_TemplateCloneRow.docx'));