我刚刚开始学习Apache POI我想在excel中制作一个类似这样的超级简单的电子表格,+----------+----------+----------+----------+----------+| 1 | 2 | 3 | 4 | 5 |+----------+----------+----------+----------+----------+我写的代码如下,public void exportTable() throws IOException{
FileOutputStream fos=new FileOutputStream(new File("C:\\Users\\*****\\OneDrive\\Desktop\\excel.xlsx"));
XSSFWorkbook wb=new XSSFWorkbook();
XSSFSheet ws=wb.createSheet();
XSSFRow row=ws.createRow(0);
for(int i=0;i<=5;i++)
{
Cell cell=row.createCell(i);
cell.setCellValue(i);
}
wb.write(fos);
fos.close();}我得到一个NoClassDefFoundError我使用以下jar文件。1)POI-4.1.0.jar2)POI-例子-4.1.0.jar3)POI-excelant-4.1.0.jar4)POI-OOXML-4.1.0.jar5)POI-OOXML-架构 - 4.1.0.jar6)POI暂存器-4.1.0.jar7)的xmlbeans-3.1.0.jar8)curvesapi-1.06.jar我在netbeans上使用jdk 1.8PS我对Apache POI几乎没有经验,所以如果你能写一个详细的答案,我将不胜感激。谢谢PPS 我不认识Maven编辑:所以我改变了一些事情1)我从“common-collections”导入了所有jar文件。2)我将“.xls”改为“.xlsx”3)我也导入了“common-compress”,现在它完美无缺。谢谢!
添加回答
举报
0/150
提交
取消