Forum


Replies: 7   Views: 3556
Format table
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 gerix  · 09-10-2011 - 12:40

Hello, I would like to ask for advice.
How do I create a table that will have the first value in bold and the other normal.
Example: Name: John =>> [b]Name:[/b] John
Source Code:

[code]
<?php
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();

$paramsTable = array(
'border' => 'none',
'border_spacing' => 5,
'size_col' => '3000',
'TBLWw' => '500',
'font' => Arial,
'border_sz' => 10
);

$tabulka1 = array(
array(
"Name:",
"John"
),
array(
"Name:",
"Kate"
),
);

$docx->addTable($tabulka1, $paramsTable);

$docx->createDocxAndDownload('example_table');

[/code]

Thank you for your answer

Posted by admin  · 11-04-2013 - 12:13

Hello,

You need to add a CreateText object and add it into the table; please check intermediate/Table.php example included on phpdocx pro.

Regards.

Posted by gerix  · 11-04-2013 - 12:13

Please show me a simple example.

Posted by gerix  · 11-04-2013 - 12:13

Why I do not work? Please advice: (
[code]
<?php
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();

$bold = $docx->addText('Bold', array('b' => 'single'));

$tab = array(
array($bold, Normal),
array($bold, Normal)
);

$docx->addTable($tab);
$docx->createDocxAndDownload('table');

[/code]

Posted by gerix  · 11-04-2013 - 12:13

Bold does not insert into the table. Always appears above it. Why? Thank you for the answer :(

Posted by ankit2rai  · 11-04-2013 - 12:13

I hope the below example will serve your purpose well…

[code]
<?php
require_once ‘../../classes/CreateDocx.inc’;
$docx = new CreateDocx();

$paramsTable = array(
‘border’ => ‘none’,
‘border_spacing’ => 5,
’size_col’ => ‘3000′,
‘TBLWw’ => ‘500′,
‘font’ => Arial,
‘border_sz’ => 10
);

$text[] =
array(
‘text’ => ‘Name : ‘,
‘b’ => ’single’,
);

$var=$docx->addElement(’addText’,$text);

$tabulka1 = array(
array(
$var,
“John”
),
array(
$var,
“Kate”
),
);

$docx->addTable($tabulka1, $paramsTable);

$docx->createDocxAndDownload(’example_table’);
[/code]

Posted by temp2010  · 04-09-2013 - 21:34

$text = array();

$text[] = array("text" => "Version 1.0");

$text = $docx->addText($text, array('rawWordML' => true));

$textFragment = $docx->createWordMLFragment($text);

$numbering = $docx->addPageNumber("numerical", array("rawWordML" => true));

$pageFragment = $docx->createWordMLFragment(array($numbering));

$value = array(array($textFragment, "Pag", $pageFragment));

$tabla = $docx->addTable($value, array("tableWidth"=>array("type" => "pct", "value" => 100), "size_col" => array(11000), "border" => "none", "rawWordML" => true));

$myFooter = $docx->createWordMLFragment($tabla);

$docx->addFooter(array("default" => $myFooter));