Styling a table with PHPdocx
June 6, 2011
This information is outdated, please, refer to the addTable method documentation for up to date info.
Do you need to insert a sophisticated table into your Word document?
You can get a hint about how to do it with the following sample code:
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$frameworks = array(
array('name' => 'Code Igniter',
'ajax' => 'Prototype/script.aculo.us, jQuery/jQuery UI',
'mvc' => 'Modified active record pattern',
'orm' => 'No',
'security' => 'Yes'
),
array('name' => 'Drupal',
'ajax' => 'jQuery/jQuery UI, more',
'mvc' => 'No',
'orm' => 'Optional module',
'security' => 'Yes'
),
array('name' => 'eZ Components',
'ajax' => 'No',
'mvc' => 'Yes',
'orm' => 'Yes',
'security' => 'Yes'
),
array('name' => 'Symfony',
'ajax' => 'Prototype, script.aculo.us, Unobtrusive Ajax ' .
'with UJS and PJS plugins',
'mvc' => 'Push',
'orm' => 'Yes',
'security' => 'Plugin'
),
array('name' => 'Zend Framework',
'ajax' => 'Toolkit-independent',
'mvc' => 'Push and Pull',
'orm' => 'Yes',
'security' => 'ACL-based'
)
);
$headerStyle[0] = array(
'b' => 'single',
'font' => 'Arial',
);
$table[] = array(
'',
'Ajax',
'MVC framework',
'ORM',
'Security Framework(s)'
);
foreach ($frameworks as $framework) {
$headerStyle[0]['text'] = $framework['name'];
$table[] = array(
$docx->addElement('addText', $headerStyle),
$framework['ajax'],
$framework['mvc'],
$framework['orm'],
$framework['security']
);
}
$paramsTable = array(
'TBLLOOKval' => 'ffff01E0',
'TBLSTYLEval' => 'Tablanormal',
'TBLWtype' => 'center',
'TBLWw' => '50',
'border' => 'single',
'border_sz' => 20,
'border_spacing' => 0,
'border_color' => '000000',
'jc' => 'center',
'size_col' => 2800
);
$docx->addTable($table, $paramsTable);
$docx->createDocx('example_table_styled');
If you enjoyed this post you might want to subscribe to our RSS Feed!
Recent Posts
-
March 4, 2013We are happy to announce the release of PHPDocX v3.2. This new version includes some important changes that greatly improve the PHPDocX...
-
February 6, 2013Since v3.0 we have included the notion of Word (or WordML) fragments to simplify the process of creating sophisticated Word documents from scratch...
-
January 31, 2013We are happy to announce the release of PHPDocX v3.1 This new version includes quite a few new features that you may find interesting: It is now...
-
January 8, 2013We have just released PHPDocX v3.0. This new version includes substantial changes that have required that this new version were not fully backwards...
-
December 21, 2012Although one can easily introduce real checkboxes in a Word document generated by PHPDocX via the embedHTML method (just include the corresponding...
PHPDocx. Dinamic generation of reports in .docx format 