如何实现数据的导入和导出(数据库为sql2000,导出文件为execl格式)??(50分)

  • 主题发起人 主题发起人 xue68111803
  • 开始时间 开始时间
X

xue68111803

Unregistered / Unconfirmed
GUEST, unregistred user!
如何实现数据的导入和导出(数据库为sql2000,导出文件为execl格式)??
 
导出到excel:
var
i,row:integer;
begin
if SaveDialog1.Execute then
begin
Screen.Cursor:=crHourGlass;
ExcelApplication1.Connect;
ExcelApplication1.Workbooks.Add(Null,0);
ExcelWorkBook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorkSheet1.ConnectTo(ExcelWorkBook1.Sheets[1] as _WorkSheet);
if not Query.Active then
begin
Query.SQL:=SQL.Lines;
Query.Open;
end;
pgbar.Visible:=true;
pgbar.Max:=query.RecordCount*query.fields.count;
pgbar.Position:=0;
for i:=0 to Query.Fields.Count-1 do
ExcelWOrkSheet1.Cells.Item[1,i+1]:=Query.Fields.FieldName;
row:=2;
while not Query.Eof do
begin
for i:=0 to Query.Fields.Count-1 do
begin
ExcelWOrkSheet1.Cells.Item[row,i+1]:=Query.Fields.AsString;
pgbar.StepIt;
end;
row:=row+1;
Query.Next;
end;
ExcelWorkBook1.SaveCopyAs(SaveDialog1.FileName);
ExcelWOrkBook1.Close(false);
pgbar.Visible:=false;
ExcelApplication1.Disconnect;
ExcelApplication1.Quit;
Screen.Cursor:=crDefault;
Application.MessageBox('Export successfully!','Information',0);
end;
end;
 
那么如何从ACCESS中导出到文本文件?要求带管道符如|2|200000|3000000|不能带空格
 
后退
顶部