找回密码
 立即注册

QQ登录

只需一步,快速开始

KearneyKang 讲师达人认证 悬赏达人认证
超级版主   /  发表于:2020-4-2 14:07  /   查看:3805  /  回复:2
本帖最后由 KearneyKang 于 2020-5-25 11:27 编辑

首先我们新建一个MVC的新的空的项目
新建的空的MVC的项目如下:
ASP.NET MVC 添加需要的引用:GrapeCity.ActiveReports.Aspnet.Viewer
如果是.Net Core 项目安装:GrapeCity.ActiveReports.AspnetCore.Viewer
在项目中,添加新建项,在新建项的选择栏中选择>>OWINStartupClass
修改StartUp1的配置信息:
  1. public class Startup1
  2.     {
  3.         public static string EmbeddedReportsPrefix = "XXXX";
  4.         public void Configuration(IAppBuilder app)
  5.         {
  6.             app.UseReporting(settings =>
  7.             {
  8.                 settings.UseFileStore(new DirectoryInfo(String.Format(@"{0}.\Reports", System.Web.HttpRuntime.AppDomainAppPath)));
  9.             });
  10.             RouteTable.Routes.RouteExistingFiles = true;
  11.         }
  12. }
复制代码
添加一个新的Reports文件夹,存放报表
添加引用文件,我这是新建了一个scripts文件夹然后把要用到的CSS和JS文件放在文件中,其中jsViewer.min.css、jsViewer.min.css在该路径下

下载ActiveReports14之后,在JS资源文件中就有需要的引用
修改MVC中Views中自带的Index页面的内容
  1. @{
  2.     ViewBag.Title = "Home Page";
  3. }

  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7.     <meta charset="utf-8" />
  8.     <title></title>
  9.     <!--Add the references to these files to the target HTML page-->
  10.     <link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.4.85/css/materialdesignicons.min.css">
  11.     <link rel="stylesheet" href="https://fonts.cat.net/css?family=Open+Sans:400,300,600,700" type="text/css">
  12.     <link rel="stylesheet" href="scripts/jsViewer.min.css" type="text/css">
  13.     <link href="scripts/index.css" rel="stylesheet" />
  14.     <script src="scripts/jsViewer.min.js"></script>
  15. </head>
  16. <body>
  17.     <!--Add the DIV element that will contain the JSViewer in the target HTML page-->
  18.     <div style="width: 100%; overflow-x: hidden">
  19.         <div style="float:right;width:100% ;height:800px" id="viewerContainer">
  20.         </div>
  21.     </div>
  22. </body>
  23. </html>
  24. <!--Add the code that initializes and passes the parameters in the JSViewer instance. The code might vary depending on the technology used to develop the JSViewer component. The example of code for the pure javascript component:-->
  25. <script type="text/javascript">

  26.     var viewer = GrapeCity.ActiveReports.JSViewer.create({
  27.         element: '#viewerContainer',
  28.         reportID: 'RdlReport1.rdlx', // the id of the report to display
  29.         availableExports: ['Xml', 'Pdf', 'Excel'],
  30.         reportService: {}
  31.         // other properties
  32.     });
  33. </script>
复制代码
现在直接运行项目,会报一个No license的错,这是由于项目中缺失license文件导致的
现在开始添加License文件

首先添加一个新的Web页面
拖入一个ActiveReports14的Webviewer在Web窗体的拆分页面就会自动是生成一个license文件
这样一个License文件就生成好了


然后运行生成,如果运行 之后还是报 “Cannotobtain report info”的错误
这是由于项目中的Global.asax文件中多了一个配置路径信息导致的。注释或者删除都行
现在运行展示:


本帖子中包含更多资源

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

x

评分

参与人数 1满意度 +5 收起 理由
GG321 + 5 赞一个!

查看全部评分

2 个回复

倒序浏览
wengMQ悬赏达人认证
银牌会员   /  发表于:2020-10-20 20:47:08
沙发
回复 使用道具 举报
KearneyKang讲师达人认证 悬赏达人认证
超级版主   /  发表于:2020-10-22 17:39:15
板凳
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部