Let us create an ASP.NET Core application using ActiveReports and render the reports in the WebDesigner.
MESCIUS.ActiveReports.Aspnetcore.Viewer
npm init -y
npm install @mescius/activereportsnet-designer
npm install @mescius/activereportsnet-viewer
Copy the following designer and viewer files/folder installed in the node_modules to the wwwroot\js and wwwroot\css folder in the application, respectively.
index.html |
Copy Code
|
---|---|
<!DOCTYPE html> <html> <head> <title>ActiveReports WebDesigner</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <style> body, html { width: 100%; height: 100%; margin: 0; padding: 0 } @@keyframes arwd-loader { from { color: #fff } to { color: #205f78 } } .ar-web-designer { width: 100%; height: 100% } .ar-web-designer__loader { display: flex; width: 100%; height: 100%; background-color: #205f78; color: #fff; font-size: 18px; animation-name: arwd-loader; animation-duration: .62s; animation-timing-function: ease-in-out; animation-iteration-count: infinite; animation-direction: alternate; justify-content: center; align-items: center } </style> <link rel="stylesheet" href="vendor/css/fonts-googleapis.css" type="text/css" /> <link rel="stylesheet" href="css/jsViewer.min.css" /> <link rel="stylesheet" href="css/web-designer.css" /> </head> <body> <!-- Required for the ActiveReports Web Viewer --> <script src="js/jsViewer.min.js"></script> <!-- designer-related js --> <script src="js/web-designer.js"></script> <!-- Designer root div --> <div id="ar-web-designer" class="ar-web-designer"> <span class="ar-web-designer__loader"><b>AR WebDesigner</b></span> </div> <script> var viewer = null; GrapeCity.ActiveReports.Designer.create('#ar-web-designer', { appBar: { openButton: { visible: true }, saveButton: { visible: true }, saveAsButton: { visible: true } }, editor: { showGrid: false }, data: { dataSets: { canModify: true }, dataSources: { canModify: true } }, preview: { openViewer: (options) => { if (viewer) { viewer.openReport(options.documentInfo.id); return; } viewer = GrapeCity.ActiveReports.JSViewer.create({ element: '#' + options.element, renderFormat: 'svg', reportService: { url: 'api/reporting', }, reportID: options.documentInfo.id, settings: { zoomType: 'FitPage' } }); } } }); </script> </body> </html> |
Program.cs |
Copy Code
|
---|---|
using GrapeCity.ActiveReports.Aspnetcore.Viewer; using GrapeCity.ActiveReports.Aspnetcore.Designer; DirectoryInfo ResourcesRootDirectory = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "resources" + Path.DirectorySeparatorChar)); var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); builder.Services.AddReportDesigner(); var app = builder.Build(); app.UseHttpsRedirection(); if (!app.Environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // Configure middleware for ActiveReports API and handlers. app.UseReportDesigner(config => config.UseFileStore(ResourcesRootDirectory)); app.UseReportViewer(config => config.UseFileStore(ResourcesRootDirectory)); app.UseDefaultFiles(); app.UseStaticFiles(); app.Run(); |