html writes / setup table cell color
This commit is contained in:
parent
d1ce0c366a
commit
13fc647d01
|
|
@ -50,6 +50,14 @@ class Table extends AbstractElement
|
|||
$rowCellCount = count($rowCells);
|
||||
for ($j = 0; $j < $rowCellCount; $j++) {
|
||||
$cellStyle = $rowCells[$j]->getStyle();
|
||||
$cellBgColor = $cellStyle->getBgColor();
|
||||
$cellFgColor = null;
|
||||
if ($cellBgColor) {
|
||||
$r = hexdec(substr($cellBgColor, 0, 2));
|
||||
$g = hexdec(substr($cellBgColor, 2, 2));
|
||||
$b = hexdec(substr($cellBgColor, 4, 2));
|
||||
$cellFgColor = (($r * 0.299 + $g * 0.587 + $b * 0.114) > 186) ? null : 'ffffff';
|
||||
}
|
||||
$cellColSpan = $cellStyle->getGridSpan();
|
||||
$cellRowSpan = 1;
|
||||
$cellVMerge = $cellStyle->getVMerge();
|
||||
|
|
@ -73,7 +81,9 @@ class Table extends AbstractElement
|
|||
$cellTag = $tblHeader ? 'th' : 'td';
|
||||
$cellColSpanAttr = (is_numeric($cellColSpan) && ($cellColSpan > 1) ? " colspan=\"{$cellColSpan}\"" : '');
|
||||
$cellRowSpanAttr = ($cellRowSpan > 1 ? " rowspan=\"{$cellRowSpan}\"" : '');
|
||||
$content .= "<{$cellTag}{$cellColSpanAttr}{$cellRowSpanAttr}>" . PHP_EOL;
|
||||
$cellBgColorAttr = (is_null($cellBgColor) ? '' : " bgcolor=\"#{$cellBgColor}\"");
|
||||
$cellFgColorAttr = (is_null($cellFgColor) ? '' : " color=\"#{$cellFgColor}\"");
|
||||
$content .= "<{$cellTag}{$cellColSpanAttr}{$cellRowSpanAttr}{$cellBgColorAttr}{$cellFgColorAttr}>" . PHP_EOL;
|
||||
$writer = new Container($this->parentWriter, $rowCells[$j]);
|
||||
$content .= $writer->write();
|
||||
if ($cellRowSpan > 1) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue