高手都上哪去了!~!!!!!
高手~~~~~~~~~~~~~~~~~~~~~~~~~~~~!我吐血了。。

解决方案 »

  1.   

    参考这个procedure TPPms010.LoadExcelFile(FileName:string);
    var
      i,j,rows:integer;
      ExcelApp, WorkBook, WorkSheet : Variant;
    begin
      inherited;
      cols:=0;
      try
        ExcelApp := CreateOleObject('Excel.Application');
      except
        on E:EolesysError do
        begin
          DispErr(E.Message);
          abort;
        end
        else
        begin
          DispErr('PPMS010-02  Could not Create Excel Application!');
          abort;
        end;
      end;
      try
        try
          ExcelApp.WorkBooks.Open(edtDir.text,,True);
          WorkBook:=ExcelApp.ActiveWorkbook;
          WorkSheet:=WorkBook.ActiveSheet;
        except
          DispInf('PPMS010-01 Can''t open file!', MB_OK + MB_ICONINFORMATION);
          abort;
        end;
        dmppms010.tblAm_allocation_Head.Append ;
        SetHeadValues;                            // set master table field value
        rows:=GetSheetRows(WorkSheet);            
        PrgrsBar.Max:=rows;
        PrgrsBar.step:=1;
        PrgrsBar.Show;
        for i:=1 to rows do
        begin
          dmppms010.tblAm_Allocation_Line.Append;
          SetLineValues;                            //将excel该行数据赋给detail表的各字段
          PrgrsBar.StepIt ;
        end;
      finally
        WorkBook.Close;
        ExcelApp.Quit;
        ExcelApp:= unassigned;
        PrgrsBar.Hide ;
      end;
    end;procedure TPPms010.Save;
    begin
      with dmPpms010.tblAm_allocation_Head  do
        if not Database.InTransaction  then
          Database.StartTransaction ;
      try
        with dmPpms010.tblAm_allocation_Head do
          if Modified or UpdatesPending then        //modified 为一公用变量,表示表数据是否改动过!
            ApplyUpdates;
        with dmPpms010.tblAm_allocation_Line do
          if Modified or UpdatesPending then
            ApplyUpdates;
        dmPpms010.tblAm_allocation_Line.Database.Commit ;
        dmPpms010.tblAm_allocation_Line.Database.StartTransaction ;
        dmPPms010.Modified :=false;
        sptnSave.Enabled :=false;
      except
        on E:EDBEngineError do
          begin
            dmPpms010.tblAm_allocation_Head.Database.Rollback ;
            Ppms010.ShowError(E);
          end;
      end;
    end;
      

  2.   

    多其其老兄再送你50!!!
    收到没有?