0

モジュールが xlsx ファイルの読み取り/書き込みを必要とするアプリで作業しています。プロジェクトに Poi.example 3.9 と xml_beans jar を既にインポートしています。それでも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();
            }
4

2 に答える 2

1

追加したライブラリを削除し、プロパティからも削除します。jar を再度インポートします。プロジェクトをクリーンアップして実行してみます。

于 2013-07-08T09:55:07.857 に答える
0

Eclipse を使用している場合は、プロジェクトを右クリックします。package explorer --> Build Path --> Configure build path --> Order and Export --> Check the Android private libraries also your jar file.

これがお役に立てば幸いです。

于 2013-07-08T10:03:03.967 に答える