Forum


Replies: 4   Views: 3318
Cell_color doesn't work
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 Evan  · 09-06-2011 - 07:53

This simple example doesn't work.

The problem is the parameter cell_color. Those cells don't have red color.

Is It my foult or really happen something wrong?

Thank you.

[code]$title = array();
$title[] =
array(
'text' => 'Title A',
'b' => 'single',
'cell_color' => 'FF0000'
);

$titleA = $docx->addElement('addText', $title);

$title[0]['text'] = 'Title B';

$titleB = $docx->addElement('addText', $title);

$title[0]['text'] = 'Title C';

$titleC = $docx->addElement('addText', $title);

$title[0]['text'] = 'Title D';

$titleD = $docx->addElement('addText', $title);

$title[0]['text'] = 'Title E';

$titleE = $docx->addElement('addText', $title);

$valuesTable = array(
array(
$titleA,
$titleB,
$titleC,
$titleD,
$titleE
),
array(
'Line A',
'Value 01',
'Value 02',
'Value 03',
'Value 04',
'Value 05'
),
array(
'Line B',
'Value 11',
'Value 12',
'Value 13',
'Value 14',
'Value 15'
),
array(
'Line C',
'Value 21',
'Value 22',
'Value 23',
'Value 24',
'Value 25'
)
);

$paramsTable = array();

$docx->addTable($valuesTable, $paramsTable);[/code]

Posted by jadeglobal  · 11-04-2013 - 12:12

cell_color does not appear to be defined anywhere. I am also breaking my head on this. Currently making all tables with HTML and then inserting the HTML

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

Hello,

Running the following script on the last version of phpdocx pro:

[quote]

require_once '../classes/CreateDocx.inc';

$docx = new CreateDocx();
$title = array();
$title[] =
array(
'text' => 'Title A',
'b' => 'single',
'cell_color' => 'C2F9B9'
);

$titleA = $docx->addElement('addText', $title);

$title[0]['text'] = 'Title B';

$titleB = $docx->addElement('addText', $title);

$title[0]['text'] = 'Title C';

$titleC = $docx->addElement('addText', $title);

$title[0]['text'] = 'Title D';

$titleD = $docx->addElement('addText', $title);

$title[0]['text'] = 'Title E';

$titleE = $docx->addElement('addText', $title);

$valuesTable = array(
array(
$titleA,
$titleB,
$titleC,
$titleD,
$titleE
),
array(
'Line A',
'Value 01',
'Value 02',
'Value 03',
'Value 04',
'Value 05'
),
array(
'Line B',
'Value 11',
'Value 12',
'Value 13',
'Value 14',
'Value 15'
),
array(
'Line C',
'Value 21',
'Value 22',
'Value 23',
'Value 24',
'Value 25'
)
);

$paramsTable = array();

$docx->addTable($valuesTable, $paramsTable);
$docx->createDocx('test_table');

[/quote]

create a new DOCX with color cells.

Regards.

Posted by jadeglobal  · 11-04-2013 - 12:12

Excellent work around! Works great!