找回密码
 立即注册

QQ登录

只需一步,快速开始

KearneyKang 讲师达人认证 悬赏达人认证
超级版主   /  发表于:2021-8-17 17:46  /   查看:1929  /  回复:0
本帖最后由 KearneyKang 于 2021-8-17 17:53 编辑

Activereports报表文件可以转换为XML形式进行存储,存储在数据库中XML形式的报表内容,也可以直接进行读取展示重点来了,该如何实现了?

1、首先需要依赖一个方法才能实现该需求:“ReportConverter”的方法,該方法.Net需要依赖该引用:GrapeCity.ActiveReports.Aspnet.Designer
Core 项目需要依赖该引用:GrapeCity.ActiveReports.Aspnetcore.Viewer
  1. namespace GrapeCity.ActiveReports.Aspnet.Designer.Utilities
  2. {
  3.     public static class ReportConverter
  4.     {
  5.         //
  6.         // 摘要:
  7.         //     Serialize GrapeCity.ActiveReports.PageReportModel.Report from JSON content
  8.         //
  9.         // 参数:
  10.         //   content:
  11.         //     JSON report content
  12.         //
  13.         // 返回结果:
  14.         //     Serialized GrapeCity.ActiveReports.PageReportModel.Report
  15.         public static Report FromJson(byte[] content);
  16.         //
  17.         // 摘要:
  18.         //     Serialize GrapeCity.ActiveReports.PageReportModel.Report from XML content
  19.         //
  20.         // 参数:
  21.         //   content:
  22.         //     XML report content
  23.         //
  24.         // 返回结果:
  25.         //     Serialized GrapeCity.ActiveReports.PageReportModel.Report
  26.         public static Report FromXML(byte[] content);
  27.         //
  28.         // 摘要:
  29.         //     Deserialize GrapeCity.ActiveReports.PageReportModel.Report to JSON content
  30.         //
  31.         // 参数:
  32.         //   content:
  33.         //     Serialized GrapeCity.ActiveReports.PageReportModel.Report
  34.         //
  35.         // 返回结果:
  36.         //     JSON report content
  37.         public static byte[] ToJson(Report report);
  38.         //
  39.         // 摘要:
  40.         //     Deserialize GrapeCity.ActiveReports.PageReportModel.Report to XML content
  41.         //
  42.         // 参数:
  43.         //   content:
  44.         //     Serialized GrapeCity.ActiveReports.PageReportModel.Report
  45.         //
  46.         // 返回结果:
  47.         //     XML report content
  48.         public static byte[] ToXml(Report report);
  49.     }
  50. }
复制代码
2、转换为XML的实现
  1. var templateXml = File.ReadAllBytes(Server.MapPath(@"Reports\URL绑定.rdlx"));
  2.             var template = ReportConverter.FromXML(templateXml);
  3.             var resultXml  = ReportConverter.ToXml(template);
复制代码
3、报表内容读取:
  1. protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             var templateXml = File.ReadAllBytes(Server.MapPath(@"Reports\城市排行.rdlx"));
  4.             var  template = ReportConverter.FromXML(templateXml);                     
  5.             this.WebViewer1.Report = template ;
  6.         }
复制代码
4、demo

本帖子中包含更多资源

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

x

0 个回复

您需要登录后才可以回帖 登录 | 立即注册
返回顶部