﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-灵魂-放水-随笔分类-打印报表</title><link>http://www.blogjava.net/zqli/category/18314.html</link><description>为学日益，为道日损。</description><language>zh-cn</language><lastBuildDate>Thu, 26 Apr 2007 09:17:22 GMT</lastBuildDate><pubDate>Thu, 26 Apr 2007 09:17:22 GMT</pubDate><ttl>60</ttl><item><title>去掉水晶报表的数据库验证界面。</title><link>http://www.blogjava.net/zqli/archive/2007/04/26/113847.html</link><dc:creator>放水老倌</dc:creator><author>放水老倌</author><pubDate>Thu, 26 Apr 2007 09:01:00 GMT</pubDate><guid>http://www.blogjava.net/zqli/archive/2007/04/26/113847.html</guid><wfw:comment>http://www.blogjava.net/zqli/comments/113847.html</wfw:comment><comments>http://www.blogjava.net/zqli/archive/2007/04/26/113847.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zqli/comments/commentRss/113847.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zqli/services/trackbacks/113847.html</trackback:ping><description><![CDATA[<p><strong>&nbsp;WinForm：</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.crystalReportViewer1.ReportSource = this.customerByLivingPlace1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 数据库Login<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (CrystalDecisions.Shared.IConnectionInfo connection in this.customerByLivingPlace1.DataSourceConnections)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connection.SetConnection("localhost", "Real_EstatePC", "**", "**");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.crystalReportViewer1.Refresh();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 子报表的Login<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (CrystalDecisions.CrystalReports.Engine.ReportDocument sr in document.Subreports)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (CrystalDecisions.Shared.IConnectionInfo connection in this.customerByLivingPlace1.DataSourceConnections)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connection.SetConnection("localhost", "Real_EstatePC", "**", "**");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br><br>注：customerByLivingPlace1指向rpt。<br><br><br><strong>WebForm：</strong><br>&nbsp;首先,为了登录方便,将数据库的用户名和密码先写到Web.config中: <br>&lt;appSettings&gt; <br>&nbsp;&nbsp;&nbsp; &lt;add key="DBServerName" value="你的数据库服务器" /&gt; <br>&nbsp;&nbsp;&nbsp; &lt;add key="DBUserID" value="sa" /&gt; <br>&nbsp;&nbsp;&nbsp; &lt;add key="DBPassWord" value="UU1Tc3lzdGVt" /&gt; <br>&lt;/appSettings&gt; </p>
<p>然后写个类来统一验证登录 <br>using System; <br>using System.Collections.Generic; <br>using System.Text; <br>using System.Configuration; </p>
<p>namespace BLL <br>{ <br>&nbsp;&nbsp;&nbsp; public class LoginCrystalReport <br>&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void Login( CrystalDecisions.CrystalReports.Engine.ReportDocument report) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string serverName=ConfigurationManager.AppSettings["DBServerName"]; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string userId = ConfigurationManager.AppSettings["DBUserID"]; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string passWord=ConfigurationManager.AppSettings["DBPassWord"]; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Set Database Logon to main report <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (CrystalDecisions.Shared.IConnectionInfo connection in report.DataSourceConnections) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (connection.ServerName == serverName) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connection.SetLogon(userId, passWord); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Set Database Logon to subreport <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (CrystalDecisions.CrystalReports.Engine.ReportDocument subreport in report.Subreports) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (CrystalDecisions.Shared.IConnectionInfo connection in subreport.DataSourceConnections) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (connection.ServerName == serverName) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connection.SetLogon(userId, passWord); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; } <br>} <br><br></p>
<img src ="http://www.blogjava.net/zqli/aggbug/113847.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zqli/" target="_blank">放水老倌</a> 2007-04-26 17:01 <a href="http://www.blogjava.net/zqli/archive/2007/04/26/113847.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个Jasperreport多表打印代码实战</title><link>http://www.blogjava.net/zqli/archive/2006/12/17/88322.html</link><dc:creator>放水老倌</dc:creator><author>放水老倌</author><pubDate>Sun, 17 Dec 2006 02:44:00 GMT</pubDate><guid>http://www.blogjava.net/zqli/archive/2006/12/17/88322.html</guid><wfw:comment>http://www.blogjava.net/zqli/comments/88322.html</wfw:comment><comments>http://www.blogjava.net/zqli/archive/2006/12/17/88322.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zqli/comments/commentRss/88322.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zqli/services/trackbacks/88322.html</trackback:ping><description><![CDATA[
		<p>源码如下：<br /><br />&lt;<a href="mailto:%@taglib">%@taglib</a> uri="/WEB-INF/struts-bean.tld" prefix="bean"%&gt;<br />&lt;<a href="mailto:%@taglib">%@taglib</a> uri="/WEB-INF/struts-html.tld" prefix="html"%&gt;<br />&lt;<a href="mailto:%@taglib">%@taglib</a> uri="/WEB-INF/struts-logic.tld" prefix="logic"%&gt;<br />&lt;<a href="mailto:%@taglib">%@taglib</a> uri="/WEB-INF/struts-nested.tld" prefix="nested"%&gt;<br />&lt;<a href="mailto:%@taglib">%@taglib</a> uri="/WEB-INF/struts-template.tld" prefix="template"%&gt;<br />&lt;<a href="mailto:%@taglib">%@taglib</a> uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%&gt;<br />&lt;<a href="mailto:%@taglib">%@taglib</a> uri="<a href="http://java.sun.com/jsp/jstl/core">http://java.sun.com/jsp/jstl/core</a>" prefix="c"%&gt;<br />&lt;<a href="mailto:%@taglib">%@taglib</a> uri="<a href="http://java.sun.com/jsp/jstl/fmt">http://java.sun.com/jsp/jstl/fmt</a>" prefix="fmt"%&gt;<br />&lt;<a href="mailto:%@taglib">%@taglib</a> uri="<a href="http://java.sun.com/jsp/jstl/sql">http://java.sun.com/jsp/jstl/sql</a>" prefix="sql"%&gt;<br />&lt;<a href="mailto:%@taglib">%@taglib</a> uri="<a href="http://java.sun.com/jsp/jstl/xml">http://java.sun.com/jsp/jstl/xml</a>" prefix="x"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="java.sql.*"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="net.sf.jasperreports.engine.JasperFillManager"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="net.sf.jasperreports.engine.JasperRunManager"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="net.sf.jasperreports.engine.*"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="net.sf.jasperreports.engine.util.*"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="net.sf.jasperreports.engine.export.*"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="net.sf.jasperreports.j2ee.servlets.*"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="java.util.*"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="java.io.*"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="net.sf.jasperreports.engine.JasperPrintManager"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="net.sf.jasperreports.view.*"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="java.sql.*, javax.sql.DataSource, javax.naming.InitialContext"%&gt;<br />&lt;<a href="mailto:%@page">%@page</a> import="java.lang.*"%&gt;<br />&lt;%<br />  InitialContext ctx = new InitialContext();<br />  DataSource ds = (DataSource) ctx.lookup("java:/MSSQLDS");<br />  Connection conn = ds.getConnection();<br />  //String accNo ="200672395001";<br />  //String projID ="200672395121";<br />  String accNo = request.getParameter("accNo");<br />  String projID = request.getParameter("proId");<br />  File reportFile1 = new File(application.getRealPath("/report/kuaibao1.jasper"));<br />  File reportFile2 = new File(application.getRealPath("/report/kuaibao2.jasper"));<br />  File reportFile3 = new File(application.getRealPath("/report/kuaibao3.jasper"));<br />  File reportFile4 = new File(application.getRealPath("/report/kuaibao4.jasper"));<br />  if (!reportFile1.exists() || !reportFile2.exists() || !reportFile3.exists() || !reportFile3.exists() || !reportFile4.exists())<br />    throw new JRRuntimeException("Fidsfsfd. The report design must be compiled first.");<br />  JasperReport jasperReport1 = (JasperReport) JRLoader.loadObject(reportFile1.getPath());<br />  JasperReport jasperReport2 = (JasperReport) JRLoader.loadObject(reportFile2.getPath());<br />  JasperReport jasperReport3 = (JasperReport) JRLoader.loadObject(reportFile3.getPath());<br />  JasperReport jasperReport4 = (JasperReport) JRLoader.loadObject(reportFile4.getPath());<br />  Map parameters = new HashMap();<br />  parameters.put("accNo", accNo);<br />  parameters.put("projID", projID);<br />  JasperPrint jasperPrint1 =<br />      JasperFillManager.fillReport(<br />          jasperReport1,<br />          parameters,<br />          conn<br />      );<br />  JasperPrint jasperPrint2 =<br />      JasperFillManager.fillReport(<br />          jasperReport2,<br />          parameters,<br />          conn<br />      );<br />  JasperPrint jasperPrint3 =<br />      JasperFillManager.fillReport(<br />          jasperReport3,<br />          parameters,<br />          conn<br />      );<br />  JasperPrint jasperPrint4 =<br />      JasperFillManager.fillReport(<br />          jasperReport4,<br />          parameters,<br />          conn<br />      );<br />  response.setContentType("application/ms_word");<br />  JRExporter exporter = null;<br />  exporter = new JRRtfExporter();<br />  List reportlist = (List)new java.util.ArrayList();<br />  reportlist.add(jasperPrint1);<br />  reportlist.add(jasperPrint2);<br />  reportlist.add(jasperPrint3);<br />  reportlist.add(jasperPrint4);<br />  // System.out.println(reportlist.size() + "list");<br />  byte[] bytes;<br />  ByteArrayOutputStream baos = new ByteArrayOutputStream();<br />  exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, reportlist);<br />  exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);<br />  exporter.exportReport();<br />  // exporter.exportReportToStream();<br />  bytes = baos.toByteArray();<br />  // System.out.println(bytes+"bytes");<br />  if (bytes != null &amp;&amp; bytes.length &gt; 0) {<br />    try {<br />     // response.reset();<br />      response.setContentType("application/ms_word");<br />      response.setHeader("Content-disposition",<br />                         "attachment; filename=yourReport.rtf");<br />      response.setContentLength(bytes.length);<br />      ServletOutputStream ouputStream = response.getOutputStream();<br />      ouputStream.write(bytes, 0, bytes.length);<br />      //ouputStream.flush();<br />      ouputStream.close();<br />      response.reset();<br />    }<br />    catch (Exception ex) {<br />      ex.printStackTrace();<br />    }<br />    finally {</p>
		<p>      conn.close();<br />    }<br />  }<br />%&gt;</p>
