Forum


Replies: 8   Views: 5024
Add table by wordfragment not working
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.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by 243127387@qq.com  · 13-10-2015 - 12:50

Hi ,

I may well be having a brain block moment. I change and run /examples/Core/addMathEquation/sample_2.php by adding a table. In the generated word, the table will not display properly. But I really need to do like this in the project of our company. We have purchased the version phpdocx-pro-5.0. We run the code is as follows:

$docx->addText('We write a math equation using OMML (the native Word XML standard for math equations):');

$docx->addMathEquation(
    '<m:oMathPara>
        <m:oMath><m:r><m:t>∪±∞=~×</m:t></m:r></m:oMath>
    </m:oMathPara>', 'omml'
);

$text = array();
$text[] = array('text' => 'The same equation inline: ');
$math = new WordFragment($docx);
$math->addMathEquation(
    '<m:oMathPara>
        <m:oMath><m:r><m:t>∪±∞=~×</m:t></m:r></m:oMath>
    </m:oMathPara>', 'omml'
);
$text[] = $math;

$table = new WordFragment($docx);
$tabeleArray=array(
     array('11','12','13'),
     array('21','22','23')
        );
$table->addTable($tabeleArray);
$text[] = $table;

$docx->addText($text);

   Am I missing something? Looking forward to your reply, thank you!

Posted by admin  · 14-10-2015 - 08:48

Hello,

The current version of phpdocx doesn't allow adding equations in cells. This feature will be added in the next version.

Regards.

Posted by 243127387@qq.com  · 14-10-2015 - 09:28

I add table ,not add MathEquation. Please assess, whether to support, thanks.

Posted by admin  · 14-10-2015 - 09:37

Hello,

We don't recommend you to add a WordFragment table with WordFragments to other element, or you'll get unexpected errors.

Please check the included examples; for further support please write to contact[at]phpdocx.com

Regards.

Posted by 243127387@qq.com  · 14-10-2015 - 14:36

Thank you for your reply, admin. please look the follow example:

$text=array();
// add textFragment
$textstr='PHPDOCX is a very good software! So we have bought the pro 5.0.';
$textFragment = new WordFragment($docx);
$textFragment->addText($textstr);
$text[]=$textFragment;

// add tableFragment
$tableFragment = new WordFragment($docx);
$tabeleArray=array(
     array('11','12'),
     array('21','22')
        );
$tableFragment->addTable($tabeleArray);
$text[] = $tableFragment;

$docx->addText($text);

run the up example, the table can't display properly. I'm very sorry, and always disturb you.

Posted by admin  · 14-10-2015 - 14:43

Hello,

As explained previously and in the documentation, you can't add a block WordFragment inside an inline WordFragment.

For further support please write to contact[at]phpdocx.com

Regards.

Posted by 243127387@qq.com  · 15-10-2015 - 11:44

OK , I will consult my boss, see whether he agrees to do this or not. Thanks.