RDLC Local report viewer for ASP.NET Core and Angular(>2.0)

前端 未结 5 1475
-上瘾入骨i
-上瘾入骨i 2020-12-08 11:38

Is there any way to show RDLC Local ReportViewer control in asp.net core webpage?

To show a ReportViewer, on a traditional WebForms application, the below code works

5条回答
  •  死守一世寂寞
    2020-12-08 12:18

    public List _dataSourceList = new List();
    public string _dataSourceName { get; set; }
    
    public string _reportPath = CommonUtil.Report_path; //set your report path in app.config file
    public Dictionary Parameters = new Dictionary();
    
    public void PDFPrint_Load() {
    
      string mimtype="";
      int extension = 1;
    
      LocalReport localReport= new LocalReport(_reportPath);
      localReport.AddDataSource(_dataSourceName, _dataSourceList);
    
      if (Parameters != null && Parameters.Count > 0)// if you use parameter in report
      {
        List reportparameter = new List();
        foreach (var record in Parameters) {
          reportparameter.Add(new ReportParameter());
        }
      }
      var result = localReport.Execute(RenderType.Pdf, extension,parameters: 
      Parameters, mimtype);
    
      byte[] bytes = result.MainStream;
      string fileName = "Report.pdf";
      return File(bytes , "application/pdf",fileName );
    }
    
        

    提交回复
    热议问题