如何写入传递一个值到excel表单中的单元格的条件是否不返回任何空值?

我需要将一个variables传递给Excel工作表单元格。所以我怎样才能检查它是否返回空值。如果它有空值,我需要在单元格中给出一个警告消息,而不是实际的单元格值。

// 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"); }