Trace de la pile
Exception in thread "main" Java.lang.Error: Unresolved compilation problems:
CELL_TYPE_STRING cannot be resolved or is not a field
CELL_TYPE_NUMERIC cannot be resolved or is not a field
CELL_TYPE_BOOLEAN cannot be resolved or is not a field
at len.a.main(a.Java:30)
Code
package len;
import Java.io.FileInputStream;
import Java.util.ArrayList;
import Java.util.Iterator;
import org.Apache.poi.ss.usermodel.Cell;
import org.Apache.poi.ss.usermodel.Row;
import org.Apache.poi.ss.usermodel.Sheet;
import org.Apache.poi.xssf.usermodel.XSSFWorkbook;
public class a {
public static void main(String[] args) throws Exception{
ArrayList data =new ArrayList();
FileInputStream f =new FileInputStream("E:\\leadsuite.xlsx");
XSSFWorkbook wb=new XSSFWorkbook(f);
Sheet s=wb.getSheet("test steps");
Iterator itr=s.iterator();
while(itr.hasNext())
{
Row r=(Row) itr.next();
Iterator cellitr=r.cellIterator();
while(cellitr.hasNext())
{
Cell celldata=(Cell) cellitr.next();
switch(celldata.getCellType())
{
case Cell.CELL_TYPE_STRING:
data.add(celldata.getStringCellValue());
break;
case Cell.CELL_TYPE_NUMERIC:
data.add(celldata.getNumericCellValue());
break;
case Cell.CELL_TYPE_BOOLEAN:
data.add(celldata.getBooleanCellValue());
break;
}
}
}
}
}
enum
s sont STRING
, NUMERIC
et BOOLEAN
, supprimez le CELL_TYPE_
et font partie de CellType enum
switch(celldata.getCellType()) {
case CellType.STRING:
data.add(celldata.getStringCellValue());
break;
case CellType.NUMERIC:
data.add(celldata.getNumericCellValue());
break;
case CellType.BOOLEAN:
data.add(celldata.getBooleanCellValue());
break;
}