Set Color of Border of Cell’s on Excel Sheet Using JExcel APIs.
Previous | Home | Next |
In this part we will know how to set Color of Border of Cell on Excel Sheet Using JExcel APIs.
For setting the colour of the border of an excel sheet's cell, we have to import the following classes,
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
As well as, we have also to import jxl.write.WritableFont class for setting the colour of the border of the cell.
The following code snippet will show how can we set the colour of theborder of a cell in a excel worksheet,
WritableFont wfobj=new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,Colour.BLUE);
WritableCellFormat cfobj=new WritableCellFormat(wfobj);
cfobj.setBackground(Colour.GREY_25_PERCENT);
cfobj.setAlignment(Alignment.LEFT);
cfobj.setOrientation(Orientation.HORIZONTAL);
cfobj.setBorder(Border.RIGHT, BorderLineStyle.MEDIUM_DASH_DOT,Colour.BLACK);
cfobj.setShrinkToFit(true);
cfobj.setWrap(true);
In the above code we have created a WritableCellFormat object and then on that object we have set the border colour by using the setBorder() method.
Previous | Home | Next |