asp.net-core - Stimulsoft 报告未显示其内容
问题描述
我正在使用 ASP.NET MVC Core 3.1 并尝试在项目内部使用 Stimulsoft 报告。报表查看器正在运行,但看不到报表的内容。
我可以知道可能是什么问题吗?
结果的图像是.. 请使用下面给出的 URL http://prntscr.com/rc1kou
代码如下:
控制器
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Stimulsoft.Report;
using Stimulsoft.Report.Mvc;
using WebApplication2.Models;
namespace WebApplication2.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
return View();
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
public IActionResult GetReport()
{
// Create the report object
StiReport report = new StiReport();
report.LoadDocument(StiNetCoreHelper.MapPath(this, "Reports/TwoSimpleLists.mrt"));
DataSet data = new DataSet("Demo");
data.ReadXml(StiNetCoreHelper.MapPath(this, "Reports/Data/Demo.xml"));
report.RegData(data);
return StiNetCoreViewer.GetReportResult(this, report);
}
public IActionResult ViewerEvent()
{
return StiNetCoreViewer.ViewerEventResult(this);
}
}
}
.CSHTML
@using Stimulsoft.Report.Mvc;
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
@Html.StiNetCoreViewer(new StiNetCoreViewerOptions()
{
Actions =
{
GetReport = "GetReport",
ViewerEvent = "ViewerEvent"
}
})
解决方案
您应该使用该Load()
方法而不是LoadDocument()
加载报告模板:
report.Load(StiNetCoreHelper.MapPath(this, "Reports/TwoSimpleLists.mrt"))
推荐阅读
- python - 即使 findstatic 找到文件,Django 静态文件 404
- python - 使用 LSTM 基于其他列预测列的未来结果
- java - 如何将带有改造的列表整数发布到 CodeIgniter Rest API
- java - 如何在指定索引上对二维数组进行冒泡排序?
- macos - 可可 - 如何让非沙盒 macOS 应用程序在登录时启动?
- xpath - Google 表格 - 在特定页面上导入 XML 时遇到问题
- android - 如何保持连续的 ImageView 并隐藏其他视图?
- python - 如何设置一个方法,其中传递的参数之一可能没有值?
- java - 有没有办法在它为空时使用“可选”的方法“orElseGet”来创建一个新列表?
- azure-cosmosdb - 增加分区键计数对 azure cosmos db 的读取性能有什么影响