Naziru Cristian Naziru Cristian - 3 years ago 223
Apache Configuration Question

Apache POI MissingCellPolicy is not really working as described in the documentation

I'm trying to set up the Apache POI for a Data Driven automation framework in Java. However, I'm kind of stuck, after several searches at the


When I try to check if a Cell in blank, the
throws this error:

The method getCell(int, Row.MissingCellPolicy) in the type XSSFRow is
not applicable for the arguments (int, Class)

is not really accepted:

RETURN_BLANK_AS_NULL cannot be resolved or is not a field

Here's my code:

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ExcelUtils {

private static XSSFSheet ExcelWSheet;
private static XSSFWorkbook ExcelWBook;
private static XSSFCell Cell;
private static XSSFRow Row;

public static void setCellData(String Result, int RowNum, int ColNum) throws Exception {

try {
Row = ExcelWSheet.getRow(RowNum);
Cell = Row.getCell(ColNum, Row.RETURN_BLANK_AS_NULL);
if (Cell == null) {
Cell = Row.createCell(ColNum);
}else {

It does continue afterwards, but I'm interested in the 'try' part.

Thanks a lot,

Answer Source

Your variable Row is a XSSFRow which does not contain the enum field RETURN_BLANK_AS_NULL.

You need to import and then use Row.RETURN_BLANK_AS_NULL.

I suggest you to rename your variable Row to avoid any conflict.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download