Quality Testing

Quality is delighting customers

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?

Views: 76

Reply to This

Replies to This Discussion

Please answer this question.

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service