Coldfusin在报表使用上补充JAVA体系在报表方面的不足,俺系统为
Window 7;ColdFusion 9 ;IIS 7;ColdFusion Report Builder;ColdFusion Builder;Crystal Report 9;MS SQL 2008 R2
安装 ColdFusion 9 ;ColdFusion Report Builder;ColdFusion Builder等略;
将ColdFusion 9 使用 IIS作为 Web Server,设置略;
俺还没将ColdFusion 9配上Tomcat
1. 设置Coldfusion report builder
使用CF的RDS,需要设置RDS连接器
local view of webroot:C:/inetpub/wwwroot/CF01/
URL of Webroot:http://localhost:8100/cf01/
2. 设计报表及预览
使用报表设计向导,类似Crystal Report,设计后可以预览
3. Web浏览,使用 <CFREPORT>显示报表
在CF Builder新建Project,新建.cfm文件,命名为welcome.cfm,添加如下语句
<CFREPORT format="PDF" template="cfr01.cfr">
</CFREPORT>
4. Web浏览,使用 动态查询,<CFREPORT>显示报表
<cfquery name="northwindemployees" datasource="MSSQL2008R2">
SELECT TOP 30 id, Yuanbianhao, shebeimingcheng, shebeipinpai, shebeishuliang
FROM dbo.Weixiu2
</cfquery>
<CFREPORT format="PDF" template="cfr01.cfr"
query="#northwindemployees#"/>
5. 使用<cfoutput>标签输出报表
<cfdocument format="flashpaper">
<h1>Employee List</h1>
<!--- Inline query used for example purposes only. --->
<cfquery name="EmpList" datasource="MSSQL2008R2">
SELECT TOP 30 id, Yuanbianhao, shebeimingcheng, shebeipinpai
FROM dbo.Weixiu2
</cfquery>
<cfoutput query="EmpList">
#EmpList.id#, #EmpList.Yuanbianhao#, #EmpList.shebeimingcheng#,
#EmpList.shebeipinpai#<br>
</cfoutput>
</cfdocument>
6. 水晶报表
When running on Windows, the cfreport tag also supports the execution of reports created using Crystal Reports version 9 or 10.(Adobe 官方)
运行环境:Windows Xp sp3; Crystal Report 9;IIS5.1; Coldfusion 9
<cfreport report="CR01.rpt">
</cfreport>
7. 使用参数动态查询
编写.cfm文件
<cfreport template="cfr01.cfr" format="flashpaper">
<cfreportparam name="paraid" value="8">
</cfreport>