procedure TForm1.Button1Click(Sender: TObject);
var
path:string;
ws:integer;
FList: TStringList;
ws1:string;
neirong:string;
begin
ws:=0;
path:='C:\2.txt';
//self.ADOConnection1.Connected:=False;
//self.ADOConnection1.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';
    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 adoquery1.Eof   do
   begin
  ws1:=adoquery1.fieldbyname('Thickness').AsString;
  adoquery1.Next;
  if ws1='16' then
  begin
FList:=   TStringList.Create;
FList.add(neirong);
  end;
end;
FList.SaveToFile(path);
edit1.Text:=inttostr(ws);
end; 
我想把excel表中的数据保存到记事本中  为什么记事本中是空的。

解决方案 »

  1.   


    procedure TForm1.Button1Click(Sender: TObject);
    var
    path:string;
    ws:integer;
    FList: TStringList;
    ws1:string;
    neirong:string;
    begin
    ws:=0;
    path:='C:\2.txt';
    //self.ADOConnection1.Connected:=False;
    //self.ADOConnection1.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';
        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;
    FList:=  TStringList.Create;{-------------------------------------这里}
    while not adoquery1.Eof  do
      begin
      ws1:=adoquery1.fieldbyname('Thickness').AsString;
      if ws1='16' then
      begin
         FList.add(neirong);
      end;
      adoquery1.Next;{-------------------------------------------------这里}
    end;
    FList.SaveToFile(path);
    edit1.Text:=inttostr(ws);
    end;
      

  2.   


    procedure TForm1.Button1Click(Sender: TObject);
    var
    path:string;
    ws:integer;
    FList: TStringList;
    ws1:string;
    neirong:string;
    begin
    ws:=0;
    path:='C:\2.txt';
    //self.ADOConnection1.Connected:=False;
    //self.ADOConnection1.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';
        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;
    FList:=  TStringList.Create;
    while not adoquery1.Eof  do
      begin
      ws1:=adoquery1.fieldbyname('Thickness').AsString;
      if ws1='16' then
      begin
         FList.add(neirong);
      end;
      adoquery1.Next;
    end;
    FList.SaveToFile(path);
    edit1.Text:=inttostr(ws);
    end;