Exportar StringGrid para TXT
Será que tem jeito de exportar dados do stringgrid para um arquivo TXT
Muito Obrigado
Muito Obrigado
Jmarcelo_8
Curtidas 0
Respostas
Fabianosales
03/12/2008
Tem sim. Use esta função aqui:
procedure ExportToCsv(Grid : TStringGrid; const FileName:string); const separador :string = ´;´; var Col, Row : integer; linha : string; f : TextFile; begin AssignFile(f, FileName); try Rewrite(f); for Row:=0 to Grid.RowCount-1 do begin linha := EmptyStr; for Col:=0 to Grid.ColCount-1 do begin linha := linha + Grid.Cells[Col, Row]; if not(Col = Grid.ColCount-1) then linha := linha + separador; end; Writeln(f, Linha); end; finally CloseFile(f); end; end;
GOSTEI 0