2010-09-08 7 views

Répondre

6

vous pouvez utiliser la propriété Hyperlinks.Address

chèque ce code

var 
    excel : Variant; 
begin 
Excel := CreateOleObject('Excel.Application');//Create an excel instance 
try 
Excel.Workbooks.Open('yourexcelfile.xls'); //open the excel workbook 
if Excel.Range['B4', 'B4'].Hyperlinks.Count > 0 then //check if exist hyperlinks in the range 
    ShowMessage(Excel.Range['B4', 'B4'].Hyperlinks[1].Address); //show the hyperlink 
finally 
if not VarIsEmpty(Excel) then 
    Excel.Quit; //Close the excel instance 
end; 
end; 
1

Si vous avez 50 dollars dans votre budget pour une bibliothèque nappe de code Delphi pour lire et écrire des fichiers Excel sans utiliser OLE ou nécessitant Excel pour être présent, vous pouvez essayer NativeExcel. C'est rapide, facile à utiliser, livré avec un fichier d'aide direct, et vous donne un grand contrôle sur les classeurs que vous créez. Voici le code pour lire la valeur de A1:

procedure TForm1.Button1Click(Sender: TObject); 
    Var Book: IXLSWorkbook; 
    ws: IXLSWorksheet; 
    sHyperlink: String; 
begin 
    Book := TXLSWorkbook.Create; 
    Book.Open('C:\Data\Book1.xls'); 
    ws := Book.Sheets[1]; 
    ShowMessage(ws.Range['A1','A1'].HyperLinks[1].Address); 
end; 
Questions connexes