public Boolean printReport(CrystalDecisions.CrystalReports.Engine.ReportClass crReport, CrystalReportViewer CrystalReportViewer1, String param1, String ParamName1, String param2, String ParamName2) { if (PrinterName=="none") return false; paramField.ParameterFieldName = ParamName1; discreteVal.Value = param1; paramField.CurrentValues.Add (discreteVal); paramFields.Add (paramField); crReport.DataDefinition.ParameterFields[0].CurrentValues.Add (discreteVal); paramField2.ParameterFieldName = ParamName2; discreteVal2.Value = param2; paramField2.CurrentValues.Add (discreteVal2); paramFields.Add (paramField2); crReport.DataDefinition.ParameterFields[1].CurrentValues.Add (discreteVal2); CrystalReportViewer1.ReportSource = crReport; CrystalReportViewer1.ParameterFieldInfo = paramFields; CrystalReportViewer1.RefreshReport(); ParameterValues tmpParam = new ParameterValues(); ParameterValues tmpParam2 = new ParameterValues(); tmpParam.Add(discreteVal); tmpParam2.Add(discreteVal2); crReport.DataDefinition.ParameterFields[0].ApplyCurrentValues(tmpParam); crReport.DataDefinition.ParameterFields[1].ApplyCurrentValues(tmpParam2); crReport.PrintOptions.PrinterName = PrinterName; // crReport.PrintToPrinter(1,false,1,1); crReport.PrintToPrinter(1,false,1,99); //Response.write (PrinterName); return true; }
public Boolean printReport(CrystalDecisions.CrystalReports.Engine.ReportClass crReport, CrystalReportViewer CrystalReportViewer1, String param, String ParamName) { bool success=false; if (PrinterName!="none") { try { paramField.ParameterFieldName = ParamName; discreteVal.Value = param; paramField.CurrentValues.Add (discreteVal); paramFields.Add (paramField); crReport.DataDefinition.ParameterFields[0].CurrentValues.Add (discreteVal); CrystalReportViewer1.ReportSource = crReport; CrystalReportViewer1.ParameterFieldInfo = paramFields; CrystalReportViewer1.RefreshReport(); ParameterValues tmpParam = new ParameterValues(); tmpParam.Add(discreteVal); crReport.DataDefinition.ParameterFields[0].ApplyCurrentValues(tmpParam); crReport.PrintOptions.PrinterName = PrinterName; //crReport.PrintToPrinter(1,false,1,1); crReport.PrintToPrinter(1,false,1,99); success=true; } catch{} } return success; }
private void printCrystalReport(CrystalDecisions.CrystalReports.Engine.ReportDocument aoReport, int aiNumCopias, int aiPageBegin, int aiPageEnd, String asPrinterName) { if (asPrinterName == String.Empty) { // Buscamos la impresora por defecto del sistema System.Drawing.Printing.PrintDocument printDoc = new System.Drawing.Printing.PrintDocument(); asPrinterName = printDoc.PrinterSettings.PrinterName; } aoReport.PrintOptions.PrinterName = asPrinterName; aoReport.PrintToPrinter(aiNumCopias, false, aiPageBegin, aiPageEnd); }
public void Print(CrystalDecisions.CrystalReports.Engine.ReportDocument Chart) { try { ReportDocument crReportDocument; crReportDocument = new ReportDocument(); //Create an instance of a report crReportDocument = Chart; //Open the PrintDialog this.printDialog1.Document = this.printDocument1; DialogResult dr = this.printDialog1.ShowDialog(); if (dr == DialogResult.OK) { //Get the Copy times int nCopy = this.printDocument1.PrinterSettings.Copies; //Get the number of Start Page int sPage = this.printDocument1.PrinterSettings.FromPage; //Get the number of End Page int ePage = this.printDocument1.PrinterSettings.ToPage; string PrinterName = this.printDocument1.PrinterSettings.PrinterName; crReportDocument = new ReportDocument(); //Create an instance of a report crReportDocument = Chart; try { //Set the printer name to print the report to. By default the sample //report does not have a defult printer specified. This will tell the //engine to use the specified printer to print the report. Print out //a test page (from Printer properties) to get the correct value. crReportDocument.PrintOptions.PrinterName = PrinterName; //Start the printing process. Provide details of the print job //using the arguments. crReportDocument.PrintToPrinter(nCopy, false, sPage, ePage); } catch { } } } catch { } }