找回密码
 立即注册

QQ登录

只需一步,快速开始

长春闻荫

注册会员

3

主题

5

帖子

36

积分

注册会员

积分
36
长春闻荫
注册会员   /  发表于:2022-1-19 12:49  /   查看:1488  /  回复:6
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            APP = app;

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseReporting(settings =>
            {
                settings.UseCompression = true;

                settings.UseFileStore(new DirectoryInfo(Environment.CurrentDirectory + "\\Reports"));

                //settings.LocateDataSource = args =>
                //{
                //    DataTable dt = new DataTable();
                //    //string name = ReportName;
                //    if (args.DataSet.Query.DataSourceName == "DataSource1")
                //    {
                //        if (args.DataSet.Name == "DataSet1")
                //        {
                //            dt.Columns.Add("产品编号");
                //            dt.Columns.Add("产品名称");
                //            dt.Columns.Add("单价");
                //            dt.Columns.Add("库存量");
                //            dt.Columns.Add("产地");
                //            dt.Rows.Add("A001", "苹果", 10, 300, "中国");
                //            dt.Rows.Add("A002", "葡萄", 20, 200, "中国");
                //            dt.Rows.Add("A003", "香蕉", 30, 400, "中国");
                //            dt.Rows.Add("A004", "甘蔗", 10, 300, "中国");
                //            dt.Rows.Add("A005", "荔枝", 20, 200, "中国");
                //            dt.Rows.Add("A006", "芒果", 30, 400, "中国");
                //        }
                //    }
                //    return dt;
                //};
                settings.UseCustomStore(GetReport);

            });

            // web设计器
            app.UseDesigner(config => config.UseFileStore(new DirectoryInfo(Environment.CurrentDirectory + "\\Reports"), false));

            app.UseMvc();
        }

        public object GetReport(string P)//获取报表名称
        {
            PageReport rep = new PageReport();

            rep.Load(new FileInfo(Environment.CurrentDirectory + "\\Reports\\"+ "TestJsonData.rdlx"));//报表路径

            rep.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);

            return rep.Report;
        }

        void Document_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
        {
            Console.WriteLine("sdfsdf");
        }

6 个回复

倒序浏览
Bella.YuanWyn认证
超级版主   /  发表于:2022-1-19 15:15:21
沙发
本帖最后由 Bella.Yuan 于 2022-1-19 15:20 编辑

您好,Document_LocateDataSource()这个函数触发,需要报表数据源设置为 DataSetProvider 才可以。

回复 使用道具 举报
长春闻荫
注册会员   /  发表于:2022-1-19 15:22:39
板凳
本帖最后由 长春闻荫 于 2022-1-19 15:24 编辑


设置的就是 DataSetProvider
而且这个 Document_LocateDataSource  实现 本身就是不运行的  而不是 GetData方法不运行

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
James.Lv讲师达人认证 悬赏达人认证 活字格认证 Wyn认证
超级版主   /  发表于:2022-1-19 23:10:51
地板
这块使用咱们的demo确实是有这个问题,这块明天我再跟研发沟通确认一下
回复 使用道具 举报
wengMQ悬赏达人认证
银牌会员   /  发表于:2022-1-20 14:48:40
5#
直接用settings.LocateDataSource = args =>这个方法就可以; rep.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);这个不用

评分

参与人数 1金币 +1000 收起 理由
Bella.Yuan + 1000 很给力!

查看全部评分

回复 使用道具 举报
wengMQ悬赏达人认证
银牌会员   /  发表于:2022-1-20 14:49:21
6#
你有什么新想法可以QQ546962925联系我
回复 使用道具 举报
Bella.YuanWyn认证
超级版主   /  发表于:2022-1-20 17:46:02
7#
wengMQ 发表于 2022-1-20 14:49
你有什么新想法可以QQ546962925联系我

非常感谢老铁帮忙回复,奖励您金币1000
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部