Skip to Content
0
Former Member
Jan 09, 2008 at 04:02 PM

Printing a report from BusinessObject Enterprise using .net

16 Views

Post Author: BrianHetman

CA Forum: .NET

I'm trying to create a .net app that will allow a user to print a report from the BusinessObject Database. Below is the code that I'm trying to use. I found this code in download of "Business Objects Support - EnterpriseXINetSamples.zip". The project from that sample group is ENTXI_vbnet_rpt_SchedulePrinter. The problems I'm having are:

1) Imports CrystalDecisions.Enterprise.Desktop. - Cannot be found. I've tried to add it as a reference, but still cannot locate it.

2) Dim ceReport As New report & ceReport = CType(ceReportObject, Report) - Type 'report' is not defined

3) Dim cePrinterOptions As ReportPrinterOptions - Type 'reportPrinterOptions' is not defined

4) .PageLayout = CeReportLayout.ceReportFileSettings - Name ceReportLayout is not declared

It's possible that 2, 3 & 4 are all a result of 1.

Development environment: Visual Studio 2005, XP sp2, Business Object XI Crystel Reports Server.Any suggestions would be greatly appreaciated. Fixes for this code or suggestions on a different/better method of printing a report. Thanks!

Imports CrystalDecisions.Enterpriseimports CrystalDecisions.Enterprise.DesktopImports CrystalDecisions.CrystalReports.EngineImports CrystalDecisions.Shared

Public Class frmRunCR Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents CRDoc As CrystalDecisions.CrystalReports.Engine.ReportDocument <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Dim configurationAppSettings As System.Configuration.AppSettingsReader = New System.Configuration.AppSettingsReader Me.CRDoc = New CrystalDecisions.CrystalReports.Engine.ReportDocument Me.SuspendLayout() ' 'CRDoc ' Me.CRDoc.FileName = CType(configurationAppSettings.GetValue("CRDoc.FileName", GetType(String)), String) ' 'frmRunCR ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(216, 45) Me.Name = "frmRunCR" Me.Text = "Run Crystal Report" Me.ResumeLayout(False)

End Sub#End Region Private Sub frmRunCR_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim serverName As String = Nothing Dim myInfoStore As InfoStore Dim sQuery As String Dim ceReportObjects As InfoObjects Dim ceReportObject As InfoObject Dim ceReport As New report Try serverName = "SRVUSE747N7F9" Dim mySessionMgr As SessionMgr = New SessionMgr() Dim myEnterpriseSession As EnterpriseSession = mySessionMgr.Logon( _ "administrator", "password", serverName, "secEnterprise") Dim myEnterpriseService As EnterpriseService = myEnterpriseSession.GetService("InfoStore") myInfoStore = New InfoStore(myEnterpriseService) sQuery = " SELECT SI_ID FROM CI_INFOOBJECTS WHERE SI_KIND = 'CrystalReport' and SI_ID = '1899'" ceReportObjects = myInfoStore.Query(sQuery) If ceReportObjects.Count > 0 Then ceReportObject = ceReportObjects.Item(1) ceReport = CType(ceReportObject, Report) Dim ceSchedulingInfo As SchedulingInfo ceSchedulingInfo = ceReport.SchedulingInfo 'run the report right now ceSchedulingInfo.RightNow = True 'run the report once only ceSchedulingInfo.Type = CeScheduleType.ceScheduleTypeOnce 'Set the ReportPrinterOptions for the report Dim cePrinterOptions As ReportPrinterOptions cePrinterOptions = ceReport.ReportPrinterOptions With cePrinterOptions .Copies = 1 .Enabled = True .FromPage = 1 .ToPage = 1 .PrinterName = "LEX01" ' this setting is mandatory .PageLayout = CeReportLayout.ceReportFileSettings End With 'Schedule the report myInfoStore.Schedule(ceReportObjects) MsgBox("Report Scheduled Successfully with an Object ID of : " + ceReportObject.Properties("SI_NEW_JOB_ID").ToString) Else 'no objects returned by query MsgBox("No report objects found by query <br>") MsgBox("Please click <a href='Index.aspx'>here</a> to return to the logon page.<br>") End If MsgBox(ceReportObjects.Count) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "First failed") End Try End End SubEnd Class