0
私はEclipseでJavaでアプリケーションを構築しています。私はXLSファイルを読んでみたい。xlsxファイルをJavaから読み取る方法
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();
}
しかし、私は私のコードを起動しようとするならば、私はこのエラーメッセージがあります:あなたのエラーメッセージが示すように
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
ことがorg.apache.commons' 'に配置する必要がありますクラスの' NoClassDefFoundError'を不平を言っているが、我々はあなたが組織 'に関連するものを輸入してきたことを見ることができません。 apache.commons'をプロジェクトに追加します。 – kenshinji
エラーメッセージには、クラスパスに[Apache Commons Collections v4](https://commons.apache.org/proper/commons-collections/)を含める必要があることが示唆されています。 [Apache POIに関するこのページ](https://poi.apache.org/overview.html)の「Component Map」セクションには、Apache POIを使用するために必要な前提条件が記載されています。 – Jesper
@kenshinji私は自分のプロジェクトにorg.apache.commonsを追加してから問題を修正しました – bircastri