onizet / html2openxml

Html2OpenXml is a small .Net library that convert simple or advanced HTML to plain OpenXml components. This program has started in 2009, initially to convert user's comments into templated Word.
MIT License
321 stars 109 forks source link

Table Background Color missing #12

Closed onizet closed 6 years ago

onizet commented 6 years ago

[copied from codeplex]

I am using the SDK 2.5/.NET 4.0 set. Consider the following HTML table:

<tr class="TableHeaderCells">
     <th style="background-color:#FFFF99;" colspan="4"></th>
     <th style="background-color:#FFFF99;" colspan="7"></th>
     <th style="background-color:#FFFF99;" colspan="5">[Header Text]</th>
</tr>
<tr class="TableHeaderCells">
     <th style="background-color:#FFFF99;" colspan="4"></th>
     <th style="background-color:#FFFF99;" colspan="3">[More Header Text]</th>
     <th style="background-color:#FFFF99;" colspan="4">[Even More Header Text]</th>
     <th style="background-color:#FFFF99;" colspan="3">[Still Even More Header Text]</th>
     <th style="background-color:#FFFF99;" colspan="2">[So Much Header Text]</th>
</tr>

When I use HTMLtoOpenXML to convert this table, I lose the "background-color" style and I haven't been able to pinpoint why yet. I think it might be here in

TableStyleCollection.ProcessCommonAttributes:
var colorValue = en.StyleAttributes.GetAsColor("background-color");

// "background-color" is also handled by RunStyleCollection which duplicate this attribute (bug #13212). Let's ignore it
if (!colorValue.IsEmpty && en.CurrentTag.Equals("<td>", StringComparison.InvariantCultureIgnoreCase)) colorValue = System.Drawing.Color.Empty;

Has anybody else seen this happen to them? If so, how did you address the issue?