I am trying to create a page to export a report to a pdf. I am using the same code I used in Visual Studio 2003, but it can't find the report class. Is it because the rpt file is not in the same namespace as the export code Here is my code. Is there an easier way to do this in 2005

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

Imports System.IO

Namespace DocumentComments

Partial Class pdfActivityReport

Inherits System.Web.UI.Page

Dim oRpt As New rptActivityReport()

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

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.


Dim ActivityReport As New dsActivityReport

Dim ta As New dsActivityReportTableAdapters.Get_ActivityReportTableAdapter

ta.Fill(ActivityReport.Get_ActivityReport, "1/1/2007", "1/11/2007 11:59 PM")

oRpt.datasource = ActivityReport

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here


End Sub

Sub ExportReport()

' ********************************

'Check to see if the application directory has a subdirectory called "Exported".

'If not, create the directory since exported files will be placed here.

'This uses the Directory class of the System.IO namespace.

' First we must create a new instance of the diskfiledestinationoptions class and

' set variable called crExportOptions to the exportoptions class of the reportdocument.

Dim crDiskFileDestinationOptions As DiskFileDestinationOptions = New DiskFileDestinationOptions()

Dim crExportOptions As ExportOptions = oRpt.ExportOptions

'Export to PDF

'append a filename to the export path and set this file as the filename property for

'the DestinationOptions class

crDiskFileDestinationOptions.DiskFileName = TEMP_DIRECTORY & "ActivityReport.pdf"

'set the required report ExportOptions properties

With crExportOptions

.DestinationOptions = crDiskFileDestinationOptions

.ExportDestinationType = ExportDestinationType.DiskFile

.ExportFormatType = ExportFormatType.PortableDocFormat

End With

'Once the export options have been set for the report, the report can be exported. The Export command

'does not take any arguments


' Export the report


Catch err As Exception




Dim file As System.IO.FileInfo = New System.IO.FileInfo(TEMP_DIRECTORY & "ActivityReport.pdf") '-- if the file exists on the server


End Try

End Sub

End Class

End Namespace

Re: Crystal Reports for Visual Studio Exporting to Excel Using Old Code


Web applications in VS 2005 no longer use or create the class files for reports. You need to use the ReportDocument object instead.

Dim myReport As new ReportDocument()
myReport.Load(Server.Mappath("myReport.rpt") 'this will work if your report is in the root directory of the web application

From here, you can treat the variable myReport like you did before when using the class.

Re: Crystal Reports for Visual Studio Exporting to Excel Using Old Code


I was using the datasource property to set the datasource of the ReportDocument. Apparently this is no longer supported either. What is the best way to specify the datasource at runtime

Re: Crystal Reports for Visual Studio Exporting to Excel Using Old Code


You should be using the method SetDatasource off of the ReportDocument.