public void GetReportMultipleDataSources_Returns_RenderedReport() { using (var reportDefinition = new FileStream("Reports\\ExampleReport2.rdlc", FileMode.Open)) { var reportRenderer = new ReportRenderer("FooDisplay", reportDefinition); reportRenderer.Initialise(); var data = new { DataSet1 = new List<string>(), // These propery names must match that of the datasets in the report DataSet2 = new List<string>() }; byte[] report = reportRenderer.GetReportAsPdf(data, new { Foo = "Bar" }); Assert.IsTrue(report.Length > 0); } }
public void GetReport_Returns_RenderedReport() { using (var reportDefinition = new FileStream("Reports\\ExampleReport.rdlc", FileMode.Open)) { var reportRenderer = new ReportRenderer("FooDisplay", reportDefinition); reportRenderer.Initialise(); var data = new List<string>(); byte[] report = reportRenderer.GetReportAsPdf(data, new { Foo = "Bar" }); Assert.IsTrue(report.Length > 0); } }
static void Main(string[] args) { Console.WriteLine("Where do you want to save your report?"); var saveLocation = Console.ReadLine(); using (var reportDefinition = new FileStream("Reports\\ExampleReport.rdlc", FileMode.Open)) { ReportRenderer renderer = new ReportRenderer("Example Report", reportDefinition); var invoices = new List<Invoice>{ new Invoice{ InvoiceNo ="00001" }, new Invoice{ InvoiceNo ="00002" }}; renderer.Initialise(); var report = renderer.GetReportAsPdf(invoices, new { HelloWorld = "hello world" }); File.WriteAllBytes(saveLocation, report); } Console.WriteLine("Report completed writing"); Console.ReadLine(); }