Imports CrystalDecisions.Shared
Dim strFileName As String = String.Empty
Dim exportOpts As New ExportOptions
Dim diskOpts As New DiskFileDestinationOptions
Dim excelFormatOpts As ExcelFormatOptions = ExportOptions.CreateExcelFormatOptions
Dim rpt As CrystalDecisions.CrystalReports.Engine.ReportDocument = CType(Me.crvReport.ReportSource, CrystalDecisions.CrystalReports.Engine.ReportDocument)
'stuff about the creating the excel file on the user's computer
sfdSaveFile.DefaultExt = "xls"
sfdSaveFile.AddExtension = True
'If mstrDefaultFileName <> String.Empty Then
' sfdSaveFile.InitialDirectory = Application.StartupPath 'Default directory
' strFileName = sfdSaveFile.InitialDirectory & "\" & mstrDefaultFileName.Replace(" ", "") & "_" & mstrUserID & "_" & Date.Now.ToString.Replace("/", ".").Replace(":", ".")
' sfdSaveFile.FileName = strFileName
'End If
sfdSaveFile.Title = "Select a location to save the Excel File"
sfdSaveFile.Filter = "All Files (*.*)|*.*|Excel 97-2003 (*.xls)|*.xls"
sfdSaveFile.FilterIndex = 2
boolCancel = (sfdSaveFile.ShowDialog(Me) = Windows.Forms.DialogResult.Cancel)
diskOpts.DiskFileName = sfdSaveFile.FileName
excelFormatOpts.ExcelTabHasColumnHeadings = True
excelFormatOpts.ExcelUseConstantColumnWidth = True 'each field in its own column--no merge
excelFormatOpts.ExcelConstantColumnWidth = 60
excelFormatOpts.ConvertDateValuesToString = True
excelFormatOpts.ExportPageHeadersAndFooters = ExportPageAreaKind.OnEachPage
excelFormatOpts.ShowGridLines = True
exportOpts.FormatOptions = excelFormatOpts
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile
exportOpts.ExportDestinationOptions = diskOpts
exportOpts.ExportFormatType = ExportFormatType.Excel
exportOpts.ExportFormatOptions = excelFormatOpts
99% of this came from Brian's code on how to export to Excel that was answered in a post.