Hi,
How to give gradient background color for document builder table?
Hi,
How to give gradient background color for document builder table?
Hi there,
Thanks for your patience. In reference to above issue, there is the Shading class allowing you to set background color of a table cell or paragraph, you can use various shading colors and textures. Please check this sample code to create a table with 4 cells having different shading, hopefully it will help you to accomplish the task.
com.aspose.words.Document doc = new com.aspose.words.Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.startTable();
builder.insertCell();
builder.getCellFormat().getShading().setTexture(TextureIndex.TEXTURE_SOLID);
builder.getCellFormat().getShading().setBackgroundPatternColor(Color.BLUE);
builder.getCellFormat().getShading().setForegroundPatternColor(Color.BLUE);
builder.insertCell();
builder.getCellFormat().getShading().setTexture(TextureIndex.TEXTURE_DIAGONAL_CROSS);
builder.getCellFormat().getShading().setBackgroundPatternColor(Color.YELLOW);
builder.getCellFormat().getShading().setForegroundPatternColor(Color.PINK);
builder.endRow();
builder.insertCell();
builder.getCellFormat().getShading().setTexture(TextureIndex.TEXTURE_50_PERCENT);
builder.getCellFormat().getShading().setBackgroundPatternColor(Color.CYAN);
builder.getCellFormat().getShading().setForegroundPatternColor(Color.MAGENTA);
builder.insertCell();
builder.getCellFormat().getShading().setTexture(TextureIndex.TEXTURE_HORIZONTAL);
builder.getCellFormat().getShading().setBackgroundPatternColor(Color.RED);
builder.getCellFormat().getShading().setForegroundPatternColor(Color.LIGHT_GRAY);
builder.endRow();
builder.endTable();
doc.save("out.docx");
Best Regards,