MicrosoftReport

A class to assist in creating Microsoft Reports.

Constructors

public class MicrosoftReport

Delegates

public event EventHandler<Microsoft.Reporting.WebForms.SubreportProcessingEventArgs> SubreportProcessing

Properties

public enum OutputFormats { PDF, Word, Excel, Image }
public class ReportOutput(string valueToEncrypt)
public byte[] RenderedBytes

The output of the report.

public string MimeType

The MimeType of the report.

public Warning[] Warnings

Any returned warnings.

Methods

public ReportOutput RenderReport(string reportPath, string dataSourceName, object dataSource, OutputFormats outputFormat = OutputFormats.PDF, List<ReportParameter> parameters = null)

Renders a report with a single data source.

string reportPath

The path to the RDLC report to render.

string dataSourceName

The datasource name in the RDLC to update.

object dataSource

The data to put in the report.

OutputFormats outputFormat
Default: OutputFormats.PDF

The output format for the report.

List<ReportParameter> parameters
Default: null

Any parameters to be passed to the report.

public ReportOutput RenderReport(string reportPath, List<ReportDataSource> dataSources, OutputFormats outputFormat = OutputFormats.PDF, List<ReportParameter> parameters = null)

Renders a report with a one or more data sources.

string reportPath

The path to the RDLC report to render.

List<ReportDataSource> dataSources

A list of data sources to add to the report.

OutputFormats outputFormat
Default: OutputFormats.PDF

The output format for the report.

List<ReportParameter> parameters
Default: null

Any parameters to be passed to the report.

public static void SetSubreportDataSource(Microsoft.Reporting.WebForms.SubreportProcessingEventArgs e, object dataSource, string name)

Set the sub report data source from within the event.

Microsoft.Reporting.WebForms.SubreportProcessingEventArgs e

The event args passed through from the RDLC processing.

object dataSource

A data source to add to the sub report.

string name

The data source name to update in the sub report.

Example

C#
public class MyClass : Controller
{
private MicrosoftReport mr = null;

public ActionResult MyReport()
{
var data = new DataSet();
... // fill data
mr = new MicrosoftReport();
mr.SubreportProcessing += Mr_SubreportProcessing;
var pdf = mr.RenderReport(Server.MapPath("~/Rdlc/MyReport.rdlc"), "dsMyDataSet", data);
... // Email the result if needed.
return File(pdf.RenderedBytes, pdf.MimeType);
}

private void Mr_SubreportProcessing(object sender, Microsoft.Reporting.WebForms.SubreportProcessingEventArgs e)
{
switch (e.ReportPath)
{
case "MySubReportName":
var data = new DataSet();
... // fill data
MicrosoftReport.SetSubreportDataSource(e, data, "dsMySubDataSet");
}
}

}