我是水晶报告的新手.我按照这个链接
Crystal Report with SQL Stored Procedure Parameter and Visual Studio设计了水晶报告
实际上我需要将不同的ID(SP的输入值)传递给我与Crystal报表连接的SP.
实际上我需要将不同的ID(SP的输入值)传递给我与Crystal报表连接的SP.
这是我将ID传递给水晶报告的代码:
protected void Button1_Click(object sender,EventArgs e) { string QuotationID = ViewState["QUOTATION_ID"].ToString(); ReportDocument reportDocument = new ReportDocument(); ParameterField paramField = new ParameterField(); ParameterFields paramFields = new ParameterFields(); ParameterdiscreteValue paramdiscreteValue = new ParameterdiscreteValue(); paramField.Name = "@id"; paramdiscreteValue.Value = QuotationID; paramField.CurrentValues.Add(paramdiscreteValue); paramFields.Add(paramField); paramFields.Add(paramField); CrystalReportViewer1.ParameterFieldInfo = paramFields; string reportPath = Server.MapPath("~/CrystalReport.rpt"); reportDocument.Load(reportPath); CrystalReportViewer1.ReportSource = reportDocument; }
但是当我点击按钮时它会询问ID …
解决方法
要在水晶上设置参数,我总是这样做:
ReportDocument reportDocument = new ReportDocument(); reportDocument.Load(reportPath); reportDocument.SetParameterValue("@id",QuotationID);
如果您想将报告转换为pdf:
var exportOptions = reportDocument.ExportOptions; exportOptions.ExportDestinationType = ExportDestinationType.NoDestination; exportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; var req = new ExportRequestContext {ExportInfo = exportOptions}; var stream = reportDocument.FormatEngine.ExportToStream(req);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。