Quality is delighting customers
Can you please try this below code:
public void SetData(int rowNum, int colNum, String sheetName, String setValue)
FileInputStream fis = new FileInputStream(new File("C://data.xlsx")));
XSSFWorkbook workbook = new XSSFWorkbook (fis);
XSSFSheet sheet = workbook.getSheet(sheetName);
XSSFRow row = sheet.getRow(rowNum);
XSSFCell col = row.createCell(colNum);
FileOutputStream fos =new FileOutputStream(new File("C://data.xlsx")));
Selenium doesn't have built-in support to read and write the excel files, so most of the software testing solutions recommend using the Apache Poi API to read/write data from the excel files.
First, you will need to add Apache POI jars into your project, or if you are using maven you can also add maven dependency into your POM file.
Below is the JAVA file to Write into the excel files sheet cells,
Java file containing a function to set values: Writing_data.java
Java file using the above class method to write the data into excel file sheet: Test_SetData_xlsx.java
To simply write data into excel files using the above-provided class files. Create a new folder under the c: with the name 'Data' and place both the files under that folder.
Please do let me know in case of any doubts or issues.