var
Int_Col,Int_row:integer; //列,行,所选字段的列
begin Ole_Execl:=Texcelapplication.Create(self);
Try
Try
Ole_Workbook:=Ole_Execl.Workbooks.Add(EmptyParam,0); //
Except End;
Ole_range:=Ole_Execl.Rows; For Int_Col:=0 to dxDBGrid2.ColumnCount-1 do
Begin
Ole_range.Cells.Item[1,Int_Col+1]:=dxDBGrid2.Columns[int_col].Caption;
End;
tbl_lld.First;
For Int_row:=2 To tbl_lld.RecordCount+1 do
Begin
For Int_Col:=0 to dxDBGrid2.ColumnCount-1 do
Begin
Ole_range.Cells.Item[Int_row,int_col+1]:=dxDBGrid2.Columns[Int_Col].Field.AsString;
End;
tbl_lld.Next;
End; Finally
Try
Ole_Execl.Save;
Ole_Execl.Disconnect;
Ole_Execl.Free;
except
end;
End;
end;
Int_Col,Int_row:integer; //列,行,所选字段的列
begin Ole_Execl:=Texcelapplication.Create(self);
Try
Try
Ole_Workbook:=Ole_Execl.Workbooks.Add(EmptyParam,0); //
Except End;
Ole_range:=Ole_Execl.Rows; For Int_Col:=0 to dxDBGrid2.ColumnCount-1 do
Begin
Ole_range.Cells.Item[1,Int_Col+1]:=dxDBGrid2.Columns[int_col].Caption;
End;
tbl_lld.First;
For Int_row:=2 To tbl_lld.RecordCount+1 do
Begin
For Int_Col:=0 to dxDBGrid2.ColumnCount-1 do
Begin
Ole_range.Cells.Item[Int_row,int_col+1]:=dxDBGrid2.Columns[Int_Col].Field.AsString;
End;
tbl_lld.Next;
End; Finally
Try
Ole_Execl.Save;
Ole_Execl.Disconnect;
Ole_Execl.Free;
except
end;
End;
end;
改为Ole_Execl.quit
>>改为Ole_Execl.quit然後, Ole_Execl := Unassigned;
Ole_Execl.Free;
该为:
ole_Excel.ActiveWorkbook.Close;
Ole_Execl.Disconnect;
Ole_Execl.Free;