Ver Mensaje Individual
  #3  
Antiguo 10-03-2009
Avatar de totote
totote totote is offline
Miembro
 
Registrado: oct 2006
Posts: 150
Reputación: 18
totote Va por buen camino
Talking

Caro muchas gracias me funcionó perfectamente, al final resultó más facil que de la forma en que lo estaba haciendo, ya que tomo los valores directamente del TStringList

Así quedó el código

Código Delphi [-]
function CsvToStringGrid(AGrid: TStringGrid; ACSVFile: String): Boolean;
var
  i,j,Columnas: integer;
  aux: String;
  p: TfrmProgress;
  sl: TStringList;
begin
  Result:= False;
  sl:= TStringList.Create;
  sl.LoadFromFile(ACSVFile);
  aux:= sl[0];
  Columnas:= ContarColumnas(aux);
  AGrid.ColCount:= Columnas;
  p:= TfrmProgress.Create(nil);
  p.pbPrincipal.Min:= 0;
  p.pbPrincipal.Max:= sl.Count;
  for i := 1 to Columnas - 1 do
    AGrid.Cells[i,0]:= GetColumna(i); // Función que devuelve el título de la columna
  j:= 0;
  p.Show;
  while (j < sl.Count ) and (p.Seguir = True) do // P.Seguir es una variable tipo Boolean que cambia su estádo Con un botón Cancelar
  begin
    i:= 1;
    AGrid.Cells[0,j]:= IntToStr(j+1);
    aux:= sl[j];
    while Pos(';',aux) > 0 do
    begin
      AGrid.Cells[i,j]:= Copy(aux,1,Pos(';',aux)-1);
      Delete(aux,1,Pos(';',aux));
      i:= i + 1;
    end;
    j:= j + 1;
    AGrid.RowCount:= j + 1;
    Result:= True;
    p.pbPrincipal.Position:= j; // Mostrar progreso
    p.Caption:= 'Completado: ' + IntToStr((j * 100) div sl.Count) + '%';
  end;
  p.Free;
end;

Saludos y muchas gracias
__________________
¡Oh nooo! no compartas, compartir es pirateria, compartir te llevara a la carcel - Revolution OS
Responder Con Cita