We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Save RDL report to physical folder

Thread ID:

Created:

Updated:

Platform:

Replies:

142641 Feb 12,2019 05:20 AM UTC Feb 1,2021 11:28 AM UTC ASP.NET Web Forms 9
loading
Tags: ReportDesigner
MEGHA
Asked On February 12, 2019 05:20 AM UTC

In Report designer how do we save RDL file to Physical folder?
As of now it is getting downloaded. I want RDL report to save in some particular folder on Save Click.

Mageshyadav M [Syncfusion]
Replied On February 13, 2019 06:28 AM UTC

Hi Megha,  
  
We can able to save or open the report using External server in web Report Designer. We have prepared the simple sample in ASP.NET WebForms application and it can be downloaded from below location.  
  
Note: In above sample we have used the External server for open/edit/save the existing report using External server.  
  
We are getting the existing reports, datasources and datasets available in our shared application as shown in below code example. If you want to use any other location then we can modify the path accordingly.   
   
ExternalServer.cs:   
   
public override List<CatalogItem> GetItems(string folderName, ItemTypeEnum type)   
        {   
            List<CatalogItem> _items = new List<CatalogItem>();   
            string targetFolder = HttpContext.Current.Server.MapPath("~/") +@"App_Data\ReportServer\";   
   
            if (type == ItemTypeEnum.Folder || type == ItemTypeEnum.Report)   
            {   
                targetFolder = targetFolder + @"Report\";   
                if (!(string.IsNullOrEmpty(folderName) || folderName.Trim() == "/"))   
                {   
                    targetFolder = targetFolder + folderName;   
                }   
            }   
   
            if (type == ItemTypeEnum.DataSet)   
            {   
                foreach (var file in Directory.GetFiles(targetFolder + "DataSet"))   
                {   
                    CatalogItem catalogItem = new CatalogItem();   
                    catalogItem.Name = Path.GetFileNameWithoutExtension(file);   
                    catalogItem.Type = ItemTypeEnum.DataSet;   
                    catalogItem.Id = Regex.Replace(catalogItem.Name, @"[^0-9a-zA-Z]+""_");   
                    _items.Add(catalogItem);   
                }   
            }   
            else if (type == ItemTypeEnum.DataSource)   
            {   
                foreach (var file in Directory.GetFiles(targetFolder + "DataSource"))   
                {   
                    CatalogItem catalogItem = new CatalogItem();   
                    catalogItem.Name = Path.GetFileNameWithoutExtension(file);   
                    catalogItem.Type = ItemTypeEnum.DataSource;   
                    catalogItem.Id = Regex.Replace(catalogItem.Name, @"[^0-9a-zA-Z]+""_");   
                    _items.Add(catalogItem);   
                }   
            }   
            else if (type == ItemTypeEnum.Folder)   
            {   
                foreach (var file in Directory.GetDirectories(targetFolder))   
                {   
                    CatalogItem catalogItem = new CatalogItem();   
                    catalogItem.Name = Path.GetFileNameWithoutExtension(file);   
                    catalogItem.Type = ItemTypeEnum.Folder;   
                    catalogItem.Id = Regex.Replace(catalogItem.Name, @"[^0-9a-zA-Z]+""_");   
                    _items.Add(catalogItem);   
                }   
            }   
            else if (type == ItemTypeEnum.Report)   
            {   
                foreach (var file in Directory.GetFiles(targetFolder, "*.rdl"))   
                {   
                    CatalogItem catalogItem = new CatalogItem();   
                    catalogItem.Name = Path.GetFileNameWithoutExtension(file);   
                    catalogItem.Type = ItemTypeEnum.Report;   
                    catalogItem.Id = Regex.Replace(catalogItem.Name, @"[^0-9a-zA-Z]+""_");   
                    _items.Add(catalogItem);   
                }   
            }   
   
            return _items;   
        }   
  
If the above suggestion doesn’t meets your requirement please let us know additional details on your requirement to assist further.  
  
Regards,  
Mageshyadav.M 


Padmini Ramamurthy [Syncfusion]
Replied On February 13, 2019 07:31 AM UTC

From: Megha T P 
Sent: Wednesday, February 13, 2019 1:35 AM
To: Syncfusion Support <support@syncfusion.com>
Subject: Re: Syncfusion support community forum 142641, Save RDL report to physical folder , has been updated. 

