3/06/2011

.net app to render SSRS report C#

I needed to write a c# app to render a SSRS report in PDF.

Found sample code here and customized it:

http://msdn.microsoft.com/en-us/library/ms251839%28VS.80%29.aspx
        protected void ExportReport(object sender, EventArgs e)
        {
            Microsoft.Reporting.WinForms.Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string extension;

            byte[] bytes = this.reportViewer1.LocalReport.Render(
               "Excel", null, out mimeType, out encoding,
                out extension,
               out streamids, out warnings);

            FileStream fs = new FileStream(@"c:\output.xls",
               FileMode.Create);
            fs.Write(bytes, 0, bytes.Length);
            fs.Close();

        }


Works great!  Just need to try PDF now.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Thoughts to Ponder