当前位置: 首页 > 知识库问答 >
问题:

用于ASP.NET Core和Angular的RDLC本地报表查看器(>2.0)

施自珍
2023-03-14

有没有方法在ASP.NET核心网页中显示RDLC本地ReportViewer控件

为了显示ReportViewer,在传统的WebForms应用程序上,下面的代码起作用。

<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

        <div style="height: 600px;">
            <rsweb:ReportViewer ID="reportViewer" runat="server" Width="100%" Height="100%"></rsweb:ReportViewer>
        </div>
    </form>
</body>
  1. ReportViewerFormVC-适用于MVC,但与ASPNET核心不兼容。
  2. MVCreportViewer-适用于MVC,但与ASPNET Core不兼容(请参阅此问题:https://github.com/ilich/MVCreportViewer/issues/121)。
  3. MVCreportViewer-不使用microsoft viewer控件,因此支持aspnet core,但不能处理本地报表(需要报表服务器url)。
  4. NGX-SSRS-ReportViewer npm package-远程报表的包装器,不支持本地报表。(需要报表服务器url)

Q1.在ASP.NET核心应用程序中使用 的最佳方法是什么?

共有1个答案

常鸿朗
2023-03-14

找到了一个npm包ng2-pdfjs-viewer,虽然它不完全是MS报表查看器,但如果您愿意使用PDFJS,该包的文档中有一个类似的示例,即使用LocalReport viewer生成pdf,并使用ng2-pdfjs-viewer在浏览器中显示它-(https://www.npmjs.com/package/ng2-pdfjs-viewer)

<!-- your.component.html -->
<button (click)="openPdf();">Open Pdf</button>
<!-- your.component.ts-->
export class MyComponent implements OnInit {
  @ViewChild('pdfViewer') pdfViewer
  ...
 
  private downloadFile(url: string): any {
    return this.http.get(url, { responseType: ResponseContentType.Blob }).map(
      (res) => {
        return new Blob([res.blob()], { type: "application/pdf" });
      });
  }
 
  public openPdf() {
    let url = "http://localhost:4200/api/GetMyPdf";
    this.downloadFile(url).subscribe(
    (res) => {
        this.pdfViewer.pdfSrc = res; // pdfSrc can be Blob or Uint8Array
        this.pdfViewer.refresh(); // Ask pdf viewer to load/reresh pdf
      }
    );
  }
[HttpGet]
[Route("MyReport")]
public IActionResult GetReport()
{
   var reportViewer = new ReportViewer {ProcessingMode = ProcessingMode.Local};
   reportViewer.LocalReport.ReportPath = "Reports/MyReport.rdlc";
 
   reportViewer.LocalReport.DataSources.Add(new ReportDataSource("NameOfDataSource1", reportObjectList1));
   reportViewer.LocalReport.DataSources.Add(new ReportDataSource("NameOfDataSource2", reportObjectList1));
 
   Warning[] warnings;
   string[] streamids;
   string mimeType;
   string encoding;
   string extension;
 
   var bytes = reportViewer.LocalReport.Render("application/pdf", null, out mimeType, out encoding, out extension, out streamids, out warnings);
 
   return File(bytes, "application/pdf")
}
 类似资料:
  • 我正在使用Birt web报表查看器4.2.1,以及如何将报表查看器语言本地化为俄语,eclipse站点仅为某些IDE提供本地化,

  • 主要内容:1 查看JasperReports JRPrint文件,2 打印JasperReports的报表1 查看JasperReports JRPrint文件 上一章:《JasperReports 填充报表》,我们已经通过JasperReports生成了.jrprint报表文件,接下来我们可以编写预览程序来预览.jrpirnt文件的效果。 输出结果如下: 2 打印JasperReports的报表 我们可以使用net.sf.jasperreports.engine.JasperPrintMana

  • 表查看器 以网格显示表数据。数据可以用两种模式显示:网格查看 和 表单查看。表查看器工具栏提供了以下功能管理数据: 开始事务、提交 或 回滚 点击 开始事务 来开始一个事务。令事务中的全部改变永久完成,点击 提交。或点击 回滚 来在当前的事务中撤消所做的工作。 提示:提交 和 回滚 按钮只有当在选项中启用 自动开始事务 或按了 开始事务 按钮时可用。 导入数据 从文件导入数据。 导出数据 导出数据

  • 如何修复:在具有AspNetCore.ReportingServices的AspNet Core Project中使用RLDC会导致异常,因为“本地报告处理过程中发生错误。索引超出了数组的范围。” 我有.网络维表单项目来添加RDLC文件。我总是在阿斯普网核心项目中复制/粘贴rdlc文件数据源。 尝试导出 pdf / Excel,它会引发上述异常。 注意:这是随机的。它有时会到来。但是当部署在IIS

  • 表单查看让你以表单查看、更新或删除数据,显示当前的记录:字段名及其值。表单的弹出菜单提供以下额外的功能:设置字段值为 Null 或空白字符串,使用当前字段值为筛选,设置表单查看格式,及更多。 导览栏让你快速地切换记录、插入、更新或删除记录。相关主题: 排序、查找或替换记录 筛选记录 操作原始数据 设置表网格格式

  • Navicat 包含一个数据查看器,让你查看、更新或删除数据。查看器还包括一些高级功能和编辑器,帮助你在操作数据时理解数据。你可以使用通用键盘导航来浏览数据。