获取以下代码的“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!");
}
}
我收到此错误:
线程“AWT-EventQueue-0”中的异常 java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook