Is it possible for a stand alone executable to generate a report and output it as PDF (or one of the other export options available from the report viewer) without displaying the ReportViewer control?
The report definition should be embedded in the executable and should not use the Reporting Services web service.
Actually you don't need a ReportViewer at all, you can directly instantiate and use a LocalReport:
LocalReport report = new LocalReport();
report.ReportPath = "templatepath";
// or use file from resource with report.ReportEmbeddedResource
// add parameters, datasource, etc.
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string filenameExtension;
byte[] bytes;
bytes =report.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
// save byte[] to file with FileStream or something else
You don't have to show the control itself.
ReportViewer rv = new ReportViewer();
rv.LocalReport.ReportPath = "templatepath";
// or use file from resource with rv.LocalReport.ReportEmbeddedResource
// add parameters, datasource, etc.
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string filenameExtension;
byte[] bytes;
bytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
// save byte[] to file with FileStream or something else
However it can render only PDF and XLS (as ReportViewer control cannot export to Word and others as Reportig Service can).
I forgot to mention that the above code is C#, using .NET framework and ReportViewer control. Check out GotReportViewer for a quickstart.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With