NullPointerException。 我想要更新的特定单元格有一些价值,但由于异常我无法更新。
driver.findElement(By.Xpath("//input[.='add to cart']")).click();
这是我的代码。在这一行提出例外:
String excelFileName = "D:\\TempLocation\\Marks.xlsx";//name of excel file
String sheetName = "Sheet1";//name of sheet
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.getSheet(sheetName) ;
System.out.println(regNo+ " " + cellNo);
Cell cellToUpdate = sheet.getRow(0).getCell(0);
cellToUpdate.setCellValue(mark);
FileOutputStream fileOut = new FileOutputStream(excelFileName);
//write this workbook to an Outputstream.
wb.write(fileOut);
fileOut.flush();
fileOut.close();
答案 0 :(得分:0)
加入此行
FileInputStream fis = new FileInputStream(new File(excelFileName));
此行的变化
XSSFWorkbook wb = new XSSFWorkbook(fis);
使其发挥作用。