将一个select 的结果 导入到一个excel表中,代码如下,用select * from table_total可以,但是select 账号 from table_total却提示错误,参数不足,老子信他的邪了,用的是access的数据库。 excelnew:=createoleobject('excel.application');
excelnew.visible:=true;
excelnew.workbooks.add;
excelnew.worksheets[1].activate;
excelnew.cells[1,1].value:='账号';
excelnew.cells[1,2].value:='户名';
excelnew.cells[1,3].value:='日均余额';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from table_ckdepman');
adoquery1.Open;
adoquery1.First; //first
v_row:=1;
while not Adoquery1.Eof do //只要记录没到最后就执行以下动作
begin
for v_column:=0 to Adoquery1.Fields.Count-1 do // column逐列导出动作
begin
excelnew.cells[v_row+1,v_column+1].value:=Adoquery1.Fields[v_column].AsString; //[行,列]
end;
v_row:=v_row+1;
Adoquery1.Next; //到下一条记录
end; adoquery1.Close;
adoquery1.SQL.clear; Excelnew.ActiveWorkBook.SaveAs(v_tablename);
varclear(Excelnew);
用'select * from table_ckdepman' 很好,但是用'select 账号,户名 from table_ckdepman'却报错,参数不足,用的access。大伙帮我看看咋回事,脑袋木了都。
excelnew.visible:=true;
excelnew.workbooks.add;
excelnew.worksheets[1].activate;
excelnew.cells[1,1].value:='账号';
excelnew.cells[1,2].value:='户名';
excelnew.cells[1,3].value:='日均余额';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from table_ckdepman');
adoquery1.Open;
adoquery1.First; //first
v_row:=1;
while not Adoquery1.Eof do //只要记录没到最后就执行以下动作
begin
for v_column:=0 to Adoquery1.Fields.Count-1 do // column逐列导出动作
begin
excelnew.cells[v_row+1,v_column+1].value:=Adoquery1.Fields[v_column].AsString; //[行,列]
end;
v_row:=v_row+1;
Adoquery1.Next; //到下一条记录
end; adoquery1.Close;
adoquery1.SQL.clear; Excelnew.ActiveWorkBook.SaveAs(v_tablename);
varclear(Excelnew);
用'select * from table_ckdepman' 很好,但是用'select 账号,户名 from table_ckdepman'却报错,参数不足,用的access。大伙帮我看看咋回事,脑袋木了都。
用'select 账号,户名,日均余额 from table_ckdepman' 才行啊