Ver Mensaje Individual
  #12  
Antiguo 18-04-2009
Avatar de JUANCBARRETO
JUANCBARRETO JUANCBARRETO is offline
Registrado
 
Registrado: mar 2007
Posts: 7
Reputación: 0
JUANCBARRETO Va por buen camino
Abrir Txt En String Grid

ABRIR TXT EN STRING GRID SEPARADO POR ALGUN TIPO DE CARACTER COMO COMA U OTRO, EN ESTE CASO POR |

Procedure Tform1.CargaTabla(Ruta:String;Tabla:TStringgrid);
var Let : File of Char;
dat : char;
n,col,fil:integer;
s : string;
begin
n:=0;
col:=0;
fil:=0;
AssignFile(Let,Ruta);
Reset (Let);
while (n <= FileSize(Let)-1) do
begin
Seek(Let,n);
Read(Let, Dat);
if (dat <> '|') and (dat<>#13)and (dat<>#10) then
begin
s:=s+dat;
end;
if (dat = '|') OR (n = FileSize(Let)-1)OR (dat=#10) then
begin
s:=TRIM(s);
S:=StringReplace(s,'"','',[rfReplaceAll]);
tabla.Cells[col,fil]:=S;
col:=col+1;
s:='';
end;
if(dat=#10)then
begin
fil:=fil+1;
col:=0;
end;
tabla.ColWidths[0]:=150;
tabla.ColWidths[1]:=80;
n:=n+1;
end;
tabla.RowCount:=fil;
CloseFile(let);
end;
Responder Con Cita