有个客户想要以下功能,
1、将AUTOCAD中的数据读取出来
2、对两张AUTOCAD图进行比较,将不同的地方用颜色表示
分不够可以再给,如果哪位兄弟能帮忙搞定,我就把我自己做的一些控件免费奉上。

解决方案 »

  1.   

    这是我自己一个控件中的源代码,你可以看看,主要是通过ole控制
    procedure Tmydbgrid.chooseexcel(sender: tobject);
    var
      msexcel, sheet: OleVariant;
      count, i: integer; //fieldnum,
      Grid: twwdbgrid;
    begin
      grid := self;
      if grid.DataSource.DataSet.Active = false then
      begin
        prompt(mtinformation, '数据为空!');
        exit;
      end;
      try
        msexcel := CreateOleObject('excel.Application');
        msexcel.visible := true;
      except
        prompt(mtinformation, '不能启动Microsoft Excel,操作失败!');
        exit;
      end;
      count := 2;
      msexcel.Workbooks.Add(emptyparam);
      msexcel.Workbooks[1].WorkSheets[1].Name := 'Excel';
      sheet := msexcel.Workbooks[1].WorkSheets['Excel'];
      for i := 1 to grid.FieldCount do
      begin
        if grid.UseTFields then
          sheet.cells[1, i] := grid.datasource.dataset.fields[i - 1].DisplayLabel
        else
          sheet.cells[1, i] := grid.Columns[i - 1].DisplayLabel;
      end;
      try
        grid.DataSource.DataSet.DisableControls;
        grid.DataSource.DataSet.First;
        while not grid.DataSource.DataSet.Eof do
        begin
          for i := 1 to grid.FieldCount do
            sheet.cells[count, i] := grid.Fields[i - 1].asstring;
          inc(count);
          grid.DataSource.DataSet.Next;
        end;
        grid.DataSource.DataSet.First;
      finally
        grid.DataSource.DataSet.EnableControls;
      end;
    end;