Printing Crystal reports
-
Hello, I am trying to pring a crystal report with parameters without previewing it first. I succeeded to pring report without parameters with the ReportDocument object. I succeeded also to print report with parameters (I inserted parameters to ParameterFields and put it in crystalReportViewer.ParameterFieldInfo) from the CrystalReportViewer but in this way the report is open in another window, and then I print it from the object. But I want to print the report with the parameters without showing it on screen first, how can I do it? Thank u for any help, sharon
-
Hello, I am trying to pring a crystal report with parameters without previewing it first. I succeeded to pring report without parameters with the ReportDocument object. I succeeded also to print report with parameters (I inserted parameters to ParameterFields and put it in crystalReportViewer.ParameterFieldInfo) from the CrystalReportViewer but in this way the report is open in another window, and then I print it from the object. But I want to print the report with the parameters without showing it on screen first, how can I do it? Thank u for any help, sharon
ok I did it :
ReportDocument report = new ReportDocument(); report.Load(@"G:\Rp3Receipt.rpt",OpenReportMethod.OpenReportByTempCopy); ParameterFieldDefinitions parametersColl = report.DataDefinition.ParameterFields; ParameterFieldDefinition paramName1 = parametersColl["prmNameInReport1"]; ParameterFieldDefinition paramName2= parametersColl["prmNameInReport2"]; ParameterValues values = new ParameterValues(); ParameterDiscreteValue val = new ParameterDiscreteValue(); val.Value = paramValue1;// the value I want to give the parameter values.Add(val); paramName1.ApplyCurrentValues(values); //-----------second parameter values = new ParameterValues(); val = new ParameterDiscreteValue(); val.Value = paramValue2; values.Add(val); paramName2.ApplyCurrentValues(values); report.PrintOptions.PrinterName = @"\\...\HPLaserJ5"; report.PrintToPrinter(1,false,1,1);