Hi , 

Thank you so much for the solution. 
I will look onto the same and get back to you. 

Regards, 
Megha 


Mageshyadav M [Syncfusion]
Replied On February 13, 2019 09:13 AM UTC

Hi Megha, 
  
Thanks for your update. Please let us know if you have any further doubts on validating the solution provided. 
  
Regards, 
Mageshyadav.M 


MEGHA
Replied On February 13, 2019 10:32 AM UTC

Hi MageshYadav,


Thank You so much for the solution.
Its working as per my reqirement with some changes.
I am able to save the file in physical path and from there reading RDL content and updating it to DB.


Regards,
Megha



Mageshyadav M [Syncfusion]
Replied On February 13, 2019 11:28 AM UTC

Hi Megha, 
  
Thanks for your update. 
  
We are glad to hear that you were able to achieve your requirement using provided solution. 
  
Regards, 
Mageshyadav.M 


MEGHA
Replied On February 13, 2019 12:52 PM UTC

Hi MageshYadav,

Like the same way is there any override option to achieve the same in Report viewer ?

<ej:ReportViewer runat="server" ID="viewer"  ReportServiceUrl="/api/ReportDesigner">
</ej:ReportViewer>

Here we need to set report path to render report viewer right.
But same i dont want to read from physical file.
I need to pass teh rdl content and render the report.

As of now doing like this.

   string reportDefID = "E4457F87-9803-4089-AA18-713F26E5A8CA";// We can get from request query string.
   string targetFolder = HttpContext.Current.Server.MapPath("~/") + @"App_Data\Report\";
  string reportPat = targetFolder + @"\" + reportDefID + ".rdl";
   viewer.ReportPath = reportPat;

Instead of setting report path is there any way we can open from filestream.

From DB reading XML and making it as filestream.
Client not allowing me to use physical path concept here so .
As given by your older example I am able to save RDL in DB and able to open designer From XML content stored in DB without physical path.

Could you please help me on this Report viewer functionality.



Regards,
Megha



Mageshyadav M [Syncfusion]
Replied On February 14, 2019 02:50 PM UTC

Hi Megha, 
 
Yes, we can achieve your requirement of passing as FileStream to ReportViewer instead of ReportPath. Please find the snippet handled in controller side below, 
 
    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) 
        { 
             
        } 
    } 
 
Please find the sample reference below which will assist your requirement, 
 
 
Note: In the above sample, we have read the physical path file as stream and loaded it. You can modify the sample as per your needs to pass the xml content as FileStream. 
 
Regards, 
Mageshyadav.M 


Yemoku
Replied On January 31, 2021 10:15 AM UTC

Hi Megha, 
 
Yes, we can achieve your requirement of passing as FileStream to ReportViewer instead of ReportPath. Please find the snippet handled in controller side below, 
 
    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) 
        { 
             
        } 
    } 
 
Please find the sample reference below which will assist your requirement, 
 
 
Note: In the above sample, we have read the physical path file as stream and loaded it. You can modify the sample as per your needs to pass the xml content as FileStream. 
 
Regards, 
Mageshyadav.M 


Dear Mageshyadav.,

Apologies for extending this thread once more. Its a nice piece of sample code. 

Whilst the OnInitReportOptions function can return a stream, I had expected that returning a report saved as a Memorystream and returning this content would also work correctly. 

If returning only a Memorystream from this function, it appears that the reportviewer control intermittently generates an exception that the reportpath/file cannot be empty or null. 

Does the physical RDL file need to exist in order for the control to function correctly?

Thanks

Yemi



Muthuramana Sankaranarayanan [Syncfusion]
Replied On February 1, 2021 11:28 AM UTC

Hi Yemoku, 

Yes we confirm that the physical RDL file need to exist in order for the above share code snippet to work correctly if you are passing the path of file as a stream. We are reading the physically present RDL file from the mentioned location and pass it to our component for further processing of the report due to which the RDL file need to physically present in that location. If it is not present then your mentioned issue will occur. Also as like mentioned previously you can also pass xml content as File stream based on your needs. 
 
If this did not help resolving your query and if the issue still persists then could you please share with us the report file, reporting controller and client side code snippet with us or if possible please share with an issue reproducible sample so that it will be helpful for us to validate the reported issue.  
 
Regards, 
Muthu Ramana S 



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon