I need to apply common formatting to all cells on a worksheet. API documentation indicates I should be able to call something similar to the following
Workbook workbook = new Workbook();
Style style = workbook.createStyle();
style.setPattern(BackgroundType.SOLID);
BorderCollection borders = style.getBorders();
borders.setStyle(CellBorderType.NONE);
However these APIs don’t appear to be available in my version of Aspose Cells. I don’t have “setPattern” method on the Style object, only “setPatternStyle”.
Can you please help me achieve the above formatting in the version of Aspose.Cells I have?
We are using aspose-cells-2.5.4.10.jar
Thanks
Hi,
Example:<o:p></o:p>
[JAVA]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Accessing the added worksheet in the Excel file
Worksheet worksheet = workbook.getWorksheets().addSheet();
Cells cells = worksheet.getCells();
//Accessing the "A1" cell from the worksheet
Cell cell=cells.getCell("A1");
Style style = cell.getStyle();
//Setting the foreground color to yellow
style.setColor(Color.YELLOW);
//Setting the background pattern to vertical stripe
style.setPatternStyle(PatternType.VERTICAL_STRIPE);
//Saving the modified style to the "A1" cell.
cell.setStyle(style);
//Accessing the "A2" cell from the worksheet
cell=cells.getCell("A2");
style = cell.getStyle();
//Setting the foreground color to blue
style.setColor(Color.BLUE);
//Setting the background color to yellow
style.setPatternColor(Color.YELLOW);
//Setting the background pattern to vertical stripe
style.setPatternStyle(PatternType.VERTICAL_STRIPE);
//Saving the modified style to the "A2" cell.
cell.setStyle(style);
//Saving the Excel file
workbook.save("C:\\output.xls",FileFormatType.DEFAULT);
Thanks Amjad. We are in the process of renewing our license file to get the latest version.
Until that process is complete, do you think you could provide me a link to the full API documentation for the version of Aspose.Cells Java I am using currently?
aspose-cells-2.5.4.10.jar
Would like the full documentation for this version.
Thanks.
Hi,