最简单的方法:
用StringList.CommaText
分隔符为空格或','
procedure TForm1.ReadTableFile(Const FileName: String);
var
F:TextFile;
S:String;
TotalRow,MyRow:Integer;
StringList1: TStringList;
begin
AssignFile(F,FileName);
Reset(F);
StringList1:=TStringList.Create;
Readln(F,S);
StringList1.CommaText:=S;
StringGrid1.ColCount:=StringList1.Count;
TotalRow:=1;
Repeat
Inc(TotalRow);
Readln(F);
Until EOF(F);//得到总行数
Reset(F);
StringGrid1.RowCount:=TotalRow;
For MyRow:=0 to TotalRow do
begin
Readln(F,S);
StringList1.CommaText:=S;
StringGrid1.Rows[MyRow]:=StringList1;
end;
StringList1.Free;
CloseFile(F);
end;