我正在尝试使用 Apache POI 创建一个简单的工作簿并收到以下错误。使用 apchhe poi 3.9 请帮助我摆脱这种感谢。
错误:
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
代码:
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();
}
}