Unable to fill the background color in xlsx file

I am Kiran and beginner and quick learner on Selenium Tool.
Query : — Unable to fill the background color in xlsx file

SetData function

public void SetData(int rowNum, int colNum, String sheetName, String setValue, short cellColor)
{

FileInputStream fis = new FileInputStream(new File(read.ObjectRepoData(“testdata”)));
@SuppressWarnings(“resource”)
XSSFWorkbook workbook = new XSSFWorkbook (fis);
XSSFSheet sheet = workbook.getSheet(sheetName);

CellStyle style = workbook.createCellStyle();
style.setFillForegroundColor(cellColor);
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);

//Create First Row
XSSFRow row = sheet.getRow(rowNum);
XSSFCell col = row.createCell(colNum);
col.setCellValue(setValue);

fis.close();

FileOutputStream fos =new FileOutputStream(new File(read.ObjectRepoData(“testdata”)));
workbook.write(fos);
fos.close();

}

Passed below line in the test case:

excel.SetData(1, 4, “Login”, “PASS”,IndexedColors.GREEN.getIndex());

Can any one help me on this please?

Default Asked on April 2, 2019 in Selenium WebDriver.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.