Ver Mensaje Individual
  #5  
Antiguo 05-02-2013
steelha steelha is offline
Miembro
 
Registrado: mar 2012
Posts: 158
Reputación: 13
steelha Va por buen camino
Ok problema de index out range resuelto, pero aun me falta mejorar la rotura de total por el valor de la columna 0, Gracias por la ayuda

Código Delphi [-]
procedure TForm1.Button4Click(Sender: TObject);
var
  ruta : string;
  dia  : Word;
  mes  : Word;
  ano  : Word;
  hor  : Word;
  min  : Word;
  sec  : Word;
  mil  : Word;
  i    : Integer;
  romp : string;
  total: Real;
  filaactual : integer;
begin
  DecodeDate(Now,ano,mes,Dia);
  DecodeTime(Now,hor,min,sec,mil);
  ruta := OpenDialog1.InitialDir +'Universal_'+inttostr(Dia)+inttostr(mes)+inttostr(ano)+'_'+inttostr(hor)+inttostr(min)+inttostr(sec  )+'.txt';

  i     := 0;
  total := 0;
  filaactual := 0;
  romp  := '';
  romp  := Trim(DataGrid.Cells[0,2]);
  for i := 1 to (DataGrid.RowCount-1) do
  begin
    DataGrid.Row := i; //Posicionar en 1ra fila a trabajar
    If Trim(DataGrid.cells[0,i]) <> '' then
    begin
      If Trim(DataGrid.cells[0,i]) <> Trim(romp) then
          begin
            filaactual := DataGridagrupado.RowCount;
            DataGridagrupado.Row := filaactual-1;
            DataGridagrupado.Cells[0,filaactual] := DataGrid.Cells[0,i];
            DataGridagrupado.Cells[1,filaactual] := DataGrid.Cells[1,i];
            DataGridagrupado.Cells[2,filaactual] := FloatToStr(total);
            total := 0;
            total := total + StrToFloat(DataGrid.cells[2,i]);
            romp  := Trim(DataGrid.cells[0,i]);
            DataGridagrupado.AddRow;
          end
      else
          total := total + StrToFloat(DataGrid.cells[2,i]);
    end;
  end;

  DataGridagrupado.SaveToCSV(ruta);
end;
Responder Con Cita