lovelyboy01 发表于 2016-9-12 17:33:22

关于区域报表加载及传参

本帖最后由 Lenka.Guo 于 2016-9-13 11:45 编辑

您好,请问C#后台代码里可以根据相对路径加载区域报表并传参吗?
类似于下面这样:
report = new PageReport(new FileInfo(Server.MapPath("~/Reports/OrderDetailsReport.rdlx")));

比如改成这样:

report = new SectionReport(new FileInfo(Server.MapPath("~/Reports/test.rpx")));
代码不可用,就是举个例子。

想通过代码加载一个路径下的区域报表,同时给这个报表传参

类似于下面这样:
((GrapeCity.ActiveReports.Document.PageDocument)report).Parameters.Value="xxx0";
((GrapeCity.ActiveReports.Document.PageDocument)report).Parameters.Value="xxx1";

就是希望能通过代码加载一个已有的区域报表并希望给区域报表传参,参数值能通过C#获取到,报表的数据源是通过OLEDB方式直接写SQL实现的。

目前本地示例中都是基于代码的区域报表,有没有直接加载报表文件的方式?谢谢!


Lenka.Guo 发表于 2016-9-13 11:44:58

您好,理解您的意思是,现在想了解 基于代码的区域报表及传参问题。
AR 提供三大类型报表报表,基于代码的区域报表(.cs),基于模板的区域报表(.rpx); 页面\RDL 报表(.rdlx)
不同类型的报表,加载方式不同:

基于代码.cs
// 创建的报表,可当作类来使用
SectionReportNamesr=New SectionReportName()
sr.Run();
传参:
srt.Parameters.DefaultValue = "123";
基于模板.rpx
// Create a Section report.GrapeCity.ActiveReports.SectionReport rpt = new GrapeCity.ActiveReports.SectionReport();
// For the code to work, report.rpx must be placed in the bin\debug folder of your project.
System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Application.StartupPath + "\\report.rpx");
rpt.LoadLayout(xtr);
rpt.Run();传参:
srt.Parameters.DefaultValue = "123";



页面\RDL 报表
// Create a page/Rdl report.
GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport();
// Load the report you want to export.
// For the code to work, this report must be stored in the bin\debug folder of your project.
rpt.Load(new System.IO.FileInfo ("report.rdlx"));
GrapeCity.ActiveReports.Document.PageDocument MyDocument = new GrapeCity.ActiveReports.Document.PageDocument (rpt);               

传参:
rpt.Report.ReportParameters.DefaultValue.Values.Add( "123");


lovelyboy01 发表于 2016-9-13 16:21:16

Lenka.Guo 发表于 2016-9-13 11:44
您好,理解您的意思是,现在想了解 基于代码的区域报表及传参问题。
AR 提供三大类型报表报表,基于代码的 ...

感谢郭老师耐心解答,已经可以了~~~

Lenka.Guo 发表于 2016-9-14 10:04:00

lovelyboy01 发表于 2016-9-13 16:21
感谢郭老师耐心解答,已经可以了~~~

好的~~~谢谢反馈~~:hjyzw:
页: [1]
查看完整版本: 关于区域报表加载及传参