P
poim111
Unregistered / Unconfirmed
GUEST, unregistred user!
先来看一段代码:
procedure TForm1.Button1Click(Sender: TObject);
var
i,row: integer;
ExcelApplication1: Variant;
begin
ExcelApplication1 := CreateOleObject( 'Excel.Application' );
ExcelApplication1.Workbooks.Open('E:/陈晶/测试/1111.xls',
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,0);
ExcelApplication1.Worksheets[1].Activate;
Query1.Open;
//逐行写入DBGRIG的表中的内容
for i:=0 to Query1.Fields.Count-1do
ExcelApplication1.Cells.Item[1,i+1]:=DBGrid1.Columns.Items
.Title.Caption;
//将DBGRID的各字段名写入EXCEL第一行
row:=2;
while not Query1.Eofdo
begin
for i:=0 to Query1.Fields.Count-1do
begin
ExcelApplication1.Cells.Item[row,i+1]:= query1.Fields.AsString;
end;
row:=row+1;
Query1.Next;
end;
ExcelApplication1.Quit;
ExcelApplication1.Disconnect;
Application.MessageBox('成功保存文件','提示',0);
end;
在这段程序执行完毕后总是提示是否对“111.XLS”进行保存!
请高手们指教一下如何让他不提示而直接对“111.XLS”进行保存!
请在原程序上进行改动!
procedure TForm1.Button1Click(Sender: TObject);
var
i,row: integer;
ExcelApplication1: Variant;
begin
ExcelApplication1 := CreateOleObject( 'Excel.Application' );
ExcelApplication1.Workbooks.Open('E:/陈晶/测试/1111.xls',
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,0);
ExcelApplication1.Worksheets[1].Activate;
Query1.Open;
//逐行写入DBGRIG的表中的内容
for i:=0 to Query1.Fields.Count-1do
ExcelApplication1.Cells.Item[1,i+1]:=DBGrid1.Columns.Items
.Title.Caption;
//将DBGRID的各字段名写入EXCEL第一行
row:=2;
while not Query1.Eofdo
begin
for i:=0 to Query1.Fields.Count-1do
begin
ExcelApplication1.Cells.Item[row,i+1]:= query1.Fields.AsString;
end;
row:=row+1;
Query1.Next;
end;
ExcelApplication1.Quit;
ExcelApplication1.Disconnect;
Application.MessageBox('成功保存文件','提示',0);
end;
在这段程序执行完毕后总是提示是否对“111.XLS”进行保存!
请高手们指教一下如何让他不提示而直接对“111.XLS”进行保存!
请在原程序上进行改动!