L
li_tj
Unregistered / Unconfirmed
GUEST, unregistred user!
我想在OleContainer中读入一个Excel文件,
然后将第二列的各列标题读出显示在
Checklistbox中,但是变量Title值始终
为空,不知是为什么?
源代码如下:
procedure Tfrm_openfile.showfile(filename:String);
var
i : Integer;
title : String;
begin
try
if not assigned(OleContainer) then
begin
olecontainer := Tolecontainer.Create(self);
OleCOntainer.Parent := ScrollBox1;
OleContainer.Align := alClient;
end;
olecontainer.CreateLinkToFile(filename,false);
olecontainer.DoVerb(ovShow);
Cur_WorkBook:=OleContainer.oleObject.Application.Workbooks.Item[1];
Cur_WorkSheet:=Cur_WorkBook.WorkSheets[1];
except
application.MessageBox('所需文档无法打开!请确定已安装合适软件!','提示'
,MB_ICONERROR);
fileisshow := false;
exit;
end;
if (Pos('xls',filename) <> 0) or (Pos('xlt',filename) <> 0) then
begin
for i := 0 to 20 do
begin
title := cur_worksheet.range[chr(ord('A')+i)+'2'].value;
if title <> '' then
list_excel.Items.Add(title)
else
break;
end;
end;
FileIsShow := True;
end;
不好意思,发在"非技术问题"了.现在重发一遍.
然后将第二列的各列标题读出显示在
Checklistbox中,但是变量Title值始终
为空,不知是为什么?
源代码如下:
procedure Tfrm_openfile.showfile(filename:String);
var
i : Integer;
title : String;
begin
try
if not assigned(OleContainer) then
begin
olecontainer := Tolecontainer.Create(self);
OleCOntainer.Parent := ScrollBox1;
OleContainer.Align := alClient;
end;
olecontainer.CreateLinkToFile(filename,false);
olecontainer.DoVerb(ovShow);
Cur_WorkBook:=OleContainer.oleObject.Application.Workbooks.Item[1];
Cur_WorkSheet:=Cur_WorkBook.WorkSheets[1];
except
application.MessageBox('所需文档无法打开!请确定已安装合适软件!','提示'
,MB_ICONERROR);
fileisshow := false;
exit;
end;
if (Pos('xls',filename) <> 0) or (Pos('xlt',filename) <> 0) then
begin
for i := 0 to 20 do
begin
title := cur_worksheet.range[chr(ord('A')+i)+'2'].value;
if title <> '' then
list_excel.Items.Add(title)
else
break;
end;
end;
FileIsShow := True;
end;
不好意思,发在"非技术问题"了.现在重发一遍.