在一个报告查看器 (rdlc) 中呈现多个报告

在一个报告查看器 (rdlc) 中呈现多个报告

问题描述:

使用 ReportViewer 我想使用 rdlc 文件在一个 pdf 中呈现多个报告.

Using ReportViewer i want to render multiple reports in one pdf using rdlc file.

Byte pdfByte = Byte();
pdfByte = ReportViewer.LocalReport.Render("PDF", Nothing, mimeType, encoding, extensions, stream, warning);
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=myfile." + extension);
Response.BinaryWrite(pdfByte);
Response.Flush();
Response.End();

这只会生成一份 pdf 报告.但我想在一个 pdf 文件中呈现多个报告.

This only generate only one report in pdf. But i want to get multiple reports rendered in one pdf file.

请帮帮我.

最简单的方法是将所有报表设计为一个主报表的子报表.然后,默认情况下,所有报告都将以一个 PDF 格式呈现.

The easiest way to do this would be to design all the reports to be sub-reports of one main report. Then, by default all reports will be rendered in one PDF.

这里有几个演示子报告的视频:第 1 部分&第 2 部分

There's a couple of videos demonstrating sub-reports here: Part 1 & Part 2

如果您无法将报告组织成子报告,那么 &坏消息...

If you can't structure your reports into sub-reports, then there is good & bad news...

坏消息:在框架中没有直接的方法来实现这一点.

Bad news: there's no straightforward way to achieve this in the framework.

好消息:可以使用 PDFsharp 3rd-party library.它是开源的免费使用,即使在商业应用中也是如此.

Good news: it's possible by using the PDFsharp 3rd-party library. It's open source & free to use, even in commercial applications.

参见上一个问题:渲染多个 .rdlc 报告使用 PDFSharp 转换为单个 PDF

祝你好运!