News
Docx document with a complex table: texts, links and images
- May 04, 2011
This information is outdated, please, refer to the addTable documentation for up to date info.
Another complex example: this time we create a document that includes a table with text, hyperlinks and an image. The link and the image may be inserted in a table, in a very easy and convenient way.
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
// Parameters for the hyperlink
$paramsLink = array(
'title' => 'Link to Google',
'link' => 'http:// www.google.es'
);
// Define the variable for the hyperlink
$link = $docx->addElement('addLink', $paramsLink);
// adding the image
$paramsImg = array(
'name' => '../files/img/image.png'
);
// Define de variable for the image
$image = $docx->addElement('addImage', $paramsImg);
// The info inside the table
$valuesTable = array(
array(
'Title A',
'Title B',
'Title C',
),
array(
'Line A',
// Adding the link to the table
$link,
// Adding the image to the table
$image,
)
);
// Parameters for the table
$paramsTable = array(
'TBLLOOKval' => 'ffff01E0',
'TBLSTYLEval' => 'Tablanormal',
'TBLWtype' => 'center',
'TBLWw' => '50',
'border' => 'single',
'border_sz' => 20,
'border_spacing' => 0,
'border_color' => 'ff0000',
'jc' => 'center',
'size_col' => 1200
);
// Constructing the table
$docx->addTable($valuesTable, $paramsTable);
// Creating the docx document
$docx->createDocx('example_table');