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
setCellData
getCell
The method getCell(int, Row.MissingCellPolicy) in the type XSSFRow is
not applicable for the arguments (int, Class)
Row.RETURN_BLANK_AS_NULL
RETURN_BLANK_AS_NULL cannot be resolved or is not a field
import java.io.FileInputStream;
import java.io.FileOutputStream;
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);
Cell.setCellValue(Result);
}else {
Cell.setCellValue(Result);
}
Your variable Row
is a XSSFRow
which does not contain the enum field RETURN_BLANK_AS_NULL
.
You need to import org.apache.poi.ss.usermodel.Row
and then use Row.RETURN_BLANK_AS_NULL
.
I suggest you to rename your variable Row
to avoid any conflict.