Forum Moderators: open

Message Too Old, No Replies

ReportDocument - HELP!

type not defined

         

wilsonbell

10:31 pm on Jan 24, 2003 (gmt 0)



This is my first time trying to use crystal reports in the VB.Net environment.
I have included the namespace :
Imports CrystalDecisions.CrystalReports.Engine
on a webform in my application, but the reportdocument class is not being recognized so that when I dim a variable v1 as New ReportDocument, I get an error saying that the "type is not defined".

Also, FormulaFieldDefinitions is not recognized either. I don't know what I am missing, but it is frustrating because it is supposed to be relatively simple I thought.

Can anyone give me direction?

Thank you,
Wilson Bell

Xoc

6:05 am on Feb 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Might try posting on the Crystal Reports forums, here: [support.crystaldecisions.com ]

tomasz

6:58 pm on Feb 5, 2003 (gmt 0)

10+ Year Member



here is a code i use
I do not use a ReportViewer due to printing limitions , i think it is better to export it to PDF.

here is simple webservice, which accepts report file name, login info, title,report formula using , export file.

returns 'OK' if extracted

'==============

Imports System.Web.Services
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Dim oRpt As New ReportDocument()
<WebMethod()> Public Function ExportReport(ByVal ReportFileName As String, _
ByVal ExportFileName As String, _
ByVal ReportTitle As String, _
ByVal ReportFormula As String, _
ByVal ReportLogon As String) As String

Dim arrLogonInfo As String() = Split(ReportLogon, ";")
'Loads report from repository location
oRpt.Load(ReportFileName)

'single table logon ; delimited string = Server;Database;UserID;Password
Dim exportOpts As New ExportOptions()
Dim diskOpts As New DiskFileDestinationOptions()

Dim crLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
crLogonInfo = oRpt.Database.Tables(0).LogOnInfo
crLogonInfo.ConnectionInfo.ServerName = arrLogonInfo(0)
crLogonInfo.ConnectionInfo.DatabaseName = arrLogonInfo(1)
crLogonInfo.ConnectionInfo.UserID = arrLogonInfo(2)
crLogonInfo.ConnectionInfo.Password = arrLogonInfo(3)

oRpt.Database.Tables(0).ApplyLogOnInfo(crLogonInfo)

exportOpts = oRpt.ExportOptions

exportOpts.ExportDestinationType = ExportDestinationType.DiskFile
diskOpts.DiskFileName = ExportFileName
exportOpts.DestinationOptions = diskOpts
Dim sExt As String = UCase(Right(ExportFileName, 3))

Select Case sExt
Case Is = "PDF"
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat
Case Is = "DOC"
exportOpts.ExportFormatType = ExportFormatType.WordForWindows
Case Is = "XLS"
exportOpts.ExportFormatType = ExportFormatType.Excel
Case Else
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat
End Select

Dim ReportFields As FormulaFieldDefinitions = oRpt.DataDefinition.FormulaFields()

oRpt.DataDefinition.FormulaFields("ReportTitle").Text = ReportTitle
Dim sExistingFormula As String = oRpt.RecordSelectionFormula
'check for existing formula

If InStr(sExistingFormula, "{") > 0 And ReportFormula <> "" Then
oRpt.RecordSelectionFormula = oRpt.RecordSelectionFormula + " and " + ReportFormula
Else
oRpt.RecordSelectionFormula = ReportFormula
End If

Try
oRpt.Export()
ExportReport = "OK"
Catch e As Exception
Dim sMes As String = "Error: " + e.Message
ExportReport = sMes
End Try
oRpt.Close()
End Function

'==========