Delphi导出数据到Excel时报OLE error 800A03EC
时间:2011-08-31
来源:互联网
用Delphi导出数据到Excel时报OLE error 800A03EC错误.
已导出的数据是260行,卡住!
请问是什么原因啊???
已导出的数据是260行,卡住!
请问是什么原因啊???
作者: daisy072486 发布时间: 2011-08-31
if (not DM.QryCE_Size.Active)and (not DM.QryCE_Thickness.Active)and (not DM.QryCE_Online.Active)
and (not DM.QryCE_Exterior_Sample.Active) then
begin
Application.MessageBox('对不起,没有CE保留品数据可以导出!','提示',MB_OK+ MB_ICONEXCLAMATION);
Exit;
end;
if Application.MessageBox('确认要导出CE保留品明细数据吗?','提示',MB_YESNO+mb_iconquestion)=IDNo then Exit;
try
ExcelApp:=CreateOleObject('Excel.Application');
except
Application.MessageBox('创建Excel文件时出现错误!','提示',MB_OK+ MB_ICONEXCLAMATION);
Exit;
end;
ExcelApp.Visible := True;
ExcelApp.Caption := '标题:CE检查保留品数据';
ExcelApp.WorkBooks.Add;
ExcelApp.WorkSheets[1].Activate;
ExcelApp.WorkSheets[1].name:='表名';
ExcelApp.ActiveSheet.Rows[1].Font.Bold:= True;
//to excel 导出数据
begin
with DM.QryCE_Reservations do
begin
DisableControls;
fieldNum := dbgrid9.fieldCount;
ExcelApp.Cells[1,1] :='CE保留品推移数据表';
FieldNum:=FieldNum;
for i:=1 to fieldNum do //写表头
begin
ExcelApp.Cells[2,i]:=FrmCE_Report.DBGrid9.Columns[i-1].Title.caption;
end;
first;
i:=2;
while not eof do
begin
for j:=1 to fieldNum do
begin
ExcelApp.Cells[line+1+i,j]:=fields[j-1].AsString;
end;
inc(i);
if (i mod 20)=0 then
ExcelApp.Cells[1,20].Activate;
next;
end;
line:=i+2;
end;
with DM.QryCE_Reservation do
begin
fieldNum := dbgrid7.fieldCount;
ExcelApp.Cells[1+line,1] :='CE保留品处理数据表';
FieldNum:=FieldNum;
for i:=1 to fieldNum do //写表头
begin
ExcelApp.Cells[line+2,i]:=FrmCE_Report.DBGrid7.Columns[i-1].Title.caption;
end;
first;
i:=2;
while not eof do
begin
for j:=1 to fieldNum do
begin
ExcelApp.Cells[line+i+1,j]:=fields[j-1].AsString;
end;
inc(i);
if (i mod 20)=0 then
ExcelApp.Cells[1,20].Activate;
next;
end;
line:=line+i+2;
end;
with DM.QryCE_Reserve_Yield do
begin
fieldNum := dbgrid8.fieldCount;
ExcelApp.Cells[line+1,1] :='CE保留品月良率数据表';
FieldNum:=FieldNum;
for i:=1 to fieldNum do //写表头
begin
ExcelApp.Cells[line+2,i]:=FrmCE_Report.DBGrid8.Columns[i-1].Title.caption;
end;
first;
i:=2;
while not eof do
begin
for j:=1 to fieldNum do
begin
ExcelApp.Cells[line+i+1,j]:=fields[j-1].AsString;
end;
inc(i);
if (i mod line+20)=0 then
ExcelApp.Cells[1,i+20].Activate;
next;
end;
EnableControls;
end;
ExcelApp.Columns[1].NumberFormatLocal:='@';
Application.MessageBox('恭喜!' + #13#10#13#10 +
'数据成功导出,请注意数据备份。', '提示', MB_OK + MB_ICONINFORMATION +MB_DEFBUTTON2);
end;
and (not DM.QryCE_Exterior_Sample.Active) then
begin
Application.MessageBox('对不起,没有CE保留品数据可以导出!','提示',MB_OK+ MB_ICONEXCLAMATION);
Exit;
end;
if Application.MessageBox('确认要导出CE保留品明细数据吗?','提示',MB_YESNO+mb_iconquestion)=IDNo then Exit;
try
ExcelApp:=CreateOleObject('Excel.Application');
except
Application.MessageBox('创建Excel文件时出现错误!','提示',MB_OK+ MB_ICONEXCLAMATION);
Exit;
end;
ExcelApp.Visible := True;
ExcelApp.Caption := '标题:CE检查保留品数据';
ExcelApp.WorkBooks.Add;
ExcelApp.WorkSheets[1].Activate;
ExcelApp.WorkSheets[1].name:='表名';
ExcelApp.ActiveSheet.Rows[1].Font.Bold:= True;
//to excel 导出数据
begin
with DM.QryCE_Reservations do
begin
DisableControls;
fieldNum := dbgrid9.fieldCount;
ExcelApp.Cells[1,1] :='CE保留品推移数据表';
FieldNum:=FieldNum;
for i:=1 to fieldNum do //写表头
begin
ExcelApp.Cells[2,i]:=FrmCE_Report.DBGrid9.Columns[i-1].Title.caption;
end;
first;
i:=2;
while not eof do
begin
for j:=1 to fieldNum do
begin
ExcelApp.Cells[line+1+i,j]:=fields[j-1].AsString;
end;
inc(i);
if (i mod 20)=0 then
ExcelApp.Cells[1,20].Activate;
next;
end;
line:=i+2;
end;
with DM.QryCE_Reservation do
begin
fieldNum := dbgrid7.fieldCount;
ExcelApp.Cells[1+line,1] :='CE保留品处理数据表';
FieldNum:=FieldNum;
for i:=1 to fieldNum do //写表头
begin
ExcelApp.Cells[line+2,i]:=FrmCE_Report.DBGrid7.Columns[i-1].Title.caption;
end;
first;
i:=2;
while not eof do
begin
for j:=1 to fieldNum do
begin
ExcelApp.Cells[line+i+1,j]:=fields[j-1].AsString;
end;
inc(i);
if (i mod 20)=0 then
ExcelApp.Cells[1,20].Activate;
next;
end;
line:=line+i+2;
end;
with DM.QryCE_Reserve_Yield do
begin
fieldNum := dbgrid8.fieldCount;
ExcelApp.Cells[line+1,1] :='CE保留品月良率数据表';
FieldNum:=FieldNum;
for i:=1 to fieldNum do //写表头
begin
ExcelApp.Cells[line+2,i]:=FrmCE_Report.DBGrid8.Columns[i-1].Title.caption;
end;
first;
i:=2;
while not eof do
begin
for j:=1 to fieldNum do
begin
ExcelApp.Cells[line+i+1,j]:=fields[j-1].AsString;
end;
inc(i);
if (i mod line+20)=0 then
ExcelApp.Cells[1,i+20].Activate;
next;
end;
EnableControls;
end;
ExcelApp.Columns[1].NumberFormatLocal:='@';
Application.MessageBox('恭喜!' + #13#10#13#10 +
'数据成功导出,请注意数据备份。', '提示', MB_OK + MB_ICONINFORMATION +MB_DEFBUTTON2);
end;
作者: daisy072486 发布时间: 2011-08-31
大侠们,快帮帮小女子吧
作者: daisy072486 发布时间: 2011-08-31
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28