<img src ="http://www.blogjava.net/zqli/aggbug/88322.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zqli/" target="_blank">放水老倌</a> 2006-12-17 10:44 <a href="http://www.blogjava.net/zqli/archive/2006/12/17/88322.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]使用Jasperreport作为报表控件开发胖客户端报表应用 </title><link>http://www.blogjava.net/zqli/archive/2006/12/17/88320.html</link><dc:creator>放水老倌</dc:creator><author>放水老倌</author><pubDate>Sun, 17 Dec 2006 02:31:00 GMT</pubDate><guid>http://www.blogjava.net/zqli/archive/2006/12/17/88320.html</guid><wfw:comment>http://www.blogjava.net/zqli/comments/88320.html</wfw:comment><comments>http://www.blogjava.net/zqli/archive/2006/12/17/88320.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zqli/comments/commentRss/88320.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zqli/services/trackbacks/88320.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 概述						我们对第一部分的内容做个简要的回忆，第一部分主要是介绍使用iReport如何制作一个数据报表，我认为文章比较详细的介绍“如何从零到满足大部分需求报表出现”。但是文中没有涉及Jasperreport的任何内容，目的是让你纯粹的理解如何做报表，因为做报表和把报表内嵌到应用程序编程是可以分工的，便于整合也便于分解。 								我们知道				iRepor...&nbsp;&nbsp;<a href='http://www.blogjava.net/zqli/archive/2006/12/17/88320.html'>阅读全文</a><img src ="http://www.blogjava.net/zqli/aggbug/88320.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zqli/" target="_blank">放水老倌</a> 2006-12-17 10:31 <a href="http://www.blogjava.net/zqli/archive/2006/12/17/88320.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[转]使用Jasperreport作为报表控件开发Web报表应用</title><link>http://www.blogjava.net/zqli/archive/2006/12/17/88319.html</link><dc:creator>放水老倌</dc:creator><author>放水老倌</author><pubDate>Sun, 17 Dec 2006 02:23:00 GMT</pubDate><guid>http://www.blogjava.net/zqli/archive/2006/12/17/88319.html</guid><wfw:comment>http://www.blogjava.net/zqli/comments/88319.html</wfw:comment><comments>http://www.blogjava.net/zqli/archive/2006/12/17/88319.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zqli/comments/commentRss/88319.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zqli/services/trackbacks/88319.html</trackback:ping><description><![CDATA[
		<h1 style="MARGIN: 17pt 0cm 16.5pt">
				<span lang="EN-US">1</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、概述</span>
				<span lang="EN-US">
						<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
						<o:p>
						</o:p>
				</span>
		</h1>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 18pt; LINE-HEIGHT: 150%">
				<span style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如何实现</span>
				<span style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">发<span lang="EN-US">Web报表有很多的选择，自定义CSS＋HTML或是XSLT＋XML或是其他控件，特别是支持图表的控件，比如：jfreechart。本文作为Web报表的一种实现方式，建议你使用Jasperreport作为报表控件，第一、二部分已经对制作报表和开发胖客户端报表应用做了介绍，其实有很多的文章可以参考实现第三部分的内容，不止是我写的这篇文章。<o:p></o:p></span></span>
		</p>
		<h1 style="MARGIN: 17pt 0cm 16.5pt">
				<span lang="EN-US" style="mso-font-kerning: 0pt">2</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">、数据连接建立</span>
				<span lang="EN-US" style="mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</h1>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 18pt; LINE-HEIGHT: 150%">
				<span style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">参考</span>
				<span lang="EN-US" style="LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-bidi-font-size: 10.5pt">
						<a href="http://blog.csdn.net/jemlee2002/archive/2004/09/28/JJEM.aspx">http://blog.csdn.net/jemlee2002/archive/2004/09/28/JJEM.aspx</a>，</span>
				<span style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">这里有详细的介绍数据库的连接过程。<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<h1 style="MARGIN: 17pt 0cm 16.5pt">
				<span lang="EN-US" style="mso-font-kerning: 0pt">3</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">、拷贝必要的</span>
				<span lang="EN-US" style="mso-font-kerning: 0pt">jar</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">文件到</span>
				<span lang="EN-US" style="mso-font-kerning: 0pt">Web</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">应用的</span>
				<span lang="EN-US" style="mso-font-kerning: 0pt">WEB-INF\lib</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">目录</span>
				<span lang="EN-US" style="mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</h1>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 18pt; LINE-HEIGHT: 150%">
				<span style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">每个<span lang="EN-US">Web应用都会有WEB-INF目录，但是lib是不一定有的，如果没有就创建它，本文需要的jar库文件有3个：<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
				<span lang="EN-US" style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">jasperreports-0.5.3.jar ：jasperreports执行时需要的API<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
				<span lang="EN-US" style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">iTextAsian.jar ：亚洲字符集支持<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
				<span lang="EN-US" style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">itext-1.02b.jar ：其他字符集支持<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; LINE-HEIGHT: 150%">
				<span style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">如果你的报表全英文或是不需要支持亚洲字符集，那么<span lang="EN-US">iTextAsian.jar、可以不要。<o:p></o:p></span></span>
		</p>
		<h1 style="MARGIN: 17pt 0cm 16.5pt">
				<span lang="EN-US" style="mso-font-kerning: 0pt">4</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">、创建</span>
				<span lang="EN-US" style="mso-font-kerning: 0pt">repotrs</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">目录并导入</span>
				<span lang="EN-US" style="mso-font-kerning: 0pt">.jasper</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">文件</span>
				<span lang="EN-US" style="mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</h1>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 28pt; LINE-HEIGHT: 150%; mso-char-indent-count: 2.0">
				<span style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">在<span lang="EN-US">Web应用中根目录下创建repotrs目录，其实这是一种建议，没有必要完全按照这样做，你可以根据你的业务需要创建N个目录或是层次目录。<o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 28pt; LINE-HEIGHT: 150%; mso-char-indent-count: 2.0">
				<span style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">把<span lang="EN-US">.jasper文件拷贝到repotrs目录下，比如例子中的BusinessRpt.jasper文件。<o:p></o:p></span></span>
		</p>
		<h1 style="MARGIN: 17pt 0cm 16.5pt">
				<span lang="EN-US" style="mso-font-kerning: 0pt">5</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">、例子程序</span>
				<span lang="EN-US" style="mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</h1>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
				<span lang="EN-US" style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">Test.jsp文件的内容：<o:p></o:p></span>
		</p>
		<table class="MsoNormalTable" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN: auto auto auto 5.4pt; BORDER-LEFT: medium none; WIDTH: 450pt; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext" cellspacing="0" cellpadding="0" width="600" border="1">
				<tbody>
						<tr style="HEIGHT: 179.25pt; mso-yfti-irow: 0; mso-yfti-lastrow: yes">
								<td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 450pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 179.25pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt" valign="top" width="600">
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;%@ page session="false" %&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;%@ page import="dori.jasper.engine.*" %&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;%@ page import="javax.naming.*"%&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;%@ page import="java.sql.*"%&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;%@ page import="javax.sql.*"%&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;%@ page import="java.util.*" %&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;%@ page import="java.io.*" %&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;html&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;head&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;title&gt;&lt;/title&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;%<span style="mso-spacerun: yes">   </span><o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-spacerun: yes">   </span>DataSource ds = null;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-spacerun: yes">   </span>try{<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>InitialContext ctx=new InitialContext();<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>ds=(DataSource)ctx.lookup("java:comp/env/jdbc/mysql");<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>Connection conn = ds.getConnection();<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>//装载jasper文件<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>File business_rpt = new File(application.getRealPath("/reports/BusinessRpt.jasper"));<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>//配置参数，可以参考《第二部分：使用Jasperreport作为报表控件开发胖客户端报表应用》<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-spacerun: yes">      </span>
														<span style="mso-spacerun: yes"> </span>
														<span style="mso-spacerun: yes"> </span>//</span>
												<span lang="EN-US">
												</span>
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">http://blog.csdn.net/jemlee2002/archive/2004/10/08/JJem3.aspx<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>//ProjectName就是iReport的变量$P{ProjectName}的名称，<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>//参考第一部分的5.6添加参数和使用参数<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>//proname就是从界面上获取的值。<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 36pt; LINE-HEIGHT: 150%; mso-char-indent-count: 4.0">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">Map parameters = new HashMap();<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>parameters.put("ProjectName ", proname); <o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-spacerun: yes">        </span>// JasperRunManager是一个输出控制管理类，下文会提及部分内容<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>JasperRunManager.runReportToHtmlFile(business_rpt.getPath(),parameters,conn);<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-spacerun: yes">       </span>//如果创建报表成功，则转向该报表，其实可以把报表套在框架内，这样实现比较有意义的报表格式。<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-tab-count: 1">     </span>
														<span style="mso-spacerun: yes">   </span>response.sendRedirect("/reports/BusinessRpt.html");<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-spacerun: yes">   </span>}catch(Exception ex){<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-spacerun: yes">       </span>out.print("出现例外，信息是:"+ex.getMessage());<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-spacerun: yes">       </span>ex.printStackTrace();<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
														<span style="mso-spacerun: yes">   </span>}<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">%&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;/head&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;body&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;/body&gt;<o:p></o:p></span>
										</p>
										<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 150%">
												<span lang="EN-US" style="FONT-SIZE: 9pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&lt;/html&gt;<o:p></o:p></span>
										</p>
								</td>
						</tr>
				</tbody>
		</table>
		<h1 style="MARGIN: 17pt 0cm 16.5pt">
				<span lang="EN-US" style="mso-font-kerning: 0pt">6</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">、关于</span>
				<span lang="EN-US" style="mso-font-kerning: 0pt">JasperRunManager<o:p></o:p></span>
		</h1>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 28pt; LINE-HEIGHT: 150%; mso-char-indent-count: 2.0">
				<span lang="EN-US" style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">JasperRunManager有很多的静态方法，控制输出的格式，比如输出格式是pdf或是html等，建议浏览JasperRunManager的一些方法，这样对开发报表输出有帮助。<o:p></o:p></span>
		</p>
		<h1 style="MARGIN: 17pt 0cm 16.5pt">
				<span lang="EN-US" style="mso-font-kerning: 0pt">7</span>
				<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">、输出内容</span>
				<span lang="EN-US" style="mso-font-kerning: 0pt">
						<o:p>
						</o:p>
				</span>
		</h1>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 18pt; LINE-HEIGHT: 150%">
				<span style="FONT-SIZE: 14pt; LINE-HEIGHT: 150%; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">例子中输出格式是以<span lang="EN-US">HTML文件格式，所以web服务器可以直接解释并显示，效果不错。<o:p></o:p></span></span>
		</p>
