Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

Selenium WebDriver: Unable to read data from Excel

I am trying to read data from Selenium and failing. Using a basic code to read one data from excel but its failing. All POIs are added in POM file.

Code:

package com.crm.qa.testcases;

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

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class testexcel {


    public static void main(String[] args) throws Exception {

        File f = new File("C:\Users\Manoj\Desktop\Contacts.xlsx");
        FileInputStream fis = new FileInputStream(f);
        Workbook wb;
        wb = new XSSFWorkbook(fis);
        Sheet s = wb.getSheet("NewContact");
        int rows = s.getLastRowNum();
        System.out.println(rows);
    }
}


ERROR:

Exception in thread "main" java.lang.NoSuchMethodError: 'org.apache.xmlbeans.XmlObject[] org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontsImpl.getXmlObjectArray(javax.xml.namespace

.QName, org.apache.xmlbeans.XmlObject[])' at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontsImpl.getFontArray(CTFontsImpl.java:71) at org.apache.poi.xssf.model.StylesTable.readFrom(StylesTable.java:210) at org.apache.poi.xssf.model.StylesTable.(StylesTable.java:138) at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:61) at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:660) at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:165) at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:278) at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:299) at com.crm.qa.testcases.testexcel.main(testexcel.java:20)

question from:https://stackoverflow.com/questions/65914464/selenium-webdriver-unable-to-read-data-from-excel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...