I want to Color a Particular Cell and Shade it using POI.
Normally to shade a Cell,one would select the Cell->rightClick->Format Cells->Fill(Tab)->Fill Effects, Select the Color and Select the Shading Style (for me here it will be GOLD and Shading style as HORIZONTAL 2nd Option).
The Problem i am facing is that i am not able to find a function that helps in Shading the Cell.Is this even possible using POI or maybe even jxl? Here is my code snippet:
FileOutputStream fileOut = new FileOutputStream("C:/poi-test.xls");
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet worksheet = workbook.createSheet("POI Worksheet");
HSSFRow row1 = worksheet.createRow((short) 0);
HSSFCell cellA1 = row1.createCell((short) 0);
cellA1.setCellValue("Hello");
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFillForegroundColor(HSSFColor.GOLD.index);
cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);\\ this part is probably redundant
cellA1.setCellStyle(cellStyle);
workbook.write(fileOut);
fileOut.close();