ASP.NET下的水晶报表打印,据我所知有以下几种办法可以打印:
1.用IE的打印.调用window.print(),但这种办法对于页面上即有报表,又有其它控件情况就无法区分,不能达到只打印报表内容的目的;
2.自已写打印代码.
代码如下:
CrystalDecisions.CrystalReports.Engine.ReportDocument rd=new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rd.Load(Server.MapPath("Crystalreport1.rpt")); rd.PrintOptions.PrinterName="打印机名称"; rd.PrintToPrinter(1,true,0,0); |
foreach(string iprt in System.Drawing.Printing.PrinterSettings.InstalledPrinters) this.DropDownList1.Items.Add(iprt); |
myrpt.ExportOptions.ExportDestinationType=CrystalDecisions.Shared.ExportDestinationType.DiskFile; myrpt.ExportOptions.ExportFormatType=CrystalDecisions.Shared.ExportFormatType.PortableDocFormat; CrystalDecisions.Shared.DiskFileDestinationOptions opt=new CrystalDecisions.Shared.DiskFileDestinationOptions(); opt.DiskFileName=@"文件名"; myrpt.ExportOptions.DestinationOptions =opt; myrpt.Export(); |