Forum Moderators: open
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
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
'==========