News
Styling a table with PHPdocx
- Jun 06, 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');