api导出excel的四种实现方法

润乾报表是纯java的,不仅本身具有很强大丰富的功能,同时还在不同层面上提供了丰富的java接口。这里主要说说业务系统中常用的一个功能–导出excel。

本文给出四种常用的通过API接口来实现导出excel的方法:其中方法1和方法2是通过类 com.runqian.report4.util.ReportUtils来实现的,方法3和方法4是通过类 com.runqian.report4.view.excel.ExcelReport来实现的。具体如下:

(1) 通过输出流FileOutputStream来导出excel

FileOutputStream fos = new FileOutputStream( “C:\\Temp\\test.xls” );
ReportUtils.exportToExcel(fos,iReport,false); //默认以不分页的方式导出excel
fos.flush();
fos.close();

(2) 通过File形式导出excel

String excelFile =”C:\\Temp\\test.xls”;
ReportUtils.exportToExcel(excelFile,iReport,false); //默认以不分页的方式导出excel

(3) 通过输出流FileOutputStream来导出excel

ExcelReport eReport = new ExcelReport();
eReport.export(iReport);
FileOutputStream fos = new FileOutputStream( “C:\\Temp\\test.xls” );
eReport.saveTo(fos);
fos.flush();
fos.close();

(4) 通过File形式导出excel

ExcelReport eReport = new ExcelReport();
eReport.export(iReport);
String excelFile =”C:\\Temp\\test.xls”;
eReport.saveTo(excelFile);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值