简体   繁体   English

导出时如何在报告查看器中设置其他名称而不是默认 pdf 文件名?

[英]How do I set other name instead of default pdf file name in report viewer while exporting it?

i have used report viewer for one of my website page and it's working fine but when i go for export , the exported file name is report4.pdf ,but i don't want that i want to give some other name instead of report4.pdf.我在我的一个网站页面上使用了报告查看器,它工作正常,但是当我进行导出时,导出的文件名为 report4.pdf,但我不希望我想给出其他名称而不是 report4.pdf . how can i do this, Please help.我该怎么做,请帮忙。

ReportViewer1.LocalReport.DisplayName = "Your Other Name Goes Here";

它仅适用于 ExportDialog 而不适用于 PrintDialog。

Its Just one line of Code.它只是一行代码。 Thats it.就是这样。 RptViewer.ServerReport.DisplayName = "Your File Name Goes Here"; RptViewer.ServerReport.DisplayName = "你的文件名在这里";

frmReportViewerX.reportViewer1.LocalReport.DisplayName = "报告名称";

I hope you are using SSRS report.我希望您正在使用 SSRS 报告。
Export option takes the SSRS file name to create pdf file.导出选项采用 SSRS 文件名来创建 pdf 文件。
Ex: if you have SSRS file somereport.rdl then when you export the report, pdf file name becomes somereport.pdf例如:如果您有 SSRS 文件 somereport.rdl 那么当您导出报告时,pdf 文件名变为 somereport.pdf

You can change the export file name as follows您可以按如下方式更改导出文件名

    1. Rename the rdl name 1.重命名rdl名称
    2. Set 'DisplayName' property of the RDL. 2. 设置 RDL 的“DisplayName”属性。

Add a button for download and write code to render the report and write to the stream.添加用于下载和编写代码以呈现报告并写入流的按钮。 Something like:就像是:

byte[] bytes = ReportViewer1.ServerReport.Render(filetype, null, out mimeType, out encoding, out extension, out streamids, out warnings);
context.Response.BinaryWrite(bytes);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM