Forum


Replies: 1   Views: 2363
How to add table in wordfragment?
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 sbhosale  · 28-09-2017 - 09:09

Hi,

 

I am trying to add  table in document using wordfragement but not getting displayed.

 

Code:

$text = [];
$table = new WordFragment( $docx );
$valuesTable = array(
 array(
  'Charge Name', 'Due Date', 'Amount'
 ),

 array(
  'Electricity', '9/28/2017' , $100.65
 )
);
$paramsTable = array(
 'border' => 'single',
 'tableAlign' => 'center',
 'borderWidth' => 5,
);
$table->addTable( $valuesTable, $paramsTable );

$html = new WordFragment( $docx);
$html->embedHtml('<p>Hi I am here <p>');
$text[] = $table;
$text[] = $html
$docx->addText($text);
$docx->createDocx('test.docx');

 

Please correct me where I am wrong.

Thanks,

 

Shilpa