我正在使用asp.net/c#与水晶报告导出为PDF格式,它正在导出Pdf罚款。但是我们将DB Table命名为Crystal Report,因此它将所有数据绑定到报告中,不按参数过滤或选择公式模型。
这是我的代码:
ReportDocument myreportdocument = new ReportDocument();
DataSet dsReport = new DataSet();
clsiCMSBLBase omenu = new clsiCMSBLBase();
string errMsg = string.Empty;
dsReport = omenu.GetListData(ref errMsg, parameters, "DBSP_PCPrintSlipRDLC");
myreportdocument = ReportFactory.GetReport(myreportdocument.GetType());
myreportdocument.Load(Server.MapPath("~/CrysReports/PCPrintSlipPUD.rpt"));
myreportdocument.SetParameterValue("UserID", Convert.ToInt32(2));
myreportdocument.SetDataSource(dsReport);
string dbUserName = ConfigurationManager.AppSettings["CrystalUserName"];
string dbPassword = ConfigurationManager.AppSettings["CrystalPassword"];
myreportdocument.SetDatabaseLogon(dbUserName, dbPassword);
cRY1.ReportSource = myreportdocument;
cRY1.SelectionFormula = " {TMP_PlotPCSlip.UserID} =" + 2;
cRY1.ReportSource = myreportdocument;
cRY1.HasCrystalLogo = false;
cRY1.DataBind();
cRY1.RefreshReport();
cRY1.BorderColor = System.Drawing.Color.Gray;
cRY1.BorderWidth = 1;
cRY1.BackColor = System.Drawing.Color.White;
cRY1.Style.Add("width", "100%");
//string filename = fact + "_" + flag + "_" + DateTime.Now.ToString("dd-MM-yyyy-HH-mm") + ".pdf";
myreportdocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, filename);
Response.End();
此过滤器代码未过滤:
myreportdocument.SetParameterValue("UserID", Convert.ToInt32(2));
即使我尝试了TableName.UserID,但也没有过滤器,所以请分享您的经验..
答案 0 :(得分:0)
Myreportdocument.RecordSelectionFormula="{table.column}=2"