on 04-15-2009 4:38 AM
In the toolbar of Crystal Report Viewer, there is export button, click it it will pop-up the file dialog for you to choose the export format and dist file location.
the default(first choice) export format in CR2008 is ".rpt", , how can I set the default export format to ".pdf"?
Thanks for help.
Hi Dennis,
You will need to create your own export button and use our API's to set the format and destination options.
We can export report through this code:
crReportDocumentObject.ExportToDisk(ExportFormatType.PortableDiskFormat,"c:
temp
myRpt.pdf");
Change the format type as per your requirement.
Your question is answered in this [thread|;
Regards,
Shweta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No reply for over a month. Closing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Unfortunately that list seems to be hard coded into the viewer and can not be changed in CR 2008.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Remove the viewer Export button from the toolstrip
Add a new Export button
On click event of the new Export button, present the user with custom export form
Use the following sample code
Private Sub frmReportPreview_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ts As ToolStrip
Dim currentExportButton As ToolStripButton
Dim newExportButton As ToolStripButton
' Replace the export button with our own export button so we can handle the event ourselves
ts = DirectCast(CRViewer.Controls(4), ToolStrip)
currentExportButton = DirectCast(ts.Items(0), ToolStripButton)
ts.Items.Remove(currentExportButton)
newExportButton = New ToolStripButton("", My.Resources.Export, AddressOf ExportButton_Click)
newExportButton.ToolTipText = "Export report to disk"
ts.Items.Insert(0, newExportButton)
End Sub
Create windows form 'frmReportExport' that contains the export file types and their order, then use the following code:
Private Sub ExportButton_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim frmExport As frmReportExport
' Allow the user to specify options such as the name of the file and format before exporting.
frmExport = New frmReportExport
frmExport.Report = Report
frmExport.ShowDialog()
End Sub
Then use the code below to run the export from the custom report export windows form.
Report.ExportToDisk(exportFormat, fileExport.SelectedFilename)
Please do note. This is an unsupported, undocumented hack of the viewer. This may work for your current app, but you risk that the same approach may not work in future versions of the viewer...
Ludek
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.