我收到了以下错误
Order.com.MainMethod.main(MainMethod.java:71)中的订单"."主"java"中的异常java.lang.NoClassDefFoundError:org/apache/xmlbeans/XmlObject在OrderBook.WriteToExcelSheet.CreateOutPutFile(WriteToExcelSheet.java:20)
我在网上查找了这个错误的原因,但无法找到我收到它的原因.
我已经包含了以下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
Run Code Online (Sandbox Code Playgroud)
码:
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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
Jha*_*nvi 81
你必须再加一个罐子.
xmlbeans-2.3.0.jar
Run Code Online (Sandbox Code Playgroud)
添加此内容并尝试.
注意:仅对于.xlsx格式的文件是必需的,而不仅仅是.xls格式.
| 归档时间: |
|
| 查看次数: |
123160 次 |
| 最近记录: |