1、在Eclipse中新建一个Java工程
2、在工程中新建【lib】文件夹,并把需要的Jar包导入PS:需要的Jar包如图所示
3、选中Jar包,右键点击【build path】-【add to build path】
4、新建Java类,并创建mian函数
5、如果需要生成【.xls】文件,输入Workbook wb = new HSSFWorkbook(); FileOutputStre锾攒揉敫am fileOut = new FileOutputStream("workbook.xls");wb.write(fileOut); fileOut.close();
6、如果需要生成【.xlsx】文件,输入Workbook wb = new XSSFWorkbook(); FileOutputStream fileOut = new FileOutputStream("workbook.xlsx"); wb.write(fileOut); fileOut.close();
7、运行的函数,我们可以看到在工程目录下生成了我们所需要的excel文件