找回密码
 立即注册

QQ登录

只需一步,快速开始

lovelyboy01

金牌服务用户

19

主题

35

帖子

140

积分

金牌服务用户

积分
140

活字格认证

lovelyboy01
金牌服务用户   /  发表于:2016-9-12 17:33  /   查看:3368  /  回复:3
本帖最后由 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[0].Value="xxx0";
((GrapeCity.ActiveReports.Document.PageDocument)report).Parameters[1].Value="xxx1";

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

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


3 个回复

倒序浏览
Lenka.Guo讲师达人认证 悬赏达人认证
超级版主   /  发表于:2016-9-13 11:44:58
推荐
您好,理解您的意思是,现在想了解 基于代码的区域报表及传参问题。
AR 提供三大类型报表报表,基于代码的区域报表(.cs),基于模板的区域报表(.rpx); 页面\RDL 报表(.rdlx)
不同类型的报表,加载方式不同:

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



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


传参:
  rpt.Report.ReportParameters[0].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
感谢郭老师耐心解答,已经可以了~~~

好的~~~谢谢反馈~~
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部