La sig. rútina quizás te sirva:
Código Delphi
[-]
uses StrUtils;
procedure StringGrid_2_Strings(StringGrid: TStringGrid; Strings: TStrings; Delimeter: String);
var
i, j: Integer;
linea: String;
begin
for i:= 0 to Pred(StringGrid.RowCount) do begin
linea := '';
for j:= 0 to StringGrid.ColCount-2 do
linea := linea + StringGrid.Cells[i,j] + Delimeter;
linea := linea + StringGrid.Cells[i,StringGrid.ColCount-1];
Strings.Add( linea )
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Clear;
StringGrid_2_Strings(StringGrid1, Memo1.Lines, '_');
end;
La sig. solución es más compacta:
Código Delphi
[-]
procedure StringGrid_2_Strings(StringGrid: TStringGrid; Strings: TStrings; Delimeter: String);
var i, line: Integer;
begin
for i:= 0 to Pred(StringGrid.RowCount) do begin
line := Strings.Add(AnsiReplaceStr(StringGrid.Rows[i].Text, #13#10, Delimeter));
Strings[line] := Copy(Strings[line], 0, Length(Strings[line])-Length(Delimeter)); end;
end;
Saludos.