Soyez le premier à donner votre avis sur cette source.
Snippet vu 8 048 fois - Téléchargée 15 fois
Imports busobj Public Class LanceReqBOxi '-------------------------------------------------------------------------------- '-- Cette class sert à travailler avec BoXi plus facilement -- '-- les fonctions les plus courantes sont implémentées, il sera -- '-- certainement necessaire d'en ajouter d'autres -- '-- Jacky ROCHARD Mise à jour le 20-03-2009 -- '-- -- '-- ConnBoXi() strUserID, strPass, strReferentiel, strMode, False, False -- '-- Propriété UserIDLdap,MdpLdap,Referentiel,AuthentifMode -- '-- RefreshReport() strPath, strNameDoc -- '-- Propriété NomReport,CheminReport -- '-- LesValeursATraiter() aVariables Propriété TableauVar -- '-- ExportReport() strNameOut Propriété NomFichierSortie -- '-- StopBOxi() -- '-- -- '-- EXEMPLE -- '-- Dim AppBOxi As New LanceReqBOxi -- '-- Dim LesVariables As ArrayList -- '-- LesVariables = New ArrayList -- '-- AppBOxi.UserIDLdap = "Identifiant utilisateur" -- '-- AppBOxi.MdpLdap = "Mot de passe utilisateur -- '-- AppBOxi.Referentiel = "YLA-----:----" (serveur de connexion) -- '-- AppBOxi.AuthentifMode = "LDAP" -- '-- AppBOxi.CheminReport = "Dossier ou se trouve le .rep" -- '-- AppBOxi.NomReport = "le nom du report .rep" -- '-- AppBOxi.NomFichierSortie = "dossier et nom du fichier .rep -- '-- AppBOxi.TableauVar = LesVariables (le tableau de variable) -- '-- AppBOxi.ConnBOxi() on se connecte -- '-- AppBOxi.RefreshReport() on traite les variables et on rafraichi -- '-- AppBOxi.ExportReport() on export -- '-- AppBOxi.StopBOxi() on stop BO -- '-- AppBOxi = Nothing -- '-------------------------------------------------------------------------------- Dim oBOxiApp As busobj.Application Dim oReport As busobj.Document Private strUserID, strPass, strReferentiel, strMode As String Private strPath, strNameDoc, strNameOut As String Private aVariables As ArrayList Public Property TableauVar() As ArrayList Get Return aVariables End Get Set(ByVal value As ArrayList) aVariables = value End Set End Property Public Property NomFichierSortie() As String Get Return strNameOut End Get Set(ByVal value As String) strNameOut = value End Set End Property Public Property NomReport() As String Get Return strNameDoc End Get Set(ByVal value As String) strNameDoc = value End Set End Property Public Property CheminReport() As String Get Return strPath End Get Set(ByVal value As String) strPath = value End Set End Property Public Property UserIDLdap() As String Get Return strUserID End Get Set(ByVal value As String) strUserID = value End Set End Property Public Property MdpLdap() As String Get Return strPass End Get Set(ByVal value As String) strPass = value End Set End Property Public Property Referentiel() As String Get Return strReferentiel End Get Set(ByVal value As String) strReferentiel = value End Set End Property Public Property AuthentifMode() As String Get Return strMode End Get Set(ByVal value As String) strMode = value End Set End Property Function ConnBOxi() As Boolean Try oBOxiApp = New busobj.Application oBOxiApp.Interactive = False 'Pour ne pas avoir d invite inutiles de la part de BO.' oBOxiApp.Logon(strUserID, strPass, strReferentiel, strMode, False, False) Return True Catch myerror As Exception MessageBox.Show("Erreur cl_ConnBOxi: " & myerror.Message) Return False End Try End Function Function RefreshReport() As Boolean Try oReport = oBOxiApp.Documents.Open(strPath & strNameDoc) LesValeursATraiter() oReport.Refresh() Return True Catch myerror As Exception MessageBox.Show("Erreur cl_RefreshReport: " & myerror.Message) Return False End Try End Function Private Sub LesValeursATraiter() '----------------------------------------------------------------- '-- Ici j'utilise un tableau à une dimension -- '-- on pourrait envisager un tableau à 2 dimensions -- '-- l'indice 0 contiendrait le nom de la variable du report -- '-- il suffirait de comparer les deux et affecter la valeur -- '-- en cas d'égalité. -- '-- Dans le fonctionnement actuel il mettre les valeurs dans le -- '-- même ordre que les variables du report. -- '----------------------------------------------------------------- Dim strLesVariables As String Dim i As Integer If oReport.Variables.Count <> 0 Then strLesVariables = oReport.Variables(1).Name For i = 0 To aVariables.Count - 1 oReport.Variables(i + 1).Value = aVariables(i) Next End If End Sub Function ExportReport() As Boolean '--------------------------------------------------------------- '-- Ici on pourrait traiter le format de l'export en fonction -- '-- du besoin en ajoutant une propriété à la class pour -- '-- choisir le format de sorti ex: ExportAsRtf -- '--------------------------------------------------------------- Try oReport.Reports(1).ExportAsText(strNameOut) oReport.Close() Return True Catch myerror As Exception MessageBox.Show("Erreur cl_ExportReport: " & myerror.Message) Return False End Try End Function Function StopBOxi() As Boolean Try oBOxiApp.Quit() oBOxiApp = Nothing Catch myerror As Exception MessageBox.Show("Erreur cl_ExportReport: " & myerror.Message) Return False End Try End Function End Class
Pas très observateur, tu es tenace, néanmoins !
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.