Free Support Forum - aspose.com

How to create patterns in a cell background

Hi,

How to create patterns in a cell background of excel sheet 2003 and excel 2007 format?

I have attached the pattern, which we want to use for a cell.

Please provide us with some sample examples.

Thanks

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

Please see the following sample code to set the cell background pattern as per your requirement.

//Create Workbook Object

Workbook wb = new Workbook();

//Open first Worksheet in the workbook

Worksheet ws = wb.getWorksheets().getSheet(0);

//Get Worksheet Cells Collection

Cells cell = ws.getCells();

//Get Cell's Style

Style style = cell.getCell(0, 0).getStyle();

style.setPatternColor(Color.BLUE);

style.setColor(Color.YELLOW);

style.setPatternStyle(PatternType.THIN_DIAGONAL_STRIPE);

//Set Cell's Style

cell.getCell(0, 0).setStyle(style);

//Save Excel File

wb.save("D:\\cell_style.xls");

Please check the following documentation link for further details regarding background styles and patterns.

http://www.aspose.com/documentation/java-components/aspose.cells-for-java/colors-background-patterns.html

Thank You & Best Regards,