I'm using this code to read something, and I want to write the result down on the same sheet. Every system output that I wish to write results for should be put on fields that are relevant. How can I read and write on the current excel sheet? 1
How can I use Selenium WebDriver to write data into an Excel file?
Test(priority=1)
public void Shift() throws Exception {
String dupshiftname=Skadmin.getData(62, 1);
String validshiftname=Skadmin.getData(63, 1);
driver.findElement(By.linkText("ADMIN")).click();
driver.findElement(By.id("sessionname")).sendKeys(dupshiftname);
if (actualTitle19.contentEquals(expectedTitle19)){
System.out.println("2.Test Passed!-Submitting without shift name alert displayed as[Shift name is required]");
Here I want this above output to be written on an excel sheet at a particular cell.
public static String getData(int r, int c) throws EncryptedDocumentException, InvalidFormatException, IOException
{
FileInputStream FIS=new FileInputStream("G://workspace//sample pro//src//testData//excel.xlsx");
Workbook WB=WorkbookFactory.create(FIS);
DataFormatter formatter = new DataFormatter(); //creating formatter using the default locale
Cell cell = WB.getSheet("Sheet1").getRow(r).getCell(c);
String str = formatter.formatCellValue(cell); //Returns the formatted value of a cell as a String regardless of the cell type.
return str;
}