知识库

推荐内容

快逸做的更好

产品优势

您的位置: 首页 > 知识库 > Api批量导出pdf

Api批量导出pdf

润乾提供了完善的pdfexcelword导出功能,然而客户往往需求报表可以实现批量导出。

使用html的方式导出的报表每次只能获取到一个对象,这是不符合客户需求的,为了满足客户的多样性需求,润乾提供了通过后台api代码批量导出报表的功能。

步骤一,复杂报表设计" target="_blank" class="quieeLink1">设计一张简单的报表,保存在c:

图一

步骤二,编辑jsp,实现api批量循环执行导出功能

<%@ page contentType=”text/html;charset=GBK” %>

<%@ taglib uri=”/WEB-INF/runqianReport4.tld” prefix=”report” %>

<%@ page import=”com.runqian.report4.model.ReportDefine” %>

<%@ page import=”com.runqian.report4.model.engine.ExtCellSet” %>

<%@ page import=”com.runqian.report4.usermodel.Context” %>

<%@ page import=”com.runqian.report4.usermodel.Engine” %>

<%@ page import=”com.runqian.report4.usermodel.IReport” %>

<%@ page import=”com.runqian.report4.util.ReportUtils” %>

<%@ page import=”com.runqian.report4.view.excel.ExcelReport” %>

<%@ page import=”java.io.File”%>

<%@ page import=”java.io.FileOutputStream”%>

<html>

<body topmargin=0 leftmargin=0 rightmargin=0 bottomMargin=0>

<%

for(int j=0;j<100;j++){

String reportTemplateFile=”C:/a.raq”;

try {

IReport iReport = null;

try {

ReportDefine rd = (ReportDefine) ReportUtils.read(reportTemplateFile);

Context cxt = new Context();

Engine engine = new Engine(rd, cxt);

iReport = engine.calc();

}catch (Exception e) {

throw new Exception(“生成iReport出错!”);

}

File file = new File(“H:/ECP/”);

if (!file.exists())

file.mkdirs();

String fileName=”H:/ECP/”+j+”.pdf”;

FileOutputStream fos = new FileOutputStream(fileName);

try {

ReportUtils.exportToPDF(fos, iReport,true,false);

} catch (Throwable e) {

e.printStackTrace();

}

fos.flush();

fos.close();

} catch (Exception e) {

e.printStackTrace();

}

}

%>

</body>

</html>

通过String fileName=”H:/ECP/”+j+”.pdf”;

pdf动态生成在H盘的ECP文件夹下

步骤三,发布jsp执行批量导出

图三

an>

发布日期:2013/05/03
本文分类: 知识库