孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

procedure SaveToExcel(AFile:string);

var

sheet,XLApp,workbook:Variant;

iRow,MaxRow:integer;

begin

screen.Cursor :=TADOTable.Create(nil);

ADOTable.Connectionstring :=FConnstr;

XLApp:=CreateObject('Excep.Application');

workbook:=CreateObject('Excel.Sheet');

XLApp.DisplayAlerts :=false;

XLApp.ScreenUpdating :=false;

XLApp.workbooks.Add;

Workbook :=XLApp.workbooks[1];

sheet :=workbook.worksheets[1];

ADOTable.TableName :='dog';

ADOTable.Open;

//写EXCEL的标题栏

iRow :=1;

sheet.Cells[iRow,1]:='狗号';

sheet.Cells[iRow,2]:='服务卡号';

.

.

.

//写EXCEL的内容

while not ADOTable.Eof do

begin

inc(iRow);

Sheet.Cells[iRow,1]:=ADOTable.FieldByName('dog').AsString;

Sheet.Cells[iRow,1]:=ADOTable.FieldByName('dog').AsString;

.

.

.

ADOTable.Next;

end;

workbook.SaveAs(AFile);

workbook.Close;

if not VarIsEmpty(XLApp) then

begin

XLApp.DisplayAlerts :=False;

XLApp.ScreenUpdateing :=True;

XLApp.Quit;

end;

ADOTable.Free;

Screen.Cursor :=crDefault;

end;

posted on 2008-09-14 14:09  孤独的猫  阅读(193)  评论(0编辑  收藏  举报