unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids,StrUtils;type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
    s:string;
    sl:TStringList;
    i,j:integer;
begin
    if opendialog1.Execute then
    begin
       stringgrid1.FixedCols :=0;
       stringgrid1.FixedRows :=0;
       stringgrid1.ColCount :=0;
       sl:= TStringList.Create();
       sl.LoadFromFile(opendialog1.FileName);
       stringgrid1.RowCount :=sl.Count;
       //***********************************************************************
       s:=sl.Strings[0];
       j:=0;
       while pos(',',s)>0 do
       begin
           stringgrid1.Cells[j,0]:=midstr(s,0,pos(',',s)-1);
           s:=copy(s,pos(',',s)+1,length(s)-pos(',',s)+1);
           inc(j);
           stringgrid1.ColCount :=j;
       end;
       stringgrid1.ColCount :=j+1;
       stringgrid1.Cells[j,0]:=midstr(s,0,length(s));
       //***********************************************************************
       for i:=1 to sl.Count-1 do
       begin
           s:=sl.Strings[i];
           j:=0;
           while pos(',',s)>0 do
           begin
               stringgrid1.Cells[j,i]:=midstr(s,0,pos(',',s)-1);
               s:=copy(s,pos(',',s)+1,length(s)-pos(',',s)+1);
               inc(j);
           end;
           //stringgrid1.ColCount :=j+1;
           stringgrid1.Cells[j,i]:=midstr(s,0,length(s));
       end;
    end;
end;end.