bonjour;
je n'arrive pas a execute un simple programme, on utilisant excel version 2007, mon programme execute sans aucune erreur mais il bogue et il ne retourne aucune valeur.
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 //--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #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) { Variant vMSExcel; Variant vFileName, vXLWorkbooks, vXLWorkbook; vFileName = "c:\\classeur1.xls"; vXLWorkbooks = vMSExcel.OlePropertyGet("Workbooks"); vXLWorkbook = vXLWorkbooks.OleFunction("Open", vFileName); Variant vWorksheet, vSheetName; vSheetName = "Feuil1"; vWorksheet = vXLWorkbook.OlePropertyGet("Worksheets",vSheetName); Variant vValue, vRange, vCell; AnsiString aValue; vRange = "A1"; vCell = vWorksheet.OlePropertyGet("Range", vRange); aValue = vCell.OlePropertyGet("Value"); Edit1->Text=aValue; } //---------------------------------------------------------------------------
Partager