Forum


Replies: 4   Views: 3208
"cell_color" option doesn't work for addtable()
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 nicolas  · 29-04-2011 - 14:19

Hi,

The "cell_color" option doesn't work for addTable() function.

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

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

$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');[/code]


Ideed, the if ($cont instanceof CreateText) and the if (!empty($cont->arrEmbeddedText[0]['cell_color'])) conditions (CreateTable.inc, line 148 PHPDOCX 2.1 PRO) are never true
Any help would be appreciated.

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

I have the same problem, here http://www.phpdocx.com/forum?vasthtmlaction=viewtopic&t=74.0

How i can do it?

Thanks.

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

Hello,

We have checked this error and found a bug that we'll be solved in the next version of phpdocx.
Apply the following path to solve the error in the current version of phpdocx:

Index: CreateTable.inc
===================================================================
--- CreateTable.inc (revisiĆ³n: 158)
+++ CreateTable.inc (copia de trabajo)
@@ -146,10 +146,10 @@
$this->generateTCW($args[1]['size_col']);
}
if ($cont instanceof CreateText) {
- if (!empty($cont->arrEmbeddedText[0]['cell_color'])) {
+ if (!empty($cont->_embeddedText[0]['cell_color'])) {
$this->generateSHD(
'solid',
- $cont->arrEmbeddedText[0]['cell_color']
+ $cont->_embeddedText[0]['cell_color']
);
}
} else {


Regards.

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

Seems you have to uncomment the contents of CreateTable::GenerateSHD as well - otherwise the call does nothing.
This worked for us.