if fileexists(Filepath1.FileName) then
begin
AssignFile(f, Filepath1.FileName);
Reset(f);
count:=0;
X:=1;
Y:=0;
while not Eof(f) do
begin
count:=count+1;
Readln(f, S);
S:=S + chr(44); //chr(44)为“,”;空格可用‘ ’
while not (S = '') do
begin
SI := Copy(S, 1, Pos(chr(44), S) - 1);
S := Copy(S, Pos(chr(44), S) + 1, Length(S));
if Copy(SI, 1, 1) = '#' then
begin
L:=Length(SI);
X:=StrToInt(Copy(SI, Pos('#', SI)+1, Pos(',',SI)-2));
Y:=StrToInt(Copy(SI, Pos(',', SI)+1, L - Pos(',', SI)));
end;
// if (SI <> ' ') and (SI <> '') and (Copy(SI, 1, 1) <> '#') then
if Copy(SI, 1, 1) <> '#' then
begin
StringGrid1.Cells[Y,X]:=trim(SI);
Inc(Y);
end;
end;
Y:=0;
Inc(X);
end;
CloseFile(f);
StringGrid1.RowCount:=count+1;