NoClassDefFoundError:javax/xml/stream/XMLStreamException
我在尝试使用 Apache POI 编写 .xlsx 文件
时遇到以下异常,
NoClassDefFoundError: javax/xml/stream/XMLStreamException
这是代码片段:-
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();
我包含以下 jars
- dom4j-1.6.1
- poi-ooxml-3.5-FINAL
- poi- 3.6-20091214
- xmlbeans-2.3.0
- ooxml-schemas-1.0
请让我知道我在这里做错了什么或者我遗漏了一些东西。
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-20091214
- xmlbeans-2.3.0
- ooxml-schemas-1.0
Please let me know what i am doing wrong here or i am missing something.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少 stax API jar
如果您查看 POI 组件页面,您会看到ooxml-schemas jar 依赖于 STAX API jar(通常由
stax-api-1.0.1.jar
提供)查看您的 POI 二进制下载,以及
ooxml-lib< /代码> 目录你会看到你需要的罐子。或者,如果您使用 Maven,它会为您下载依赖项
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