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++Builder Discussion :

Problems with ExcelApplication1->Workbooks->Open


Sujet :

C++Builder

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Inscrit en
    Mai 2007
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 2
    Par défaut Problems with ExcelApplication1->Workbooks->Open
    Hey, I have problem in C++ builder 6.0. I don't know how to open ***.xlt(excel workbooks). Please help.

    Error :

    [C++ Error] Unit1.cpp(28): E2285 Could not find a match for 'Workbooks::Open(char *,OleVariant,OleVariant,OleVariant,OleVariant,OleVariant,OleVariant,
    OleVariant,OleVariant,OleVariant,OleVariant,OleVariant,OleVariant,
    OleVariant,OleVariant,int)

    Code :

    void __fastcall TForm1::Button1Click(TObject *Sender)
    {


    int a = 50;
    ExcelApplication1->Connect();
    ExcelApplication1->set_Visible(true, true);
    ExcelApplication1->Workbooks->Open("C:\g1.xlt", EmptyParam, EmptyParam, EmptyParam, EmptyParam,
    EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
    EmptyParam, EmptyParam, EmptyParam, 0);


    ExcelWorkbook1->ConnectTo(ExcelApplication1->ActiveWorkbook);
    ExcelWorksheet1->ConnectTo(ExcelApplication1->ActiveSheet);

    ExcelWorksheet1->Cells->set_Item(Variant(1), Variant(1),Variant(WideString("Tekst")) );
    ExcelWorksheet1->Cells->set_Item(Variant(2), Variant(1),Variant(WideString(a)) );


    }


    Thanks.

  2. #2
    Membre éprouvé
    Avatar de Sunchaser
    Homme Profil pro
    OPNI (Objet Programmant Non Identifié)
    Inscrit en
    Décembre 2004
    Messages
    2 059
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : OPNI (Objet Programmant Non Identifié)
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : Décembre 2004
    Messages : 2 059
    Par défaut
    Hi,

    May be you should take a look here : F.A.Q

    Remember please that you're on a french site, and that you should try to translate your questions ...

    By,

  3. #3
    Rédacteur
    Avatar de blondelle
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    2 738
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 2 738
    Par défaut
    Salut techSoul:
    J'espere que tu pourra traduire car ce Forum est francais je te donne un lien sur le site pour l'exemple:
    Je te conseille d'utiliser OleExcel ou tu trouvera plus d'informations et de morceaux de code

  4. #4
    Nouveau candidat au Club
    Inscrit en
    Mai 2007
    Messages
    2
    Détails du profil
    Informations forums :
    Inscription : Mai 2007
    Messages : 2
    Par défaut
    Variant vMSExcel;
    Variant vFileName, vXLWorkbooks, vXLWorkbook;

    vFileName = "c:\\g1.xls";
    vXLWorkbooks = vMSExcel.OlePropertyGet("Workbooks"); // stop here. Error
    vXLWorkbook = vXLWorkbooks.OleFunction("Open", vFileName);
    }

    http://lfe.developpez.com/Excel/

    It's very intresting syntax. I don't understand. See this :

    vXLWorkbook = vXLWorkbooks.OleFunction("Open", vFileName);

    &

    ExcelApplication1->Workbooks->Open();


    Sunchaser sorry, I don't have good French dictionary. I'm from Lithuania and can writing just English or Russian.

  5. #5
    Rédacteur
    Avatar de blondelle
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    2 738
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 2 738
    Par défaut
    Le code pour ouvrir et rendre visible Excel:
    Le .cpp
    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
    //---------------------------------------------------------------------------
    #include <vcl.h>
    #pragma hdrstop
    #include <utilcls.h> //  <--- ne pas oublier
    #include "Unit1.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
            : TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
    try
     {
        vMSExcel = Variant::GetActiveObject("Excel.Application");
    }
    // une exception est levee ici si Excel n'est pas cree elle n'apparait quand
    // mode pas a pas relancer par RUN
     catch(...)
     {
        vMSExcel = Variant::CreateObject("Excel.Application");
    }
    vMSExcel.OlePropertySet("Visible", true);
    vFileName = "c:\\classeur1.xls";
    vXLWorkbooks = vMSExcel.OlePropertyGet("Workbooks");
    vXLWorkbook = vXLWorkbooks.OleFunction("Open", vFileName);
    }
    Le .h
    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
     
    //---------------------------------------------------------------------------
    #ifndef Unit1H
    #define Unit1H
    //---------------------------------------------------------------------------
    #include <Classes.hpp>
    #include <Controls.hpp>
    #include <StdCtrls.hpp>
    #include <Forms.hpp>
    //---------------------------------------------------------------------------
    class TForm1 : public TForm
    {
    __published: // IDE-managed Components
            TButton *Button1;
            void __fastcall Button1Click(TObject *Sender);
    private: // User declarations
    public:  // User declarations
            __fastcall TForm1(TComponent* Owner);
    Variant vMSExcel, vFileName, vXLWorkbooks, vXLWorkbook;
    };
    //---------------------------------------------------------------------------
    extern PACKAGE TForm1 *Form1;
    //---------------------------------------------------------------------------
    #endif

Discussions similaires

  1. problem with "getResourceAsStream"
    Par adilou1981 dans le forum Général Java
    Réponses: 1
    Dernier message: 14/02/2008, 21h39
  2. Réponses: 1
    Dernier message: 16/10/2007, 18h15
  3. Problem with Sessions
    Par Chiabni dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 02/05/2006, 10h41

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