Github. github & #039; srcPhpWordAutoloader. php & #039; PhpOfficePhpWordAutoloader: register (); $ phpWordnewPhpOfficePhpWordPhpWord (); Everyelementyouwantto... https://github.com/PHPOffice/PHPWord
Require_once 'src/PhpWord/Autoloader. php ';
\ PhpOffice \ PhpWord \ Autoloader: register ();
$ PhpWord = new \ PhpOffice \ PhpWord ();
// Every element you want to append to the word document is placed in a section.
// To create a basic section:
$ Section = $ phpWord-> addSection ();
// After creating a section, you can append elements:
$ Section-> addText ("hello & word ");
$ ObjWriter = \ PhpOffice \ PhpWord \ IOFactory: createWriter ($ phpWord, 'word2007 ');
$ ObjWriter-> save('helloworld.doc ');
The above is the code for generating the document. Because it is a technical document, the "&" symbol must be used. I don't know why the file cannot be opened after this character is added.
Reply content:
Https://github.com/PHPOffice/PHPWord
Require_once 'src/PhpWord/Autoloader. php ';
\ PhpOffice \ PhpWord \ Autoloader: register ();
$ PhpWord = new \ PhpOffice \ PhpWord ();
// Every element you want to append to the word document is placed in a section.
// To create a basic section:
$ Section = $ phpWord-> addSection ();
// After creating a section, you can append elements:
$ Section-> addText ("hello & word ");
$ ObjWriter = \ PhpOffice \ PhpWord \ IOFactory: createWriter ($ phpWord, 'word2007 ');
$ ObjWriter-> save('helloworld.doc ');
The above is the code for generating the document. Because it is a technical document, the "&" symbol must be used. I don't know why the file cannot be opened after this character is added.