Nested Css in workbook

I’m trying to use the following code to create a workbook with different colors on each row. It doesn’t seem to like the nested css I’m using. If I open this html in a web browser by itself, I’ll see the 2 colors. When it creates the workbook, there aren’t any colors.

I’m using Aspose.Cells 7.5.1

var writer = new StringWriter();
style = @"
tr.Row1 td.Col1 { background-color: #BCC7D8; }
tr.Row2 td.Col1 { background-color: #e6e6e6; }
“;
content = @”
Row 1 - Cell 1
Row 2 - Cell 1
“;
using (var htmlWriter = new System.Web.UI.HtmlTextWriter(writer))
{
htmlWriter.WriteFullBeginTag(“html”);

htmlWriter.WriteFullBeginTag(“head”);
htmlWriter.Write(”");
htmlWriter.Write(style);
htmlWriter.WriteEndTag(“head”);

htmlWriter.WriteFullBeginTag(“body”);
htmlWriter.Write(content);
htmlWriter.WriteEndTag(“body”);

htmlWriter.WriteEndTag(“html”);
}

string html = writer.ToString();

byte[] data = Encoding.UTF8.GetBytes(html);
var stream = new MemoryStream(data);

var loadOptions = new LoadOptions(LoadFormat.Html);

var wb = new Workbook(stream, loadOptions);

Hi Steve,

Thanks for your posting and using Aspose.Cells.

We have noticed this issue. Aspose.Cells does not recognizes the nested css in workbook. However, MS-Excel is able to show it correctly.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-42475.

I have attached the screenshot that shows the MS-Excel display of your html for a reference.

Screenshot:

@sswift ,

This to inform you that your issue has been resolved. The fix will be included in an upcoming release (Aspose.Cells v26.8) that we plan to release in the first half of August 2026. You will be notified when the next version is released.
The result after applying the fix is attached for your review.
output.zip (6.0 KB)