-2

I am trying to retrieve data from an excel sheet, this is the code:

 public static void main(String[] args) throws  Exception  {
    File f = new File("C:\\Users\\Alex\\Documents\\Victoria.xlsx");
    Workbook wb =  WorkbookFactory.create(f);
    Sheet s = wb.getSheetAt(0);
    Row r =s.getRow(0);
    Cell c=r.getCell(0);
    s.getLastRowNum();
    int rowcount = s.getLastRowNum();
    System.out.println("rows are"+rowcount);
    System.out.println(c.getStringCellValue());
}

when I run it this is the error message I am getting:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
## Heading ## org.apache.poi.openxml4j.util.ZipSecureFile$1 (file:/C:/Users /Alex/Downloads/selenium-java-3.6.0/poi-3.17/poi-ooxml-3.17.jar) to field java.io.FilterInputStream.in
WARNING: Please consider reporting this to the maintainers of org.apache.poi.openxml4j.util.ZipSecureFile$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap 
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:266) 
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:226) 
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:205)
at CreateSingle_ValueRet.main(CreateSingle_ValueRet.java:13)
Caused by: java.lang.ClassNotFoundException:
org.apache.commons.collections4.ListValuedMap
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) 
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more

I am using Eclipse Oxigen.

baudsp
  • 4,076
  • 1
  • 17
  • 35
Vic.A
  • 1
  • 3

1 Answers1

0

You miss commons-colletions4 in your classpath. Add it and the exception should go away.

Jens
  • 67,715
  • 15
  • 98
  • 113