报告生成在C#中煞费苦心......需要帮助 [英] report generation in C# painstakingly slow......need help

查看:59
本文介绍了报告生成在C#中煞费苦心......需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Crystal Reports 10 SDK和C#VS 2005。


我有一个水晶报告,其中包含重复记录的记录。 然后每个记录包含2个子报告,子报告从每个记录的相同数据源拉出,它刚刚过滤。


当我将报告导出为PDF中的1000个Crystal记录时,它需要55秒。


当我在自己的C#代码中做同样的事情时,需要花费大约45分钟!!


我不能想想为什么会这样,因为我在我的代码中所做的就是从数据库中检索数据集,然后将报告数据源设置为数据集并调用"ExportToDisk"。


这是我的代码:


//创建并加载报告
CrystalDecisions CrystalReports Engine ReportDocument 报告 = new CrystalDecisions CrystalReports 引擎 ReportDocument ();


report 加载 FileDirectory + "Event Schedule.rpt" );
报告 SetDataSource dtEventList );
report OpenSubreport "EventEmployees" )。 SetDataSource dtEventEmployees );
report OpenSubreport "EventPoses" )。 SetDataSource dtEventPosesList );


//将水晶报告导出为PDF格式
report ExportToDisk CrystalDecisions 共享 ExportFormatType PortableDocFormat ," MasterEventSchedule.pdf" );
report 关闭 ();
report < FONT size = 2>。 Dispose ();


< FONT face = Verdana> dtEventList,dtEventEmployees和dtEventPosesList是我手动从数据库填写的数据表。 来自dtEventEmployees和dtEventPosesList的记录通过EventID字段绑定到dtEventList中的记录。 我还检查了子报告参数字段,并且该链接的参数在那里。 除此之外,我没有看到任何会减慢出口过程的事情。 有没有人有任何想法?

解决方案

在Crystal中,数据是直接从数据库中提取的,在你传递的代码中在数据表中。使用数据表/数据集会导致各种缓慢,特别是当您开始链接它们时,就像您已经完成的那样。


I'm using Crystal Reports 10 SDK and C# VS 2005.

I have a crystal report with records that repeat down the page.  Each record then contains 2 subreports, the subreports pull from the same datasource for each record, its just filtered.

When I export the report to PDF for 1000 records in Crystal, it takes about 55 seconds.

When I do the same thing in my own C# code, it takes upwards of about 45 minutes!!

I can't think of why this is happening because all I'm doing in my code, is retrieving datasets from a database, then setting the reports datasource to the datasets and calling "ExportToDisk".

Here's my code:

// Create and load report
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

report.Load(FileDirectory + "Event Schedule.rpt");
report.SetDataSource(dtEventList);
report.OpenSubreport("EventEmployees").SetDataSource(dtEventEmployees);
report.OpenSubreport("EventPoses").SetDataSource(dtEventPosesList);

// Export crystal report to PDF format
report.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, "MasterEventSchedule.pdf");
report.Close();
report.Dispose();

dtEventList, dtEventEmployees and dtEventPosesList are datatables that I manually fill in from the database.  Records from dtEventEmployees and dtEventPosesList are tied to records in dtEventList by an EventID field.  I also checked the subreports parameters field, and the parameter for this linkage is there.  Other than that, I don't see ANYTHING that would slow down the export process.  Does anybody have any ideas?

解决方案

In Crystal, the data is being pulled from the database directly, in your code you are passing in datatables.  Using datatables/datasets can cause all sorts of slowness, expecially when you start linking them like you have done.


这篇关于报告生成在C#中煞费苦心......需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