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

C++/CLI Discussion :

G�n�rer un document Word/Excel - Visual C++/CLI


Sujet :

C++/CLI

Vue hybride

Message pr�c�dent Message pr�c�dent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Informaticien - Profesionnal master application development
    Inscrit en
    Octobre 2011
    Messages
    47
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activit� : Informaticien - Profesionnal master application development
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2011
    Messages : 47
    Par d�faut G�n�rer un document Word/Excel - Visual C++/CLI
    Bonjour � tous,

    Je suis actuellement sur un projet en Visual C++/CLI et je dois maintenant g�n�rer un document Word et Excel � partir des donn�es de mon soft.

    Seulement je ne trouve aucun exemple ni librairie effectuant cette t�che I/O pour du .docx, .xls.

    Sauriez-vous m'orienter ?

    Merci

    (Si le point � d�j� �t� abord� merci de me reporter � la discussion, �a n'apparait pas sur les dix premi�re pages)

  2. #2
    Expert confirm�
    Homme Profil pro
    D�veloppeur informatique
    Inscrit en
    F�vrier 2005
    Messages
    5 503
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 53
    Localisation : France, Val de Marne (�le de France)

    Informations professionnelles :
    Activit� : D�veloppeur informatique
    Secteur : Conseil

    Informations forums :
    Inscription : F�vrier 2005
    Messages : 5 503
    Par d�faut
    Voici le SDK officiel pour le format d'Office2007 et sup�rieur.
    http://www.microsoft.com/en-us/downl....aspx?id=30425

  3. #3
    Membre averti
    Homme Profil pro
    Informaticien - Profesionnal master application development
    Inscrit en
    Octobre 2011
    Messages
    47
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activit� : Informaticien - Profesionnal master application development
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2011
    Messages : 47
    Par d�faut
    Citation Envoy� par bacelar Voir le message
    Voici le SDK officiel pour le format d'Office2007 et sup�rieur.
    http://www.microsoft.com/en-us/downl....aspx?id=30425
    Merci, je vais tester cela aujourd'hui.

  4. #4
    Membre averti
    Homme Profil pro
    Informaticien - Profesionnal master application development
    Inscrit en
    Octobre 2011
    Messages
    47
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activit� : Informaticien - Profesionnal master application development
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2011
    Messages : 47
    Par d�faut
    Si quelqu'un � du code d'exemple en C++/CLI ?

  5. #5
    Expert confirm�
    Homme Profil pro
    D�veloppeur informatique
    Inscrit en
    F�vrier 2005
    Messages
    5 503
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 53
    Localisation : France, Val de Marne (�le de France)

    Informations professionnelles :
    Activit� : D�veloppeur informatique
    Secteur : Conseil

    Informations forums :
    Inscription : F�vrier 2005
    Messages : 5 503
    Par d�faut
    Il est normalement assez simple de faire une traduction C# C++/CLI, non ?

  6. #6
    Expert �minent
    Avatar de M�dinoc
    Homme Profil pro
    D�veloppeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 397
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    �ge : 41
    Localisation : France

    Informations professionnelles :
    Activit� : D�veloppeur informatique
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 397
    Par d�faut
    Tr�s facile pour C# 2.0, un peu moins en C# 3.0 quand les expressions lambda apparaissent.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parl� avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  7. #7
    Membre averti
    Homme Profil pro
    Informaticien - Profesionnal master application development
    Inscrit en
    Octobre 2011
    Messages
    47
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activit� : Informaticien - Profesionnal master application development
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2011
    Messages : 47
    Par d�faut
    Citation Envoy� par bacelar Voir le message
    Il est normalement assez simple de faire une traduction C# C++/CLI, non ?
    Simple je sais pas .. J'ai pas mal de difficult� � traduire cet exemple C# en C++/CLI.

    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
     
    // Take the data from a two-dimensional array and build a table at the 
    // end of the supplied document.
    public static void AddTable(string fileName, string[,] data)
    {
        using (var document = WordprocessingDocument.Open(fileName, true))
        {
     
            var doc = document.MainDocumentPart.Document;
     
            Table table = new Table();
     
            TableProperties props = new TableProperties(
                new TableBorders(
                new TopBorder
                {
                    Val = new EnumValue<BorderValues>(BorderValues.Single),
                    Size = 12
                },
                new BottomBorder
                {
                  Val = new EnumValue<BorderValues>(BorderValues.Single),
                  Size = 12
                },
                new LeftBorder
                {
                  Val = new EnumValue<BorderValues>(BorderValues.Single),
                  Size = 12
                },
                new RightBorder
                {
                  Val = new EnumValue<BorderValues>(BorderValues.Single),
                  Size = 12
                },
                new InsideHorizontalBorder
                {
                  Val = new EnumValue<BorderValues>(BorderValues.Single),
                  Size = 12
                },
                new InsideVerticalBorder
                {
                  Val = new EnumValue<BorderValues>(BorderValues.Single),
                  Size = 12
            }));
     
            table.AppendChild<TableProperties>(props);
     
            for (var i = 0; i <= data.GetUpperBound(0); i++)
            {
                var tr = new TableRow();
                for (var j = 0; j <= data.GetUpperBound(1); j++)
                {
                    var tc = new TableCell();
                    tc.Append(new Paragraph(new Run(new Text(data[i, j]))));
     
                    // Assume you want columns that are automatically sized.
                    tc.Append(new TableCellProperties(
                        new TableCellWidth { Type = TableWidthUnitValues.Auto }));
     
                    tr.Append(tc);
                }
                table.Append(tr);
            }
            doc.Body.Append(table);
            doc.Save();
        }
    }
    J'en ai fais ceci (je montre o� le bloque pas l'enti�ret� du code):

    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
     
    // Create an empty table.
    				Table^ table = gcnew Table();
     
    				TopBorder^ topBorder = gcnew TopBorder();
    				BottomBorder^ bottomBorder = gcnew BottomBorder();
    				LeftBorder^ leftBorder = gcnew LeftBorder();
    				RightBorder^ rightBorder = gcnew RightBorder();
    				InsideHorizontalBorder^ insideHorizontalBorder = gcnew InsideHorizontalBorder();
     
    				//^ topBorder = gcnew TopBorder();
     
    				topBorder->Val = BorderValues::Dashed;
    				topBorder->Size = 24;
    				bottomBorder->Val = BorderValues::Dashed;
    				bottomBorder->Size = 24;
    				leftBorder->Val = BorderValues::Dashed;
    				leftBorder->Size = 24;
    				rightBorder->Val = BorderValues::Dashed;
    				rightBorder->Size = 24;
    				insideHorizontalBorder->Val = BorderValues::Dashed;
    				insideHorizontalBorder->Size = 24;
     
    				// Create a TableProperties object and specify its border information.
    				TableProperties^ tblProp = gcnew TableProperties(gcnew TableBorders(topBorder, bottomBorder, leftBorder, rightBorder, insideHorizontalBorder));
     
    				// Append the TableProperties object to the empty table.
    				table->AppendChild(tblProp);
    Le code se compile sans probl�me mais en revanche cel� plante sur cette ligne :

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
     
    // Create a TableProperties object and specify its border information.
    TableProperties^ tblProp = gcnew TableProperties(gcnew TableBorders(topBorder, bottomBorder, leftBorder, rightBorder, insideHorizontalBorder));
    en me disant que :

    Une exception non g�r�e du type 'System.InvalidOperationException' s'est produite dans DocumentFormat.OpenXml.dll

    Informations suppl�mentaires*: Cannot insert the OpenXmlElement "newChild" because it is part of a tree.


    Voil� o� j'en suis !

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. [XL-2007] Probl�me code VBA depuis excel pour g�n�rer un document word publipost�
    Par stechet dans le forum Macros et VBA Excel
    R�ponses: 1
    Dernier message: 05/02/2015, 10h03
  2. R�ponses: 6
    Dernier message: 25/08/2014, 16h02
  3. R�ponses: 0
    Dernier message: 26/05/2014, 09h47
  4. R�ponses: 7
    Dernier message: 09/10/2009, 14h12
  5. G�n�rer un document Word
    Par kwakanar dans le forum C++
    R�ponses: 3
    Dernier message: 08/06/2006, 13h08

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