开发者

NoClassDefFoundError: javax/xml/stream/XMLStreamException

I am getting the following exception while trying to write an .xlsx file using Apache POI

NoClassDefFoundError: javax/xml/stream/XMLStreamException

Here's the Code Snippet:-

XSSFWorkbook wb = new XSSFWorkbook();
        Sheet sheet = wb.createSheet();
        Row row = sheet.createRow(0);
        Cell cell = row.createCell(0);
        cell.setCellValue(100);
        FileOutputStream fileOut = new FileOutputStream("D:\\workspace\\April\\Excel Test\\workbook.xlsx");
        wb.write(fileOut);
        fileOut.close();

I have the following jars included

  • dom4j-1.6.1
  • poi-ooxml-3.5-FINAL
  • poi-3.6-2009121开发者_JAVA百科4
  • xmlbeans-2.3.0
  • ooxml-schemas-1.0

Please let me know what i am doing wrong here or i am missing something.


You're missing the stax API jar

If you look at the POI Components page you'll see that the ooxml-schemas jar depends on a STAX API jar (most typically provided by stax-api-1.0.1.jar)

Look in your POI binary download, and in the ooxml-lib directory you'll see the jar you need. Alternately, if you use Maven, it'll download the dependency for you

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