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

Free Support Forum - aspose.com

Issue with creating border for a named range using Aspose cells for JAVA

Hi,

I am using Aspose for Cells for Java. I dont find any SetOutlineBorder() method to be used for Range object. I dont find any such method for the Range class. Could you please clarify regarding whether your API support is available for JAVA for setting an border for a Named Range?

Could you please let me know on how can I draw a border for a specific NamedRange using Aspose cells for JAVA.

regards,
perindev kumar


This message was posted using Email2Forum by ShL77.

Dear Perindev,

Thanks for considering Aspose.

Well the Range class is for internal usage only, kindly use NamedRange instead. The jave version does not have setOutlineBorder, but you may apply borders quite easily.

May the following code snippet help you for your task, kindly consult it :)

//Instantiate a new Workbook.
Workbook workbook = new Workbook();
//Get the first worksheet in the book.
Worksheet WS = workbook.getWorksheets().getSheet(0);
//Create a named range of cells.
com.aspose.cells.NamedRange range = WS.getCells().createNamedRange("MyRange",1, 1, 1, 17);
Style stl;
//Create the style object with respect to the style of a cell.
stl= WS.getCells().getCell(1,1).getStyle();
stl.setBorderLine(0,5);
stl.setBorderLine(1,5);
stl.setBorderLine(2,5);
stl.setBorderLine(3,5);
stl.setBorderColor(0,Color.BLACK);
stl.setBorderColor(1,Color.BLUE);
stl.setBorderColor(2,Color.GREEN);
stl.setBorderColor(3,Color.RED);
//solid Pattern setting.
stl.setColor(Color.YELLOW);
stl.setPatternStyle(PatternType.SOLID);

//Apply the style to the range.

for (int r = range.getStartRow();r<=range.getEndRow();r++)

{

for (int c = range.getStartColumn(); c<=range.getEndColumn();c++)

{

WS.getCells().getCell(r,c).setStyle(stl);

}

}

//Save the excel file.
workbook.save("e:\\files\\rangeborderstyles1.xls");

Thank you.