I am getting the following exception while trying to write an .xlsx file using Apache POI
尝试使用Apache POI编写.xlsx文件时,我收到以下异常
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
- dom4j的-1.6.1
- poi-ooxml-3.5-FINAL
- POI-OOXML-3.5-FINAL
- poi-3.6-20091214
- POI-3.6-20091214
- xmlbeans-2.3.0
- XMLBeans的-2.3.0
- ooxml-schemas-1.0
- OOXML-架构 - 1.0
Please let me know what i am doing wrong here or i am missing something.
请让我知道我在这里做错了什么,或者我错过了什么。
1 个解决方案
#1
4
You're missing the stax API jar
你错过了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
)
如果查看POI Components页面,您会看到ooxml-schemas jar依赖于STAX API jar(最常见的是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
查看您的POI二进制文件下载,在ooxml-lib目录中,您将看到所需的jar。或者,如果您使用Maven,它将为您下载依赖项
#1
4
You're missing the stax API jar
你错过了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
)
如果查看POI Components页面,您会看到ooxml-schemas jar依赖于STAX API jar(最常见的是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
查看您的POI二进制文件下载,在ooxml-lib目录中,您将看到所需的jar。或者,如果您使用Maven,它将为您下载依赖项