0

I am working in an app in which a module requires to read/write in xlsx file. i have already imported Poi.example 3.9 and xml_beans jar in my project. but still it giving an error of NoClassDefFoundError within the code. here is my code:-

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();
            }
Krrishnaaaa
  • 689
  • 11
  • 23

2 Answers2

1

Delete the library that you have added and remove from the properties also. Now import the jar again. Clean the project and try to run.

Sagar Patil
  • 1,400
  • 15
  • 29
0

If you are using eclipse then right click in your project from package explorer --> Build Path --> Configure build path --> Order and Export --> Check the Android private libraries also your jar file.

I hope this will help you.

Gunaseelan
  • 14,415
  • 11
  • 80
  • 128