Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.NoClassDefFoundError:org/apache/poi/hssf/usermodel/HSSFWorkbook错误_Java_Excel_Hssfworkbook - Fatal编程技术网

java.lang.NoClassDefFoundError:org/apache/poi/hssf/usermodel/HSSFWorkbook错误

java.lang.NoClassDefFoundError:org/apache/poi/hssf/usermodel/HSSFWorkbook错误,java,excel,hssfworkbook,Java,Excel,Hssfworkbook,正在获取以下代码的“NoClassDefFoundError” public static void exportTable(JTable table, File file){ try{ TableModel model = table.getModel(); // FileWriter out = new FileWriter(file);

正在获取以下代码的“NoClassDefFoundError”

public static void exportTable(JTable table, File file){

        try{
                TableModel model = table.getModel();                    

               // FileWriter out = new FileWriter(file);

                HSSFWorkbook workBook = new HSSFWorkbook();
                HSSFSheet sheet = workBook.createSheet();
                HSSFRow headingRow = sheet.createRow(0);
                short rowNo = 1;
                for(int i=0; i < model.getColumnCount(); i++) {
                //out.write(model.getColumnName(i) + "\t");
                 headingRow.createCell((short)i).setCellValue(model.getColumnName(i));
                }
               // out.write("\n");
                for(int i=0; i< model.getRowCount(); i++) {
                     HSSFRow row = sheet.createRow(rowNo);
                     for(int j=0; j < model.getColumnCount(); j++) {
                        //out.write(model.getValueAt(i,j).toString()+"\t");
                          row.createCell((short)j).setCellValue(model.getValueAt(i,j).toString());
                    }
                     rowNo++;
               }
                  try{
                      FileOutputStream fos = new FileOutputStream(file);
                      workBook.write(fos);
                      fos.flush();
                  }catch(FileNotFoundException e){
                      e.printStackTrace();
                      System.out.println("Invalid directory or file not found");
                  }catch(IOException e){
                      e.printStackTrace();
                      System.out.println("Error occurred while writting excel file to directory");
                  }


        }catch(Exception e){
            JOptionPane.showMessageDialog(null,"Invalid File Location!");
        }
    }
publicstaticvoidexporttable(JTable表,文件){
试一试{
TableModel模型=table.getModel();
//FileWriter out=新的FileWriter(文件);
HSSFWorkbook=新的HSSFWorkbook();
HSSFSheet sheet=workBook.createSheet();
HSSFRow headingRow=sheet.createRow(0);
短行数=1;
对于(int i=0;i
我得到了这个错误:


线程“AWT-EventQueue-0”java.lang.NoClassDefFoundError:org/apache/poi/hssf/usermodel/HSSFWorkbook中出现异常

是否导入了包含HSSFWorkbook的库?编辑您的问题以包含导入语句。请给出完整的代码,当一个或多个
.class
文件在运行时丢失时,会出现NoClassDefFoundError,但目前无法真正理解为什么会出现这样的错误,使用提供的代码块。@MarsAtomic这是一个异常,不是编译错误,所以根据我的理解,import语句应该可以