Fórum Exportar StringGrid para TXT #366675
03/12/2008
0
Será que tem jeito de exportar dados do stringgrid para um arquivo TXT
Muito Obrigado
Muito Obrigado
Jmarcelo_8
Curtir tópico
+ 0
Responder
Posts
11/12/2008
Fabianosales
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;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)