我在到delphi 中打开execl到表,出错了,帮看看 ( 积分: 20 )

  • 主题发起人 主题发起人 jesseyzy
  • 开始时间 开始时间
J

jesseyzy

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
eparam:olevariant;
docutype:olevariant;
wkbk:_workbook;
filename:olevariant;
begin
form1.OpenDialog1.InitialDir:=extractfiledir(paramstr(0));
form1.OpenDialog1.Execute ;
try
form1.ExcelApplication1.Connect ;
except
showmessage('cant connect !');
exit;
end;
form1.ExcelApplication1.Visible[0]:=false;
form1.ExcelApplication1.Caption:='execl document!';

eparam:=emptyparam;
docutype:=0;

try
wkbk:=form1.ExcelApplication1.Workbooks.Add(eparam,docutype);

wkbk:=form1.ExcelApplication1.Workbooks.Open(form1.OpenDialog1.FileName,
emptyparam,emptyparam,
emptyparam,emptyparam,emptyparam,emptyparam,
emptyparam,emptyparam,emptyparam,emptyparam,
emptyparam,emptyparam,emptyparam,emptyparam,docutype );
except
begin
form1.ExcelApplication1.Disconnect ;
form1.ExcelApplication1.Quit ;
showmessage('select the execl');
exit;
end;
end;
showmessage('2nddddddd!!');

form1.ExcelApplication1.Disconnect ;
form1.ExcelApplication1.Quit ;
showmessage('convert is finish!!');
end;

提示:access violation at address 00000000;reader of address 00000000;process stopped
帮看看!·

在执行open 语句的时候
提示:access violation at address 00000000;reader of address 00000000;process stopped
 
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
eparam:olevariant;
docutype:olevariant;
wkbk:_workbook;
filename:olevariant;
begin
form1.OpenDialog1.InitialDir:=extractfiledir(paramstr(0));
form1.OpenDialog1.Execute ;
try
form1.ExcelApplication1.Connect ;
except
showmessage('cant connect !');
exit;
end;
form1.ExcelApplication1.Visible[0]:=false;
form1.ExcelApplication1.Caption:='execl document!';

eparam:=emptyparam;
docutype:=0;

try
wkbk:=form1.ExcelApplication1.Workbooks.Add(eparam,docutype);

wkbk:=form1.ExcelApplication1.Workbooks.Open(form1.OpenDialog1.FileName,
emptyparam,emptyparam,
emptyparam,emptyparam,emptyparam,emptyparam,
emptyparam,emptyparam,emptyparam,emptyparam,
emptyparam,emptyparam,emptyparam,emptyparam,docutype );
except
begin
form1.ExcelApplication1.Disconnect ;
form1.ExcelApplication1.Quit ;
showmessage('select the execl');
exit;
end;
end;
showmessage('2nddddddd!!');

form1.ExcelApplication1.Disconnect ;
form1.ExcelApplication1.Quit ;
showmessage('convert is finish!!');
end;

提示:access violation at address 00000000;reader of address 00000000;process stopped
帮看看!·

在执行open 语句的时候
提示:access violation at address 00000000;reader of address 00000000;process stopped
 
我有一个类似程序,发给你,但愿有所帮助。
procedure Treport_form.Button1Click(Sender: TObject);
var
Current_File:string;
str:string;
ItemIndex,Doc,Table: OleVariant;
ConfirmConversions, ReadOnly, AddToRecentFiles,
PasswordDocument, PasswordTemplate, Revert,
FileName,filename2,WritePasswordDocument, WritePasswordTemplate, Format,Encoding,Visible: OleVariant;
canshu1,canshu2,canshu3:OleVariant;
sheet:variant;
i,j, p_type_num,stu_num:integer;
score: array of integer;
begin
try

//启动excel,读取成绩数据

ExcelApplication1.Connect;

ExcelWorkBook1.ConnectTo
(ExcelApplication1.Workbooks.Open(Current_File, EmptyParam,
EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,
EmptyParam,EmptyParam, EmptyParam,EmptyParam,0));
ExcelWorkBook1.Activate;
ExcelWorksheet1.ConnectTo(ExcelWorkBook1.ActiveSheet as _WorkSheet);
ExcelWorkSheet1.Activate;
sheet:=ExcelApplication1.ActiveSheet;
.......
except
.......
finally

ExcelWorkSheet1.Disconnect;
ExcelWorkBook1.Disconnect;
ExcelApplication1.Disconnect;
ExcelApplication1.quit;
end;
 
能否发个完整的给我
能把execl的的数据倒入到数据库的,
谢谢
yzy2000@126.com
qq:25826507
 
分数太少,我可以告诉你个很简单的!读取3000条记录估计2秒都不到的
你这样的读取,完了,100条记录估计都花你2秒了!
 
我只有这么点点分了
我是菜鸟!
帮帮忙忙?
 
后退
顶部