如何将参数传递给报表文档并直接打印它
本文关键字:打印 文档 报表 参数传递 | 更新日期: 2023-09-27 18:27:07
如何将参数传递给报表文档并直接打印这是我的代码:
ReportDocument rd = new ReportDocument();
ParameterField p=new ParameterField();
p.Name="parm1";
ParameterDiscreteValue pv = new ParameterDiscreteValue();
pv.Value = "value1";
p.CurrentValues.Add(pv);
string str = Path.Combine(Application.StartupPath, "Print''rpt1.rpt");
//rd.SetParameterValue("parm1", "test");
rd.Load(str);
rd.ParameterFields.Add(p);
var dialog = new PrintDialog();
rd.PrintOptions.PrinterName = dialog.PrinterSettings.PrinterName;
rd.PrintToPrinter(1, false, 0, 0);
我现在实际上没有。但在添加以下参数之前,我更改了rd.Load(str);
:
ReportDocument rd = new ReportDocument();
rd.Load(str);
ParameterField p=new ParameterField();
p.Name="parm1";
ParameterDiscreteValue pv = new ParameterDiscreteValue();
pv.Value = "value1";
p.CurrentValues.Add(pv);
string str = Path.Combine(Application.StartupPath, "Print''rpt1.rpt");
//rd.SetParameterValue("parm1", "test");
rd.ParameterFields.Add(p);
var dialog = new PrintDialog();
rd.PrintOptions.PrinterName = dialog.PrinterSettings.PrinterName;
rd.PrintToPrinter(1, false, 0, 0);
it works correctly.