Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » ClassNotFoundException
ClassNotFoundException [message #1817850] Sun, 01 December 2019 00:00 Go to next message
Eclipse UserFriend
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 10:27 Go to previous messageGo to next message
Eclipse UserFriend
- 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 114 times)
Re: ClassNotFoundException [message #1818692 is a reply to message #1817960] Mon, 23 December 2019 07:37 Go to previous message
Eclipse UserFriend
Thanks for the code.
Previous Topic:Developing Processing Sketches in Eclipse
Next Topic:Eclipse on Java 13 vs Annotations
Goto Forum:
  


Current Time: Sun Aug 31 09:30:17 EDT 2025

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

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

Back to the top