Header传入 https://gcdn.grapecity.com.cn/fo ... mp;page=1#pid490463
获取报表参数
private ReportParameter GRPars(Report CRpt, string parname)
{
ReportParameter rptpar = null;
try
{
for (int pi = 0; pi < CRpt.ReportParameters.Count; pi++)
{
if (CRpt.ReportParameters[pi].Name == parname)
{
return CRpt.ReportParameters[pi];
}
}
}
catch (Exception ex)
{
}
return rptpar;
}
Header值在UseCustomStore加入一个报表参数
settings.UseCustomStore(r =>
{
PageReport pageReport = new PageReport();
pageReport.Load(new FileInfo("报表路径"));
ReportParameter DefPar = new ReportParameter();
DefPar = new ReportParameter();
DefPar.Name ="Header";
DefPar.AllowBlank = true;
DefPar.DataType = ReportParameterDataType.String;
DefPar.Hidden = true;
DefPar.DefaultValue.Values.Add(HttpContext.Current.Request.Headers["Authorization"].ToString());
pageReport.Report.ReportParameters.Add(DefPar);
return pageReport.Report;
});
settings.LocateDataSource = arg =>
{
ReportParameter Headerparm = GRPars(arg.Report, "Header");
string Header= Headerparm.DefaultValue.Values[0].ToString(); //获取Header值
}
|