如果打印机无效,Crystal Reports 加载速度会非常慢
在 Crystal Reports 中,如果其他开发人员设计了报表,我会看到错误“此报表使用无效打印机。将使用默认打印机。”
我注意到,当报告出现此错误消息时,需要很长时间才能以编程方式打开报告。当打印机无效时,一份报告的加载时间长达 1 1/2 分钟,而当我修好打印机后,加载时间仅需 5 秒。问题是,我们可以修复网络打印机中的报告,但我们将软件部署给没有我们打印机设置的客户。他们可能有所有报告的加载时间。
如何以编程方式将打印机设置为默认打印机,以加快报告加载速度?
下面的代码不起作用;至少,无论我是否能够从该打印机名称进行打印,加载仍然需要 1 1/2 分钟。我正在使用 ReportDocument (CrystalDecisions.CrystalReports.Engine.ReportDocument) 对象进行打印。这是代码片段,以及我尝试设置新打印机的位置。
// Create CrystalDecisions.CrystalReports.Engine.ReportDocument object ReportDocument crReportDocument = new ReportDocument(); // Typically this is set to .PortableDocFormat ExportFormatType selectedOutputType = m_ExportFormat; System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings(); crReportDocument.PrintOptions.PrinterName = printerSettings.PrinterName; // Load() takes an EXTREMELY long time // if the RPT file is saved with a printer not found on this computer. crReportDocument.Load(m_FileName);
In Crystal Reports, if another developer designed a report, I see the error "This report uses an invalid printer. The default printer will be used instead."
I noticed that it takes a VERY long time to open reports programatically when they have this error message. One report took up to 1 1/2 minutes to load with an invalid printer, and then only 5 seconds to load when I fixed the printer. The problem is, we can fix the reports within our network printers, but we deploy our software to customers who will not have our printer setup. They likely have these load times for ALL reports.
How do I set the printer programatically to the default printer, to speed the report loading up?
The code below didn't work; at least, it still took 1 1/2 minutes to load, whether I am able to print from that printer name or not. I am using a ReportDocument (CrystalDecisions.CrystalReports.Engine.ReportDocument) object to print. Here is a snippet of the code, along with where I am trying to set a new printer.
// Create CrystalDecisions.CrystalReports.Engine.ReportDocument object ReportDocument crReportDocument = new ReportDocument(); // Typically this is set to .PortableDocFormat ExportFormatType selectedOutputType = m_ExportFormat; System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings(); crReportDocument.PrintOptions.PrinterName = printerSettings.PrinterName; // Load() takes an EXTREMELY long time // if the RPT file is saved with a printer not found on this computer. crReportDocument.Load(m_FileName);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在水晶报表中选择“无打印机”选项。
Try to choose the "No Printer" option in crystal report.
这些链接可能会有所帮助。基本上,它的意思是,如果报告是根据特定打印机设计的,它将寻找该打印机,从而导致延迟。
http://social.msdn .microsoft.com/Forums/en-US/vscrystalreports/thread/54f9cb09-41f3-4191-b705-e4f0f38dfb4a
http://kb.sagesoftwareonline.com/cgi-bin/sagesoftwareonline.cfg/php/enduser /std_adp.php?p_faqid=19460&p_created=1158860711&p_topview=1#6
These links might help. Basically, its saying that if the report is designed off a specific printer, it will look for that printer, causing a delay.
http://social.msdn.microsoft.com/Forums/en-US/vscrystalreports/thread/54f9cb09-41f3-4191-b705-e4f0f38dfb4a
http://kb.sagesoftwareonline.com/cgi-bin/sagesoftwareonline.cfg/php/enduser/std_adp.php?p_faqid=19460&p_created=1158860711&p_topview=1#6