How To Use Phpword With Yii?

Hello,

I’ve problem with exporting records from model into MS Word document. Records contain strings and images, and should be exported to .doc file, with each record on separate page. I’m able to pass IDs of records for export to controller, but how to use phpWord with it???

It would be great if you could help me with example…

Thanks in advance,

Hi EdinM, welcome to the forum.

In order to use phpWord library in Yii, what you have to do is just to load it.

The following is a wiki about loading phpExcel library, but you should read it, because you will encounter the same problem when you load the library.

http://www.yiiframework.com/wiki/101/how-to-use-phpexcel-external-library-with-yii

http://www.yiiframework.com/wiki/101/how-to-use-phpexcel-external-library-with-yii#c8432

And, about writing the word contents, you have to follow the instructions of phpWord documents.

The programming in phpWord needs the same kind of knowledge when you do programming for word and/or excel in C# .net/Visual Basic/VB Script/macros. If you have experience in them, you will feel at home.

There’s nothing that Yii can do to help you there, except for providing the contents from db or so.

[P.S.]

Note that phpWord can not write .DOC file. It only supports .DOCX file.