在Java Noclassdeffounderror中写入Excel
当我尝试将数据添加到Java Ant中的Excel时,它显示noclassDeffoundError
,即使我导入了Apache POI的所有JAR文件。这是错误:
线程中的异常“ main” java.lang.noclassdeffounderror:org/apache/commons/io/output/unsynchronized bytearrayoutputstream
这是我尝试的代码:
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("Sheet1");
XSSFRow row = sheet.createRow(0);
Cell cell0 = row.createCell(0);
cell0.setCellValue("HelloWorld!");
try{
FileOutputStream out = new FileOutputStream(new File("Result.xlsx"));
wb.write(out);
out.close();
System.out.println("Done");
}catch(FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
这些是JAR导入的文件:
When I try to add data to Excel from Java Ant, it shows NoClassDefFoundError
, even that I imported all Jar files of Apache Poi. This is the Error:
Exception in thread "main" java.lang.NoClassDefFoundError:org/apache/commons/io/output/UnsynchronizedByteArrayOutputStream
This is the code i tried:
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("Sheet1");
XSSFRow row = sheet.createRow(0);
Cell cell0 = row.createCell(0);
cell0.setCellValue("HelloWorld!");
try{
FileOutputStream out = new FileOutputStream(new File("Result.xlsx"));
wb.write(out);
out.close();
System.out.println("Done");
}catch(FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
These are Jar imported files:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题解决了!似乎我还需要在导入JAR文件之后添加依赖性。xml!
Problem solved! It seems i needed to add dependecy to build.xml also after importing jar files!