[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 594: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 650: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 1110: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 1110: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 1110: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 5277: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 5277: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 5277: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3903)
Fórum Xmaker • Importar do Excel
Página 1 de 1

Importar do Excel

Enviado: Março 1st, 2013, 11:18 am
por Dimmy Angelo
Alguém tem algum código pra importar do Excel

Re: Importar do Excel

Enviado: Março 5th, 2013, 7:07 am
por Leão
Cara, melhor mesmo, é fazer a exportação para arquivo texto, existe um exemplo
que funciona no help do Xmaker, cria a tabela com os campos correspondente é
só importar...


Obrigado,
Leão

Re: Importar do Excel

Enviado: Março 7th, 2013, 4:01 pm
por ricardobhte
Amigo, veja se resolve achei essa procedure na internet
procedure TForm1.BitBtn1Click(Sender: TObject);
var
excel: Variant;
x: Integer;
arquivo: string;
begin
arquivo:='c:\Teste.xls';
Excel:=CreateOleObject('Excel.Application');
Excel.Visible:=False;
Excel.DisplayAlerts:=False;
Excel.Workbooks.Add;
Excel.Workbooks[1].Sheets.Add;
Excel.Workbooks[1].WorkSheets[1].Name:='Teste';
Excel.Workbooks[1].WorkSheets[1].DisplayPageBreaks:=False;
Excel.Columns.AutoFit;

qryTeste.First;
while (not qryTeste.Eof) do
begin
excel.WorkBooks[1].Sheets[1].Cells[x,1]:=qryTeste.FieldByName('CAMPO').AsString;
qryTeste.Next;
end;

Excel.WorkBooks[1].Sheets[1].SaveAs(arquivo);
Excel.WorkBooks.Open(arquivo);
Excel.Visible:=True;
end;