我是做船舶制造的,以前在学校学过DELPHI 
我要的做的目的是将 excel表中的某行中一样的字段导入记事本中。
比如
Circ.   Length Circ   Width

0.126 848.5 413.7 16
0.126 848.5 413.7 16
0.043 493.3 100 14
0.043 493.3 100 14
0.21 1131.4 544.5 16
0.21 1131.4 544.5 16
0.061 670.9 100 14
0.061 670.9 100 14
0.735 1630 800 13
width字段中16导出导记事本中,13的导出导另一个记事本中,14的导出到另一个记事本中。
如何能做到。
谢谢 源码

解决方案 »

  1.   

    把excel文件导入数据库,使用数据库的sql语句处理后存入不同的文本文件
      

  2.   

    1. 读取每一行字符
    2. 抓取最后两个字符是否匹对【13,14,16】
    3. if str=‘13’ then 将该行写入文字档中,依次判断14,16的情况
      

  3.   

    直接用ado连接excel,然后进行判断  self.ADOConnection3.Connected:=False;  self.ADOConnection3.ConnectionString:='Provider=MSDASQL.1;Persist Security Info=False;'+
                                            'Data Source=study;Extended Properties="DSN=study;DBQ='+
                                            path+'study;DefaultDir='+path+';DriverId=790;FIL=excel 8.0;'+
                                            'MaxBufferSize=2048;PageTimeout=5;";Initial Catalog='+path+'study';
      try
        self.ADOConnection3.Connected:=True;
        con:=True;
      except
        con:=False;
      end;
      if con=False then
        Exit;
      self.ADOQuery4.Close;
      self.ADOQuery4.Connection:=self.ADOConnection3;
      Self.ADOQuery4.SQL.Clear;
      self.ADOQuery4.SQL.Add('select * from [sheet1$]');
      self.ADOQuery4.Open;
      self.ADOQuery4.First;
      while not Self.ADOQuery4.Eof do
      begin
        s:=self.ADOQuery4.FieldByName('width).AsString;
        if s='16' then
        begin
        end;
        if s='13' then
        beign
        end;
        if s='14' then
        beign
        end;
        self.ADOQuery4.Next;  end;
      

  4.   

    3 楼的方法好,直接在DELPHI中用SQL查询出结果,存到另一个表中,导出你要的文件
      

  5.   

    好像循环除问题了     
    self.ADOConnection1.Connected:=True;  self.ADOQuery1.Close;
      self.ADOQuery1.Connection:=self.ADOConnection1;
      Self.ADOQuery1.SQL.Clear;
      self.ADOQuery1.SQL.Add('select * from [ws$]');
      self.ADOQuery1.Open;
      self.ADOQuery1.first;
      while not Self.ADOQuery1.Eof do
      begin
      ws1:=adoquery1.fieldbyname('Thickness').AsString;
      if ws1='16' then
      ws:=ws+1;
    end;
    edit1.Text:=inttostr(ws);
    end;
    这样之后死机
      

  6.   

    好像循环除问题了    
    self.ADOConnection1.Connected:=True;   self.ADOQuery1.Close; 
      self.ADOQuery1.Connection:=self.ADOConnection1; 
      Self.ADOQuery1.SQL.Clear; 
      self.ADOQuery1.SQL.Add('select * from [ws$]'); 
      self.ADOQuery1.Open; 
      self.ADOQuery1.first; 
      while not Self.ADOQuery1.Eof do 
      begin 
      ws1:=adoquery1.fieldbyname('Thickness').AsString; 
      if ws1='16' then 
      ws:=ws+1; 
    end; 
    edit1.Text:=inttostr(ws); 
    end; 
    这样之后死机
      

  7.   

    循环里应该加adoquery1.next
    while not Self.ADOQuery1.Eof do 
    begin 
      ws1:=adoquery1.fieldbyname('Thickness').AsString; 
      if ws1='16' then 
      ws:=ws+1; 
      adoquery1.next
    end; 
      

  8.   

    给你个DELPHI7操作EXCEL的例子,这里怎么发附件啊。
    到我邮箱吧:[email protected] .我回你