Extraer data de un Excel y subirla a un Cursor - - - FUNCIONANDO

170 views
Skip to first unread message

Jesús Guillén

unread,
Dec 12, 2019, 4:14:26 PM12/12/19
to Comunidad de Visual Foxpro en Español
LOCAL miExcel, lcConnstr, lcSQLCmd as String
LOCAL lnSuccess,lnSQLHand as Integer
LOCAL lcCursor as Cursor

miExcel= Getfile('xls, xlsx, xlsm, xlsb', 'Archivo:', 'Aceptar', 0, 'Seleccione una hoja de cálculo')
If Empty(miExcel)
Return .F.
Endif

Local loExcel As Excel.Application
loExcel = Createobject("Excel.application")

m.loExcel.Workbooks.Open(miExcel)
m.loExcel.Sheets(1).Select

Local oSheet As Object, lcSheet As String
oSheet = m.loExcel.ActiveSheet
lcSheet = m.oSheet.Name

loExcel.DisplayAlerts = .F.
m.loExcel.Workbooks.Close()
m.loExcel.Quit()
loExcel = Null
Release m.oSheet, m.loExcel

lcConnstr = [Driver={Microsoft Excel Driver (*.xls)};DBQ=] + miExcel
lnSQLHand = Sqlstringconnect( m.lcConnstr )

lcSQLCmd  = [Select * FROM "] + m.lcSheet + [$"]
lnSuccess = SQLExec( m.lnSQLHand, m.lcSQLCmd, [xlResults] )

SQLDisconnect(m.lnSQLHand)

BROWSE TITLE ALIAS()
* ---> el alias del cursor final es xlResults
*Eliminar el 1 del SCT si no no les va a cargar el formulario. Saludos a Todos
form1.SCT1
form1.scx

René Salamanca

unread,
Dec 12, 2019, 6:44:20 PM12/12/19
to Comunidad de Visual Foxpro en Español
Muchas gracias Jesús, excelente herramienta........

micky khan

unread,
Dec 23, 2019, 10:45:06 AM12/23/19
to publice...@googlegroups.com
No abra alguno que no use el odbc ???


--
Visita el Blog de la Comunidad Visual FoxPro en Español: http://comunidadvfp.blogspot.com
---
Has recibido este mensaje porque estás suscrito al grupo "Comunidad de Visual Foxpro en Español" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a publicesvfoxp...@googlegroups.com.
Para ver esta conversación en el sitio web, visita https://groups.google.com/d/msgid/publicesvfoxpro/17d2f4e9-ae6c-4141-a1ce-a3f96b20b0f8%40googlegroups.com.


--
  <_>
 (o o)
 (  °  )
<>-<>
Micky Khan

HernanCano

unread,
Dec 24, 2019, 5:20:17 PM12/24/19
to Comunidad de Visual Foxpro en Español
Sí, varios....
Reply all
Reply to author
Forward
0 new messages