0

I am reading an excel sheet in selenium,intellij. I am using the code below and the versions for apache are as;

compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile group: 'org.apache.poi', name: 'poi', version: '3.16'
compile group: 'nz.ac.waikato.cms.weka', name: 'WekaExcel', version:'1.0.5'

i am getting this error;

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.poi.util.POILogger.log(ILjava/lang/Object;)V

public class ExcelRead {
    public static void main(String []args) {

        try {
            // Specify the path of file
            File src=new File("/home/mfaheem/WIND/Repository/ecommerce-int/src/ExcelSheets/UserDetail.xlsx");

            // load file
            FileInputStream fis = new FileInputStream(src);

            // Load workbook
            XSSFWorkbook wb=new XSSFWorkbook(fis);

            // Load sheet- Here we are loading first sheetonly
            XSSFSheet sh1= wb.getSheetAt(0);

            // getRow() specify which row we want to read.

            // and getCell() specify which column to read.
            // getStringCellValue() specify that we are reading String data.


            System.out.println(sh1.getRow(0).getCell(0).getStringCellValue());

            System.out.println(sh1.getRow(0).getCell(1).getStringCellValue());

            System.out.println(sh1.getRow(1).getCell(0).getStringCellValue());


        } catch (Exception e) {

            System.out.println(e.getMessage());

        }

    }

}
SedJ601
  • 12,173
  • 3
  • 41
  • 59
faheem
  • 11
  • 2
  • 8
  • You have to make sure you import all of the POI's dependencies. – SedJ601 Jun 28 '17 at 13:45
  • i have done that, and its confirm because test is running. I think its the problem of mismatch between the versions. I am not sure about the aligned versions. – faheem Jun 28 '17 at 14:08
  • Well, try saving the excel file in a different format. If it is .xlsx change it to .xls or vice-versa. – SedJ601 Jun 28 '17 at 14:10
  • I still think it's a dependency problem though. Go [here](https://stackoverflow.com/questions/18231134/how-to-avoid-java-lang-nosuchmethoderror-org-apache-poi-util-ioutils-copyljava). – SedJ601 Jun 28 '17 at 14:11
  • i have checked this question before posting mine – faheem Jun 28 '17 at 14:15
  • This error seems to lead to the same problem. Like [here](https://stackoverflow.com/questions/33415904/apache-poi-parsing-error). I suggest you triple check your jars and make sure that the jars you are using are correct for the version of POI you are using. – SedJ601 Jun 28 '17 at 14:18
  • These are the versions, compile group: 'commons-io', name: 'commons-io', version: '2.5' compile group: 'org.apache.poi', name: 'poi', version: '3.16' compile group: 'nz.ac.waikato.cms.weka', name: 'WekaExcel', version: '1.0.5' compile group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '3.7' compile group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '2.6.0' compile group: 'org.apache.poi', name: 'ooxml-schemas', version: '1.3' i think all are the latest versions – faheem Jun 28 '17 at 14:32
  • i have resolved the issue – faheem Jun 29 '17 at 07:57
  • but the code is not working. i get some other errors – faheem Jun 29 '17 at 08:47
  • 1
    solved! The issue was that i was using the latest version of apache poi. But the only working one is apache poi 3.5 final. So, i suggest you all to use it. Thanks – faheem Jun 29 '17 at 10:23

0 Answers0