Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Report Viewer

Report Viewer

Scheduled Pinned Locked Moved ASP.NET
questionlearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kenexcelon
    wrote on last edited by
    #1

    It appears that the print button does not show in a report viewer with the processing mode set to local. How would I process the report viewer to either print or to open a new window with the contents in a printable page? Would it be ReportViewer1.Render? I am learning this new control and am not familiar with that method or if that would even work. Thanks

    Revolutionary: Disk drives go round and round.

    S 1 Reply Last reply
    0
    • K kenexcelon

      It appears that the print button does not show in a report viewer with the processing mode set to local. How would I process the report viewer to either print or to open a new window with the contents in a printable page? Would it be ReportViewer1.Render? I am learning this new control and am not familiar with that method or if that would even work. Thanks

      Revolutionary: Disk drives go round and round.

      S Offline
      S Offline
      Samer Aburabie
      wrote on last edited by
      #2

      I can answer you regardin the render method ... you probably meant the ReportViewer.LocalReport.Render method ... well its the main method in the ReportViewer Control ... this method uses the report definition (which is an xml format stored in rdlc file referring to the report) to render the report defintion with its data to the ASP.NET page ... the LocalReport will have the definition and its integrated with the stored procedure or the datasource ... then using some parameters to the render method you get an array of bytes which is the output you want ... Take a look at the code below:

      ///Render the report as an attachement
      string format="PDF";//Excel, Html ... etc

      Warning[] warnings;
      string[] streamIDs;
      string mimeType;
      string encoding;
      string extension;
      string deviceInfo = "";

      byte[] buffer = viewer.LocalReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamIDs, out warnings);

      this.Response.Clear();
      this.Response.AddHeader("Content-Type", mimeType);
      this.Response.AddHeader("Content-Disposition", "attachment; filename=" + reportName + "." + extension);
      this.Response.BinaryWrite(buffer);
      this.Response.End();

      The above code will render the specified local report as PDF and return the result as an array of bytes ... then you write this array of bytes to back to the response as a dialog of Open or Save ... I needed this trick in a project and it worked fine with me ... I could render the report to PDF Excel or whatever I can to be as the user can just download easly. Hope this could help ...

      Sincerely Samer Abu Rabie Note: Please remember to rate this post to help others whom reading it.

      K 1 Reply Last reply
      0
      • S Samer Aburabie

        I can answer you regardin the render method ... you probably meant the ReportViewer.LocalReport.Render method ... well its the main method in the ReportViewer Control ... this method uses the report definition (which is an xml format stored in rdlc file referring to the report) to render the report defintion with its data to the ASP.NET page ... the LocalReport will have the definition and its integrated with the stored procedure or the datasource ... then using some parameters to the render method you get an array of bytes which is the output you want ... Take a look at the code below:

        ///Render the report as an attachement
        string format="PDF";//Excel, Html ... etc

        Warning[] warnings;
        string[] streamIDs;
        string mimeType;
        string encoding;
        string extension;
        string deviceInfo = "";

        byte[] buffer = viewer.LocalReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamIDs, out warnings);

        this.Response.Clear();
        this.Response.AddHeader("Content-Type", mimeType);
        this.Response.AddHeader("Content-Disposition", "attachment; filename=" + reportName + "." + extension);
        this.Response.BinaryWrite(buffer);
        this.Response.End();

        The above code will render the specified local report as PDF and return the result as an array of bytes ... then you write this array of bytes to back to the response as a dialog of Open or Save ... I needed this trick in a project and it worked fine with me ... I could render the report to PDF Excel or whatever I can to be as the user can just download easly. Hope this could help ...

        Sincerely Samer Abu Rabie Note: Please remember to rate this post to help others whom reading it.

        K Offline
        K Offline
        kenexcelon
        wrote on last edited by
        #3

        I will definitely give it a shot. Thank you!

        Revolutionary: Disk drives go round and round.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups