- /// <summary>
- /// 将报表直接打印输出
- /// </summary>
- /// <param name="ARSetting"></param>
- /// <param name="sType"></param>
- /// <param name="sFile"></param>
- public static void PrintReport(linkReportPrint printSetting)
- {
- //public static void PrintReport(ActiveReportSetting ARSetting)
- PageReport pageReport = ReportLoad(printSetting.ARSetting);
- pageReport.Run();
- //pageReport.Document.Printer.DefaultPageSettings.Margins.Bottom = 0;
- //pageReport.Document.Printer.DefaultPageSettings.Margins.Left = 0;
- //pageReport.Document.Printer.DefaultPageSettings.Margins.Right = 0;
- //pageReport.Document.Printer.DefaultPageSettings.Margins.Top = 0;
- //pageReport.Document.Printer.PaperSize.RawKind = 0;
- //pageReport.Document.Printer.PaperSize.Width = 14;
- //pageReport.Document.Printer.PaperSize.Height = 20;
- if ((printSetting.printerName != null) && (printSetting.printerName != ""))
- {
- pageReport.Document.Printer.PrinterName = printSetting.printerName; // "Foxit Reader PDF Printer";
- }
- //pageReport.Document.Printer.PrinterSettings.Copies = 1;
- //pageReport.Document.Printer.PrinterSettings.FromPage = 1;
- //pageReport.Document.Printer.PrinterSettings.ToPage = 2;
- //pageReport.Document.Printer.PrinterSettings.PrintRange = 0;
- ////GrapeCity.ActiveReports.PrintExtension.Print(_document, true, true);
- //GrapeCity.ActiveReports.PrintExtension.Print(pageReport.Document,
- // showPrintDialog: printSetting.showPrintDialog,
- // showPrintProgressDialog: printSetting.showPrintProgressDialog);
- pageReport.Document.Print(showPrintDialog: printSetting.showPrintDialog,
- showPrintProgressDialog: printSetting.showPrintProgressDialog,
- usePrintingThread: true);
- }
复制代码- /// <summary>
- /// 根据指定的设置内容加载报表
- /// </summary>
- private static PageReport ReportLoad(ActiveReportSetting ARSetting)
- {
- string file_name = ARSetting.reportFile;
- //string file_name = @"C:\TOTALLINK\REPORTS\TEST01.rdlx";
- PageReport pr = new PageReport(new System.IO.FileInfo(file_name));
- try
- {
- //处理多数据源连接字符串
- for (int i = 0; i < ARSetting.connString.Length; i++)
- {
- if (ARSetting.connString[i] != "" && i < pr.Report.DataSources.Count)
- {
- pr.Report.DataSources[i].ConnectionProperties.ConnectString = ARSetting.connString[i];
- }
- }
- //处理参数列表
- for (int i = 0; i < ARSetting.para.Length; i++)
- {
- if (i < pr.Report.ReportParameters.Count)
- {
- pr.Report.ReportParameters[i].DefaultValue.Values.Add(ARSetting.para[i]);
- }
- }
- }
- catch (Exception)
- {
- //throw;
- }
- return pr;
- }
复制代码 上面是主要的代码,谢谢。
|