locked
How do I export rdlc report directly to pdf on button click. RRS feed

  • Question

  • User623775271 posted

    Hi,

    I am using multiple dataset's to create rdlc report. What I need to export the report directly in .pdf format on button_click event without showing MicrosoftReportViewer. Please help me...

    Thanx to all in advance..

    Friday, September 7, 2012 4:38 AM

All replies

  • Friday, September 7, 2012 4:42 AM
  • User2105670541 posted

    try to visit the link below, it has all the things you need exactly:

    http://forums.asp.net/t/1556522.aspx/1

    Wednesday, September 12, 2012 12:58 AM
  • User623775271 posted

    I used the given code, DataSource is perfectly added to report but I also have to pass 18 Local Parameters from code behiend, how can i pass them???

    Wednesday, September 12, 2012 1:21 AM
  • User2105670541 posted

    you can create report parameter like below:

    ReportViewer viewer = new ReportViewer(); 
    viewer.ProcessingMode = ProcessingMode.Local; 
    viewer.LocalReport.ReportPath = "YourReportHere.rdlc";
    
    ReportParameter param1 = new ReportParameter("Parameter1Name", "Paramerter1Value");
    ReportParameter param2 = new ReportParameter("Parameter2Name", "Paramerter2Value");
    viewer.LocalReport.SetParameters(new ReportParameter[] { param1, param2 }); 

    and later you can add them in your report viewer just before your rendering code begins:

    byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
    Wednesday, September 12, 2012 1:51 AM
  • User623775271 posted

    Doing the same, but it is showing Error

    System.IO.FileNotFoundException: Could not find file 'D:\Syndicate System\RptGetQuotationDetails.rdlc'.

    while this report is already generated in ReportViewer.

    Wednesday, September 12, 2012 1:55 AM
  • User2105670541 posted

    well you need to have the report hosted in your application/web site directory and you need to pass it using virtual path like:

    if hosted in root directory of your application:

    viewer.LocalReport.ReportPath = "~/YourReportHere.rdlc";

    if inside any folder:

    viewer.LocalReport.ReportPath = "~/YourFolderName/YourReportHere.rdlc"; 
    Wednesday, September 12, 2012 2:00 AM
  • User623775271 posted

    This problem is automatically resolved but now the issue is I used 3 datasets in single report and as you said I passed all three of them using DatasetTableAdapter, but report only accepts first datasource and showing error of other two datasource not supplied..

    Wednesday, September 12, 2012 2:10 AM
  • User2105670541 posted

    are you adding your dataset like below:

    viewer.LocalReport.DataSources.Add(dataset1); //also the same code for other datasets

    Wednesday, September 12, 2012 2:23 AM
  • User623775271 posted

    It is not working..

    Still the error is same..

    Wednesday, September 12, 2012 2:39 AM