我已经在本网站中使用控制台应用程序将.pdf输出的.rdlc渲染为一些文章。对C#.net新建立的应用程序与下面的应用程序相同给出了一个错误,说 : !> Rdclrender.exe Rdclrender.Program.Main(字串[] args = {串[0]})线28 我类如下给出:将RDLC渲染为pdf输出控制台应用程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Reporting.WinForms;
namespace Rdclrender
{
class Program
{
static void Main(string[] args)
{
// Variables
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
// Setup the report viewer object and get the array of bytes
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = "Report.rdlc";
byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
using (System.IO.FileStream fs = new System.IO.FileStream("output.pdf", System.IO.FileMode.Create))
{
fs.Write(bytes, 0, bytes.Length);
}
// Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
/* Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + extension);
Response.BinaryWrite(bytes); // create the file
Response.Flush(); // send it to the client to download*/
}
}
}
这是创建的.rdl PDF的方式?我已经将我的.rdl重命名为手动添加.rdlc项目。
是的,我在WinForms项目中也采用了同样的方式,我们也使用客户端报告。 – Dannydust
@Dannydust你可以弄清楚我提到的错误是什么?我想将报告本地保存到光盘。不能使用报告查看器显示。它应该是一个后台进程。 – flute
你不能调试你的应用程序吗?真的很难说出了什么问题。如果你可以发布一个异常,这将是很好的。但有两个问题:您是否有一个名为“Report.rdlc”的现有报告文件?如果是的话,你可以把完整的路径放在那里。即viewer.LocalReport.ReportPath = @“c:\ myfolder \ Report.rdlc”; – Dannydust