The special characters of the doc file generated by phpword cannot be opened.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.