在Crystal Reports中,如果其他开发人员设计了报表,我会看到错误“此报表使用的打印机无效 . 将使用默认打印机 . ”
我注意到,当他们收到此错误消息时,以编程方式打开报告需要花费很长时间 . 使用无效打印机加载一个报告需要1 1/2分钟,然后在我修复打印机时加载仅需5秒钟 . 问题是,我们可以在我们的网络打印机中修复报告,但我们将软件部署到没有打印机设置的客户 . 他们可能拥有所有报告的加载时间 .
How do I set the printer programatically to the default printer, to speed the report loading up?
下面的代码不起作用;至少,它仍然需要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);