Reporting services 如何在没有服务器或UI的情况下从嵌入式报表定义生成PDF?

Reporting services 如何在没有服务器或UI的情况下从嵌入式报表定义生成PDF?,reporting-services,Reporting Services,独立可执行文件是否可以生成报表并将其输出为PDF格式(或报表查看器提供的其他导出选项之一),而不显示ReportViewer控件 报表定义应嵌入到可执行文件中,并且不应使用Reporting Services web服务。您不必显示控件本身 ReportViewer rv = new ReportViewer(); rv.LocalReport.ReportPath = "templatepath"; // or use file from resource with rv.LocalRepor

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


报表定义应嵌入到可执行文件中,并且不应使用Reporting Services web服务。

您不必显示控件本身

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服务那样导出到Word和其他文件)


我忘了提到上面的代码是C#,使用.NET framework和ReportViewer控件。查看快速启动。

实际上,您根本不需要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

能否将.rdlc报告直接传递给带有参数的pdf?我有两个下拉列表,我拉我的报告。自动导出为pdf时,我无法使参数正常工作。以下是我得到的错误:Microsoft.ReportingServices.ReportProcessing.ReportProcessing异常:尚未指定运行报告所需的一个或多个参数


当我使用reportviewer时,DropDownList可以工作,但我想跳过这一步。如果数据没有任何参数,我也可以直接将其转换为pdf格式。我的下拉列表被称为ddlyear和ddlmonth。

+1是我要找的确切问题。我无法使用StackOverflow的搜索找到它,但这是Google上“local report pdf site:StackOverflow.com”的第一个结果。记录在案,用于呈现为Excel的格式是“Excel”,而不是“XLS”。