I am working on an application where we have some content that is provided by our users as HTML and that content can contain HTML. If we insert some HTML in an Aspose Word Document that contains a table, it seems to prevent us from changing the color of future tables created directly without HTML.
Here’s a repro-case:
String html = "<table><tbody><tr><td style='background: red'>Red HTML</td></tr></tbody></table>";
DocumentBuilder docBuilder = new DocumentBuilder();
docBuilder.insertHtml(html);
docBuilder.insertBreak(BreakType.LINE_BREAK);
docBuilder.getCellFormat().getShading().setBackgroundPatternColor(Color.BLUE);
docBuilder.startTable();
Cell cell = docBuilder.insertCell();
docBuilder.write("I should be blue, green or yellow");
docBuilder.endRow();
docBuilder.endTable();
cell.getCellFormat().getShading().setBackgroundPatternColor(Color.GREEN);
docBuilder.getCellFormat().getShading().setBackgroundPatternColor(Color.YELLOW);
docBuilder.getDocument().save("test.doc");
In this code, an HTML table is inserted with a cell with a red background. Then a second table is inserted but I can’t do anything to get the cells in this table to not be red. As you can see, I’ve tried using the CellFormat property on the DocumentBuilder both before and after as well as the CellFormat on the cell itself. In the above, the code that tries to set the cell color to blue and then green and then yellow, but none of those work. The cell remains red.
If I comment out the insertHtml call, then I get a green cell as I would expect.
I am using Aspose.Words 2.4.2 for JDK 1.5.