How can I change the default filename to which the report will be exported? I need to change this at run time, based on which report they have run and on which products.
Is there a way to set this? Right now, it always exports to "Report.pdf" and that isn't going to work for this project.
I looked in the documentation, and in this forum, and have come up empty for setting the filename when the ReportViewer is being used (direct export to PDF is covered quite nicely here in the forum, however.)
Thanks!
15 Answers, 1 is accepted
The default name of the file, when exporting a report, is the name of the report class plus the appropriate extension. As of now, there is not way to override that name at runtime. You can create different report classes with different names that inherit from your original report, and each of them will be exported with its appropriate name.
We will consider adding this functionality in a future version. There is no workaround I can suggest at the present moment.
Best wishes,
Rossen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
To our great regret we didn't got enough time and postponed the feature for the next version, due at the end of the year. Sorry for the delay.
Kind regards,
Svetoslav
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Has this feature has been implemented in the latest version? (i.e. changing the export file name at runtime). If so, how do you do it?
Thanks,
-Gary
You should use the DocumentName property of the report for this purpose.
Best wishes,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Hi,
As you suggested, the DocumentName property not working I am using Version 17.023.118 in Telerik reporting designer.
Hi Brajalal,
Indeed, when you export from the Standalone Report Designer, the default name of the document is the Name of the Report.
The DocumentName is used when you export from the viewers.
Hello,
I know this post is quite old, but this is still not working for me. I tried setting Report.DocumentName from C# but export still saves the file using the class name in my report. I'm changing Report.DocumentName inside the Report_ReportNeedDataSourceEvent. Should that work fine?
I'm using Telerik Reports version 13.1.19.618 (runtime version v4.0.30319)
Thanks!
Hello Andrew,
The approach you have found is the recommended one.
Basically, we advise avoiding modifying reports' structures in events. You should be able to set the DocumentName property in the NeedDataSource event. For more details, please check Changes on items in report events are not applied and Modifying or Creating a report at Run-Time KB articles.
Regards,
Progress Telerik
Andrew,
Here's the vb code we use. It works. We make a reportbook since sometimes we add cover pages or additional reports and set the filename there. If you only have a single report you can ignore the first IF statement. Hope it helps
If
_CoverType > 0
Then
Select
Case
RepType
Case
5, 22, 27, 30, 34, 36, 38, 42, 43, 46, 70
' portrait
CoverPage =
New
Reporting.CoverPage(_dtc, stitle, bmp)
Case
Else
CoverPage =
New
Reporting.CoverPageLandscape(_dtc, stitle, bmp)
End
Select
End
If
Dim
repbook
As
New
Telerik.Reporting.ReportBook
If
_CoverType > 0
Then
repbook.Reports.Add(CoverPage)
End
If
repbook.DocumentName =
"MyPDFFileName"
'<---This is your PDF file name
repbook.Reports.Add(thereport)
thereport.DocumentName = repname
myreport.Report = repbook
' thereport
End
If
Hello Andrew,
When you set the DocumentName property, the value is not used when exporting from the Standalone report designer. The report filename will be used instead. However, if you integrate the report in some of the report viewers then the value of the property will be taken into account and the report will be saved with the new name.
Regards,
Neli
Progress Telerik