var ExcelApp: Variant; Astr:string; Begin If OpenDialog1.Execute Then APath := OpenDialog1.FileName Else Exit; If Not FileExists(APath) Then Begin ShowMessage('您所选择的文件不存在!'); Exit; End; Try ExcelApp := CreateOleObject('Excel.Application'); ExcelApp.Workbooks.Open(APath); ExcelApp.WorkSheets[1].Activate; Astr := ExcelApp.Cells[1, 1].Value; end;
var
ExcelApp: Variant;
Astr:string;
Begin
If OpenDialog1.Execute Then
APath := OpenDialog1.FileName
Else
Exit; If Not FileExists(APath) Then
Begin
ShowMessage('您所选择的文件不存在!');
Exit;
End;
Try
ExcelApp := CreateOleObject('Excel.Application');
ExcelApp.Workbooks.Open(APath);
ExcelApp.WorkSheets[1].Activate; Astr := ExcelApp.Cells[1, 1].Value;
end;
http://topic.csdn.net/u/20071016/09/d43520da-42ba-40ea-b6a6-5d42383e5e6c.html