Skip to content

Error when instantiating template processor #2061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
igoroguraramos opened this issue Apr 15, 2021 · 2 comments
Closed

Error when instantiating template processor #2061

igoroguraramos opened this issue Apr 15, 2021 · 2 comments

Comments

@igoroguraramos
Copy link

setValue('nome', 'Igor Ogura Ramos'); $templateProcessor->saveAs("teste2.docx"); error: Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given in C:\xampp\htdocs\brax\app\lib\vendor\phpoffice\phpword\src\PhpWord\Shared\ZipArchive.php:387 Stack trace: #0 C:\xampp\htdocs\brax\app\lib\vendor\phpoffice\phpword\src\PhpWord\Shared\ZipArchive.php(387): count(0) #1 [internal function]: PhpOffice\PhpWord\Shared\ZipArchive->pclzipLocateName('word/header1.xm...') #2 C:\xampp\htdocs\brax\app\lib\vendor\phpoffice\phpword\src\PhpWord\Shared\ZipArchive.php(115): call_user_func_array(Array, Array) #3 C:\xampp\htdocs\brax\app\lib\vendor\phpoffice\phpword\src\PhpWord\TemplateProcessor.php(119): PhpOffice\PhpWord\Shared\ZipArchive->__call('locateName', Array) #4 C:\xampp\htdocs\brax\app\index.php(8): PhpOffice\PhpWord\TemplateProcessor->__construct('teste.docx') #5 {main} thrown in C:\xampp\htdocs\brax\app\lib\vendor\phpoffice\phpword\src\PhpWord\Shared\ZipArchive.php on line 387 Help please
@igoroguraramos
Copy link
Author

`<?php
include("lib/vendor/autoload.php");

use \PhpOffice\PhpWord\TemplateProcessor;

\PhpOffice\PhpWord\Settings::setZipClass(\PhpOffice\PhpWord\Settings::PCLZIP);

$templateProcessor = new TemplateProcessor("teste.docx");
$templateProcessor->setValue('nome', 'Igor Ogura Ramos');
$templateProcessor->saveAs("teste2.docx");`

@igoroguraramos
Copy link
Author

Word archive incorret

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant