コンソール アプリケーションを使用して .rdlc を .pdf 出力にレンダリングするために、この Web サイトのいくつかの記事を参照しました。 string[] args = {string[0]}) 28 行目 私のクラスは以下のとおりです。
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 に変更し、.rdlc アイテムをプロジェクトに追加しました。