uses
ComObj;
procedure TForm1.Button1Click(Sender: TObject);
var
XLApplication: Variant;
XLSheet : Variant;
XLBook : Variant;
begin
XLApplication := CreateOleObject('Excel.Application');
XLApplication.DisplayAlerts := False;
XLApplication.Visible := False;
XLBook := XLApplication.WorkBooks.Open('e:\test.xlsx');
XLSheet := XLBook.Sheets['Sheet1'];
XLSheet.UsedRange.Copy;
if not VarIsEmpty(XLApplication) then begin
XLApplication.DisplayAlerts := False;
XLApplication.Quit;
end;
end;
버튼 클륵 후 메모장에 붙여넣기 해보세요..
|