Guest User

Untitled

a guest
Dec 14th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <?php
  2.  
  3. require 'vendor/autoload.php';
  4.  
  5. $phpWord = new PhpOfficePhpWordPhpWord();
  6.  
  7. $document = $PHPWord->loadTemplate('Template.docx'); //шаблон
  8. $document->setValue('d_num', '777'); //номер договора
  9. $document->setValue('d_date', '04.10.2014'); //дата договора
  10. $document->setValue('last_name', 'Никоненко'); //фамилия
  11. $document->setValue('name', 'Сергей');// имя
  12. $document->setValue('surname', 'Васильевич');// отчество
  13.  
  14. header("Content-Description: File Transfer");
  15. header('Content-Disposition: attachment; filename="my dream.docx"');
  16. header('Content-Type: application/vnd.openxmlformats-
  17. officedocument.wordprocessingml.document');
  18. header('Content-Transfer-Encoding: binary');
  19. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  20. header('Expires: 0');
  21.  
  22. $xmlWriter = PhpOfficePhpWordIOFactory::createWriter($phpWord,
  23. 'Word2007');
  24. $xmlWriter->save("php://output");
Add Comment
Please, Sign In to add comment