Y
yuren5340468
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure Tfliter_form.writeexecle(sender:tobject);
var
excelapp:texcelapplication;
excelwkbook:texcelworkbook;
excelwksheet:texcelworksheet;
i,j:integer;
fname:string;
sname:string;
begin
sname:=outdatastr;
fname:='delphi to excel';
qfliter.SQL.Text:='select * from student where politics=sname';
showmessage(qfliter.SQL.Text);
qfliter.Open;
try
excelapp:=texcelapplication.Create(application);
excelwkbook:=texcelworkbook.Create(application);
excelwksheet:=texcelworksheet.Create(application);
excelapp.Connect;
except
messagedlg('excel 可能没有安好!',mterror,[mbyes],0);
abort;
end;
excelapp.Workbooks.Add(null,0);//[Error] fliter.pas(159): Undeclared identifier: 'null'
excelwkbook.ConnectTo(excelapp.Workbooks[1]);
excelwksheet.ConnectTo(excelwkbook.Worksheets[1]as_worksheet);//[Error] fliter.pas(161): Incompatible types: 'IDispatch' and '_Worksheet'
qfliter.First;
qfliter.DisableControls;
for j:=0 to qfliter.FieldCount-1 do begin
excelwksheet.Cells.Item[1,j+1]:=qfliter.Fields[j].DisplayLabel;
end;
for i:=2 to qfliter.RecordCount+1 do
begin
for j:=0 to qfliter.Fields.Count-1 do begin
excelwksheet.Cells.Item[1,j+1]:=qfliter.Fields[j].AsString;
end;
qfliter.Next;
end;
excelwksheet.Columns.AutoFit;
excelwksheet.SaveAs(fname);
qfliter.EnableControls;
excelapp.Quit;
excelapp.Free;
excelwkbook.Free;
excelwksheet.Free;
end;
编译没通过
[Error] fliter.pas(159): Undeclared identifier: 'null'
[Error] fliter.pas(161): Incompatible types: 'IDispatch' and '_Worksheet'
把我所有的分都给了
var
excelapp:texcelapplication;
excelwkbook:texcelworkbook;
excelwksheet:texcelworksheet;
i,j:integer;
fname:string;
sname:string;
begin
sname:=outdatastr;
fname:='delphi to excel';
qfliter.SQL.Text:='select * from student where politics=sname';
showmessage(qfliter.SQL.Text);
qfliter.Open;
try
excelapp:=texcelapplication.Create(application);
excelwkbook:=texcelworkbook.Create(application);
excelwksheet:=texcelworksheet.Create(application);
excelapp.Connect;
except
messagedlg('excel 可能没有安好!',mterror,[mbyes],0);
abort;
end;
excelapp.Workbooks.Add(null,0);//[Error] fliter.pas(159): Undeclared identifier: 'null'
excelwkbook.ConnectTo(excelapp.Workbooks[1]);
excelwksheet.ConnectTo(excelwkbook.Worksheets[1]as_worksheet);//[Error] fliter.pas(161): Incompatible types: 'IDispatch' and '_Worksheet'
qfliter.First;
qfliter.DisableControls;
for j:=0 to qfliter.FieldCount-1 do begin
excelwksheet.Cells.Item[1,j+1]:=qfliter.Fields[j].DisplayLabel;
end;
for i:=2 to qfliter.RecordCount+1 do
begin
for j:=0 to qfliter.Fields.Count-1 do begin
excelwksheet.Cells.Item[1,j+1]:=qfliter.Fields[j].AsString;
end;
qfliter.Next;
end;
excelwksheet.Columns.AutoFit;
excelwksheet.SaveAs(fname);
qfliter.EnableControls;
excelapp.Quit;
excelapp.Free;
excelwkbook.Free;
excelwksheet.Free;
end;
编译没通过
[Error] fliter.pas(159): Undeclared identifier: 'null'
[Error] fliter.pas(161): Incompatible types: 'IDispatch' and '_Worksheet'
把我所有的分都给了