Click here to Skip to main content
15,917,862 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I want to export a crystal report to pdf format . I want to put the name of the report as default filename while I exporting. In my case I set report title using the code as below
reportdocument.SummaryInfo.ReportTitle = "01-02-2013 to 20-04-2013"
So it put date range as the default filename, instead of putting the actual file name.
I want to keep the report title to show as the report header, but at the same time I want to show the report file name as the default name while exporting. How to solve this, please help?
Kschuler 2-Jul-13 14:46pm    
If you are using a save document dialog control, then just set the .FileName to whatever in you want before you call it via .ShowDialog.
Reji Ab 2-Jul-13 15:10pm    
Thanks,. But I am using the built in dialog in crystal report viewer. So I don't have any control on it
santosh_131 3-Jul-13 15:04pm    
did you check rptDoc.ExportToHttpResponse,try the following
rptDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, this.Page.Response, true, fileName);

If you are using the default dialog for exporting, i think it will not be possible,

However you can check the events that are generated in the Crystal Reports code behind file to check whether any event is fired at the time of exporting the report.

If this is not there, then instead of using the default toolbar button for export, you have to create your own code for exporting it to PDF, there you can specify the file name while exporting.

Somewhat like this.

Dim myRpt As New ReportDocument
CrystalReportViewer1.ReportSource = myRpt
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New _
Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = <fullpathwithfilename>
CrExportOptions = myRpt.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With

Hope this helps.
Share this answer
You may set the Report title which your Default File name should be..

cr.SummaryInfo.ReportTitle = "Default File Name"
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900