Advertisement
miraage

docx

Mar 7th, 2012
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2.  
  3. class Docx
  4. {
  5.     private $_doc;
  6.     private $_name;
  7.  
  8.     public function __construct($template)
  9.     {
  10.         $this->_name = $template;
  11.         $this->_doc  = new phpdocx($template);
  12.     }
  13.  
  14.     public function save($outFile, $params = array())
  15.     {
  16.         if ($outFile == $this->_name)
  17.         {
  18.             throw new Exception('Output file is the same as input template');
  19.         }
  20.  
  21.         if (count($params))
  22.         {
  23.             foreach ($params as $key => $value)
  24.             {
  25.                 $this->_doc->assign('#' . $key . '#', $value);
  26.             }
  27.         }
  28.  
  29.         $this->_doc->save($outFile);
  30.     }
  31.  
  32. }
  33.  
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement