Reputation: 11
I am getting the following error while trying to open an excel file using selenium JUni4 web driver in eclipse. Error and code is shown below. I am new to JAVA. Please help.
public void xlRead_TC(String sPath, int sSheet) throws Exception{
//Workbook book = Workbook.createWorkbook(f);
System.out.println("Step 1B - Opening excel files Reached");
File myxl = new File(sPath);
FileInputStream myStream = new FileInputStream(myxl);
//Workbook w;
//w = Workbook.getWorkbook(myStream);
XSSFWorkbook myWB = new XSSFWorkbook(myStream);
//XSSFSheet mySheet = myWB.getSheetAt(sSheet); // Referring to 1st sheet
//xRows_Inp = mySheet.getLastRowNum()+1;
//xCols_Inp = mySheet.getRow(0).getLastCellNum();
System.out.println("Rows are " + xRows_Inp);
System.out.println("Cols are " + xCols_Inp);
//Workbook[] wbs = new Workbook[] { new HSSFWorkbook(), new XSSFWorkbook() };
//xRows_TC = mySheet.getLastRowNum()+1;
//xCols_TC = mySheet.getRow(0).getLastCellNum();
//System.out.println("Rows are " + xRows_TC);
//System.out.println("Cols are " + xCols_TC);
//xData_TC = new String[xRows_TC][xCols_TC];
}
Exception
java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:154)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:141)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:54)
Upvotes: 1
Views: 375
Reputation: 15890
It seems you run an older version of POI which still required the dom4j third party library. You have two options:
1) Upgrade to the latest release of POI where this library is not needed any more
2) Add the dom4j jar file to your classpath. The jar-file is part of the binary distribution of POI.
Upvotes: 1
Reputation: 2219
I got issue like you somtimes. You can do by this way: rebuild project + refresh project in IDE. If it still does not work, you should restart IDE. Hope this help :))
Upvotes: 0