独立可执行文件是否可以生成报告并将其输出为PDF(或报告查看器中提供的其他导出选项之一)而不显示ReportViewer控件?

报告定义应嵌入可执行文件中,不应使用Reporting Services Web服务。

有帮助吗?

解决方案

实际上你根本不需要ReportViewer,你可以直接实例化并使用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

其他提示

您不必自己显示控件。

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

但是它只能呈现PDF和XLS(因为ReportViewer控件无法像Reportig Service那样导出到Word和其他人)。

我忘了提到上面的代码是C#,使用.NET框架和ReportViewer控件。查看 GotReportViewer 快速入门。

您可以直接将.rdlc报告传递给带参数的pdf吗?我有两个下拉列表,我提取报告。在自动导出为pdf时,我无法使参数生效。这是我得到的错误:Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:尚未指定运行报告所需的一个或多个参数。

当我使用reportviewer时,下拉列表会起作用,但我想跳过此步骤。如果它没有任何参数,我也可以将我的数据直接转到pdf。我的下拉列表被称为ddlyear和ddlmonth。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top