C
caoliu
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm2.BitBtn1Click(Sender: TObject);
var
MsExcel:Variant;
i:integer;
outtxt:TextFile;
str:string;
begin
if Edit1.Text<>'' then
begin
fileCreate(Edit1.Text);
assignfile(outtxt,Edit1.Text);
end
else
begin
filecreate('Outbound.txt');
assignfile(outtxt,'Outbound.txt');
end;
MsExcel:=CreateOleObject('Excel.Application');
For i:=0 to (ListView1.Items.Count -1) do
MsExcel.WorkBooks.open(ListView1.Items.Item.Caption);
MsExcel.Visible:=false;
MsExcel.WorkSheets[1].Activate;
with MsExcel.WorkSheets[1] do
begin
j:=2;
while not Eof do
begin
for i:=2 to 10 do
begin
Read(Cells.Item[j,i]);
str:=Cells.Item[j,i];
Write(outtxt,str+'');
end;
Writeln(outtxt);
end;
end;
end;
end.
大家帮我看这段代码:
编译到with MsExcel.WorkSheets[1] do报错,是不是不能这样写.
以下两行代码这样写对吗?
Read(Cells.Item[j,i]);
str:=Cells.Item[j,i];
var
MsExcel:Variant;
i:integer;
outtxt:TextFile;
str:string;
begin
if Edit1.Text<>'' then
begin
fileCreate(Edit1.Text);
assignfile(outtxt,Edit1.Text);
end
else
begin
filecreate('Outbound.txt');
assignfile(outtxt,'Outbound.txt');
end;
MsExcel:=CreateOleObject('Excel.Application');
For i:=0 to (ListView1.Items.Count -1) do
MsExcel.WorkBooks.open(ListView1.Items.Item.Caption);
MsExcel.Visible:=false;
MsExcel.WorkSheets[1].Activate;
with MsExcel.WorkSheets[1] do
begin
j:=2;
while not Eof do
begin
for i:=2 to 10 do
begin
Read(Cells.Item[j,i]);
str:=Cells.Item[j,i];
Write(outtxt,str+'');
end;
Writeln(outtxt);
end;
end;
end;
end.
大家帮我看这段代码:
编译到with MsExcel.WorkSheets[1] do报错,是不是不能这样写.
以下两行代码这样写对吗?
Read(Cells.Item[j,i]);
str:=Cells.Item[j,i];