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 :

Problème affichage contenu document


Sujet :

VB.NET

  1. #1
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    90
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 90
    Points : 32
    Points
    32
    Par défaut Problème affichage contenu document
    Bonjour,

    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
        Public Function PrintDoc(ByVal TemplateName As String, ByVal DataSource As DataSet, Optional ByVal Codage As TypeCodage = TypeCodage.NoCodage) As String 'ByVal CreateFile As String, Optional ByVal AskIfExist As Boolean = True,
     
            Dim StringPrintDoc As String
            Dim StringToBase64 As String
            Dim HashTable As New Hashtable()
     
            Dim StreamDocument As Stream
     
            HashTable = Me.ConversionHashTable(DataSource)
     
            Try
                Dim MS As New MemoryStream
                Dim wordDocument As WordprocessingDocument = WordprocessingDocument.Create(MS, WordprocessingDocumentType.Document)
                Dim mainPart As MainDocumentPart = wordDocument.AddMainDocumentPart()
     
                mainPart.Document = New Document()
                Dim body As Body = mainPart.Document.AppendChild(New Body())
                Dim para As Paragraph = body.AppendChild(New Paragraph())
                Dim run As Run = para.AppendChild(New Run())
                run.AppendChild(New Text("Ca fonctionne :)"))
                StreamDocument = mainPart.GetStream()
                StringToBase64 = StreamDocument.ToString()
                StringPrintDoc = EncodeTo64(StringToBase64)
                TextBox1.Text = StringToBase64
                TextBox2.Text = StringPrintDoc
            Catch ex As NullReferenceException
                Console.WriteLine(Err.Description)
            Catch ex As ArgumentException
            End Try
     
            Return StringPrintDoc
        End Function
    Al'exécution du code devrait s'afficher "Ca fonctionne" seulement j'ai ceci "MS.Internal.IO.Zip.ZipIOModeEnforcingStream" à la pace.
    Quel est le problème ?

  2. #2
    Membre éprouvé

    Homme Profil pro
    Inscrit en
    Mars 2012
    Messages
    691
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Israël

    Informations forums :
    Inscription : Mars 2012
    Messages : 691
    Points : 929
    Points
    929
    Par défaut
    Salut

    Apprend à utiliser le debugger (F8) et continue pas à pas
    ainsi tu pourras discerner le bug ou au moins à quelle ligne de ton code
    le bug se produit

  3. #3
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    90
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 90
    Points : 32
    Points
    32
    Par défaut
    Merci.
    J'ai déjà utiliser le Debuger et ça me dit juste où est l'erreur.

  4. #4
    Membre éprouvé

    Homme Profil pro
    Inscrit en
    Mars 2012
    Messages
    691
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Israël

    Informations forums :
    Inscription : Mars 2012
    Messages : 691
    Points : 929
    Points
    929
    Par défaut
    à quelle ligne ?

  5. #5
    Nouveau membre du Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Février 2012
    Messages
    90
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2012
    Messages : 90
    Points : 32
    Points
    32
    Par défaut
    J'ai trouvé la solution :

    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
        Public Function PrintDoc(ByVal TemplateName As String, ByVal DataSource As DataSet, Optional ByVal Codage As TypeCodage = TypeCodage.NoCodage) As String 'ByVal CreateFile As String, Optional ByVal AskIfExist As Boolean = True,
     
            Dim StringPrintDoc As String
            Dim StringToBase64 As String
            Dim HashTable As New Hashtable()
            Dim StreamDocument As Stream
            Dim SR As StreamReader
     
            HashTable = Me.ConversionHashTable(DataSource)
     
            Try
                Dim MS As New MemoryStream
                Dim wordDocument As WordprocessingDocument = WordprocessingDocument.Create(MS, WordprocessingDocumentType.Document)
                Dim mainPart As MainDocumentPart = wordDocument.AddMainDocumentPart()
                mainPart.Document = New Document(New Body(New Paragraph(New Run(New Text("Ca fonctionne")))))
     
                StreamDocument = mainPart.GetStream()
                SR = New StreamReader(StreamDocument)
     
                StringToBase64 = SR.ReadToEnd()
     
                StringPrintDoc = EncodeTo64(StringToBase64)
                TextBox1.Text = StringToBase64
                TextBox2.Text = StringPrintDoc
            Catch ex As Exception
                Console.WriteLine(Err.Description)
            End Try
     
            Return StringPrintDoc
        End Function
    Par contre, maintenant, j'ai une autre erreur, mon StringToBase64 est vide

Discussions similaires

  1. [Toutes versions] Problème lecture contenu document Word
    Par CTotophe85 dans le forum Word
    Réponses: 4
    Dernier message: 29/07/2014, 02h48
  2. Réponses: 2
    Dernier message: 07/11/2013, 15h35
  3. Problème affichage contenu div
    Par Nandou56 dans le forum GWT et Vaadin
    Réponses: 1
    Dernier message: 09/10/2012, 01h35
  4. BO5.1.6/Webi: problème d'affichage de document
    Par Ahkrane dans le forum Webi
    Réponses: 2
    Dernier message: 01/12/2006, 16h03
  5. [DIV] [FireFox] Problème affichage du contenu dans un div
    Par jibouze dans le forum Balisage (X)HTML et validation W3C
    Réponses: 6
    Dernier message: 24/11/2005, 11h06

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