cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Report Viewer Export options

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (2)

Answers (2)

Former Member
0 Kudos

No reply for over a month. Closing

former_member184995
Active Contributor
0 Kudos

Unfortunately that list seems to be hard coded into the viewer and can not be changed in CR 2008.

Former Member
0 Kudos

We are using CR 2008 , we want to change the dropdown list of export in crystal report viewer.

i found in IIS one fie export.js , after change in export.js file. the drop down list is same.

i do not want create custom button on web, i want ot use same toolbar

help me????????

Gaurav Maheshwari

Former Member
0 Kudos

Hello Gaurav,

Its neither recommended to make any changes in the viewer control nor possible using CR api's. This is just to ensure the stability of the viewer.

Just so that you are aware, kindly post new questions in new posts rather than appending in closed posts for better response.

Thanks.

ido_millet
Active Contributor
0 Kudos

I've modified the export options dialog to control what export formats are available in my Crystal 2008 Viewer, so this is clearly possible and there are no negative impacts on stability.

However, afaik, the only way to achieve this is by modifying the toolbar in code.

Former Member
0 Kudos

share or any reference link to modify the toolbar

do you have sample code.

former_member183750
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Is that possible to set a default directory with this apporach when user click the "export" button?

I have to keep all export types.

I was able to replace the export button with my own button but not sure what i need to do next.

Help me please.