Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
Hello,
I try put chart in variable.
.....
$chart = new WordFragment();
$data = array(
'Legend 1' => array(20),
'Legend 2' => array(30),
'Legend 3' => array(40)
);
$paramsChart = array(
'data' => $data,
'type' => 'pie3DChart'
);
$chart->addChart($paramsChart);
$docx->replaceVariableByWordML(array('QUESTION_6_CHART' => $chart));
....
Browser shows this is:
Fatal error: Call to a member function addFromString() on a non-object in ...../tools/4.6/classes/CreateDocx.inc on line 1188
--------
php check.php
OK PHP version is 5.3.18
OK Zip support is enabled.
OK DOM support is enabled.
OK XML support is enabled.
OK Tidy support is enabled.
If you have any issue or problem please send us the following info:
PHP_VERSION: 5.3.18
PHP_OS: Linux
PHP_UNAME: Linux sdi5.example.ru 2.6.33.20-bitrix10 #6 SMP Thu Nov 24 17:29:20 MSK 2011 x86_64
SERVER_NAME:
SERVER_SOFTWARE:
SERVER_ADDR:
SERVER_PROTOCOL:
HTTP_HOST:
HTTP_X_FORWARDED_FOR:
PHP_SELF: check.php
ZipArchive: 1
DomDocument: 1
SimpleXMLElement: 1
Tidy: 1
Hello,
You need to the replaceVariableByWordFragment replaceVariableByWordML not replaceVariableByWordML. Please read these pages fo more information:
http://www.phpdocx.com/api-documentation/templates/replace-variable-word-fragment-Word-document
http://www.phpdocx.com/api-documentation/templates/replace-variable-wordml-Word-document
Regards.
I changed to replaceVariableByWordFragment. The same error. From CLI too.
Hello,
Please run the included examples in the Templates/replaceVariableByWordFragment folder and check if the output is fine.
And please send to contact[at]phpdocx.com the most simple script that illustrates the problem.
Regards.
Examples is working. But this script is not.
----------------------------------
require_once('../../../classes/CreateDocx.inc');
$docx = new CreateDocxFromTemplate('../../files/TemplateWordFragment_3.docx');
$chart = new WordFragment();
$data = array(
'Legend 1' => array(20),
'Legend 2' => array(30),
'Legend 3' => array(40)
);
$paramsChart = array(
'data' => $data,
'type' => 'pie3DChart'
);
$chart->addChart($paramsChart);
$docx->replaceVariableByWordFragment(array('WORDFRAGMENT_BODY' => $chart), array('type' => 'block'));
$docx->createDocx('example_replaceVariableByExternalFile_chart');
Hello,
You can't invoke this line:
$chart = new WordFragment();
without the main $docx.
If you check the included examples in detail, you'll see this line:
$wf = new WordFragment($docx, 'document');
You need to set the main $docx where to use the WordFragment object.
Regards.
It's working. 8-)
Thank you