FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
importar de excel a sql 2000
Hola amigos como puedo importar archivos de excel usando delphi 7 a sql server 2000, lo que quiero es que la aplicacion realice importacion si tengo varios archivos de excel como puedo abrirlo y recorrerlo y después importarlo a la vez a sql. Preferiblemente usando OpenDialog, desde ya gracias por cualquier ayuda...
__________________
ronimaxh Rep. Dominicana |
#2
|
|||
|
|||
Importar a SQL
Hola:
Ahi te envio el siguiente codigo que lo he ido conformando con cosas del club Código:
var x: Integer; Excel : Variant; Archivo: String; procedure TFormEntradaFecha.OKBtnClick(Sender: TObject); var j: Integer; hoja: Variant; begin try Excel := CreateOleObject('Excel.Application'); except Excel.Quit; showmessage('No se pudo crear el Objecto Excel.'); raise; end; if OpenDialogXls.Execute then Archivo:= OpenDialogXls.FileName else exit; NombreFichero:= ExtractFileName(Archivo); Excel.Workbooks.Open(Archivo); j:= MostrarTerritoriounidades.Value + 8; try with InsTabla1 do begin Hoja:= ExcelApp.Worksheets.Item['tabla1']; Hoja.Activate; Close; Parameters.ParamByName('@territorio').Value:= cbTerritorio.KeyValue; Parameters.ParamByName('@fecha').Value:= Int(DTP1.Date); Parameters.ParamByName('@altas').Value:= Excel.Cells[j,2].Value; Parameters.ParamByName('@bajas').Value:= Excel.Cells[j,3].Value; Parameters.ParamByName('@movimientos').Value:= Excel.Cells[j,4].Value; Parameters.ParamByName('@dirigtotal').Value:= Excel.Cells[j,5].Value; Parameters.ParamByName('@dirigmuj').Value:= Excel.Cells[j,6].Value; Parameters.ParamByName('@tectotal').Value:= Excel.Cells[j,7].Value; Parameters.ParamByName('@tecmuj').Value:= Excel.Cells[j,8].Value;; Parameters.ParamByName('@admontotal').Value:= Excel.Cells[j,9].Value; Parameters.ParamByName('@admonmuj').Value:= Excel.Cells[j,10].Value; Parameters.ParamByName('@servtotal').Value:= Excel.Cells[j,11].Value;; Parameters.ParamByName('@servmuj').Value:= Excel.Cells[j,12].Value;; Parameters.ParamByName('@obtotal').Value:= Excel.Cells[j,13].Value;; Parameters.ParamByName('@obmuj').Value:= Excel.Cells[j,14].Value;; Parameters.ParamByName('@militares').Value:= Excel.Cells[j,15].Value;; Parameters.ParamByName('@promedio').Value:= Excel.Cells[j,16].Value;; Parameters.ParamByName('@promacum').Value:= Excel.Cells[j,17].Value;; Parameters.ParamByName('@indirectos').Value:= Excel.Cells[j,18].Value;; Parameters.ParamByName('@porciento').Value:= Excel.Cells[j,19].Value;; Prepared:= True; ExecProc; end; with InsTabla2 do begin Hoja:= ExcelApp.Worksheets.Item['tabla2']; Hoja.Activate; Close; Parameters.ParamByName('@territorio').Value:= cbTerritorio.KeyValue; Parameters.ParamByName('@fecha').Value:= Int(DTP1.Date); Parameters.ParamByName('@cajeroa').Value:= Excel.Cells[j,2].Value; Parameters.ParamByName('@cajerob').Value:= Excel.Cells[j,3].Value; Parameters.ParamByName('@cajeror').Value:= Excel.Cells[j,4].Value; Parameters.ParamByName('@veedor').Value:= Excel.Cells[j,5].Value; Parameters.ParamByName('@boveda').Value:= Excel.Cells[j,6].Value; Parameters.ParamByName('@jefetrip').Value:= Excel.Cells[j,7].Value; Parameters.ParamByName('@choferesc').Value:= Excel.Cells[j,8].Value;; Parameters.ParamByName('@asv').Value:= Excel.Cells[j,9].Value; Parameters.ParamByName('@jefeinst').Value:= Excel.Cells[j,10].Value; Parameters.ParamByName('@jefegrupo').Value:= Excel.Cells[j,11].Value;; Parameters.ParamByName('@asp').Value:= Excel.Cells[j,12].Value;; Parameters.ParamByName('@oficialguardia').Value:= Excel.Cells[j,13].Value;; Parameters.ParamByName('@cctv').Value:= Excel.Cells[j,14].Value;; Parameters.ParamByName('@jefemens').Value:= Excel.Cells[j,15].Value;; Parameters.ParamByName('@chofermens').Value:= Excel.Cells[j,16].Value;; Parameters.ParamByName('@jefepiso').Value:= Excel.Cells[j,17].Value;; Parameters.ParamByName('@cajerov').Value:= Excel.Cells[j,18].Value;; Prepared:= True; ExecProc; end; Excel.quit; ShowMessage('El fichero ha sido importado exitosamente'); except ShowMessage(' !!!!! ATENCION !!!!! ' + chr(13) + 'El fichero no pudo ser importado' + chr(13) + 'Revise el fichero de importación'); end; end; |
#3
|
|||
|
|||
gracias por responder amigo, aqui va la pregunta,
ostrarTerritoriounidades.Value 'que es esto no lo entiendo'
__________________
ronimaxh Rep. Dominicana |
|
|
Temas Similares | ||||
Tema | Autor | Foro | Respuestas | Último mensaje |
Importar Excel a RTF | CARSOFT_AR | Varios | 0 | 24-08-2005 19:59:18 |
importar de excel a BD | jmlifi | Varios | 2 | 09-08-2005 11:47:18 |
Importar Campos De Excel | jadelphi | Varios | 2 | 13-04-2005 20:02:54 |
Problema al actualizar Excel 2000 a Excel XP | victork_py | Servers | 1 | 06-08-2004 19:20:41 |
importar de excel | joanajj | Servers | 3 | 04-08-2004 12:35:02 |
|