We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to use customized colors

Hi.

Please let me know how to use self defined colors schemes.

Sunil

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. It is not quite clear for me what you need to achieve. Would you please provide me more information about your needs?

Best regards.

Hi.

How to use hex color value in background/forground.

Sunil

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Please see the following code:

// Use the hex number syntax

java.awt.Color myRed = new java.awt.Color(0xFF0000);

// Alternatively, use Color.decode

java.awt.Color myGreen = java.awt.Color.decode("0x00FF00");

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.insertCell();

//Set background color

builder.getCellFormat().getShading().setBackgroundPatternColor(myRed);

builder.write("Here is red bacground");

builder.insertCell();

builder.getCellFormat().getShading().setBackgroundPatternColor(myGreen);

builder.write("Here is green bacground");

builder.endRow();

builder.endTable();

//Save output document

doc.save("C:\\Temp\\out.doc");

Hope this helps.

Best regards.