Ticket Q477399
Visible to All Users

XtraReports - Custom filename when exporting via the reports toolbar

created 12 years ago

Hi,

I am trying to find a way to create a custom filename for files that are exported via the XtraReports report toolbar. I have tried all of the suggestions that I could find in other DevExpress support tickets and none of them have worked. The name of the report that I am exporting is "PerformanceXtraReport" and the filenames for the export are always PerformanceXtraReport.pdf (or appropriate extension for the file type selected). The things that I have changed that haven't had an impact on the filename are as follows:

  1. Updated the ExportOptions.PrintPreviewOptions.DefaultFileName to "Test" through the Properties menu in Visual Studio
  2. Set this.ExportOptions.PrintPreview.DefaultFileName = "Test"; in the report's initializer in the report file's code-behind file
  3. Set this.PerformanceReportViewer.Report.ExportOptions.PrintPreview.DefaultFileName = "Test"; (where PerformanceReportViewer is of type XtraReports.Web.ReportViewer) in the Page_Load event for the code-behind for the ascx file that the Report viewer appears on
  4. Set report.ExportOptions.PrintPreview.DefaultFileName = "Test"; (where report is of type PerformanceXtraReport) when creating an instance of the report and settings it to the PerformanceReportViewer.Report property.

I have done all 4 of these and the file name continues to default to PerformanceXtraReport.pdf when the file is exported using the report's toolbar. I have founds ways that look like they will work using a separate button on the page and using a MemoryStream and the ExportToPdf() method but I would like to continue using the report toolbar so that way of doing it won't work for me.

Any ideas?

Thank you in advance for your help.

Answers approved by DevExpress Support

created 12 years ago (modified 12 years ago)

Hi Layne,
Please use the XtraReport.Name property to accomplish this task. Here is some sample code:

C#
... XtraReport1 rep = new XtraReport1(); rep.Name = "1234"; ReportViewer1.Report = rep; ...

Thanks,
Elliot

    Show previous comments (6)

      It appears the assignment to DisplayName must be BEFORE the call to CreateDocument. If you assign DisplayName after CreateDocument it is ineffective.

      DevExpress Support Team 11 years ago

        Hi Nolan,

        When you call the CreateDocument method, you force the Report instance to generate the resulting document based on the current Report state. Once the document is generated, changing any report properties does not affect the document until you call the CreateDocument method again.

        That is why changing the DisplayName property value after calling the CreateDocument method does not work.

        I hope my explanation is clear.

          Works fine. Thanks a lot

          Other Answers

          created 6 years ago (modified 6 years ago)

          ASPxGridview_exporter.FileName = HttpUtility.UrlEncode(nameyouwant).Replace("+", " ");

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.