Tuesday, 29 January 2013

How to Show rdlc report file into pdf format

 string MimeType = "";
    string Encoding = "";
    string strExtension = "";
    string[] streamIds = null;
    Warning[] warnings = null;


protected void Page_Load(object sender, EventArgs e)
    {
        ds = objBll.reportuser();
      
        ReportDataSource rds = new ReportDataSource();
        rds.Name = "userreportsDS_DataTable1";
        rds.Value = ds.Tables[0];
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(rds);
        ReportViewer1.LocalReport.ReportPath = Server.MapPath("Reports/")+"useruploadReport.rdlc";

        byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out MimeType, out Encoding, out strExtension, out streamIds, out warnings);
        Response.Buffer = true;
        Response.Clear();
        Response.ContentType = MimeType;
        Response.AddHeader("content-position", bytes.Length.ToString());
        Response.BinaryWrite(bytes); // create the file
     

    }

No comments:

Post a Comment