D
douglas
I am new to using Visual Basic.Net 2005. I want to pass a crystal report
object between two different click events. Below is my my code the way it
currently exists.
Can you tell me how to change the code so that the click events would be
aware of the crystal report object?
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class cryClass
Dim cryRpt As New ReportDocument
Dim excelFile As String = "c:\crystalExport.xls"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cryRpt As New ReportDocument
cryRpt.Load("C:\crystalreport.rpt")
CrystalReportViewer1.ReportSource = cryalRpt
CrystalReportViewer1.Refresh()
Try
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New
CrystalDecisions.Shared.DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New
CrystalDecisions.Shared.ExcelFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = excelFile
CrExportOptions = cryalRpt.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.Excel
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
cryalRpt.Export()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
object between two different click events. Below is my my code the way it
currently exists.
Can you tell me how to change the code so that the click events would be
aware of the crystal report object?
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class cryClass
Dim cryRpt As New ReportDocument
Dim excelFile As String = "c:\crystalExport.xls"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim cryRpt As New ReportDocument
cryRpt.Load("C:\crystalreport.rpt")
CrystalReportViewer1.ReportSource = cryalRpt
CrystalReportViewer1.Refresh()
Try
Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New
CrystalDecisions.Shared.DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New
CrystalDecisions.Shared.ExcelFormatOptions()
CrDiskFileDestinationOptions.DiskFileName = excelFile
CrExportOptions = cryalRpt.ExportOptions
With CrExportOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.Excel
.DestinationOptions = CrDiskFileDestinationOptions
.FormatOptions = CrFormatTypeOptions
End With
cryalRpt.Export()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub