IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

création d'un report


Sujet :

VB.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Février 2007
    Messages
    92
    Détails du profil
    Informations forums :
    Inscription : Février 2007
    Messages : 92
    Par défaut création d'un report
    bonjour. ça fait 2 semaines que je suis coincé. je n'arrive pas à construire un état d'impression avec le report de vb2008. si quelqu'un a un tuto ou un code source, je suis preneur. j'ai fouillé partout mais en vain. j'attends que vous me donnez un tuyau pour démarrer enfin.
    merci de votre compréhension

  2. #2
    Membre averti
    Homme Profil pro
    freeLance
    Inscrit en
    Avril 2011
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Burkina Faso

    Informations professionnelles :
    Activité : freeLance
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2011
    Messages : 22
    Par défaut Creer un Etat d'impression
    slt melancolie
    Pour commencer vs devrez creer vos Etats (.rpt) à l'aide de Cristal Report.
    vs devrez creer une form et le renommer en frmViewReport.
    Ensuite Regardez dans l'onglet Outils ou Tool de ton EDI,Clique sur CristalReportViewer et place le dans ton form renommé frmViewReport.
    Faites une copie de cette fonction dans votre form frmViewReport :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
        Friend Function ViewReport(ByVal sReportName As String, Optional ByVal sSelectionFormula As String = "", Optional ByVal param As String = "") As Boolean
            'Declaring variablesables
            Dim intCounter As Integer
            Dim intCounter1 As Integer
            'Crystal Report's report document object
            Dim objReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            'object of table Log on info of Crystal report
            Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
            'Parameter value object of crystal report
            ' parameters used for adding the value to parameter.
            Dim paraValue As New CrystalDecisions.Shared.ParameterDiscreteValue
            'Current parameter value object(collection) of crystal report parameters.
            Dim currValue As CrystalDecisions.Shared.ParameterValues
            'Sub report object of crystal report.
            Dim mySubReportObject As CrystalDecisions.CrystalReports.Engine.SubreportObject
            'Sub report document of crystal report.
            Dim mySubRepDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            Dim strParValPair() As String
            Dim strVal() As String
            Dim index As Integer
            Try
                'Load the report
                objReport.Load(sReportName)
                'Check if there are parameters or not in report.
                intCounter = objReport.DataDefinition.ParameterFields.Count
                'As parameter fields collection also picks the selection
                ' formula which is not the parameter
                ' so if total parameter count is 1 then we check whether
                ' its a parameter or selection formula.
                If intCounter = 1 Then
                    If InStr(objReport.DataDefinition.ParameterFields(0).ParameterFieldName, ".", CompareMethod.Text) > 0 Then
                        intCounter = 0
                    End If
                End If
                'If there are parameters in report and
                'user has passed them then split the
                'parameter string and Apply the values
                'to their concurrent parameters.
                If intCounter > 0 And Trim(param) <> "" Then
                    strParValPair = param.Split("&")
                    For index = 0 To UBound(strParValPair)
                        If InStr(strParValPair(index), "=") > 0 Then
                            strVal = strParValPair(index).Split("=")
                            paraValue.Value = strVal(1)
                            currValue = objReport.DataDefinition.ParameterFields(strVal(0)).CurrentValues
                            currValue.Add(paraValue)
                            objReport.DataDefinition.ParameterFields(strVal(0)).ApplyCurrentValues(currValue)
                        End If
                    Next
                End If
                'Set the connection information to ConInfo
                'object so that we can apply the
                'connection information on each table in the report
                'ConInfo.ConnectionInfo.UserID = <Guengane>
                'ConInfo.ConnectionInfo.Password = <keeptRy1n9>
                'ConInfo.ConnectionInfo.ServerName = <localhost>
                'ConInfo.ConnectionInfo.DatabaseName = <Database Name>
                For intCounter = 0 To objReport.Database.Tables.Count - 1
                    objReport.Database.Tables(intCounter).ApplyLogOnInfo(ConInfo)
                Next
                ' Loop through each section on the report then look
                ' through each object in the section
                ' if the object is a subreport, then apply logon info
                ' on each table of that sub report
                For index = 0 To objReport.ReportDefinition.Sections.Count - 1
                    For intCounter = 0 To objReport.ReportDefinition.Sections(index).ReportObjects.Count - 1
                        With objReport.ReportDefinition.Sections(index)
                            If .ReportObjects(intCounter).Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
                                mySubReportObject = CType(.ReportObjects(intCounter), CrystalDecisions.CrystalReports.Engine.SubreportObject)
                                mySubRepDoc = mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)
                                For intCounter1 = 0 To mySubRepDoc.Database.Tables.Count - 1
                                    mySubRepDoc.Database.Tables(intCounter1).ApplyLogOnInfo(ConInfo)
                                Next
                            End If
                        End With
                    Next
                Next
                'If there is a selection formula passed to this function then use that
                If sSelectionFormula.Length > 0 Then
                    objReport.RecordSelectionFormula = sSelectionFormula
                End If
                'Re setting control
                rptViewer.ReportSource = Nothing
                'Set the current report object to report.
                rptViewer.ReportSource = objReport
                'Show the report
                rptViewer.Show()
                Return True
            Catch ex As System.Exception
                MsgBox(ex.Message)
            End Try
        End Function
    Pour Charger votre Etat d'Impression,vs pourrez créer un bouton Imprimer.
    Dans le bouton Imprimer instanciez votre frmViewReport,spécifiez le repertoire de vos Etats d'impression par :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    Dim objForm As New frmViewReport
            objForm.ViewReport("D:\ETAT_REPORT\Etat_Impression.rpt", , )
            objForm.Refresh()
            objForm.Show()
    ça marche bien.
    Slt

Discussions similaires

  1. Création d'un reporting sur Excel 2010
    Par ninapita dans le forum Excel
    Réponses: 1
    Dernier message: 20/06/2013, 09h45
  2. [Débutant] Création d'un report viewer
    Par Cédric0102 dans le forum C#
    Réponses: 3
    Dernier message: 03/04/2013, 14h44
  3. Réponses: 2
    Dernier message: 04/05/2011, 12h06
  4. Création planning avec report
    Par Atomix51 dans le forum Excel
    Réponses: 3
    Dernier message: 09/11/2008, 12h24
  5. [Rave Report] problème de création dynamique
    Par Nivux dans le forum Rave
    Réponses: 2
    Dernier message: 24/05/2003, 00h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo