0
 Data Driven Method* Error NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook 
File scr = new File("Numbers.xlsx"); 
FileInputStream inputStream = new FileInputStream(scr);
XSSFWorkbook wb = new XSSFWorkbook(inputStream);
XSSFSheet sheet1 = wb.getSheetAt(0);
double data0 = sheet1.getRow(1).getCell(0).getNumericCellValue();
String value = NumberToTextConverter.toText(data0);
System.out.println(value);

*How to solve this error *

DEBUG   15421   [freemark] (): Couldn't find template in cache for "Extent.ftl"("en_US", UTF-8, parsed); will try to load it.
DEBUG   15421   [freemark] (): TemplateLoader.findTemplateSource("Extent_en_US.ftl"): Not found
DEBUG   15421   [freemark] (): TemplateLoader.findTemplateSource("Extent_en.ftl"): Not found
DEBUG   15421   [freemark] (): TemplateLoader.findTemplateSource("Extent.ftl"): Found
DEBUG   15421   [freemark] (): Loading template for "Extent.ftl"("en_US", UTF-8, parsed) from "jar:file:/C:/Users/PoojaPatange/.m2/repository/com/relevantcodes/extentreports/2.41.2/extentreports-2.41.2.jar!/com/relevantcodes/extentreports/view/Extent.ftl"
DEBUG   15421   [freemark] (): Couldn't find template in cache for "Extent.ftl"("en_US", UTF-8, parsed); will try to load it.
DEBUG   15421   [freemark] (): TemplateLoader.findTemplateSource("Extent_en_US.ftl"): Not found
DEBUG   15421   [freemark] (): TemplateLoader.findTemplateSource("Extent_en.ftl"): Not found
DEBUG   15421   [freemark] (): TemplateLoader.findTemplateSource("Extent.ftl"): Found
DEBUG   15421   [freemark] (): Loading template for "Extent.ftl"("en_US", UTF-8, parsed) from "jar:file:/C:/Users/PoojaPatange/.m2/repository/com/relevantcodes/extentreports/2.41.2/extentreports-2.41.2.jar!/com/relevantcodes/extentreports/view/Extent.ftl"
Jens
  • 67,715
  • 15
  • 98
  • 113
Pooja Patange
  • 47
  • 1
  • 10
  • As you're running from command line, you need to poi jar to your classpath. Follow [Including jars in classpath on commandline](https://stackoverflow.com/questions/2096283/including-jars-in-classpath-on-commandline-javac-or-apt) – Sukhpal Singh Nov 14 '18 at 10:29
  • @sukhpal I'm running in command prompt – Pooja Patange Nov 14 '18 at 10:38
  • If you don't answers know, please don't give minus point(this leads to block the account, we are learners), there are peoples who are giving answers and helping us. – Pooja Patange Nov 14 '18 at 10:57

2 Answers2

3

You have to add below dependency

 <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.9</version>
    </dependency>

as per your error you also have to add below dependency as well

<dependency>
    <groupId>com.relevantcodes</groupId>
    <artifactId>extentreports</artifactId>
    <version>2.41.2</version>
</dependency>
Jens
  • 67,715
  • 15
  • 98
  • 113
GauravRai1512
  • 834
  • 6
  • 14
2

Add the following dependencies in your project:

<dependency>
              <groupId>org.apache.poi</groupId>
              <artifactId>poi</artifactId>
              <version>3.10-FINAL</version>
           </dependency>


        <dependency>
             <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.10-FINAL</version>
       </dependency>
Pooja Aggarwal
  • 1,163
  • 6
  • 14