怎么把ADOTABLE里的数据导出去EXECL里面去?等程序怎么写啊??

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      excelApp: Variant;
      row, col: integer;
    begin
      excelApp := CreateOleObject('Excel.Application');// uses ComObj
      excelApp.WorkBooks.Add;
      excelApp.Visible := True;
      for col := 1 to self.ADOTable1.FieldCount do
      begin
        excelApp.Cells[1, col].Value := self.ADOTable1.Fields[col - 1].FieldName;
      end;
      for row := 1 to self.ADOTable1.RecordCount do
      begin
        for col := 1 to self.ADOTable1.FieldCount do
        begin
          excelApp.Cells[row + 1, col].Value := Self.ADOTable1.Fields[col - 1].AsString;
        end;
        self.ADOTable1.Next;
      end;
      excelApp := UnAssigned;
    end;
      

  2.   

    提示这样的错误怎么办啊?
    [Error] Unit_ygda.pas(307): Undeclared identifier: 'CreateOleObject'
    [Fatal Error] blocway.dpr(64): Could not compile used unit 'Unit_ygda.pas'
      

  3.   

    // 看这行代码后面的注释
    excelApp := CreateOleObject('Excel.Application');// uses ComObj