Hi there,
I am using VB.NET2003 with CR.
I have a good working webform that exports the CR to pdf when I hit the
print button.
Now what I want is that it exports the CR to Excel instead of Pdf.
I have tried some options but it always goes wrong with the parameters.
Can anybody help me to modify my code that works for pdf so that it will
work for excel.
I really like it to be modified, so please no completely different solution
with the chance that it will not work for the parameters.
(When possible ofcourse)
This is the code:
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.CrystalReports.Engine.ReportDocum ent
Imports CrystalDecisions.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Dim BeginPeriode As Date
Dim EindPeriode As Date
BeginPeriode = Session("BeginPeriode")
EindPeriode = Session("EindPeriode")
Dim myReport As New _Rapport_KO_ZonderContract
Dim myParameterFields As New ParameterFields
Dim myParameterField As New ParameterField
Dim myRangeValues As New ParameterRangeValue
Dim myRangeValue As New ParameterRangeValue
myParameterField.ParameterFieldName = "Periode"
myRangeValue.StartValue = BeginPeriode
myRangeValue.EndValue = EindPeriode
myReport.SetParameterValue("Periode", myRangeValue)
crViewer.ReportSource = myReport
'export to pdf
Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
Dim myDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions
Dim myExportFile As String
myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
Session.SessionID.ToString & ".pdf"
myDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
myDiskFileDestinationOptions.DiskFileName = myExportFile
myExportOptions = myReport.ExportOptions
With myExportOptions
.DestinationOptions = myDiskFileDestinationOptions
.ExportDestinationType = .ExportDestinationType.DiskFile
.ExportFormatType = .ExportFormatType.PortableDocFormat
End With
Try
myReport.Export()
Catch err As Exception
Response.Write("<BR>")
Response.Write(err.Message.ToString)
End Try
Session("exportbestand") = myExportFile
End Sub
Kind regards,
Alison