Set Different Style of Border of Cell’s on Excel Sheet Using JExcel APIs.
Previous | Home | Next |
Now, we will see how to set Different Style of Border of Cell’s on Excel Sheet Using JExcel APIs.
For setting the particular style for a border of an excel sheet's cell, we have to import the following classes,
import jxl.format.Border;
import jxl.format.BorderLineStyle;
As well as, we have also to import jxl.write.WritableFont class for setting the border of the cell.
The following code snippet will show how can we set the different styles of the border 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 by using the setBorder() method. And in this method we have set the border style to MEDIUM_DASH_DOT style.
Previous | Home | Next |