//在线等待
//以下是具体实现的过程代码,
//但运行时它提示错误:Incompatible types: 'TCustomDBGridEh' and 'TFileName'
//请各位帮忙看下,非常感谢
procedure TfrmDataParent.btnOutputClick(Sender: TObject);
var
  ExpClass:TDBGridEhExportClass;
  Ext:String;
begin  //从DBGridEh导出数据到.XLS文件或者HTM文件
  screen.Cursor:=Crhourglass;
  dlgSave.FileName:='newfile';
  if dlgSave.Execute then
  begin
    if dlgSave.FilterIndex=1 then
    begin
      ExpClass := TDBGridEhExportAsXLS;
      Ext:='xls';
    end
    else
    if  dlgSave.FilterIndex=2 then
    begin
      ExpClass := TDBGridEhExportAsHTML;
      Ext:='htm';
    end;
    dlgSave.FileName := dlgSave.FileName+'.'+ Ext;
    SaveDBGridEhToExportFile(ExpClass,dlgSave.FileName,True);
  end;
  screen.Cursor:=CrDefault;
end;
//在线等待

解决方案 »

  1.   

    http://blog.csdn.net/cornermoss/archive/2005/05/26/381115.aspx
    摘要:Modify By 角落的青苔@2005/05/13 说明:增加导出过程中的回调功能(用户停止,进度条) 是否在第一行插入FieldName 改错:以前只能对word类型数值写入,DWord会Range Check error;已修正,见CellInteger //这个单元原来的Col和Row刚好弄反了(已修正):-( 增加导出分页的功能,因为xls单页不能超过 65536 行    (全文共37739字)
      

  2.   

    你的参数错了 SaveDBGridEhToExportFile(ExpClass,(这里应该有TDBGridEh),dlgSave.FileName,True);UnitDBGridEhImpExptype  TDBGridEhExportClass = class of TDBGridEhExport;procedure SaveDBGridEhToExportFile( ExportClass: TDBGridEhExportClass; DBGridEh: TCustomDBGridEh; const FileName: String; IsSaveAll: Boolean);DescriptionSaveDBGridEhToExportFile writes selected area or the whole DBGridEh to the file in specified format.
    ExportClass parameter is one of the next classes:
    TDBGridEhExportAsText, TDBGridEhExportAsCsv, TDBGridEhExportAsHTML, TDBGridEhExportAsRTF, TDBGridEhExportAsVCLDBIF or TDBGridEhExportAsXLS.
    IsSaveAll parameter indicates whether to export whole grid or only selection.EhLib Software
      

  3.   

    cornermoss:
    很感谢你的答复,可惜那边内容太多,本人技术又有限,看不懂。