其它開源免費的報表工具都要我們寫代碼,快逸是做到了使用Tag標簽就能發布復雜的報表,但作為程序員,總想把報表是怎麼運算的搞清楚,今天寫了幾行代碼測試,效果還可以,把快逸的API調用思路寫了一個大概,希望對大家有所幫助:
<%@ page contentType="text/Html;charset=GBK" %>
<%@ taglib uri="/WEB-INF/runqianReport4.tld" prefix="report"%>
<%@ page import="com.runqian.report4.model.*"%>
<%@ page import="com.runqian.report4.util.*"%>
<%@ page import="com.runqian.report4.usermodel.*"%>
<%@ page import="com.runqian.report4.vIEw.Html.*"%>
<%@ page import="com.runqian.report4.vIEw.Excel.*"%>
<%@ page import="Java.util.*" %>
<%@ page import="Java.io.*" %>
<%@ page import="Java.sql.*" %>
<Html>
<head>
<title>潤乾報表4.0</title>
</head>
<body>
<% //根據報表,生成參數與宏的字符串
request.setCharacterEncoding("GBK");
String report=request.getParameter("report");
if(report.indexOf(".raq")<0) report+=".raq";
//第一步,讀取報表模板
InputStream fis=application.getResourceAsStream("/reportFiles/"+report);
ReportDefine rd = (ReportDefine)ReportUtils.read( fis );
//第二步,新建上下文對象
Driver driver = (Driver) Class.forName("com.newatlanta.jturbo.driver.Driver").newInstance();
DriverManager.registerDriver(driver);
Connection con = DriverManager.getConnection("jdbc:JTurbo://127.0.0.1/web4/charset=GBK","sa",