サーバーまたはUIなしで埋め込みレポート定義からPDFを生成する方法は?

StackOverflow https://stackoverflow.com/questions/138203

  •  02-07-2019
  •  | 
  •  

質問

ReportViewerコントロールを表示せずに、スタンドアロンの実行可能ファイルでレポートを生成し、PDF(またはレポートビューアーから利用可能な他のエクスポートオプションの1つ)として出力することは可能ですか?

レポート定義は実行可能ファイルに埋め込まれ、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コントロールはWordや他のReportigサービスとはエクスポートできないため)。

.NETフレームワークとReportViewerコントロールを使用した上記のコードがC#であることを忘れていました。クイックスタートについては、 GotReportViewer をご覧ください。

.rdlcレポートをパラメーター付きでpdfに直接渡すことはできますか?レポートを取得する2つのドロップダウンリストがあります。 pdfに自動的にエクスポートするときに、パラメーターを機能させることができません。エラーは次のとおりです。Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:レポートの実行に必要な1つ以上のパラメーターが指定されていません。

reportviewerを使用するとドロップダウンリストが機能しますが、この手順をスキップします。また、パラメータがない場合は、データを直接PDFに送信することもできます。私のドロップダウンリストはddlyearとddlmonthと呼ばれます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top