如何在没有reportpath的情况下打开syncfusion report viewer

问题描述 投票:0回答:1

我在DB中有RDL内容。所以基于reportID,我可以渲染数据库内容。我不想在系统中添加物理文件,因为Reportviewer在寻找reportpath怎么能实现这个呢?

使用RDL内容字符串直接显示报表查看器

由于API是保密的,因此无法查看所需的覆盖方法。

aspx页面:

代码背后:

string targetFolder = HttpContext.Current.Server.MapPath("~/") + @"Report Templates\ReportViewer\";
string reportPath = targetFolder + @"\" + reportDefID + ".rdl";

deDesign oDE = new deDesign();
deReportDefinition oDef = oDE.getReportDefinition(reportDefID);
string sXML = oDef.export();

Hashtable oProps = oDef.getProperties("REPORTNAME");
lblReportName.Text = oProps["REPORTNAME"].ToString();

File.WriteAllText(reportPath, sXML);
viewer.ReportPath = reportPath;

lblStatus.Text = string.IsNullOrEmpty(sXML) ? "No Data Found" : "";
dvReportViewer.Visible = string.IsNullOrEmpty(sXML) ? false : true;
c# jquery asp.net reportviewer syncfusion
1个回答
1
投票

是的,我们可以通过将FileStream传递给Syncfusion ReportViewer而不是ReportPath来实现您的要求。请找到下面控制器侧处理的片段,

public class ReportApiController : ApiController, IReportController 
{ 
    public object PostReportAction(Dictionary<string, object> jsonResult) 
    { 
        return ReportHelper.ProcessReport(jsonResult, this); 
    } 

    [System.Web.Http.ActionName("GetResource")] 
    [AcceptVerbs("GET")] 
    public object GetResource(string key, string resourcetype, bool isPrint) 
    { 
        return ReportHelper.GetResource(key, resourcetype, isPrint); 
    } 

    public void OnInitReportOptions(ReportViewerOptions reportOption) 
    { 
        FileStream fs = new FileStream(HttpContext.Current.Server.MapPath("~/App_Data/GroupingAgg.rdl"), FileMode.Open, FileAccess.Read); 
        reportOption.ReportModel.Stream = fs; 
    } 

    public void OnReportLoaded(ReportViewerOptions reportOption) 
    { 

    } 
} 

请在下面找到有助于您的要求的样本参考,

http://www.syncfusion.com/downloads/support/directtrac/general/ze/ReportviewerSample141241572.zip

注意:在上面的示例中,我们已将物理路径文件作为流读取并加载它。您可以根据需要修改示例,以将xml内容作为FileStream传递。

© www.soinside.com 2019 - 2024. All rights reserved.