I hope the following helps (excerpt from the relevant parts of the code)
using (ZUtilities.SSRS.Report report = new ZUtilities.SSRS.Report { ReportServerPath = VParameter.GetValue("SSRS_WebServiceUrl", _repo.Parameters).ToString(), Format = rformat, ReportPath = "some_path_on_ssrs_server" }) { report.Params.Add("Id", id.ToString()); report.Credentials = nwc; MemoryStream ms = new MemoryStream(); report.Render().CopyTo(ms); FileContentResult fsr = new FileContentResult(ms.ToArray(), rctype); fsr.FileDownloadName = String.Format("EPV-{0}-{1:yyyyMMdd}.{2}", epv.ExternalReference, DateTime.Now, fext); ms.Close(); return fsr; }
with the following (note flow control)
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.IO; namespace ZUtilities.SSRS { public enum ReportFormats { Html = 1, MHtml, Pdf, Xlsx, Docx } public class ReportFormat { static ReportFormat() { Html = new ReportFormat { Code = ReportFormats.Html, Instruction = "HTML4.0" }; MHtml = new ReportFormat { Code = ReportFormats.MHtml, Instruction = "MHTML" }; Pdf = new ReportFormat { Code = ReportFormats.Pdf, Instruction = "PDF" }; Xlsx = new ReportFormat { Code = ReportFormats.Xlsx, Instruction = "EXCELOPENXML" }; Docx = new ReportFormat { Code = ReportFormats.Docx, Instruction = "WORDOPENXML" }; } private ReportFormat() { } public ReportFormats Code { get; set; } public String Instruction { get; set; } public static ReportFormat Html { get; private set; } public static ReportFormat MHtml { get; private set; } public static ReportFormat Pdf { get; private set; } public static ReportFormat Xlsx { get; private set; } public static ReportFormat Docx { get; private set; } public static ReportFormat ByCode(ReportFormats code) { switch (code) { case ReportFormats.Html: return Html; case ReportFormats.MHtml: return Html;
source share