0

I am getting error like [ Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap at excelExport.ReadWriteExcel1.main(ReadWriteExcel1.java:15)) ] . Can Someone please guide me for the same.

package excelExport;

import java.io.File;
import java.io.FileInputStream;

import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ReadWriteExcel1 
{
    public static void main (String []args) throws Exception
    {
        File src=new File("C:\\Users\\techbrain\\Downloads\\Selenium Jar\\TestData.xlsx");
        FileInputStream fis = new FileInputStream(src);
        XSSFWorkbook wb=new XSSFWorkbook(fis);
        XSSFSheet sheet=wb.getSheetAt(0);
          
        int rowcount=sheet.getLastRowNum()+1;
        System.out.println("Total rows is "+rowcount);
        for(int i=0; i<rowcount; i++)
        {
            String data0=sheet.getRow(i).getCell(0).getStringCellValue();
            System.out.println("Data from Row"+i+" is "+data0);
        }
         wb.close();
    }
}

enter image description here

Alexey R.
  • 8,057
  • 2
  • 11
  • 27
Pratik
  • 13
  • 7
  • I have edited your question. Selenium cannot work with excel files. Selenium work with browsers. What you are writing about is Apache POI library. – Alexey R. Oct 19 '20 at 12:40
  • 1
    Aren't you just missing the `commons-collections4` library ? – Conffusion Oct 19 '20 at 12:42
  • 1
    I believe Collections4 dependency resolve it.. You need to use jar for it.. https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1 – Anil K Oct 19 '20 at 12:45
  • @AnilK I also use the Commons-Collection jar file. https://prnt.sc/v2ri09 – Pratik Oct 20 '20 at 04:06
  • Now error/exception changed, you need to add another dependency jar.. follow this link.. https://stackoverflow.com/a/26993119/8607192 . Best to use maven/gradle. – Anil K Oct 20 '20 at 05:14

0 Answers0