繁体   English   中英

如何使用.NET将报表打印到选定的打印机,SAP Crystal在64位服务器(Win2k8)上报告Engine 64位?

[英]How to print reports to the chosen printer using .NET, SAP Crystal reports Engine 64 bit on a 64 bit server (Win2k8)?

我们有一个基于.NET远程处理的Windows应用程序。 它是使用.NET Framework 2.0构建的32位应用程序。 我们正在使用.NET Framework 4(32位–版本13.0.3)的SAP Crystal报表运行时引擎来实现报表功能。 还有一个打印功能,在批处理运行期间,用户可以将相应的报告打印到所选打印机。 整个安装程序在Windows Server 2003服务器上运行良好。 现在,我们尝试将应用程序迁移到Windows Server 2008,打印无法正常工作。 它始终将报告打印到Windows Server 2008计算机上的默认打印机,而不是将报告打印到所选打印机。

CrystalDecisions.CrystalReports.Engine,CrystalDecisions.ReportSource和CrystalDecisions.Shared是从中引用的DLL。

C:\\ Program Files \\ SAP BusinessObjects \\ .net Framework 4.0的Crystal报表\\ Common \\ SAP BusinessObjects Enterprise Xi 4.0 \\ Win32_x86

我们将应用程序转换为64位版本。 即使安装了Windows Server 2008,SAP Crystal Reports仍为.NET Framework 4(64位–版本13.0.3)运行时引擎,打印仍无法正常工作(始终打印到默认打印机)。 在64位安装文件夹中也找不到上述DLL。

C:\\ Program Files \\ SAP BusinessObjects \\ .net Framework 4.0的Crystal报表\\ Common \\ SAP BusinessObjects Enterprise Xi 4.0 \\ Win64_X64

我找不到任何代码问题,我认为这绝对是兼容性问题。 我在这个问题上停留了一个多月。 请帮忙。

我们找到了问题和解决方法。 它与代码有关。

string printPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string rptFileName=@"\sample.rpt";
string PrinterName=Console.ReadLine();

ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(printPath + rptFileName);
reportDocument.PrintOptions.PrinterName = PrinterName;           
reportDocument.PrintToPrinter(1, true, 0, 0);

即使分配了正确的打印机名称,reportDocument.PrintOptions.PrinterName始终为空。 该代码已作如下更改,并且在具有现有集安装程序的Windows Server 2008 R2(SAP Crystal Reports报告32位/ 64位版本-13.0.3)上也能正常运行,甚至没有转换为64位。

ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(printPath + rptFileName);
System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
printerSettings.PrinterName = PrinterName;
reportDocument.PrintToPrinter(printerSettings, new PageSettings(), false);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM