Fórum Importar dados Planilha Excel #239169
23/06/2004
0
Um cliente tem uma planilha excel com muitos dados, onde são controlados custos com gastos de combustíveis. Preciso importar os dados da planilha para o sistema que foi desenvolvido em delphi 7 com firebird.
Alguém pode me dar uma ajuda, ou tem alguma rotina já pronta?
Aguardo Resposta
Raphael
Rbfonseca
Curtir tópico
+ 0Post mais votado
18/05/2009
[url]http://ibexpert.net/ibe/index.php?n=Doc.ScriptExecutive#Insertex[/url]
Powerlog Tecnologia
Gostei + 1
Mais Posts
23/06/2004
Oberdan
Espero ter ajudado.
Oberdan :!:
Gostei + 0
02/04/2009
Andradedenilson
declare nas Uses
ComObj
function XlsToStringGrid(AGrid: TStringGrid; AXLSFile: string): Boolean; const xlCellTypeLastCell = $0000000B; var XLApp, Sheet: OLEVariant; RangeMatrix: Variant; x, y, k, r: Integer; begin Result := False; //Cria Excel- OLE Object XLApp := CreateOleObject(´Excel.Application´); try //Esconde Excel XLApp.Visible := False; //Abre o Workbook XLApp.Workbooks.Open(AXLSFile); Sheet := XLApp.Workbooks[ExtractFileName(AXLSFile)].WorkSheets[1]; Sheet.Cells.SpecialCells(xlCellTypeLastCell, EmptyParam).Activate; //Pegar o número da última linha x := XLApp.ActiveCell.Row; //Pegar o número da última coluna y := XLApp.ActiveCell.Column; //Seta Stringgrid linha e coluna AGrid.RowCount := x; AGrid.ColCount := y; //Associaca a variant WorkSheet com a variant do Delphi RangeMatrix := XLApp.Range[´A1´, XLApp.Cells.Item[X, Y]].Value; //Cria o loop para listar os registros no TStringGrid k := 1; repeat for r := 1 to y do AGrid.Cells[(r - 1), (k - 1)] := RangeMatrix[K, R]; Inc(k, 1); until k > x; RangeMatrix := Unassigned; finally //Fecha o Excel if not VarIsEmpty(XLApp) then begin XLApp.Quit; XLAPP := Unassigned; Sheet := Unassigned; Result := True; end; end;
pra chamar a função vc pode utilizar um opendialog
if OpenDialog1.Execute then XlsToStringGrid(zGrid1,OpenDialog1.FileName);
espero ter ajudado.
Gostei + 0
18/05/2009
Sidimarsilva
Eu estou tentando usar sua funçao mas esta dando erro:
Incompatible types: ´TStringGrud´ and ´TDBGrid´
vc saberia me dizer o motivo?
Gostei + 0
18/05/2009
Sidimarsilva
Gostei + 0
20/05/2009
Powerlog Tecnologia
[url]http://forum.devmedia.com.br/viewtopic.php?t=100577[/url]
Gostei + 1
Clique aqui para fazer login e interagir na Comunidade :)