Thema: Delphi Excel Tabelle auslesen

Einzelnen Beitrag anzeigen

CB2206

Registriert seit: 4. Feb 2003
Ort: Kaarst
13 Beiträge
 
Delphi 7 Enterprise
 
#7
  Alt 4. Feb 2003, 07:24
Code:
uses
 Excel97; // falls Excel 97 benutzt wird

var
  excel: TExcelApplication;
  wb: _WorkBook;
  ws: _WorkSheet;
  lcid: Integer;
Code:
    // Excel öffnen
    lcid := GetUserDefaultLCID;

    excel := TExcelApplication.Create(FormMain);
    excel.Connect;

    // Exceldatei laden (test.xls)
    wb := excel.Workbooks.Open('test.xls', emptyParam, emptyParam, emptyParam, emptyParam,
                        emptyParam, emptyParam, emptyParam, emptyParam, emptyParam, emptyParam,
                        emptyParam, emptyParam, lcid);

    // erstes Worksheet auswählen
    ws := wb.Sheets[1] as _WorkSheet;
Code:
  // Feld A1 ausgeben
  ShowMessage(ws.Cells.Item[y,x].Value);
Code:
    // Excel schließen - Datei NICHT speichern
    wb.Close(False, emptyParam, emptyParam, lcid);
    excel.Quit;
Code:
    // Excel schließen - Datei speichern
    wb.Close(True, 'C:\test.xls', emptyParam, lcid);
    excel.Quit;
Gruß
CB
  Mit Zitat antworten Zitat