我試圖使用Apache POI創建一個簡單的工作簿,並得到以下errors.Using apchhe POI 3.9好心幫我擺脫這種感謝的簡單工作簿。出錯創建使用Apache POI
錯誤:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
at xlscreate.xlsclass.main(xlsclass.java:24)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException
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 java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
CODE:
import java.io.FileOutputStream;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.InputStream;
public class xlsclass {
public static void main(String[] args) throws Exception,Throwable{
// Workbook wb = new HSSFWorkbook();
// FileOutputStream fileOut = new FileOutputStream("workbook.xls");
// wb.write(fileOut);
// fileOut.close();
Workbook wb = new XSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream("c:/workbook.xlsx");
wb.write(fileOut);
fileOut.close();
}
}
你有進口org.apache.xmlbeans.XmlException?我在代碼中看不到這一點。 – 2013-02-21 11:48:41