Lenka.Guo 发表于 2020-1-21 09:27:47

如何替换HTML5Viewer为JSViewer 指南

1.    先进行版本转换 在Visual Studio 中使用转换工具,会一键替换旧项目的dll 及Web.config文件为当前安装的版本。 2.    设置项目 .Net Framework 版本为 4.6.2 3.    安装 JSViewer 需要的Nuget包l在菜单栏中>>选择工具>>NuGet包管理器>>程序包管理器控制台l选择对应的包nMicrosoft.Owin.Host.SystemWeb4.0.0 nMicrosoft.Owin4.0.0 4.    选中项目,添加新项à OWIN Startupclass 用于设置报表存放路径 5.    右键单击项目添加ActiveReports 必要的引用或者通过添加新项->Reporting-RDL 报表来自动生成对应dllC:\Program Files (x86)\CommonFiles\GrapeCity\ActiveReports 13如lGrapeCity.ActiveReports.Aspnet.Viewer.dll 6.    添加 Scripts 脚本文件 到项目中及 Web.config 文件(如果 旧项目的 Web.config文件没有改动的话,可直接覆盖)JS 代码可以从NPM 直接获取https://www.npmjs.com/package/@grapecity/ar-viewer
7.    修改 Startup.cs函数//Startup.csusing GrapeCity.ActiveReports.Aspnet.Viewer;            publicvoid Configuration(IAppBuilder app){    <...>    app.UseReporting(settings =>    {      // Reporting middleware settings      settings.UseFileStore(newDirectoryInfo("path to the reports folder"));
    });} 8.在html页面中输入以下代码,完成<!DOCTYPEhtml><html><head>    <meta charset="utf-8" />    <title></title><!--Addthe references to these files to the target HTML page-->    <link rel="stylesheet" href="https://cdn.materialdesignicons.com/2.4.85/css/materialdesignicons.min.css">    <link rel="stylesheet"href="https://fonts.cat.net/css?family=Open+Sans:400,300,600,700"type="text/css">    <link rel="stylesheet"href="scripts/jsViewer.min.css" type="text/css">    <scriptsrc="scripts/jsViewer.min.js"></script></head><body><!--Addthe DIV element that will contain the JSViewer in the target HTML page-->    <div class=theme-defaultid="viewerContainer">Loading Report</div></body></html><!--Addthe code that initializes and passes the parameters in the JSViewer instance.The code might vary depending on the technology used to develop the JSViewercomponent. The example of code for the pure javascript component:--><scripttype="text/javascript">    var viewer =GrapeCity.ActiveReports.JSViewer.create({      element: '#viewerContainer',      reportID: 'ReportName.rdlx', // the idof the report to display      availableExports: ['Xml', 'Pdf','Excel'],      reportService: {}      // other properties    });</script>

页: [1]
查看完整版本: 如何替换HTML5Viewer为JSViewer 指南