HSSFWorkbook错误

时间:2013-09-13 03:05:52

标签: java excel jframe poi-hssf

您好,我在尝试使用HSSF工作簿时遇到错误。看到此错误

Exception in thread "Thread-13" java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook
    at digicare.tracking.serial.BulkUpload.UploadProgress$1read2.run(UploadProgress.java:95)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.hssf.usermodel.HSSFWorkbook
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)

这是我的代码:

try {
    file = new FileInputStream(new File(FilePath));
    try {
        workbook = new HSSFWorkbook(file);
    } catch (Exception e2){
        JOptionPane.showMessageDialog(null, "Error1" + e2.getMessage());
    }

    //HSSFSheet sheet = workbook.getSheetAt(0);
    //HSSFRow row;
    //HSSFCell cell;  
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
      JOptionPane.showMessageDialog(null, "Error1" + e1.getMessage()); 
} catch (IOException e) {
// TODO Auto-generated catch block
      JOptionPane.showMessageDialog(null, "Error2 "+ e.getMessage()); 
}

似乎每当我尝试使用工作簿部分时,它都会返回错误

1 个答案:

答案 0 :(得分:0)

你的构建路径中是否有POI jar。它说没有找到类.HSSF与XLS文件相关联。

有关Eclipse中的示例,请参阅here

根据您使用的IDE,设置过程可能会有所不同。