“TDBGridEh”类型的变量不能申明!!函数如下:请问各位高手在使用时有什么要注意的??
function DbGridSaveToExcel(as_dbgrid: TDBGridEh;
  as_dataset: TAdodataset): Integer;
var
    i:integer;
    li_row:integer;
    ExcelApplication1:tExcelApplication;
    ExcelWorkbook1:tExcelWorkbook;
    ExcelWorksheet1:tExcelWorksheet;
  
    tb_temp:TBook;
    img_show:TImage;
begin    result:=0;    Try
        ExcelApplication1:=tExcelApplication.Create(nil);
        ExcelWorkbook1:=tExcelWorkbook.Create(nil);
        ExcelWorksheet1:=tExcelWorksheet.Create(nil);
        ExcelApplication1.AutoConnect:=false;
       // ExcelApplication1.ConnectTo( nil);
        ExcelApplication1.Connect;//EXCEL应用程序
//  
    Except
        MessageDlg('Excel may not be installed',mtError, [mbOk], 0);
        Abort;
    End;
 
    ExcelApplication1.Visible[0]:=true;
   // ExcelApplication1.Caption:='Excel Application';    try
      {  ExcelApplication1.Workbooks.Open(as_FileName  ,
            EmptyParam,EmptyParam,EmptyParam,EmptyParam,
            EmptyParam,EmptyParam,EmptyParam,EmptyParam,
            EmptyParam,EmptyParam,EmptyParam,EmptyParam,0);
       }//        ExcelApplication1.Workbooks.Add(EmptyParam,0);
        //ExcelWorkbook1.Connectto( ExcelApplication1.Workbooks[1] ) ;        ExcelWorkbook1.Connectto( ExcelApplication1.Workbooks.Add(EmptyParam,0)  ) ;
       // ExcelWorkbook1.ConnectTo( as _workbook  );//ExcelWorkbook1与Eexcelapplication1建立连接
        ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets[1] as _Worksheet);//Excelworksheet1与
        //ExcelWorksheet1.Cells.Item[1,1]:='1';     li_row:=1;  
     ExcelWorksheet1.Rows.Font.Name:='宋体';
     ExcelWorksheet1.Rows.Font.size:=9;
     ExcelWorksheet1.Rows.AutoFit;
     //ExcelWorksheet1.rows.NumberFormat:='@';//          ExcelWorksheet1.Select                     
//     ExcelWorksheet1.Range['b1','b'+inttostr(as_dataset.RecordCount)].NumberFormat:='@';     for i:=1 to      as_dbgrid.Columns.Count do
     begin        ExcelWorksheet1.Cells.Item[li_row,i]:=as_dbgrid.Columns[i-1].Title.Caption;
     end;
     ExcelWorksheet1.Range['a1','a100'].NumberFormat:='@';
     ExcelWorksheet1.Range['b1','b100'].NumberFormat:='@';     inc(li_row);
     tb_temp:=as_dataset.GetBook;
     as_dbgrid.Enabled:=false;
     as_dataset.First;    img_show:=TImage.Create(as_dbgrid.Parent);
    img_show.Parent:=as_dbgrid;
    img_show.Name:='img_showProgress';
    img_show.Visible:=true;
    img_show.Width:=300;
    img_show.Height:=20;
    img_show.Left:=round(  (as_dbgrid.Width-300)/2 );
    img_show.Top :=round(as_dbgrid.Height/3);
    img_show.BringToFront;
     while not as_dataset.Eof do
     begin
         for i:=1 to      as_dbgrid.Columns.Count do
         begin
            ExcelWorksheet1.Cells.Item[li_row,i]:=trim(as_dataset.fieldbyname(
                                        as_dbgrid.Columns[i-1].FieldName).asstring )  ;         end;
         inc(li_row);
         application.ProcessMessages;
          P_HRDrawImage( img_show ,
                        round(as_dataset.RecNo/as_dataset.RecordCount*img_show.Width),
                        inttostr( round(as_dataset.RecNo/as_dataset.RecordCount*100) )+'%'
                    );
         as_dataset.Next;
     end;     as_dataset.GotoBook(tb_temp);
     as_dataset.FreeBook(tb_temp);
     as_dbgrid.Enabled:=true;    ExcelApplication1.Visible[0]:=true;
    //ExcelWorksheet1.PrintPreview;
    ExcelWorksheet1.Disconnect;
    ExcelWorkbook1.Disconnect;
    ExcelApplication1.Disconnect;
    ExcelWorksheet1.Free;
    ExcelWorkbook1.Free;
    ExcelApplication1.Free;
    except
      on e:exception do begin
        as_dbgrid.Enabled:=true;
        ExcelApplication1.Visible[0]:=true;
        ExcelWorksheet1.Disconnect;
        ExcelWorkbook1.Disconnect;
        ExcelApplication1.Disconnect;
        ExcelWorksheet1.Free;
        ExcelWorkbook1.Free;
        ExcelApplication1.Free;        ShowMessage(e.Message);
        exit;
      end;
    end;    img_show.Free;
result:=1;
end;