Java 如果excel工作表中没有返回任何空值,如何编写向单元格传递值的条件?
我需要向excel工作表单元格传递一个变量。因此,我如何检查它是否返回空值。如果它有空值,我需要在单元格中发出警报消息,而不是实际的单元格值Java 如果excel工作表中没有返回任何空值,如何编写向单元格传递值的条件?,java,excel,selenium,Java,Excel,Selenium,我需要向excel工作表单元格传递一个变量。因此,我如何检查它是否返回空值。如果它有空值,我需要在单元格中发出警报消息,而不是实际的单元格值 // Element fetching Element= driver.findElement(By.xpath(".//*[@id='Form1']/table[3]/tbody/tr[5]/td[3]/a")) ; Email_ID
// Element fetching
Element= driver.findElement(By.xpath(".//*[@id='Form1']/table[3]/tbody/tr[5]/td[3]/a")) ;
Email_ID = Element.getText();
FileInputStream fis = new FileInputStream("E:\\ExcelRead.xls");
Workbook wb = WorkbookFactory.create(fis);
Sheet sh = wb.getSheet("Input");
// File Handling
Row row = sh.createRow(ExcelRow);
Cell cell_3 = row.createCell(2);
cell_3.setCellValue(Email_ID);
//文件处理
FileOutputStream fos = new FileOutputStream("E:\\ExcelRead.xls");
wb.write(fos);
fos.close();
System.out.println("Excel File Written.");
检查是否为
null
。这可以应用于任何对象
String value = null;
if(value != null)
{
//do your logic
}
else
{
System.out.println("Null Value");
}