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
Starting in 2019, the Reporting control is no longer included in Essential Studio. If you're experiencing issues with the Syncfusion Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion and appreciate your understanding.

Save report in FieExplorer

Hi,
I'm trying to generate and save reports of each product in a specific folder in FileExplorer. The function fetch in order table and if it finds a new order it create a folder and add the ordered product report to that folder.
I don't know where is the error. Can you help me to achieve this?

foreach (var o in order)
{
      var path = Server.MapPath("~/FileExplorerContent/" + o.CustomerName + "/" + o.OrderId);
        Directory.CreateDirectory(path);
                try
                {
                    foreach (var p in db.Product)
                    {
                        if (p.Pid == o.Pid)
                        {
                            string fileName = null;
                            HttpContext httpContext = System.Web.HttpContext.Current;
                            ReportWriter reportWriter = new ReportWriter(path);
                            reportWriter.ReportPath = Server.MapPath("~/App_Data/Report.rdl");
                            reportWriter.ReportProcessingMode = ProcessingMode.Remote;

                            List<ReportParameter> parameters = new List<ReportParameter>();
                            parameters.Add(new ReportParameter() { Name = "Pid", Labels = new List<string>() { o.Pid }, Values = new List<string>() { o.Pid } });
                            reportWriter.SetParameters(parameters);
                            

                            fileName = o.Pid+ ".pdf";

                            reportWriter.Save(fileName, WriterFormat.PDF, httpContext.Response);
                        }
                    }
                }
                catch (Exception ex){}
            }
        }


1 Reply

YD Yuvaraj Devarajan Syncfusion Team May 10, 2017 10:54 AM UTC

Hi Anis, 

Thanks for contacting Syncfusion support. 

We can generate and save the report PDF file directly in dynamically created directory by passing the file path name and format in save method as shown in below code example, 

public ActionResult Index(string button) 
        { 
            try 
            {               
                var path = Server.MapPath("~/App_Data/Test"); 
                Directory.CreateDirectory(path); 
                string fileName = null;                
                HttpContext httpContext = System.Web.HttpContext.Current; 
                ReportWriter reportWriter = new ReportWriter(); 
                reportWriter.ReportPath = Server.MapPath("~/App_Data/Report.rdl"); 
                reportWriter.ReportProcessingMode = ProcessingMode.Remote; 
                List<ReportParameter> parameters = new List<ReportParameter>(); 
                parameters.Add(new ReportParameter() { Name = "Ord", Labels = new List<string>() { "AAA" }, Values = new List<string>() { "AAA" } }); 
                reportWriter.SetParameters(parameters); 
 
                fileName = "file.pdf"; 
                reportWriter.Save(path+"/"+fileName, WriterFormat.PDF);                                          
            } 
            catch 
            { 
            } 
            return View(); 
        } 

We have prepared a sample and it can be downloaded from below location, 

Please refer to the below UG document for more detail, 

If the problem still occurs, then revert the sample with issue reproducible procedure to validate the mentioned issue at our end. 

Regards, 
Yuvaraj D. 


Loader.
Live Chat Icon For mobile
Up arrow icon