我收到以下错误
线程“main”中的异常 java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject at OrderBook.WriteToExcelSheet.CreateOutPutFile(WriteToExcelSheet.java:20) at OrderBook.MainMethod.main(MainMethod.java:71)
我在网上查找了这个错误的原因,但找不到我得到它的原因。
我已包含以下 jar 文件
poi-3.9-20121203.jar,
poi-excelant-3.9-20121203.jar,
poi-examples-3.9-20121203.jar,
poi-ooxml-3.9-20121203.jar,
poi-ooxml-schemas-3.9-20121203.jar,
poi-scratchpad-3.9-20121203.jar
代码:
public class WriteToExcelSheet {
public static Map < Integer, Object[] > data = new TreeMap < Integer, Object[] > ();
public static void CreateOutPutFile() {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Orderbook Stats");
//This data needs to be written (Object[])
//Iterate over data and write to sheet
Set < Integer > keyset = data.keySet()
int rownum = 0;
for (Integer key: keyset) {
Row row = sheet.createRow(rownum++);
Object[] objArr = data.get(key);
int cellnum = 0;
for (Object obj: objArr) {
Cell cell = row.createCell(cellnum++);
if (obj instanceof String) cell.setCellValue((String) obj);
else if (obj instanceof Integer) cell.setCellValue((Integer) obj);
}
}
try {
//Write the workbook in file system
System.out.println("OutPutStats.xlsx writing..............................");
FileOutputStream out = new FileOutputStream(new File("FileLocation/o.xlxs"));
workbook.write(out);
out.close();
System.out.println("OutPutStats.xlsx written successfully on disk.");
} catch (Exception e) {
e.printStackTrace();
}
}
}