Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Crystal Report Viewer - Programmatically restricting File Format options

In Crystal Reports Viewer (2008) for ASP.Net, when you click on the Export button, the Export dialog shows up with File Format options:

  • Crystal Reports (RPT)
  • PDF
  • Microsoft Excel(97-2003)
  • Microsoft Excel(97-2003) Data-Only
  • Microsoft Word (97-2003)
  • Microsoft Word (97-2003) Editable
  • Rich Text Format (RTF)
  • XML

etc..

Does anyone know how to remove some of these options so that end users wouldn't see it?

like image 734
arakkots Avatar asked Feb 28 '23 11:02

arakkots


2 Answers

We've ran into this same issue and ended up rolling our own export page and limited the selection there.

It works great, but I would have expected more from Crystal Reports!

like image 99
mattruma Avatar answered Apr 13 '23 00:04

mattruma


From what I was able to find, you could try to create your own export button option, removing the given button option and adding your own to the asp page. You would need to start by dragging the button onto the page and double clicking it to auto generate the code. From there add the code

crystalReportViewer1.ExportReport ()  

Once this code is in it will use the default settings for the export options, however if you want to change the export options within that button then you have to manually code it.

' Declare variables and get the export options.
Dim exportOpts As New ExportOptions()
Dim diskOpts As New DiskFileDestinationOptions()
Dim excelFormatOpts As New ExcelFormatOptions()
exportOpts = Report.ExportOptions

' Set the excel format options.
excelFormatOpts.ExcelTabHasColumnHeadings = true

exportOpts.ExportFormatType = ExportFormatType.Excel
exportOpts.FormatOptions = excelFormatOpts

' Set the export format.
exportOpts.ExportFormatType = ExportFormatType.Excel

exportOpts.ExportDestinationType = ExportDestinationType.DiskFile

' Set the disk file options.
diskOpts.DiskFileName = fileName
exportOpts.DestinationOptions = diskOpts

Report.Export()

MSDN SITE

This link gives you the same code posted above. It show how to do it in Visual Basic code. therefor in your aspx.vb code you would have to manually enter the the types of formats you want.

like image 22
Justin Gregoire Avatar answered Apr 13 '23 00:04

Justin Gregoire