gpt4 book ai didi

java.lang.ClassNotFoundException : org. apache.xmlbeans.XmlObject 错误

转载 作者:IT老高 更新时间:2023-10-28 20:47:39 27 4
gpt4 key购买 nike

我收到以下错误

Exception in thread "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();
}
}
}

最佳答案

您必须再添加一个 jar 。

xmlbeans-2.3.0.jar

添加并尝试。

注意:只有 .xlsx 格式的文件才需要,而不仅仅是 .xls 格式的文件。

关于java.lang.ClassNotFoundException : org. apache.xmlbeans.XmlObject 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19739026/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com