This is a migrated thread and some comments may be shown as answers.

Error generating report containing subreport with UriReportSource

1 Answer 211 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Luca
Top achievements
Rank 1
Luca asked on 17 Jul 2015, 02:51 PM

Hi everybody,

I've just created a .trdx report containing a subreport using Telerik Report Designer. I would like to export a pdf file based on this report so I've created a web page having this method server side:

void ExportToPDF()
{
    var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
    var deviceInfo = new System.Collections.Hashtable();
 
    UriReportSource NetCatalogPDF = new UriReportSource();
    NetCatalogPDF.Uri = Server.MapPath("~/Report/Standard/CatalogPDF.trdx");
 
    NetCatalogPDF.Parameters.Add(new Telerik.Reporting.Parameter("CompanyCode", CompanyCode));
    NetCatalogPDF.Parameters.Add(new Telerik.Reporting.Parameter("LanguageCode", PageLanguage));
    NetCatalogPDF.Parameters.Add(new Telerik.Reporting.Parameter("FamilyId", (ddlFamily.SelectedValue != "-1") ? ddlFamily.SelectedValue : null));
    NetCatalogPDF.Parameters.Add(new Telerik.Reporting.Parameter("IncludePrices", chkIncludePrices.Checked));
 
    if (chkIncludePrices.Checked)
    {
        NetCatalogPDF.Parameters.Add(new Telerik.Reporting.Parameter("PriceListCode", ddlPriceList.SelectedValue));
        NetCatalogPDF.Parameters.Add(new Telerik.Reporting.Parameter("CustomerCode", txtCustomerCode.Text));
    }
    else
    {
        NetCatalogPDF.Parameters.Add(new Telerik.Reporting.Parameter("PriceListCode", null));
        NetCatalogPDF.Parameters.Add(new Telerik.Reporting.Parameter("CustomerCode", null));
    }
     
    NetCatalogPDF.Parameters.Add(new Telerik.Reporting.Parameter("ImagesPath", Server.MapPath("/Catalog/public/images/catalog/products/zoom")));
 
    var connectionStringHandler = new ReportConnectionStringManager(ConnectionString);
 
    try
    {
        var reportSource = connectionStringHandler.UpdateReportSource(NetCatalogPDF);
        var result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);
 
        this.Response.Clear();
        this.Response.ContentType = result.MimeType;
        this.Response.Cache.SetCacheability(HttpCacheability.Private);
        this.Response.Expires = -1;
        this.Response.Buffer = true;
 
        // Uncomment to handle the file as attachment
        //Response.AddHeader("Content-Disposition",
        //              string.Format("{0};FileName=\"{1}\"",
        //                              "attachment",
        //                              "Report.pdf"));
 
        this.Response.BinaryWrite(result.DocumentBytes);
        this.Response.End();
    }
    catch (Exception ex)
    {
        ErrMess = ex.Message;
    }
}

 

 Anyway the line

var result = reportProcessor.RenderReport("PDF", reportSource, deviceInfo);

throw an exception:

Cannot find the file 'c:\windows\system32\inetsrv\CatalogPDF_Sub.trdx'. "CatalogPDF_Sub.trdx" is subreport file name. Obviously the path is wrong because that file is located in the same main report folder ("~/Report/Standard/").

How can I solve this problem?

 Thank you in advance for your replies.

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 21 Jul 2015, 03:50 PM
Hello Luca,

Most probably the sub report is specified via relative path, and the error occurs in the UpdateReportSource method on resolving the SubReport item's ReportSource property as the target TRDX file is not mapped correctly on the server.

Please debug the method and check at which point the SubReport.ReportSource is handled and where you need to add logic for mapping the TRDX file on the server.


I hope the provided information is helpful.

Regards,
Stef
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Luca
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or