BI ReportViewer调用报表服务器报表源

本文详细介绍如何在报表浏览器中指定报表文件,包括调整视图大小、禁用凭证提示、设置缩放模式、配置远程处理模式及报表服务器URL。同时,文章深入探讨了通过代码动态设置报表参数的方法,如填报期间、经销商大区代码等,并展示了如何通过认证进行报表访问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//为报表浏览器指定报表文件
ReportViewer1.SizeToReportContent = true;
ReportViewer1.ShowCredentialPrompts = false;
ReportViewer1.ZoomMode = ZoomMode.PageWidth;
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://192.168.1.1/ReportServer");
ReportViewer1.ServerReport.ReportPath = "/report/Report1";
ReportViewer1.ServerReport.ReportServerCredentials = new ReportSCredentials("", "", "");

List<string> listCode = new List<string>();
List<ReportParameter> parameters = new List<ReportParameter>
{
     new ReportParameter("填报期间填报期间", "[填报期间].[填报期间].&[201901]"),
     new ReportParameter("经销商大区代码", "[经销商].[大区代码].[All]"),
     new ReportParameter("经销商小区代码", listCode .ToArray())
};
ReportViewer1.ServerReport.SetParameters(parameters);

报表还需要通过报表服务器的认证

public class ReportSCredentials : IReportServerCredentials
    {
        private string _UserName;
        private string _PassWord;
        private string _DomainName;

        public ReportSCredentials(string UserName, string PassWord, string DomainName)
        {
            _UserName = UserName; _PassWord = PassWord; _DomainName = DomainName;
        }

        public WindowsIdentity ImpersonationUser
        {
            get { return null; }
        }

        public ICredentials NetworkCredentials
        {
            get
            {
                if (string.IsNullOrEmpty(_UserName) || string.IsNullOrEmpty(_PassWord)) { return null; }
                else if (string.IsNullOrEmpty(_DomainName)) { return new NetworkCredential(_UserName, _PassWord); }
                else { return new NetworkCredential(_UserName, _PassWord, _DomainName); }
            }
        }

        public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
        {
            authCookie = null;
            user = password = authority = null;
            return false;
        }
    }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值