S
SmallA
Unregistered / Unconfirmed
GUEST, unregistred user!
我将查询到的数据输出到EXCEL文件,但没有标题,不知怎么写呢?
同时不想每次输出时都打开EXCEL,存盘时想有个提示窗口出来,输入
存的文件名.代码如下,请指点
var
i,row,column:integer;
begin
Try
ExcelApplication1.Connect;
Except
MessageDlg('本机尚没安装EXCEL,请先安装',mtError, [mbOk], 0);
Abort;
End;
ExcelApplication1.Visible[0]:=True;
ExcelApplication1.Caption:='Excel Application';
ExcelApplication1.Workbooks.Add(Null,0);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);
FindADOQuery.Open;
row:=1;
While Not(FindADOQuery.Eof) do
begin
column:=1;
for i:=1 to FindADOQuery.FieldCount do
begin
ExcelWorksheet1.Cells.Item[row,column]:=FindADOQuery.fields[i-1].AsString;
column:=column+1;
end;
FindADOQuery.Next;
row:=row+1;
end;
同时不想每次输出时都打开EXCEL,存盘时想有个提示窗口出来,输入
存的文件名.代码如下,请指点
var
i,row,column:integer;
begin
Try
ExcelApplication1.Connect;
Except
MessageDlg('本机尚没安装EXCEL,请先安装',mtError, [mbOk], 0);
Abort;
End;
ExcelApplication1.Visible[0]:=True;
ExcelApplication1.Caption:='Excel Application';
ExcelApplication1.Workbooks.Add(Null,0);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);
FindADOQuery.Open;
row:=1;
While Not(FindADOQuery.Eof) do
begin
column:=1;
for i:=1 to FindADOQuery.FieldCount do
begin
ExcelWorksheet1.Cells.Item[row,column]:=FindADOQuery.fields[i-1].AsString;
column:=column+1;
end;
FindADOQuery.Next;
row:=row+1;
end;