我做了一个极简单的数据库查询,连接Access数据库,sql就一句,select a,b from c,d where c.f = d.f ; 结果在DBGrid中显示,请问如何将结果保存到一张EXCEL表格中?如果再查询另一张表,怎样把结果追加到刚才那张表格中?谢谢!

解决方案 »

  1.   

    procedure TLoad_Frm.Button3Click(Sender: TObject);
    var 
       MSExcel: Variant;
       FileName: String;
       i,j,k :integer;
    begin
      try
        MSExcel:=CreateOLEObject('Excel.Application');
        FileName:= ExtractFilePath(Application.ExeName) + '年度统计.XLS';
        MSExcel.WorkBooks.Open(FileName);
        MSExcel.Visible:=False;
        //进程条
        Gauge1.Visible := True;
        //报表标题
        MSExcel.Cells[16,12].Value:=year.Text+'年度水电费';
        ADO_Goods.Close;
        ADO_Goods.SQL.Clear;
        ADO_Goods.SQL.Text:='select Sum(WaterF) as WaterF, Sum(ElectF) as ElectF ,Count(ElectF) as SFZ from SDF where year='''+year.Text+''' ';
        ADO_Goods.Open;
        MSExcel.Cells[18,12].Value:='总水费:'+ADO_Goods.FieldByName('WaterF').AsString;
        MSExcel.Cells[20,12].Value:='总电费:'+ADO_Goods.FieldByName('ElectF').AsString;
        Gauge1.MaxValue:=ADO_Goods.FieldByName('SFZ').AsInteger*2;
        //2月
        ADO_Goods.Close;
        ADO_Goods.SQL.Clear;
        ADO_Goods.SQL.Text:='select a.WaterF as WaterF,a.WaterN as WaterN,a.ElectF as ElectF,a.ElectN as ElectN,b.XM as XM,a.XM,b.DoorId as DoorId from SDF a ,tblrywh b where b.XM=a.XM  and a.year='''+year.Text+''' and a.month=''2'' order by b.RYBH';
        ADO_Goods.Open;
        ADO_Goods.First;
        //从有数据的行逐行读入数据
        i:=1;
        while not ADO_Goods.Eof do
        begin
           MSExcel.Cells[i+46,1].Value:=Trim(ADO_Goods.FieldByName('XM').AsString);
           MSExcel.Cells[i+46,2].Value:=Trim(ADO_Goods.FieldByName('DoorId').AsString);       MSExcel.Cells[i+46,3].Value:=ADO_Goods.FieldByName('WaterN').AsString;
           MSExcel.Cells[i+46,4].Value:=ADO_Goods.FieldByName('WaterF').AsString;
           MSExcel.Cells[i+46,16].Value:=ADO_Goods.FieldByName('ElectN').AsString;
           MSExcel.Cells[i+46,17].Value:=ADO_Goods.FieldByName('ElectF').AsString;       Gauge1.AddProgress(1);
           i:=i+1;
           ADO_Goods.Next;
        end;
        //4月
        ADO_Goods.Close;
        ADO_Goods.SQL.Clear;
        ADO_Goods.SQL.Text:='select a.WaterF as WaterF,a.WaterN as WaterN,a.ElectF as ElectF,a.ElectN as ElectN,b.XM as XM,a.XM,b.DoorId as DoorId from SDF a ,tblrywh b where b.XM=a.XM  and a.year='''+year.Text+''' and a.month=''4'' order by b.RYBH';
        ADO_Goods.Open;
        ADO_Goods.First;
        //从有数据的行逐行读入数据
        i:=1;
        while not ADO_Goods.Eof do
        begin
           MSExcel.Cells[i+46,5].Value:=ADO_Goods.FieldByName('WaterN').AsString;
           MSExcel.Cells[i+46,6].Value:=ADO_Goods.FieldByName('WaterF').AsString;
           MSExcel.Cells[i+46,18].Value:=ADO_Goods.FieldByName('ElectN').AsString;
           MSExcel.Cells[i+46,19].Value:=ADO_Goods.FieldByName('ElectF').AsString;
           Gauge1.AddProgress(1);
           i:=i+1;
           ADO_Goods.Next;
        end;
        //6月
        ADO_Goods.Close;
        ADO_Goods.SQL.Clear;
        ADO_Goods.SQL.Text:='select a.WaterF as WaterF,a.WaterN as WaterN,a.ElectF as ElectF,a.ElectN as ElectN,b.XM as XM,a.XM,b.DoorId as DoorId from SDF a ,tblrywh b where b.XM=a.XM  and a.year='''+year.Text+''' and a.month=''6'' order by b.RYBH';
        ADO_Goods.Open;
        ADO_Goods.First;
        //从有数据的行逐行读入数据
        i:=1;
        while not ADO_Goods.Eof do
        begin
           MSExcel.Cells[i+46,7].Value:=ADO_Goods.FieldByName('WaterN').AsString;
           MSExcel.Cells[i+46,8].Value:=ADO_Goods.FieldByName('WaterF').AsString;
           MSExcel.Cells[i+46,20].Value:=ADO_Goods.FieldByName('ElectN').AsString;
           MSExcel.Cells[i+46,21].Value:=ADO_Goods.FieldByName('ElectF').AsString;
           Gauge1.AddProgress(1);
           i:=i+1;
           ADO_Goods.Next;
        end;
        //8月
        ADO_Goods.Close;
        ADO_Goods.SQL.Clear;
        ADO_Goods.SQL.Text:='select a.WaterF as WaterF,a.WaterN as WaterN,a.ElectF as ElectF,a.ElectN as ElectN,b.XM as XM,a.XM,b.DoorId as DoorId from SDF a ,tblrywh b where b.XM=a.XM  and a.year='''+year.Text+''' and a.month=''8'' order by b.RYBH';
        ADO_Goods.Open;
        ADO_Goods.First;
        //从有数据的行逐行读入数据
        i:=1;
        while not ADO_Goods.Eof do
        begin
           MSExcel.Cells[i+46,9].Value:=ADO_Goods.FieldByName('WaterN').AsString;
           MSExcel.Cells[i+46,10].Value:=ADO_Goods.FieldByName('WaterF').AsString;
           MSExcel.Cells[i+46,22].Value:=ADO_Goods.FieldByName('ElectN').AsString;
           MSExcel.Cells[i+46,23].Value:=ADO_Goods.FieldByName('ElectF').AsString;
           Gauge1.AddProgress(1);
           i:=i+1;
           ADO_Goods.Next;
        end;
        //10月
        ADO_Goods.Close;
        ADO_Goods.SQL.Clear;
        ADO_Goods.SQL.Text:='select a.WaterF as WaterF,a.WaterN as WaterN,a.ElectF as ElectF,a.ElectN as ElectN,b.XM as XM,a.XM,b.DoorId as DoorId from SDF a ,tblrywh b where b.XM=a.XM  and a.year='''+year.Text+''' and a.month=''10'' order by b.RYBH';
        ADO_Goods.Open;
        ADO_Goods.First;
        //从有数据的行逐行读入数据
        i:=1;
        while not ADO_Goods.Eof do
        begin
           MSExcel.Cells[i+46,11].Value:=ADO_Goods.FieldByName('WaterN').AsString;
           MSExcel.Cells[i+46,12].Value:=ADO_Goods.FieldByName('WaterF').AsString;
           MSExcel.Cells[i+46,24].Value:=ADO_Goods.FieldByName('ElectN').AsString;
           MSExcel.Cells[i+46,25].Value:=ADO_Goods.FieldByName('ElectF').AsString;
           Gauge1.AddProgress(1);
           i:=i+1;
           ADO_Goods.Next;
        end;
        //12月
        ADO_Goods.Close;
        ADO_Goods.SQL.Clear;
        ADO_Goods.SQL.Text:='select a.WaterF as WaterF,a.WaterN as WaterN,a.ElectF as ElectF,a.ElectN as ElectN,b.XM as XM,a.XM,b.DoorId as DoorId from SDF a ,tblrywh b where b.XM=a.XM  and a.year='''+year.Text+''' and a.month=''12'' order by b.RYBH';
        ADO_Goods.Open;
        ADO_Goods.First;
        //从有数据的行逐行读入数据
        i:=1;
        while not ADO_Goods.Eof do
        begin
           MSExcel.Cells[i+46,13].Value:=ADO_Goods.FieldByName('WaterN').AsString;
           MSExcel.Cells[i+46,14].Value:=ADO_Goods.FieldByName('WaterF').AsString;
           MSExcel.Cells[i+46,26].Value:=ADO_Goods.FieldByName('ElectN').AsString;
           MSExcel.Cells[i+46,27].Value:=ADO_Goods.FieldByName('ElectF').AsString;
           Gauge1.AddProgress(1);
           i:=i+1;
           ADO_Goods.Next;
        end;
        //小计
        ADO_Goods.Close;
        ADO_Goods.SQL.Clear;
        ADO_Goods.SQL.Text:='select Sum(a.WaterF) as WaterF,sum(a.ElectF) as ElectF from SDF a ,tblrywh b where b.XM=a.XM  and a.year='''+year.Text+''' group by a.XM';
        ADO_Goods.Open;
        ADO_Goods.First;
        //从有数据的行逐行读入数据
        i:=1;
        while not ADO_Goods.Eof do
        begin
           MSExcel.Cells[i+46,15].Value:=ADO_Goods.FieldByName('WaterF').AsString;
           MSExcel.Cells[i+46,28].Value:=ADO_Goods.FieldByName('ElectF').AsString;
           Gauge1.AddProgress(1);
           i:=i+1;
           ADO_Goods.Next;
        end;
        Gauge1.Hide;
      Except
        Gauge1.Hide;
        Exit;
      end;  MSExcel.Visible:=True;
    end;
      

  2.   

    MSExcel.ActiveSheet.UsedRange.Rows.Count; 追加的时候MSExcel.Cells[i+MSExcel.ActiveSheet.UsedRange.Rows.Count,15].
      

  3.   

    绝对值得参考的超级贴子
    http://www.delphibbs.com/delphibbs/dispq.asp?lid=1691966
      

  4.   

    导出DBGrid文件到Excel    unit DBGridExport;interfaceusesSysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls, Db, DBGrids, Comobj, extctrls, comctrls, ActiveX;typeTSpaceMark = (csComma, csSemicolon, csTab, csBlank, csEnter);TDBGridExport = class(TComponent)privateFDB_Grid: TDBGrid; {读取DBGrid的源}FTxtFileName: string; {文本文件名}FSpaceMark: TSpaceMark; {间隔符号}FSpace_Ord: Integer; {间隔符号的Asc数值}FTitle: string; {显示的标题}FSheetName: string; {工作表标题}FExcel_Handle: OleVariant; {Excel的句柄}FWorkbook_Handle: OleVariant; {书签的句柄}FShow_Progress: Boolean; {是否显示插入进度}FProgress_Form: TForm; {进度窗体}FRun_Excel_Form: TForm; {启动Excel提示窗口}FProgressBar: TProgressBar; {进度条}function Connect_Excel: Boolean; {启动Excel}function New_Workbook: Boolean; {插入新的工作博}function InsertData_To_Excel: Boolean; {插入数据}procedure Create_ProgressForm(AOwner: TComponent); {创建进度显示窗口}procedure Create_Run_Excel_Form(AOwner: TComponent); {创建启动Excel窗口}procedure SetSpaceMark(Value: TSpaceMark); {设置导出时的间隔符号}protectedpublicconstructor Create(AOwner: TComponent); override; {新建}destructor Destroy; override; {销毁}function Export_To_Excel: Boolean; overload; {导出到Excel中}function Export_To_Excel(DB_Grid: TDBGrid): Boolean; overload;function Export_To_Txt(NewFile: Boolean = True): Boolean; overload; {导出到文本文件中}function Export_To_Txt(FileName: string; NewFile: Boolean = True): Boolean; overload;function Export_To_Txt(DB_Grid: TDBGrid; NewFile: Boolean = True): Boolean; overload;function Export_To_Txt(FileName: string; DB_Grid: TDBGrid; NewFile: Boolean = True): Boolean; overload;publishedproperty DB_Grid: TDBGrid read FDB_Grid write FDB_Grid;property Show_Progress: Boolean read FShow_Progress write FShow_Progress;property TxtFileName: string read FTxtFileName write FTxtFileName;property SpaceMark: TSpaceMark read FSpaceMark write SetSpaceMark;property Title: string read FTitle write FTitle;property SheetName: string read FSheetName write FSheetName;end;procedure Register;implementationprocedure Register;beginRegisterComponents('Stone', [TDBGridExport]);end;{-------------------------------------------------------------------------------}{新建}constructor TDBGridExport.Create(AOwner: TComponent);begininherited Create(AOwner);FShow_Progress := True;FSpaceMark := csTab;end;{销毁}destructor TDBGridExport.Destroy;beginvarClear(FExcel_Handle);varClear(FWorkbook_Handle);inherited Destroy;end;{===============================================================================}{导出到文本文件中}function TDBGridExport.Export_To_Txt(NewFile: Boolean = True): Boolean;varTxt: TStrings;Tmp_Str: string;data_Str: string;i, j: Integer;Column_name: string;Data_Set: TDataSet;book: pointer;Before_Scroll, Afrer_Scroll: TDataSetNotifyEvent;beginResult := False;if NewFile = True thenFTxtFileName := '';if FTxtFileName = '' thenbeginwith TSaveDialog.Create(nil) dobeginTitle := '请选择输出文件名';DefaultExt := 'txt';Filter := '文本文件(*.Txt)|*.txt';Options := [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofNoReadOnlyReturn, ofEnableSizing];if Execute thenFTxtFileName := FileName;Free;if FTxtFileName = '' then {如果没有选中文件,则直接推出}exit;end;if FTxtFileName = '' thenbeginraise exception.Create('没有指定输出文件');Exit;end;end;if FDB_Grid = nil thenraise exception.Create('请输入DBGrid名称');Txt := TStringList.Create;try{显示插入进度}if FShow_Progress = True thenbeginCreate_ProgressForm(nil);FProgress_Form.Show;end;{第一行,插入标题}Tmp_Str := ''; //FDB_Grid.Columns[0].Title.Caption;for i := 1 to FDB_Grid.Columns.Count doif FDB_Grid.Columns[i - 1].Visible = True thenTmp_Str := Tmp_Str + FDB_Grid.Columns[i - 1].Title.Caption + Chr(FSpace_Ord);Tmp_Str := Copy(Tmp_Str, 1, Length(Tmp_Str) - 1);Txt.Add(Tmp_Str);{插入DBGrid中的数据}Data_Set := FDB_Grid.DataSource.DataSet;{记忆当前位置并取消任何事件}// new(book);book := Data_Set.GetBook;Data_Set.DisableControls;Before_Scroll := Data_Set.BeforeScroll;Afrer_Scroll := Data_Set.AfterScroll;Data_Set.BeforeScroll := nil;Data_Set.AfterScroll := nil;if FShow_Progress = True thenbeginData_Set.Last;FProgress_Form.Refresh;FProgressBar.Max := Data_Set.RecordCount;end;{插入DBGrid中的所有字段}Data_Set.First;j := 2;while not Data_Set.Eof dobeginif FShow_Progress = True thenFProgressBar.Position := j - 2;Column_name := FDB_Grid.Columns[0].FieldName;Tmp_Str := ''; //Data_Set.FieldByName(Column_name).AsString;for i := 1 to FDB_Grid.Columns.Count doif FDB_Grid.Columns[i - 1].Visible = True thenbegindata_Str := FDB_Grid.Fields[i - 1].DisplayText;Tmp_Str := Tmp_Str + data_Str + Chr(FSpace_Ord);end;Tmp_Str := Copy(Tmp_Str, 1, Length(Tmp_Str) - 1);Txt.Add(Tmp_Str);j := j + 1;Data_Set.Next;end;{恢复原始事件以及标志位置}Data_Set.GotoBook(book);Data_Set.FreeBook(book);// dispose(book);Data_Set.EnableControls;Data_Set.BeforeScroll := Before_Scroll;Data_Set.AfterScroll := Afrer_Scroll;{写到文件}Txt.SaveToFile(FTxtFileName);Result := True;finallyTxt.Free;if FShow_Progress = True thenbeginFProgress_Form.Free;FProgress_Form := nil;end;end;end;function TDBGridExport.Export_To_Txt(FileName: string; NewFile: Boolean = True): Boolean;beginFTxtFileName := FileName;Result := Export_To_Txt(NewFile);end;function TDBGridExport.Export_To_Txt(DB_Grid: TDBGrid; NewFile: Boolean = True): Boolean;beginFDB_Grid := DB_Grid;Result := Export_To_Txt(NewFile);end;function TDBGridExport.Export_To_Txt(FileName: string; DB_Grid: TDBGrid; NewFile: Boolean = True): Boolean;beginFTxtFileName := FileName;FDB_Grid := DB_Grid;Result := Export_To_Txt(NewFile);end;{-------------------------------------------------------------------------------}{设置导出时的间隔符号}procedure TDBGridExport.SetSpaceMark(Value: TSpaceMark);beginFSpaceMark := Value;case Value ofcsComma: FSpace_Ord := ord(',');csSemicolon: FSpace_Ord := ord(';');csTab: FSpace_Ord := 9;csBlank: FSpace_Ord := 32;csEnter: FSpace_Ord := 13;end;end; 
      

  5.   

    {===============================================================================}{导出到Excel中}function TDBGridExport.Export_To_Excel: Boolean;beginif FDB_Grid = nil thenraise exception.Create('请输入DBGrid名称');Result := False;if Connect_Excel = True thenif New_Workbook = True thenif InsertData_To_Excel = True thenResult := True;end;function TDBGridExport.Export_To_Excel(DB_Grid: TDBGrid): Boolean;beginFDB_Grid := DB_Grid;Result := Export_To_Excel;end; {-------------------------------------------------------------------------------}{启动Excel}function TDBGridExport.Connect_Excel: Boolean;{连接Ole对象}function My_GetActiveOleObject(const ClassName: string; out Ole_Handle: IDispatch): Boolean;var //IDispatchClassID: TCLSID;Unknown: IUnknown;l_Result: HResult;beginResult := False;l_Result := CLSIDFromProgID(PWideChar(WideString(ClassName)), ClassID);if (l_Result and $80000000) = 0 thenbeginl_Result := GetActiveObject(ClassID, nil, Unknown);if (l_Result and $80000000) = 0 thenbeginl_Result := Unknown.QueryInterface(IDispatch, Ole_Handle);if (l_Result and $80000000) = 0 thenResult := True;end;end;end;{创建OLE对象}function My_CreateOleObject(const ClassName: string; out Ole_Handle: IDispatch): Boolean;varClassID: TCLSID;l_Result: HResult;beginResult := False;l_Result := CLSIDFromProgID(PWideChar(WideString(ClassName)), ClassID);if (l_Result and $80000000) = 0 thenbeginl_Result := CoCreateInstance(ClassID, nil, CLSCTX_INPROC_SERVER orCLSCTX_LOCAL_SERVER, IDispatch, Ole_Handle);if (l_Result and $80000000) = 0 thenResult := True;end;end;varl_Excel_Handle: IDispatch;beginif FShow_Progress = True thenbeginCreate_Run_Excel_Form(nil);FRun_Excel_Form.Show;end;if My_GetActiveOleObject('Excel.Application', l_Excel_Handle) = False thenif My_CreateOleObject('Excel.Application', l_Excel_Handle) = False thenbeginFRun_Excel_Form.Free;FRun_Excel_Form := nil;raise exception.Create('启动Excel失败,可能没有安装Excel!');Result := False;Exit;end;FExcel_Handle := l_Excel_Handle;if FShow_Progress = True thenbeginFRun_Excel_Form.Free;FRun_Excel_Form := nil;end;Result := True;end;
    {插入新的工作博}function TDBGridExport.New_Workbook: Boolean;vari: Integer;beginResult := True;tryFWorkbook_Handle := FExcel_Handle.Workbooks.Add;exceptraise exception.Create('新建Excel工作表出错!');Result := False;Exit;end;if FTitle <> '' thenFWorkbook_Handle.Application.ActiveWindow.Caption := FTitle;if FSheetName <> '' thenbeginfor i := 2 to FWorkbook_Handle.Sheets.Count doif FSheetName = FWorkbook_Handle.Sheets[i].Name thenbeginraise exception.Create('工作表命名重复!');Result := False;exit;end;tryFWorkbook_Handle.Sheets[1].Name := FSheetName;exceptraise exception.Create('工作表命名错误!');Result := False;exit;end;end;end;{插入数据}function TDBGridExport.InsertData_To_Excel: Boolean;vari, j, k: Integer;data_Str: string;Column_name: string;Data_Set: TDataSet;book: pointer;Before_Scroll, Afrer_Scroll: TDataSetNotifyEvent;begintry{显示插入进度}if FShow_Progress = True thenbeginCreate_ProgressForm(nil);FProgress_Form.Show;end;{第一行,插入标题}{仅仅插入可见数据}j := 1;for i := 1 to FDB_Grid.Columns.Count doif FDB_Grid.Columns[i - 1].Visible = True thenbeginFWorkbook_Handle.WorkSheets[1].Cells[1, j].Value := FDB_Grid.Columns[i - 1].Title.Caption;FWorkbook_Handle.WorkSheets[1].Columns[j].ColumnWidth := FDB_Grid.Columns[i - 1].Width div 6;j := j + 1end;{插入DBGrid中的数据}Data_Set := FDB_Grid.DataSource.DataSet;{记忆当前位置并取消任何事件}// new(book);book := Data_Set.GetBook;Data_Set.DisableControls;Before_Scroll := Data_Set.BeforeScroll;Afrer_Scroll := Data_Set.AfterScroll;Data_Set.BeforeScroll := nil;Data_Set.AfterScroll := nil;if FShow_Progress = True thenbeginData_Set.Last;FProgress_Form.Refresh;FProgressBar.Max := Data_Set.RecordCount;end;Data_Set.First;k := 2;while not Data_Set.Eof dobeginif FShow_Progress = True thenFProgressBar.Position := k;j := 1;for i := 1 to FDB_Grid.Columns.Count dobeginif FDB_Grid.Columns[i - 1].Visible = True thenbeginColumn_name := FDB_Grid.Columns[i - 1].FieldName;data_Str := FDB_Grid.Fields[i - 1].DisplayText;FWorkbook_Handle.WorkSheets[1].Cells[k, j].Value := data_Str;j := j + 1;end;end;k := k + 1;Data_Set.Next;end;{恢复原始事件以及标志位置}Data_Set.GotoBook(book);Data_Set.FreeBook(book);// dispose(book);Data_Set.EnableControls;Data_Set.BeforeScroll := Before_Scroll;Data_Set.AfterScroll := Afrer_Scroll;Result := True;finallyFExcel_Handle.Visible := True;FExcel_Handle.Application.ScreenUpdating := True;if FShow_Progress = True thenbeginFProgress_Form.Free;FProgress_Form := nil;end;end;end;{===============================================================================}{启动Excel时给出进度显示}procedure TDBGridExport.Create_Run_Excel_Form(AOwner: TComponent);varPanel: TPanel;Prompt: TLabel; {提示的标签}beginif assigned(FRun_Excel_Form) then exit;FRun_Excel_Form := TForm.Create(AOwner);with FRun_Excel_Form dobegintryFont.Name := '宋体'; {设置字体}Font.Size := 9;BorderStyle := bsNone;Width := 300;Height := 100;BorderWidth := 2;Color := clBlue;Position := poScreenCenter;Panel := TPanel.Create(FRun_Excel_Form);with Panel dobeginParent := FRun_Excel_Form;Align := alClient;BevelInner := bvNone;BevelOuter := bvRaised;Caption := '';end;Prompt := TLabel.Create(Panel);with Prompt dobeginParent := panel;AutoSize := True;Left := 25;Top := 25;Caption := '正在导出数据,请稍候……';end;exceptend;end;end; {===============================================================================}{创建进度显示窗口}procedure TDBGridExport.Create_ProgressForm(AOwner: TComponent);varPanel: TPanel;Prompt: TLabel; {提示的标签}beginif assigned(FProgress_Form) then exit;FProgress_Form := TForm.Create(AOwner);with FProgress_Form dobegintryFont.Name := '宋体'; {设置字体}Font.Size := 9;BorderStyle := bsNone;Width := 300;Height := 100;BorderWidth := 2;Color := clBlue;Position := poScreenCenter;Panel := TPanel.Create(FProgress_Form);with Panel dobeginParent := FProgress_Form;Align := alClient;BevelInner := bvNone;BevelOuter := bvRaised;Caption := '';end;Prompt := TLabel.Create(Panel);with Prompt dobeginParent := panel;AutoSize := True;Left := 25;Top := 25;Caption := '正在导出数据,请稍候……';end;FProgressBar := TProgressBar.Create(panel);with FProgressBar dobeginParent := panel;Left := 20;Top := 50;Height := 18;Width := 260;end;exceptend;end;end; end.