I'm building an app with Eclipse in Java. I want to read XLS file.
public Carico leggiOrdineDaFile_Mazzeo(Fornitore f,String file){
try{
FileInputStream inputStream = new FileInputStream(new File(file));
Workbook workbook = new XSSFWorkbook(inputStream);
Sheet firstSheet = workbook.getSheetAt(0);
Iterator<Row> iterator = firstSheet.iterator();
Carico ordine = new Carico();
List<DettOrdini> listaArticoli = new ArrayList<DettOrdini>();
while (iterator.hasNext()) {
Row nextRow = iterator.next();
Iterator<Cell> cellIterator = nextRow.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
System.out.print(cell.getStringCellValue());
break;
case Cell.CELL_TYPE_BOOLEAN:
System.out.print(cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_NUMERIC:
System.out.print(cell.getNumericCellValue());
break;
}
System.out.print(" - ");
}
System.out.println();
}
((BufferedReader) workbook).close();
inputStream.close();
}
But if I try to start my code, I have this error message:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap
I have imported in my project this library:
poi-3.17.jar
poi-excelant-3.17.jar
poi-ooxml-3.17.jar
poi-ooxml-schemas-3.17.jar
poi-scratchpad-3.17.jar
xmlbeans-2.6.0.jar
curveaspi-1.0.4.jar
As your error message suggests : you are simply missing an import org.apache.commons
.
See for reference https://commons.apache.org/proper/commons-collections/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.