<img src ="http://www.blogjava.net/zqli/aggbug/88319.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zqli/" target="_blank">放水老倌</a> 2006-12-17 10:23 <a href="http://www.blogjava.net/zqli/archive/2006/12/17/88319.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>［转］JasperReport 用户手册</title><link>http://www.blogjava.net/zqli/archive/2006/12/11/87004.html</link><dc:creator>放水老倌</dc:creator><author>放水老倌</author><pubDate>Mon, 11 Dec 2006 11:39:00 GMT</pubDate><guid>http://www.blogjava.net/zqli/archive/2006/12/11/87004.html</guid><wfw:comment>http://www.blogjava.net/zqli/comments/87004.html</wfw:comment><comments>http://www.blogjava.net/zqli/archive/2006/12/11/87004.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zqli/comments/commentRss/87004.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zqli/services/trackbacks/87004.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1 										简介																																																										       JasperReport										是一个强大、灵活的报表生成工具，能够展示丰富的页面内容，并将之转换成								PDF								...&nbsp;&nbsp;<a href='http://www.blogjava.net/zqli/archive/2006/12/11/87004.html'>阅读全文</a><img src ="http://www.blogjava.net/zqli/aggbug/87004.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zqli/" target="_blank">放水老倌</a> 2006-12-11 19:39 <a href="http://www.blogjava.net/zqli/archive/2006/12/11/87004.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>［转］使用iReport制作报表的详细过程（Windows环境下）</title><link>http://www.blogjava.net/zqli/archive/2006/12/11/87002.html</link><dc:creator>放水老倌</dc:creator><author>放水老倌</author><pubDate>Mon, 11 Dec 2006 11:36:00 GMT</pubDate><guid>http://www.blogjava.net/zqli/archive/2006/12/11/87002.html</guid><wfw:comment>http://www.blogjava.net/zqli/comments/87002.html</wfw:comment><comments>http://www.blogjava.net/zqli/archive/2006/12/11/87002.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zqli/comments/commentRss/87002.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zqli/services/trackbacks/87002.html</trackback:ping><description><![CDATA[第一部分：使用iReport制作报表的详细过程（Windows环境下）<br /><p>提示:在有些板块，文中的图片看不到，建议到我的blog浏览文章：<a href="http://blog.csdn.net/jemlee2002/" target="_blank"><font color="#000000">http://blog.csdn.net/jemlee2002/</font></a><br />文章将会涉及3个方面的内容：</p><p>第一部分：使用iReport制作报表的详细过程（Windows环境下）</p><p>第二部分：使用Jasperreport作为报表控件开发胖客户端报表应用</p><p>第三部分：使用Jasperreport作为报表控件开发Web报表应用 <br /><br /><br /><br /></p><h1>1、前言</h1><p>在网络上可以搜索到很多使用iReport和Jasperreport配合实现各种报表任务的文章，但是我觉得很少有一篇（几乎没有）做一个比较详细的介绍如何使用iReport制作报表的全过程，我所看过的文章的基本思想是覆盖面广，很多内容都是提及即过，并不是开发人员都有时间为每个实践花费时间自己实现，如果能有更详细的资料，那岂不是一件乐事。出于这个念头促使我写这篇文章，希望能对那些使用iReport和Jasperreport朋友有所帮助，特别是需要亲身去实现报表的朋友，希望能给你们带来一点帮助。本文不是对iReport的每个细节进行介绍，关于iReport的每个细节可以参考iReport网站的资料，但是可能得花费一些费用。一般用户没有必要付出这些费用，因为我们关心的是如何制作我们需要的报表，而不是去扩展iReport，比如制作iReport的插件。<br /><br /></p><h1>2、准备</h1><h2>2.1、下载JDK</h2><p>地址：<a href="http://www.sun.com/" target="_blank"><font face="Times New Roman" color="#000000">http://www.sun.com</font></a>，选择<font face="Times New Roman">1.3</font>以上版本（建议<font face="Times New Roman">1.4.2</font>以上版本），安装<font face="Times New Roman">JDK</font>，默认安装即可；如果你的系统已经有安装过<font face="Times New Roman">JDK</font>或是有<font face="Times New Roman">JRE</font>即可省略这一步骤，验证<font face="Times New Roman">JDK</font>或是<font face="Times New Roman">JRE</font>是否可以默认运行，在命令行（<font face="Times New Roman">CMD</font>）打入<font face="Times New Roman">X:&gt;java </font>如果出现：<font face="Times New Roman">Usage</font>：<font face="Times New Roman">java………………………..</font>开头的一堆信息既是通过验证。否则必须进行配置，配置信息如下，在<font face="Times New Roman">windows</font>的环境变量设置：</p><p><font face="Times New Roman">path</font>：在最后面加入“<font face="Times New Roman">;java</font>的安装目录”</p><p><font face="Times New Roman">JAVA_HOME </font>：“<font face="Times New Roman">java</font>的安装目录”</p><p><font face="Times New Roman">CLASSPATH</font>：“<font face="Times New Roman">java</font>的安装目录<font face="Times New Roman">\\bin</font><font face="宋体">”<br /></font>重新验证<font face="Times New Roman">JDK</font>或是<font face="Times New Roman">JRE</font>是否可以在CMD任何位置运行</p><h2>2.2、下载iReport</h2><p>地址：<a href="http://ireport.sourceforge.net/" target="_blank"><font face="Times New Roman" color="#000000">http://ireport.sourceforge.net/</font></a>，选择<font face="Times New Roman">0.3.2</font>版本（发稿之前为止建议使用的版本）解压<font face="Times New Roman">iReport</font>在任意目录，解压后的文件里面有一个<font face="Times New Roman">iReport.bat</font>，通过双击，过大约<font face="Times New Roman">30</font>秒钟如果可以弹出<font face="Times New Roman">iReport</font>的主窗体即表明你的系统已经可以运行<font face="Times New Roman">iReport</font>了，如果不能弹出主窗体，一般是第一步骤错误，或是没有完成。</p><h2>2.3、准备数据库</h2><p><font face="Times New Roman">iReport</font>支持绝大部分数据库，只要该数据库能提供<font face="Times New Roman">JDBC</font>驱动器。本文提供<font face="Times New Roman">MySql</font>数据库作为例子，但是文章最后会提到如何配置<font face="Times New Roman">Oracle</font>的支持。关于数据库的安装和建立表不属于本文的范围，请参考其他资料。本文假设已经安装了<font face="Times New Roman">MySql</font>和在<font face="Times New Roman">MySql</font>已经有一些表，并且确定表中已经有数据了。</p><p><font face="Times New Roman">*</font>【特别提示】<font face="Times New Roman">MySql</font>的版本要求与<font face="Times New Roman">iReport</font>文件夹下的<font face="Times New Roman">Lib</font>目录的使用<font face="Times New Roman">MySql</font>驱动程序兼容，笔者建议到<font face="Times New Roman"><a href="http://www.mysql.org/" target="_blank"><font color="#000000">http://dev.mysql.com/downloads/</font></a></font>下载最新版本<font face="Times New Roman">mysql</font>的驱动器，这样就不会应为<font face="Times New Roman">JDBC</font>驱动器的问题而当心数据库的支持问题。</p><h2>2.4、启动MySql服务</h2><p>确定<font face="Times New Roman">Mysql</font>使用的的字符集是重要的问题，特别是对需要中文报表的朋友，应该特别注意这个问题。<font face="Times New Roman"></font></p><h2>2.5、确定商务逻辑</h2><p><font face="Times New Roman">       </font>也就是希望完成什么样的报表任务。需要实现的报表的详细描述，这是实现报表的业务条件，否则所有的任务绝大部分没有意义。本文使用一个<font face="Times New Roman">Bug</font>记录表为例，本文的例子是制作一个根据项目和项目中的模块分组的<font face="Times New Roman">Bug</font>量统计。<br /></p><h1>3、开始配置基本信息</h1><h2>3.1、配置界面使用的语言和报表输出路径</h2><p><font face="Times New Roman">       </font>第一次进入系统是英文环境，可以通过【<font face="Times New Roman">Tools</font>】－【<font face="Times New Roman">Options</font>】开启配置iReport系统的基本信息对话框。在“<font face="Times New Roman">Language</font>”选项里面选择你需要的界面语言，比如“中文－中国”。点击【<font face="Times New Roman">Apply</font>】按钮，系统既把整个界面中文化。</p><p><font face="Times New Roman">       </font>在配置iReport系统的基本信息对话框中选择【编译】<font face="Times New Roman">Label</font>，之后决定你的报表输出路径，可以把“编译在报表数据文件夹”选择打勾，这样报表的<font face="Times New Roman">jrxml</font>文件和<font face="Times New Roman">jasper</font>文件就放置同一文件夹。（在新建报表时会要求你把<font face="Times New Roman">jrxml</font>文件保存到指定的文件夹）</p><p>【<font face="Times New Roman">Options</font>】选项中的一部分参数修改不能通过【<font face="Times New Roman">Apply</font>】按钮直接起作用，比如“<font face="Times New Roman">Look&amp;Feel</font>”，必须重新启动<font face="Times New Roman">iReport</font>才能起作用。不知道是不是iReport的<font face="Times New Roman">Bug</font>？！最后【存档】。</p><h2>3.2、配置MySql的数据库连接</h2><p><font face="Times New Roman">       </font>这就是报表与数据库的接口。可以通过【资料来源】－【连接<font face="Times New Roman">/</font>资料来源】开启配置列表对话框，<font face="Times New Roman">iReport</font>会记录以前使用的所有连接，除非你手工删除这些连接，否则所有的连接都会存在连接<font face="Times New Roman">/</font>资料来源配置列表对话框中，不管是否确实可用。</p><p><font face="Times New Roman">       </font>点击【<font face="Times New Roman">New</font>】进入配置新连接界面，如图：<br /></p><p><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/o_1.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /></p><p>填写JDBC连接需要的信息，iReport支持多种数据源连接，如图：<br /><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/o_2.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /></p><p>本文只是介绍DataBase JDBC Connection连接方式，这也是最常用的方式，特别是在嵌入式报表应用。所有的信息填写并测试通过之后，最后就是保存信息。回到配置列表对话框，关闭对话框，完成MySql数据库JDBC连接配置。<br />提示：如果你需要报表提供中文内容显示可以在JDBC URL下工夫，比如输入：<br />jdbc:mysql://localhost/SUBRDB?user=****&amp;password=****&amp;useUnicode=true&amp;characterEncoding=GB2312<br />其中的****号替换成数据库的用户合密码。<br /></p><h2>3.3、新建一个空报表的基本配置</h2><p>单击工具栏的第一个工具“<font face="Times New Roman">New Report</font>”，新建一个报表，输入报表名称和定义报表的一些参数，比如名称输入<font face="Times New Roman">BugsRpt</font>（例子是做一个项目的<font face="Times New Roman">Bug</font>量统计报表）<font face="Times New Roman">,</font>单击【<font face="Times New Roman">More….</font>】选择标签，填写或是选择<font face="Times New Roman">XML</font>编码，这是关系到你的<font face="Times New Roman">XML</font>支持的字符集的选择，请根据需要选择，比如需要你的<font face="Times New Roman">XML</font>文件支持中文，那么可以输入<font face="Times New Roman">GB2312</font>或是<font face="Times New Roman">GBK</font>，之后点击【<font face="Times New Roman">OK</font>】按钮，进入报表的设计界面。</p><p><font face="Times New Roman">*</font>【特别提示】请在开始任何工作之前保存报表，这时<font face="Times New Roman">iReport</font>提示保存报表的位置，选择合适的位置之后输入<font face="Times New Roman">BugsRpt</font>作为名称。</p><h2>3.4、定义报表可能需要的字体类型及其属性</h2><p><font face="Times New Roman">       </font>一个报表的内容五花八门，有表头、栏位名、数据、其他变量信息等等，如果这些信息都是一致的字体和属性（比如颜色），那么整个报表就死气沉沉，显得很粗糙了。我们可以在为报表添加每个元素时定义元素的属性，但是那是一个多么费时的工作，如果能预先定义一些属性的组合，之后在创建每个元素时只需选择这些组合的其中一个即可，省事又快速。</p><p><font face="Times New Roman">       </font>单击【预览】－【报表字体】开启自定义组合对话框。单击【<font face="Times New Roman">New</font>】进入定义详细对话框，如图：按照图中的顺序填写信息和步骤，依次定义“表头”、“组”、“列”、“列内容”、“统计计算”、“其他”等6中字体组合。注意PDF内嵌字体的选择，如果你需要报表时以PDF文件格式提供，那么对此需要作出选择。<br /></p><p></p><p></p><p><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/o_3.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /></p><h1>4、理解几个重要的概念</h1><h2>4.1、iReport的输出格式</h2><p><font face="Times New Roman">iReport</font>的预览输出格式可以支持以下几种：</p><p><font face="Times New Roman">PDF</font>、<font face="Times New Roman">HTML</font>、<font face="Times New Roman">CSV</font>、<font face="Times New Roman">JAVA2D</font>、<font face="Times New Roman">Excel</font>、纯文字、<font face="Times New Roman">JRViewer</font>，其中最常用的是<font face="Times New Roman">PDF</font>、<font face="Times New Roman">JRViewer</font>。本文以<font face="Times New Roman">JRViewer</font>为例子。<font face="Times New Roman">JRViewer</font>是直接以<font face="Times New Roman">C/S</font>方式作为报表的输出格式，在<font face="Times New Roman">JFrame</font>框架下输出。<font face="Times New Roman">Jasperreport</font>提供默认的<font face="Times New Roman">JRViewer</font>输出类。</p><h2><font face="Arial">4.2</font>、报表的动态对象变量、参数、字段</h2><p>在使用<font face="Times New Roman">iReport</font>的过程中会碰到很多与变量（<font face="Times New Roman">Variables</font>）、参数（<font face="Times New Roman">Parameters</font>）、字段（<font face="Times New Roman">Fields</font>）这些有关的内容，我们要介绍这些对象的使用和意义：</p><p>·字段（<font face="Times New Roman">Fields</font>）：是数据库抽取出来的，希望在报表中出现的数据库内容。比如一个<font face="Times New Roman">ID</font>的所有值。<font face="Times New Roman">$F{ filedsName }<br /><p></p></font></p><p></p><p>·参数（<font face="Times New Roman">Parameters</font>）：这是你的应用需要提供给报表的入口，比如你希望在报表被解释的时候提供<font face="Times New Roman">Where</font>语句的条件值，那么就可以使用参数（<font face="Times New Roman">Parameters</font>）。<font face="Times New Roman">$P{ parameterName }<br /><p></p></font></p><p></p><p>·变量（<font face="Times New Roman">Variables</font>）：这是报表中一些逻辑运算的表现，比如统计值。<font face="Times New Roman">$V{ variablesName }<br /><p></p></font></p><p></p><p>每种对象的定义格式如每个对象的后面说明，比如定义一个变量（<font face="Times New Roman">Variables</font>），那么表达式就写成<font face="Times New Roman">$V{ variablesName }</font>，报表中出现的就是这个变量的名称。后文会详细的介绍使用方法。</p><h2>4.3、编译、静态运行、动态运行</h2><p><font face="Times New Roman">Jasperreport</font>运行时需要的就是一个<font face="Times New Roman">jasper</font>后缀的文件，编译过程其实就是把<font face="Times New Roman">jrxml</font>后缀的文件生成<font face="Times New Roman">jasper</font>后缀的文件。（可以参考<font face="Times New Roman">Jasperreport</font>的运行原理）</p><p>静态运行和动态运行是相对的，后者带数据源运行，比如带数据库运行。前者就是静态文本运行，和数据源无关，如果报表中出现和数据源有关的对象，则以<font face="Times New Roman">null</font>显示。</p><h2><font face="Arial">4.4</font>、报表结构</h2><p><font face="Times New Roman">       </font>一个报表的结构大致是<font face="Times New Roman">几</font>个部分：<font face="Times New Roman">title</font>、<font face="Times New Roman">pageHeader</font>、<font face="Times New Roman">columnHeader</font>、<font face="Times New Roman">detial</font>、<font face="Times New Roman">columnFooter</font>、<font face="Times New Roman">pageFooter</font>、<font face="Times New Roman">summary</font>、<font face="Times New Roman">groupHeader</font>、<font face="Times New Roman">groupfooter</font>。<br /></p><p></p><p></p><p><font face="Times New Roman">·Title</font>：每个报表一般会有一个名字，比如×××销售报表，<font face="Times New Roman">title</font>就是搁置这个名称的最好地方了，当然你也可以根据需要搁置在合适的地方。</p><p><font face="Times New Roman">·pageHeader</font>：报表的一些公共要素，比如页码、创建时间、创建人等信息放置在这里是比较好的选择。</p><p><font face="Times New Roman">·columnHeader</font>：无可非议的这里是放置列的名称，记住不是列数据。</p><p><font face="Times New Roman">·Detial</font>：放置需要循环的数据，比如销售记录数据。</p><p><font face="Times New Roman">·columnFooter</font>：放置列级别的统计计算值或是列的说明。</p><p><font face="Times New Roman">·pageFooter</font>：放置页级别的统计值或是页的说明。</p><p><font face="Times New Roman">·Summary</font>：可能需要对几页（你的报表可能有几个页组成）的统计值。比如<font face="Times New Roman">50</font>个销售记录共占用了<font face="Times New Roman">3</font>页，那么放置这些统计记录的统计值最好的地方就是<font face="Times New Roman">summary</font>。</p><p><font face="Times New Roman">·groupHeader</font>：每个表的内容可能需要根据某个属性进行划分显示内容和计算内容，比如希望以月份为单位每组分开显示销售记录，那么就可以定义一个组（组的定义参考后文），<font face="Times New Roman">groupHeader</font>就是放置组说明或是组标志最好的地方。</p><p><font face="Times New Roman">·Groupfooter</font>：放置组的统计或是说明<br /></p><p></p><p></p><h1>5、向表添加对象</h1><h2>5.1、添加静态对象</h2><p>可以通过工具栏的工具添加静态对象，比如文本，点击【<b><i><font face="Times New Roman">T</font></i></b>】，之后在报表的空白处单击，如此即可把静态对象添加到报表，然后拖动对象的边框，使它的大小合适，双击对象弹出对象的属性配置对话框，切换到【<font face="Times New Roman">Font</font>】<font face="Times New Roman">Label</font>，在“<font face="Times New Roman">Report font</font>”的<font face="Times New Roman">ComBox</font>选择“表头”字体，（表头字体是前文提供的自定义属性组合），再切换到【<font face="Times New Roman">Static Text</font>】<font face="Times New Roman">Label</font>，修改表头的名字，比如“<font face="Times New Roman">Bug</font>统计报表”或是“销售记录统计表”等等与业务有关的内容。添加图片，请点击【<font face="Times New Roman">Image Tool</font>】，之后的操作与<font face="Times New Roman">Text</font>类似。其他静态对象操作步骤类似。<br /></p><p></p><p></p><h2>5.2、使用连接</h2><p><font face="Times New Roman">       </font>还记得前文提供的（<font face="Times New Roman">3.2</font>节）配置<font face="Times New Roman">MySql</font>数据库连接吗？这里我们将要使用前文配置的连接了。选择菜单【建立】－【使用动态连接】开启可选的动态连接，选择任何一个你需要的连接最后【<font face="Times New Roman">OK</font>】，保存报表，这样你的报表就使用了这个连接了。</p><p><font face="Times New Roman">*</font>【特别提示】此连接必须与以后应用程序使用的连接一致。<br /><br /></p><p></p><p></p><h2>5.3、创建SQL查询语句</h2><p><font face="Times New Roman">       SQL</font>语句是对任何<font face="Times New Roman">RDBMS</font>起作用的语言，外部用户需要使用这些语言管理维护数据库中的数据，同样的，<font face="Times New Roman">iReport</font>也是需要这么做，我们需要提供查询数据库的语言－<font face="Times New Roman">SQL</font>语句，这样，<font face="Times New Roman">iReport</font>即可通过此<font face="Times New Roman">SQL</font>语句获取数据，之后组织到报表中并显示出来，以满足用户的需要为目的。</p><p><font face="Times New Roman">       </font>通过菜单【资料来源】－【报表查询】开启<font face="Times New Roman">SQL</font>输入对话框，并在【<font face="Times New Roman">Report SQL Query</font>】<font face="Times New Roman"> Label</font>中输入<font face="Times New Roman">SQL</font>语句如图：图中的“<font face="Times New Roman">Automatically Retrieve Fields</font>”<font face="Times New Roman">checkbox</font>和“<font face="Times New Roman">ReadFields</font>”<font face="Times New Roman">Button</font>是确认自动获取还是手动获取数据库表的可用<font face="Times New Roman">Fields</font>。单击【<font face="Times New Roman">OK</font>】，保存报表。<br /></p><p><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/o_4.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /></p><h2>5.4、创建<font face="宋体">字段</font>动态对象</h2><p>报表的动态对象有变量、参数、字段，前文提及了他们的概念，这里将要一一讲解如何使用。</p><p>字段也就是数据库中的字段，通过菜单【预览】－【报表字段】开启字段的列表（工具条上可以找到相应的工具），可以拖放任意字段到报表的任何位置，比如拖动一部分<font face="Times New Roman">Bug</font>的内容字段到<font face="Times New Roman">detial</font>段（内容无关紧要，只要知道原理）。</p><h2><font face="Arial">5.5</font>、创建组</h2><p>组是一个很重要的概念，一个报表可以多个组，每个组以一个关键字为标记，比如希望<font face="Times New Roman">Bug</font>统计是根据项目（或是产品）进行统计的。那么可以设立一个项目标记的组。如图：<br /><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/o_5.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /><br />组的参数设定可以看界面即可理解部分，其中最主要的是“Group expression”，这是必须输入格式正确的并且存在的字段名称，本文的“proname”是【字段】中的一个元素。依此类推，建立其他的组对象。每建立一个组，在报表的界面上都会出现该组对应的段，如图：至于他们的意义和容纳的内容参考“4.4报表结构”，他们是首尾对应出现的。（Header和Footer）<br /><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/o_6.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /></p><h2>5.6、添加参数和使用参数</h2><p>我们重申参数作用，一般是需要外界提供参数给报表的入口，比如SQL语句的where条件的表达式。通过【预览】－【报表参数】开启报表参数列表对话框（工具条上可以找到相应的工具）。如图：输入名称及其他参数。【ok】,保存报表。<br /><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/51118/o_7.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /></p><p>那么如何使用呢？打开<font face="Times New Roman">SQL</font>语句对话框，参考“<font face="Times New Roman">5.3</font>创建<font face="Times New Roman">SQL</font>查询语句”，这时候的<font face="Times New Roman">SQL</font>语句应该是：<font face="Times New Roman"><br />SELECT *</font></p><p><font face="Times New Roman">FROM bugs  where proname=$P{ProjectName} order by proname,modulename<br /><font face="宋体">注意其中的红体字部分，就是把刚才定义的变量运用到</font><font face="Times New Roman">SQL</font>语句了。这样当应用提供参数时，只要指定提供给这个参数，那么报表解释引擎即可替换这些变量然后再执行<font face="Times New Roman">SQL</font>语句，在第二部分提到编程时，会提供参数设定代码。<br /><br /><p></p></font></p><p></p><h2>5.7、添加变量和使用变量<br /><p></p></h2><p>变量的定义类似参数，通过【预览】－【报表变量】开启报表变量列表对话框（工具条上可以找到相应的工具），如图，图中定义的变量的作用是：定义一个<font face="Times New Roman">Bug</font>的计数器，数据类型是<font face="Times New Roman">java.lang.Integer,</font>使用<font face="Times New Roman">Count</font>函数进行统计字段<font face="Times New Roman">tester</font>，作用范围是模块组，也就是统计模块的<font face="Times New Roman">Bug</font>量。其中的<font face="Times New Roman">tester</font>可以改成其他非组对象，比如<font face="Times New Roman">proname</font>是组对象，就不要用作这里的统计参数。以上提供的是自定义变量，其实iReport系统还有提供一些内嵌（<font face="Times New Roman">Buildin</font>）的变量，比如页码，行记录数等，视需要而使用。<br /><br /></p><p><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/51118/o_8.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /></p><h1>6、最后的报表</h1><h2>6.1、完成后的报表</h2><h2><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/o_9.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /></h2><h2>6.2、预览报表<br /><p></p></h2><h2><font size="3">点击动态运行报表，出现如图内容：</font></h2><h2><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/o_10.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /></h2><h1>7、总结</h1><p>第一部分只是介绍了如何制作一个动态数据报表，其实<font face="Times New Roman">iReport</font>还有提供很多的特性供开发人员使用，比如柱状图、饼图、及各种形状的图形等，满足企业绝大部分应用的需求。希望你能继续研究并充分利用。<font size="3">    </font></p><h2><p>    关于使用<font face="Times New Roman">Oracle</font>数据库作为数据源的内容：提供与使用的<font face="Times New Roman">Oracle</font>版本对应的<font face="Times New Roman">JDBC</font>驱动，把驱动放置在<font face="Times New Roman">iReport</font>的<font face="Times New Roman">lib</font>目录，配置数据库的<font face="Times New Roman">JDBC</font>连接时如图：其它操作基本没有区别。</p></h2><h2><font size="3"><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/o_11.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /></font></h2><h1>8、补充内容</h1><h2>8.1、实现表格</h2><p>可以在Detial中加入必要线条实现表格，配合columnFooter、columnHeader、Detial这3个位置实现，您可以试试画线的位置！<br /><img onmousewheel="return bbimg(this)" style="CURSOR: pointer" onclick="javascript:window.open(this.src);" src="http://www.3doing.net/forums/temp/o_12.JPG" onload="javascript:if(this.width&gt;screen.width-500)this.style.width=screen.width-500;" /></p><img src ="http://www.blogjava.net/zqli/aggbug/87002.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zqli/" target="_blank">放水老倌</a> 2006-12-11 19:36 <a href="http://www.blogjava.net/zqli/archive/2006/12/11/87002.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>