Hi,
see attachment. The piece of code creates a table with 3 cells. The first cell should be red, the second green and the third blue. I use Document builder (not using it does not work either) and
CellFormat cellFormat = m_DocumentBuilder.getCellFormat();
cellFormat.clearFormatting();
…
cellFormat.getShading().setTexture(TextureIndex.TEXTURE_SOLID);
cellFormat.getShading().setForegroundPatternColor(bkColor);
cellFormat.getShading().setBackgroundPatternColor(bkColor);
this does not work either:
Cell result = m_DocumentBuilder.insertCell();
result.getCellFormat().getShading().setTexture(TextureIndex.TEXTURE_SOLID);
result.getCellFormat().getShading().setForegroundPatternColor(bkColor);
result.getCellFormat().getShading().setBackgroundPatternColor(bkColor);
Could you please provide a valid workaround or fix this (both variants) as soon as possible and send me an information, when this will be fixed.
BR,
Torsten
Hi Torsten,
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);// We call this method to start building the table.
builder.startTable();
builder.insertCell();
builder.getCellFormat().clearFormatting();
builder.getCellFormat().getShading().setBackgroundPatternColor(Color.RED);builder.write(“Row 1, Cell 1 Content.”);
// Build the second cell
builder.insertCell();
builder.getCellFormat().clearFormatting();
builder.getCellFormat().getShading().setBackgroundPatternColor(Color.GREEN);builder.write(“Row 1, Cell 2 Content.”);
// Build the third cell
builder.insertCell();
builder.getCellFormat().clearFormatting();
builder.getCellFormat().getShading().setBackgroundPatternColor(Color.BLUE);builder.write(“Row 1, Cell 3 Content.”);
// Call the following method to end the row and start a new row.
builder.endRow();// Signal that we have finished building the table.
builder.endTable();// Save the document to disk.
doc.save(“C:\temp\out.docx”);
It works! Thank you so much for your fast help!