wu8829 发表于 2015-1-12 10:26:00

打印报表报错(急)

工程师:您好!

      在RDL报表中添加了一个Image控件,控件Value的值通过参数设置。但发现一个问题:若我未设置这个参数的值,预览报表没问题,但打印报表就出现错误:


       请问如何解决呢?另外在c#代码中,可否动态删除RDL报表中的Image控件或参数的值呢?

iceman 发表于 2015-1-12 10:30:00

回复 1楼wu8829的帖子

您好,

根据当前描述我们很难重现问题,能否提供一个简单的重现问题 Demo ,我们可以快速的定位问题?

后台代码操作报表子控件请参考:
http://blog.gcpowertools.com.cn/post/2014/10/28/how-to-access-pagereports-reportitems-using-code.aspx

谢谢

wu8829 发表于 2015-1-12 11:00:00

iceman 发表于 2015-1-12 11:52:00

回复 3楼wu8829的帖子

预览的时候没有问题因为指定了图片参数 Company_Seal 值。
请问你在打印的时候是否指定了该值?

我查看你的代码这句用于获取路径:

string Company_Seal = DataLevel.Function.GetCompany(Session.Contents["User_Department"].ToString(), 11); //获取供应商印章


另外,需要删除固定页面报表中控件测试代码如下:

            PageReport pr = new PageReport(new System.IO.FileInfo(this.Server.MapPath("PageReport1.rdlx")));
            PageDocument doc = new PageDocument(pr);
            GrapeCity.ActiveReports.PageReportModel.FixedPage FP = doc.PageReport.Report.Body.ReportItems as GrapeCity.ActiveReports.PageReportModel.FixedPage;
            FP.Pages.ReportItems.RemoveAt(0);


谢谢

wu8829 发表于 2015-1-12 12:04:00

打印的时候还要指定?怎么指定?代码如何写?

如果是需要删除固定页面报表中的参数,又该如何写?

iceman 发表于 2015-1-12 15:58:00

回复 5楼wu8829的帖子

测试代码如下:

            PageReport Print_Temp = new PageReport(new System.IO.FileInfo(this.Server.MapPath("RdlReport1.rdlx")));

            string Company_Seal = ""; //获取供应商印章

            if (Company_Seal.Length > 1)
            {
                Print_Temp.Report.ReportParameters.DefaultValue.Values.Add(".." + Company_Seal);
            }
            else
            {
                //移除参数
                Print_Temp.Report.ReportParameters.RemoveAt(0);
                //移除控件
                Print_Temp.Report.Body.ReportItems.RemoveAt(0);
            }

            this.WebViewer1.Report = Print_Temp;

Demo:

wu8829 发表于 2015-1-12 16:26:00

已解决,谢谢,可以封贴了。

iceman 发表于 2015-1-12 16:37:00

回复 7楼wu8829的帖子

好的,不客气。

为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢http://gcdn.gcpowertools.com.cn/attachment.aspx?attachmentid=10062
页: [1]
查看完整版本: 打印报表报错(急)