Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » ClassNotFoundException
ClassNotFoundException [message #1817850] Sun, 01 December 2019 05:00 Go to next message
Jessica Hop is currently offline Jessica HopFriend
Messages: 1
Registered: December 2019
Junior Member
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;


public void ReadXL(String Path) throws Exception
{
FileInputStream myStream=null;

System.out.println("InReadxl");
File xlFile = new File(Path);

myStream = new FileInputStream(xlFile);
HSSFWorkbook myWB = new HSSFWorkbook(myStream);

...........................

}

HSSFWorkbook myWB = new HSSFWorkbook(myStream); is creating
ClassNotFoundException() after adding external jar file
"poi-3.7-20101029".What might be causing the prolem?Please,let me know
the soultion of this problem.

Thanks
Re: ClassNotFoundException [message #1817960 is a reply to message #1817850] Tue, 03 December 2019 15:27 Go to previous messageGo to next message
Eitan Rosenberg is currently offline Eitan RosenbergFriend
Messages: 149
Registered: October 2018
Senior Member
- If you can try to use xlsx files and then you can use XSSF (See https://poi.apache.org/)

- I am using Maven and I have those dependencies (jars....)

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

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.1</version>
</dependency>

Some code:

package examples;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class Main {

public static void main(final String[] args) {
new Main();
}

public Main() {

try (FileInputStream myStream = new FileInputStream(new File("H:/Temp/MyTemp.xls"));
final HSSFWorkbook hssfWorkbook = new HSSFWorkbook(myStream);) {

final HSSFSheet hssfSheet = hssfWorkbook.getSheet("Sheet1");

final HSSFRow hssfRow = hssfSheet.getRow(0);

final HSSFCell hssfCell = hssfRow.getCell(1);

System.out.println(hssfCell);

} catch (final IOException exception) {
exception.printStackTrace();
}

}

}

This works for MyTemp.xls
  • Attachment: MyTemp.xls
    (Size: 5.50KB, Downloaded 95 times)
Re: ClassNotFoundException [message #1818692 is a reply to message #1817960] Mon, 23 December 2019 12:37 Go to previous message
Bhondawe Patil is currently offline Bhondawe PatilFriend
Messages: 23
Registered: October 2019
Junior Member
Thanks for the code.
Previous Topic:Developing Processing Sketches in Eclipse
Next Topic:Eclipse on Java 13 vs Annotations
Goto Forum:
  


Current Time: Mon Dec 02 16:16:52 GMT 2024

Powered by FUDForum. Page generated in 0.03365 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top