Hello guys!
Above all sorry for my english
Yesterday I have found an exellent PHPWord class ( http://phpword.codeplex.com/ )
I'm going to create the module that based on phpWord that allows to work with .doc files and use doc templates.
My programming skills let to do it with no problem but I want to code this class support maximally using existing PW abilities.
One my big problem (exactly - my non-acquaintance) is on saving generated DOC-file.
This PHP class saves document in any directory that I can choose using $document->save('/dir/Solarsystem.docx'); instruction.
I'm going to show a little example for you:
require_once '../PHPWord.php';
$PHPWord = new PHPWord();
$document = $PHPWord->loadTemplate('Template.docx');
$document->setValue('Value1', 'Sun');
$document->setValue('Value2', 'Mercury');
$document->setValue('Value3', 'Venus');
$document->setValue('weekday', date('l'));
$document->setValue('time', date('H:i'));
$document->save('Solarsystem.docx');
This code replaces some values in template document and saves it.
And one main question - how to save it right using PW? The best variant is to save it to DB like other files saving through admin interface, but more perfect is to give file to user by setting headers in response, with no fixing it in DB or file system
Hope for your help
Thanks!
PHPWord_0.6.2_Beta.zip