I'm trying to use phpdocx with Yii. The code snippet below (table example) is in a 'view' file of yii and it works.
BUT the following code with (template example) leads to the following Fatal error:
[b]Fatal error: Call to a member function close() on a non-object in /var/www/JobCockpit/phpdocx/classes/CreateTemplate.inc on line 163[/b]
How could this be resolved?
[i](template example) - error
[/i]
[code]
define('PHPDOCX_INCLUDE_PATH', (dirname(Yii::app()->basePath)).'/phpdocx');
require_once PHPDOCX_INCLUDE_PATH.'/classes/AutoLoader.inc';
spl_autoload_unregister(array('YiiBase','autoload'));
spl_autoload_register(array('AutoLoader','load'));
$docx = new CreateDocx();
$docx->addTemplate('files/mytemplate.docx');
$docx->addTemplateVariable('FIELD1', $model->field1);
$docx->addTemplateVariable('FIELD1', $model->field2);
$filename = "phpdocxGeneratedFile";
$docx->createDocx($filename);[/code]
[i]
(table example) - works[/i]
[code]define('PHPDOCX_INCLUDE_PATH', (dirname(Yii::app()->basePath)).'/phpdocx');
require_once PHPDOCX_INCLUDE_PATH.'/classes/AutoLoader.inc';
spl_autoload_unregister(array('YiiBase','autoload'));
spl_autoload_register(array('AutoLoader','load'));
$docx = new CreateDocx();
$myvar = $model->field1;
$valuesTable = array(
array(
$myvar,
12
),
array(
21,
22
),
);
$paramsTable = array(
'border' => 'single',
'border_sz' => 20
);
$docx->addTable($valuesTable, $paramsTable);
$filename = "phpdocxGeneratedFile";
$docx->createDocx($filename);[/code]