Quality Testing

Quality is delighting customers

How to create a method to set cell value in a xlsx file?

How to create a method to set cell value in a xlsx file?

Views: 86

Reply to This

Replies to This Discussion

Can you please try this below code:

public void SetData(int rowNum, int colNum, String sheetName, String setValue)
{
try
{
FileInputStream fis = new FileInputStream(new File("C://data.xlsx")));
@SuppressWarnings("resource")
XSSFWorkbook workbook = new XSSFWorkbook (fis);
XSSFSheet sheet = workbook.getSheet(sheetName);


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

fis.close();

FileOutputStream fos =new FileOutputStream(new File("C://data.xlsx")));
workbook.write(fos);
fos.close();
}catch(Exception e)
{
e.printStackTrace();
}

}

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service