Set Cell’s Background Color on Excel Sheet Using JExcel APIs.

Set Cell’s Background Color on Excel Sheet Using JExcel APIs.

Previous Home Next

 

In this tutorial we'll learn to set Cell’s Background Color on Excel Sheet Using JExcel APIs.

To change the background colour of the cells of the excel sheet, we should import the following class,

jxl.format.Colour;
This class contains various colours that can be applied to the various cells of the worksheet.
 For setting the background colour of the cells of an excel spreadsheet, we have to import the jxl.format.Colour class. The following steps are generally used for formatting the background colour of the 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);

In the above code snippet we have created a WritableFont object and then pass that object to the WritableCellFormat constructor , after that we have set the background of the cell to GREY_25_PERCENT.


 

Previous Home Next