我正在一個模塊需要在xlsx文件中讀取/寫入的應用程序中工作。 我已經在我的項目中導入了Poi.example 3.9和xml_beans jar。 但仍然在代碼中給出NoClassDefFoundError
的錯誤。 這裏是我的代碼: -在android中的xlsx文件中讀/寫:NoClassDefFoundError
try{
FileInputStream file = new FileInputStream(new File("< path of excel file.....xlsx"));
XSSFWorkbook wb = new XSSFWorkbook(file);
XSSFSheet sheet = wb.getSheetAt(0);
//iterate through each row from first sheet
Iterator<Row> rowIterator = sheet.iterator();
while(rowIterator.hasNext()){
Row row = rowIterator.next();
//Fore each row iterate through each column
Iterator<Cell> cellIterator = row.cellIterator();
while(cellIterator.hasNext()){
Cell cell = cellIterator.next();
switch (cell.getCellType()){
case Cell.CELL_TYPE_BOOLEAN:
System.out.print(cell.getBooleanCellValue() + "\t\t");
break;
case Cell.CELL_TYPE_NUMERIC:
System.out.print(cell.getNumericCellValue() + "\t\t");
break;
case Cell.CELL_TYPE_STRING:
System.out.print(cell.getStringCellValue() + "\t\t");
break;
}
}
System.out.println("");
}
file.close();
FileOutputStream out = new FileOutputStream (new File("< path of excel file.....xlsx"));
wb.write(out);
out.close();
} catch(FileNotFoundException e){
e.printStackTrace();
} catch (IOException e){
e.printStackTrace();
}
[NoClassDefFoundError](http://stackoverflow.com/a/17106357/2194831)的解決方案。 請求之前搜索... – Krrishnaaaa
也添加錯誤堆棧。 –