@@ -50,6 +50,14 @@ public function write()
50
50
$ rowCellCount = count ($ rowCells );
51
51
for ($ j = 0 ; $ j < $ rowCellCount ; $ j ++) {
52
52
$ cellStyle = $ rowCells [$ j ]->getStyle ();
53
+ $ cellBgColor = $ cellStyle ->getBgColor ();
54
+ $ cellFgColor = null ;
55
+ if ($ cellBgColor ) {
56
+ $ r = hexdec (substr ($ cellBgColor , 0 , 2 ));
57
+ $ g = hexdec (substr ($ cellBgColor , 2 , 2 ));
58
+ $ b = hexdec (substr ($ cellBgColor , 4 , 2 ));
59
+ $ cellFgColor = (($ r * 0.299 + $ g * 0.587 + $ b * 0.114 ) > 186 ) ? null : 'ffffff ' ;
60
+ }
53
61
$ cellColSpan = $ cellStyle ->getGridSpan ();
54
62
$ cellRowSpan = 1 ;
55
63
$ cellVMerge = $ cellStyle ->getVMerge ();
@@ -73,7 +81,9 @@ public function write()
73
81
$ cellTag = $ tblHeader ? 'th ' : 'td ' ;
74
82
$ cellColSpanAttr = (is_numeric ($ cellColSpan ) && ($ cellColSpan > 1 ) ? " colspan= \"{$ cellColSpan }\"" : '' );
75
83
$ cellRowSpanAttr = ($ cellRowSpan > 1 ? " rowspan= \"{$ cellRowSpan }\"" : '' );
76
- $ content .= "< {$ cellTag }{$ cellColSpanAttr }{$ cellRowSpanAttr }> " . PHP_EOL ;
84
+ $ cellBgColorAttr = (is_null ($ cellBgColor ) ? '' : " bgcolor= \"# {$ cellBgColor }\"" );
85
+ $ cellFgColorAttr = (is_null ($ cellFgColor ) ? '' : " color= \"# {$ cellFgColor }\"" );
86
+ $ content .= "< {$ cellTag }{$ cellColSpanAttr }{$ cellRowSpanAttr }{$ cellBgColorAttr }{$ cellFgColorAttr }> " . PHP_EOL ;
77
87
$ writer = new Container ($ this ->parentWriter , $ rowCells [$ j ]);
78
88
$ content .= $ writer ->write ();
79
89
if ($ cellRowSpan > 1 ) {
0 commit comments