I will work on getting you sample code but its a bit complicated because we are using Aspose to generate HTML representation of an excel spreadsheet and then attempting to update the contents of a cell using Aspose.Cell’s HtmlString property.
In this case, after the HTML is generated, the HtmlString property is created as:
<Font Style=“FONT-WEIGHT: bold;FONT-STYLE: italic;FONT-FAMILY: arial;FONT-SIZE: 10pt;COLOR: #ff0000;Background-Color: #ffff99;”>Please see below…</Font>
Note that the Font styling here is being added to this html Font element based on a parent td element’s class being a shared style created during the html generation of the spreadsheet.
We attempt to assign the following into the cell’s HtmlString property:
<font style=“font-style: normal; font-weight: normal; text-decoration: none;”>Please see below.</font>
The resulting value in the HtmlString property is:
<Font Style=“FONT-FAMILY: arial;FONT-SIZE: 10pt;COLOR: #ff0000;Background-Color: #ffff99;”>Please see below.</Font>
Note that it did get rid of the original FONT-WEIGHT and FONT-STYLE attributes. However, the parent td elements shared class is being inherited and the display still shows the cell’s content as bolded and as italic.
It seems that our assignment html string with the “font-style: normal” and “font-weight: normal” attributes into the HtmlString property removes the original attributes instead of explicitly setting the style attributes our string is specifying. Without those being explicitly specified in the cell’s html, the inherited styles from the parent element takes control.
I suspect it has something to do with those attribute values being the css default values and maybe the logic thinks it is enough to simply remove the original attributes instead of explicitly using our updated attribute values.
Note that the class assigned to the parent td element is derived from the Aspose Workbook method “GetStyleInPool” and, in this case, results in the following shared class:
.style74
{
text-align: general;
vertical-align: top;
white-space:normal;word-wrap:break-word;
background:#FFFF99;
font-size: 10pt;
font-weight: 700;
font-style: italic;
font-family: “arial”;
border-top: 1px solid #000000;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
border-left: 1px solid #000000;
}