Cell shading got removed while setting table style

I wanted to create a table with background Red colour and cell in 1x1 position in Yellow colour. After setting the cell shading background colour of 1x0 cell is removed.

Code used

TableStyle tableStyle = (TableStyle)doc.getStyles().add(StyleType.TABLE, "TableStyleTest");
tableStyle.getShading().setBackgroundPatternColor(Color.RED);
builder.startTable();

for (int i = 0; i < 4; i++)
{
    for (int j = 0; j < 4; j++)
    {
        builder.insertCell();
        builder.write("Row " + (i + 1) + ", Column " + (j + 1));
    }
    builder.endRow();
}

Table table = builder.endTable();
table.setStyle(tableStyle);
table.getRows().get(1).getCells().get(1).getCellFormat().getShading().setBackgroundPatternColor(Color.YELLOW);

Find the attachment.

@vibinkrishnadas42
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-24995

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@vibinkrishnadas42 The reason for this behavior is in UseWord2002TableStyleRules option which is enabled when the document is saved with the default compatibility options. If a table has a custom table style and a direct cell formatting, the formatting inherited from the table style is reset for some of the cells.
Starting from 2010 compatibility version, this flag is not accepted and the table is displayed as expected.
We can suggest that the customer should drop UseWord2002TableStyleRules flag or save the document in the actual compatibility version.

// The first way.
Document doc = new Document();
doc.CompatibilityOptions.UseWord2002TableStyleRules = false;
....

// The second way.
OoxmlSaveOptions so = new OoxmlSaveOptions();
so.Compliance = OoxmlCompliance.Iso29500_2008_Transitional;
Document doc = new Document();
doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2019);
..
doc.Save("out.docx", so); 

The issues you have found earlier (filed as WORDSNET-24995) have been fixed in this Aspose.Words for Java 24.1 update.