.net core 应用程序“default web site”中的服务器错误_如何使用具有FastReport.Core库的Online Designer...

许多FastReport.Core用户都对报表生成器如何在使用React库编写的Web应用程序中工作感兴趣。在本文中,我们将介绍使用在线设计器的方法。尽管它与常规报表显示在同一个Web对象中,但与React中显示的差异很大。

如果您从未在React上使用.Net Core上的后端创建应用程序,那么您需要:

1)安装NodeJS。这是一个软件包,允许您在服务器端执行JavaScript代码,以及安装各种JavaScript库。

2)安装Microsoft Visual Studio 2017或其他IDE + .Net Core SDK 2.0。

要创建应用程序,请在项目所在的文件夹中打开Windows命令提示符,然后执行以下命令:

dotnet new react -o ReactFRCoreDesigner

打开创建的项目。让我们将FastReport库添加到NuGet包管理器中。配置文件夹的本地包源:

C: Program Files(x86) FastReports FastReport.Net Nugets

安装FastReport.Core包。

在项目中找到Startup.cs文件,并在Configure()方法中添加一行代码:

app.UseFastReport();

现在我们可以在项目中使用报表生成器。

除了显示在线设计器之外,我们还会查看传输所需报表名称的方式,并将其上传到在线设计器。因此,我们将App_Data文件夹添加到项目中。在其中,我们将从FR.Net安装目录中的Demos Reports文件夹添加报表模板。

acaa3ec94f2bc1c368ca60fec531e56f.png

如您所见,我们还从同一文件夹中添加了一个xml文件。这是一个报告数据库。

找到Controllers文件夹。我们可以使用SampleDataController控制器。添加两个方法:

…using FastReport.Web;using System.IO;…[HttpGet("[action]")] public IActionResult Design(string name) { WebReport WebReport = new WebReport(); WebReport.Width = "1000"; WebReport.Height = "1000"; if (name != "Blank") WebReport.Report.Load("App_Data/" + name + ".frx"); // Load the report into the WebReport object System.Data.DataSet dataSet = new System.Data.DataSet(); // Create a data source dataSet.ReadXml("App_Data/nwind.xml"); // Open the database xml WebReport.Report.RegisterData(dataSet, "NorthWind"); // Registering the data source in the report  WebReport.Mode = WebReportMode.Designer; // Set the web report object mode - designer display WebReport.DesignerLocale = "en"; WebReport.DesignerPath = @"WebReportDesigner/index.html"; // We set the URL of the online designer WebReport.DesignerSaveCallBack = @"api/SampleData/SaveDesignedReport"; // Set the view URL for the report save method WebReport.Debug = true; ViewBag.WebReport = WebReport; // pass the report to View return View(); }  [HttpPost("[action]")] // call-back for save the designed report public IActionResult SaveDesignedReport(string reportID, string reportUUID) { ViewBag.Message = String.Format("Confirmed {0} {1}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值