Controlling PDF export filename
Folks, Our client has requested that we change the export file name (PDF and others) to match the report name. Currently, the name is based on the report's filename (eg, foo.rdl exports as foo.pdf) -- this causes problems because the same RDL is being used for a few fairly different reports. Is this controllable at all? thanks, --randy
January 18th, 2006 10:57am

If you are using the ReportViewer control, you can set the DisplayName property. This will affect the export file name and the document map root node label. If you are using direct url access to the report server, the name can't be changed. In that case, you would need to implement your own export UI that retrieved the exported report from the server and relayed it to the client with a custom content disposition header.
Free Windows Admin Tool Kit Click here and download it now
January 20th, 2006 2:30am

Hello, I need help on this isse too, it sounded thatyou somehow exported it to pdf. I am using SQL 2006 and Reporting Services 2005 and rendering report in my asp.net application. I am trying to export reports under a button click, can anyone give me a sample code? Thanks
May 25th, 2006 11:00am

Dear Brian, I am coding with C# and can not find the reportViewer's DisplayName property? Below is my code for the form that I display the reportviewer in where and what code should I insert so that I change the filename automatically? Thanks in advance. Best regards, Kaan Demirtas using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace GECKOV2 { public partial class KonfirmasyonRaporForm : Form { public KonfirmasyonRaporForm() { InitializeComponent(); } private void KonfirmasyonRaporForm_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'KonfirmasyonDataSet.KonfirmasyonVerilenOrderlar' table. You can move, or remove it, as needed. this.KonfirmasyonVerilenOrderlarTableAdapter.Fill(this.KonfirmasyonDataSet.KonfirmasyonVerilenOrderlar); this.reportViewer1.RefreshReport(); } private void KonfirmasyonRaporForm_FormClosed(object sender, FormClosedEventArgs e) { ; if (MessageBox.Show("Raporda yer alan urunlerin konfirmasyon bilgilerini gonderildi olarak isaretlemek istermisiniz?", "Konfirmasyon islemi onaylama", MessageBoxButtons.YesNo, MessageBoxIcon.Question)==DialogResult.Yes) { string konfirmeEdildiDiyeIsaretle = "update siparisler set FabrikaOnayiMusteriyeGonderildi=1 from KonfirmasyonVerilenOrderlar where siparisler.OrderID=KonfirmasyonVerilenOrderlar.KonfirmasyonVerilenOrderID"; MessageBox.Show(Program.SqlKomutIsle(konfirmeEdildiDiyeIsaretle)); } } } }
Free Windows Admin Tool Kit Click here and download it now
June 5th, 2007 11:13am

What a huge PITA! Is MS going to fix this anytime soon? This should be something that can be set regardless of whether you are using direct url access or not.
August 6th, 2007 11:29am

>> I am trying to export reports under a button click, can anybody give me a sample code? Sure. <s> Is this remote or local mode ? And did you want the output to show up in a window? In this example, it happens to be a local mode report, and I bring the PDF up in a window... it is definitely not the only way... You can see where I am setting the temporary file name on the server -- considering that the user can decide what filename to save it to on the client side, I didn't see the point of getting all excited about the server-side file name, but you'll get the picture. Also, I wrote this example for somebody else, and in that case we needed to adjust the datasource before export -- probably not true in your case, but it won't hurt to keep it in, it's not much code, and you'll get a better idea of what is really going on here, how to add in whatever you do need to add. If it turns out you're in remote mode, it's doable also. HTH, >L< Code Snippet Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim buffer As Byte(), f As String, fs As System.IO.FileStream f = System.IO.Path.GetTempFileName() System.IO.Path.ChangeExtension(f, "PDF") ' there is probably a better way to set up the rendered PDF ' for redirecting to the Response output, but this one works. ' here is the binding bit. Revise to suit your dynamic situation. ' if you aren't really dynamically binding data against one ' loaded report, but rather changing ' reports to suit the user's needs, that will work too. Dim ReportDataSourceX = New Microsoft.Reporting.WebForms.ReportDataSource() ReportDataSourceX.Name = "DataSet1_Recipient" ReportDataSourceX.Value = Me.SqlDataSource1 With Me.ReportViewer1.LocalReport .DataSources.Clear() .DataSources.Add(ReportDataSourceX) buffer = .Render("PDF", Nothing, Nothing, Nothing, Nothing, Nothing, Nothing) End With fs = New System.IO.FileStream(f, System.IO.FileMode.Create) fs.Write(buffer, 0, buffer.Length) fs.Close() fs.Dispose() Response.ContentType = "Application/pdf" Response.WriteFile(f) Response.End() System.IO.File.Delete(f) End Sub
Free Windows Admin Tool Kit Click here and download it now
August 6th, 2007 11:47am

Over 2 years later and this post still helped me; thank you!The more direct way to return the buffer returned by localreport.Render (no need to write to a temp file) is: Response.OutputStream.Write(buffer,0,buffer.length)
November 12th, 2009 1:58pm

can anyone please tell me how to set up the display name property. I have designed the layout of report in BIDS 2008 and do not find any option called Display Name. where to put all this code please suggest. Thanks for your help
Free Windows Admin Tool Kit Click here and download it now
January 3rd, 2012 4:58pm

how to use the DisplayName property? I am using BIDS2008 I have designed the reports in the BIDS without any coding at all. Please guide me how to put this property and use it for setting the name of of the pdf exported on the name of variable used to create the report. Thanks
January 3rd, 2012 5:18pm

ReportViewer.LocalReport.DisplayName
Free Windows Admin Tool Kit Click here and download it now
January 12th, 2012 10:10am

Thanks its really helpful. this.ReportViewer1.ServerReport.DisplayName="Dynamic Name";
July 25th, 2012 12:37am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics