Set Cell’s Foreground Colour on Excel Sheet Using JExcel APIs.
Previous | Home | Next |
Now we will learn how to set the Cell’s Foreground Colour on Excel Sheet Using JExcel APIs.
For setting the foreground colour, i.e setting the font colour firstly we have to import the jxl.write.WritableFont class whose constructor allows to set the foreground colour of worksheet.
To set the foreground colour of the cell of a worksheet first we create a WritableFont object in which we pass the font colour in the constructor of the WritableFont class, afterwards we pass the object of WritableFont to the constructor of the WritableCellFormat class. This can be done as,
WritableFont wfobj=new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,Colour.BLUE);
WritableCellFormat cfobj=new WritableCellFormat(wfobj);
Previous | Home | Next |