应该差不多。。。
unit SJWG1;
interface
uses
Business.System, Business.Model, Business.Forms, Business.Data;
var
ss: String;
lForm : TCT1 ;
type
TSJWG1 = class(TFormDoc)
InfoBroker: TInfoBroker;
DataSetBrokerBZSJJ1: TDataSetBroker;
GroupBox1: TGroupBox;
Button1: TButton;
DataGridASSETCODE: TDataGridColumn;
DataGridASSETNAME: TDataGridColumn;
DataGridASSETSPEC: TDataGridColumn;
DataGridASSETUNIT: TDataGridColumn;
DataGridASSETNUM: TDataGridColumn;
DataGridASSETPRICE: TDataGridColumn;
DataGridDEPTID: TDataGridColumn;
DataGridADDRESS: TDataGridColumn;
DataGridBUYDATE: TDataGridColumn;
DataGridBEGINUSEDATE: TDataGridColumn;
DataGridUSEDYEARLIMIT: TDataGridColumn;
DataGridORIGINALVALUE: TDataGridColumn;
DataGridUSEMAN: TDataGridColumn;
DataGridSTATUS: TDataGridColumn;
DataGridREMARK: TDataGridColumn;
Button2: TButton;
Button3: TButton;
DataGrid: TDataGrid;
procedure Button1Click(Sender: TObject);
private
{private declarations}
procedure showCT1Form;
public
{public declarations}
// Procedure ExportToExcel(DataGrid : TDataGrid ; FileName : string ) ;
end;
type
TMyThread = class(TThread)
private
FForm: TSJWG1;
public
procedure Execute; override;
property Form: TSJWG1 read FForm write FForm;
end;
implementation
procedure TSJWG1.Button1Click(Sender: TObject);
var
t: TMyThread;
begin
t := TMyThread.Create(True);
lForm := TCT1.Create(Context) ;
t.Form := Self ;
t.Execute ;
lForm.Free ;
end;
procedure TMyThread.Execute;
var
i: Integer;
l: Integer;
begin
try
Synchronize(FForm.ShowCT1Form); //同步显示
Forms.Application.ProcessMessages ;
FForm.DataGrid.SaveToXLS('c:\test.xls' , true ) ;
except
end;
end;
procedure TSJWG1.showCT1Form;
begin
lForm.Show;
end;
end. |