Valor linha do Excel
boa tarde!
gostaria de saber com posso estar fazendo, para pegar o valor da linha de uma planilha do excel, e gravar em um arquivo txt;
Obrigado
gostaria de saber com posso estar fazendo, para pegar o valor da linha de uma planilha do excel, e gravar em um arquivo txt;
Obrigado
Airto
Curtidas 0
Respostas
Fabio.hc
13/05/2004
Tente assim:
Este exemplo esta pegando a linha 1 da planilha excel e gravando no arquivo texto.
Este exemplo esta pegando a linha 1 da planilha excel e gravando no arquivo texto.
Uses ComObj procedure TForm1.Button1Click(Sender: TObject); var Excel : Variant; Coluna:Integer; P:string; txt: textfile; begin try AssignFile(txt, ´c:\Arquivo.txt´); if not FileExists(´c:\Arquivo.txt´) then Rewrite(txt,´c:\Arquivo.txt´); Append(txt); Excel := CreateOleObject(´Excel.Application´); Excel.WorkBooks.Open(´C:\Pasta1.xls´); Coluna:=1; P:=Excel.WorkBooks[1].Sheets[1].Cells[1,Coluna]; while ( P <> ´´) do begin WriteLn(txt, Excel.WorkBooks[1].Sheets[1].Cells[1,Coluna]); Coluna:=Coluna+1; P:=Excel.WorkBooks[1].Sheets[1].Cells[1,Coluna]; end finally Excel.WorkBooks.Close; CloseFile(txt); end; end;
GOSTEI 0