【Java】如何利用POI生成Excel文件
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();
FileOutputStream 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文件

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
                                阅读量:135
阅读量:76
阅读量:43
阅读量:135
阅读量:98