crystal reports 和sql-server共同进行报表的开发
1:crystal reports功能自述
crystal reports 用于处理数据库,帮助用户分析和解释重要信息。使用 crystal reports 可以方便地创建简单报表,同时它也提供了创建复杂或专用的报表所需的整套工具。
创建所能想象的任何报表
crystal reports 几乎可以从任何数据源生成您需要的报表。内置报表专家在您生成报表和完成一般的报表任务过程中,会一步一步地指导您进行操作。报表专家通过公式、交叉表、子报表和设置条件格式帮助表现数据的实际意义,揭示可能被隐藏掉的重要关系。如果文字和数字确实不够充分,则用地理地图和图形进行形象的信息交流。
将报表扩展到 web
crystal reports 的灵活性并未停留在创建报表这一功能上 ?您可以用各种各样的格式发布报表,包括用 microsoft 的 word 和excel 发布、通过电子邮件甚至 web 发布。高级的 web 报表功能允许工作组中的其他成员在他们自己的 web 浏览器中查看或更新共享报表。
将报表并入应用程序
通过将 crystal reports 的报表处理功能整合到自己的数据库应用程序中,应用程序和 web 开发人员可以节省开发时间并满足用户的需求。crystal reports 支持大多数流行的开发语言,可以方便地在任何应用程序中添加报表。
不论您是 it 行业的站点管理员,还是营销推广经理,也无论您是金融业的数据库管理员还是 ceo,crystal reports 都堪称是一个功能强大的工具,它可以帮助每一个人分析、解释重要信息。
2:crystal reports和sql-server结合
crystal虽然提供了强大的报表功能,但是对于复杂的逻辑运算,却是很难实现。但是,crystal中可以像添加表一样添加存储过程,这就给我们的复杂运算提供了简便的处理方法。
3:例子
这是我们给国航公司it服务项目做的报表的sql-server存储过程部分。(欢迎大家共同讨论)
a:每个员工的处理故障完成数、总数
fgw_proc1.txt
--fgw_proc1 处理故障完成数、总数
create procedure [ahd].[fgw_proc1](@开始时间 datetime , @结束时间 datetime)
as
declare @begin int , @end int /*转时间*/
exec fgw_util1 @开始时间, @begin output
exec fgw_util1 @结束时间, @end output
declare @userid int, @handled float, @total float
create table #temp_proc1
(
userid int,
handled float,
total float
)
declare cur_ctct cursor for select id from ahd.ahd.ctct --取所有的用户id
open cur_ctct
fetch cur_ctct into @userid
while @@fetch_status = 0
begin
--get @handle through exec fgw_proc2
exec fgw_proc1_1 @userid , @begin , @end , @handled output , @total output /*call下个存储过程,得到某个用户的解决数、接触故障数*/
insert into #temp_proc1 values (@userid , @handled , @total) /*将用户信息插入临时表*/
fetch next from cur_ctct into @userid /*记录下移*/
end
close cur_ctct
deallocate cur_ctct
select * from #temp_proc1 /*生成结束集*/
drop table #temp_proc1 /*释放*/
go
fgw_proc1_1.txt
--fgw_proc1_1
create procedure [ahd].[fgw_proc1_1](@userid int , @begin int , @end int , @handled float output , @total float output)
as
set @handled = 0
set @total = 0
declare @cr_id int, @zh_id int, @status char(12), @to_status char(12), @cnt int, @open_date int
--handled /*计算此人的处理完成故障数*/
declare cur11_1 cursor for select ahd.call_req.id as cr_id, ahd.ztr_his.id as zh_id, ahd.call_req.status, ahd.ztr_his.to_status, ahd.ztr_his.to_cnt as cnt, ahd.call_req.open_date from ahd.call_req left outer join ahd.ztr_his on ahd.call_req.persid = ahd.ztr_his.call_req_id where ahd.call_req.type='i' and (ahd.call_req.status in ('cl', 'ttpc')) and (ahd.ztr_his.to_status in ('l1wip', 'l2wip', 'icp', 'srbyl1', 'srbyl2', 'nccbyl1', 'nccbyl2', 'crbyl1', 'crbyl2')) and ahd.call_req.open_date>@begin and ahd.call_req.open_date<@end and ahd.ztr_his.to_cnt = @userid
open cur11_1
fetch cur11_1 into @cr_id, @zh_id, @status, @to_status, @cnt, @open_date /*事件id,历史id,状态,处理人,打开时间取所需要的值*/
while @@fetch_status = 0 /*循环每一个记录*/
begin
declare @count2 int /*每个事件单在历史记录中有多少条*/