Ver Mensaje Individual
  #6 (permalink)  
Antiguo 02-09-2008, 14:18:08
Elkin Uribe
 
Mensajes: n/a
Predeterminado Re: foxpro y office 2007

Hola Alberto, puedes bajar el archivo AccessDatabaseEngine lo instalas en
cada equipo donde la aplicacion importe este tipo de archivo (servidor y
estaciones), y ya puedes importar directamente, mira la informacion que
amablemente me paso Anders y que me permite trabajar con cualquier archivo
de excel indiferente de la version la he probado con version 97,2003 y 2007.
Todo lo que te anexo es para que te des una idea, todo esto lo he sacado del
portal del pueblo, espero no ofender a nadie


*-----------------------------------
* AUTHOR: Trevor Hancock
* CREATED: 02/15/08 04:55:31 PM
* ABSTRACT: Code demonstrates how to connect to
* and extract data from an Excel 2007 Workbook
* using the "Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)"
* from the 2007 Office System Driver: Data Connectivity Components
*-----------------------------------
LOCAL lcXLBook AS STRING, lnSQLHand AS INTEGER, ;
lcSQLCmd AS STRING, lnSuccess AS INTEGER, ;
lcConnstr AS STRING
* CLEAR
CLOSE DATABASES
lcXLBook = [C:\debido_cobrar.xls]

lcConnstr = [Driver=] + ;
[{Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};] + ;
[DBQ=] + lcXLBook

IF !FILE( lcXLBook )
MESSAGEBOX([Excel file not found])
RETURN .F.
ENDIF
*-- Attempt a connection to the .XLSX WorkBook.
*-- NOTE: If the specified workbook is not found,
*-- it will be created by this driver! You cannot rely on a
*-- connection failure - it will never fail. Ergo, success
*-- is not checked here. Used FILE() instead.
lnSQLHand = SQLSTRINGCONNECT( lcConnstr )

*-- Connect successful if we are here. Extract data...
lcSQLCmd = [Select * FROM "Hoja1$"]
lnSuccess = SQLEXEC( lnSQLHand, lcSQLCmd, [xlResults] )
* ? [SQL Cmd Success:], IIF( lnSuccess > 0, 'Esta Bien!', 'Fallo' )
IF lnSuccess < 0
LOCAL ARRAY laErr[1]
AERROR( laErr )
? laErr(3)
SQLDISCONNECT( lnSQLHand )
RETURN .F.
ENDIF


*-- Show the results
SELECT xlResults
* BROWSE NOWAIT
SQLDISCONNECT( lnSQLHand )
COPY TO temporal


***Barra de progreso en degradé de colores
***Autor: Gabriel Mandelli
***ID. DARKFOX

* Primero creamos un formulario
PUBLIC oform
oform=CREATEOBJECT("MyForm")
oform.WINDOWSTATE=0
oform.HEIGHT=39
oform.LEFT=0
oform.TOP=0
oform.WIDTH=406
oform.controlbox = .f.
oform.autocenter = .T.
oform.borderstyle = 0
oform.titlebar = 0
SET CENTURY on
SET DATE TO mdy

* Agregamos los distintos objetos que forman el termómetro
* Está formado por dos contenedores: C0 y C1
* En el container C1 se agregan dos líneas y 200 shapes
* que son los que se irán pintando con los colores en
* degradé a medida que progresa el proceso determinado
* En el container C0 se agrega un texbox con el título
oform.termometro.c1.ADDOBJECT('Linea1','shape')
WITH oform.termometro.c1.linea1
.BACKSTYLE=0
.BACKCOLOR=RGB(88,112,156)
.HEIGHT=2
.LEFT=0
.SPECIALEFFECT=0
.TOP=0
.WIDTH=402
.VISIBLE=.T.
ENDWITH
oform.termometro.c1.ADDOBJECT('Linea2','shape')
WITH oform.termometro.c1.linea2
.BACKSTYLE=0
.BACKCOLOR=RGB(88,112,156)
.HEIGHT=2
.LEFT=0
.SPECIALEFFECT=0
.TOP=18
.WIDTH=402
.VISIBLE=.T.
ENDWITH
FOR I=1 TO 200
figura='Shape'+ALLTRIM(STR(I))
oform.termometro.c1.ADDOBJECT(figura,'shape')
figura1='oform.termometro.c1.'+figura
WITH &figura1.
.BORDERCOLOR=RGB(88,112,156)
.BACKCOLOR=RGB(88,112,156)
.FILLSTYLE=0
.FILLCOLOR=RGB(0,255,0)
.TOP=2
.HEIGHT=15
.WIDTH=2
.LEFT=(I*2)-1
.CURVATURE=0
.VISIBLE=.F.
ENDWITH
ENDFOR
WITH oform.termometro.c0
.ADDOBJECT('label1','label')
.label1.CAPTION='Titulo'
.label1.BORDERSTYLE=0
.label1.BACKSTYLE=0
.label1.FONTBOLD=.T.
.label1.FORECOLOR=RGB(255,255,255)
.label1.TOP=2
.label1.HEIGHT=16
.label1.WIDTH=300
.label1.LEFT=2
.label1.VISIBLE=.T.
ENDWITH
* Se muestra el formulario con el termómetro
oform.SHOW()
* Se llama al procedimiento iniciar que efectúa los cálculos
* necesarios para seleccionar los colores correspondientes a
* cada shape del termómetro
DO iniciar
RETURN
*****
PROCEDURE iniciar
* Se eligen los colores de inicio y final
* Si se quiere colores predeterminados sacar los GETCOLOR y
* poner el valor RGB() deseado
*!* c1=GETCOLOR()
*!* suspend()
*!* c2=GETCOLOR()
*!* suspend()
c1=65535
c2=0
a1=INT(c1/(256*256))
v1=INT(MOD(c1,256*256)/256)
r1=INT(MOD(MOD(c1,256*256),256))
a2=INT(c2/(256*256))
v2=INT(MOD(c2,256*256)/256)
r2=INT(MOD(MOD(c2,256*256),256))
entero = 0
* reg = 200
titulo = 'Procesando Morosos...' &&Título que desea colocarle a la barra
oform.termometro.configuracion

set talk off
set echo off
set safe off
set dele on
close data
SET EXCLUSIVE off
SET MULTILOCKS on
PUBLIC final1
SELECT 1
USE morosos &&&excl
SET ORDER TO ficha
CURSORSETPROP('Buffering',5,'morosos') &&Buffering optimista
reg = RECCOUNT()
GO top
SCAN FOR LASTKEY() # 27 &&&FOR ctr = 1 TO reg
*!* ctr = RECNO()
*!* oform.termometro.barra
IF LASTKEY() # 27
BEGIN TRANSACTION
replace acumulado_año_actual1 WITH acumulado_año_actual, ;
acumulado_año_anterior1 WITH acumulado_año_anterior, ;
recargos1 WITH recargos, ;
saldo1 WITH saldo, ;
descuentos1 WITH descuentos, ;
devoluciones1 WITH devoluciones, ;
facturado1 WITH facturado
IF TABLEUPDATE(2,.F.,'morosos')
END TRANSACTION
ELSE
ROLLBACK
ENDIF
ENDIF
ENDSCAN
* oform.termometro.borrar
select morosos
SET ORDER TO ficha
* delete for val(codprov) = 0
* pack
c1=65535
c2=0
a1=INT(c1/(256*256))
v1=INT(MOD(c1,256*256)/256)
r1=INT(MOD(MOD(c1,256*256),256))
a2=INT(c2/(256*256))
v2=INT(MOD(c2,256*256)/256)
r2=INT(MOD(MOD(c2,256*256),256))
entero = 0
titulo = 'Actualizando Saldos Morosos...' &&Título que desea colocarle a
la barra
oform.termometro.configuracion


SELECT 2
USE temporal EXCLUSIVE
GO top
DELETE
PACK
reg = RECCOUNT()
GO top
SCAN FOR LASTKEY() # 27 &&&FOR ctr = 1 TO reg
ctr = RECNO()
oform.termometro.barra
*****
* Procesos que se realiza
* reemplazar el INKEY por el proceso
* INKEY(.01)
*****
SELECT morosos
GO TOP
* LOCATE FOR ALLTRIM(ficha) == alltrim(temporal.ficha)
IF !SEEK(alltrim(temporal.ficha),"Morosos")
IF LASTKEY() # 27
BEGIN TRANSACTION
INSERT INTO morosos (telefono,direccion,cedula, ;
facturado, acumulado_año_actual,;
acumulado_año_anterior, recargos,saldo,;
ficha, nombre, ruta, descuentos, devoluciones, ;
direccion_cobro, estado, dia, mes, ano, fecha) VALUES ;
(IIF(ISNULL(temporal.telefono)," ",ALLTRIM(temporal.telefono)),;
IIF(ISNULL(temporal.direccion)," ",ALLTRIM(temporal.direccion)), ;
IIF(ISNULL(temporal.cedula),"",ALLTRIM(temporal.ce dula)),;
IIF(ISNULL(temporal.facturado),0,VAL(temporal.fact urado)), ;
IIF(ISNULL(temporal.acumulado_),0,VAL(temporal.acu mulado_)),;
IIF(ISNULL(temporal.años_anter),0,VAL(temporal.año s_anter)),0,;
IIF(ISNULL(temporal.saldo),0,VAL(temporal.saldo)), ;
IIF(ISNULL(temporal.ficha)," ",temporal.ficha),;
IIF(ISNULL(temporal.propietari)," ",temporal.propietari), ;
IIF(ISNULL(temporal.ruta)," ",temporal.ruta), ;
IIF(ISNULL(temporal.descuentos),0,VAL(temporal.des cuentos)), ;
IIF(ISNULL(temporal.devolucion),0,VAL(temporal.dev olucion)), ;
IIF(ISNULL(temporal.direccion_)," ",temporal.direccion_), ;
IIF(ISNULL(temporal.estado),"",ALLTRIM(temporal.es tado)), ;
IIF(ISNULL(temporal.dia),"",PADL(ALLTRIM(temporal. dia),2,"0")), ;
IIF(ISNULL(temporal.mes),"",PADL(ALLTRIM(temporal. mes),2,"0")), ;
IIF(ISNULL(temporal.año),"",ALLTRIM(temporal.año)) , ;
IIF(ISNULL(temporal.mes),DATE(),IIF(ISNULL(tempora l.dia),DATE(),IIF(ISNULL(temporal.año),DATE(),;
CTOD(PADL(ALLTRIM(temporal.mes),2,"0")+"/"+PADL(ALLTRIM(temporal.dia),2,"0");
+"/"+ALLTRIM(temporal.año))))))
IF TABLEUPDATE(2,.F.,'Morosos')
END TRANSACTION
ELSE
ROLLBACK
ENDIF
ENDIF
ELSE
IF LASTKEY() # 27
BEGIN TRANSACTION
replace acumulado_año_actual WITH
IIF(ISNULL(temporal.acumulado_),0,VAL(temporal.acu mulado_)), ;
acumulado_año_anterior WITH
IIF(ISNULL(temporal.años_anter),0,VAL(temporal.año s_anter)), ;
recargos WITH 0, ;
saldo WITH IIF(ISNULL(temporal.saldo),0,VAL(temporal.saldo)), ;
descuentos WITH
IIF(ISNULL(temporal.descuentos),0,VAL(temporal.des cuentos)), ;
devoluciones WITH
IIF(ISNULL(temporal.devolucion),0,VAL(temporal.dev olucion)), ;
facturado WITH
IIF(ISNULL(temporal.facturado),0,VAL(temporal.fact urado))
IF TABLEUPDATE(2,.F.,'Morosos')
END TRANSACTION
ELSE
ROLLBACK
ENDIF
ENDIF
ENDIF
SELECT temporal
ENDSCAN
CURSORSETPROP('Buffering',1,'morosos') &&Buffering optimista
close data
USE
SET EXCLUSIVE off
oform.termometro.borrar
oform.RELEASE
ENDPROC
************
DEFINE CLASS MyForm AS FORM
CAPTION="Termómetro"
BORDERSTYLE=3
AUTOCENTER=.T.
HEIGHT=39
LEFT=0
TOP=0
WIDTH=406
ADD OBJECT termometro AS termo
ENDDEFINE
DEFINE CLASS termo AS CONTAINER
HEIGHT=44
WIDTH=408
SPECIALEFFECT=1
BACKSTYLE=0
ADD OBJECT c1 AS CONTAINER WITH;
LEFT=1,;
HEIGHT=20,;
TOP=20,;
WIDTH=403,;
BACKCOLOR=RGB(0,128,192),;
BACKSTYLE=1,;
BORDERCOLOR=RGB(0,128,192)
ADD OBJECT c0 AS CONTAINER WITH;
LEFT=1,;
HEIGHT=20,;
TOP=0,;
WIDTH=403,;
BACKCOLOR=RGB(0,128,192),;
BACKSTYLE=1,;
BORDERCOLOR=RGB(0,128,192)
PROCEDURE INIT
PUBLIC titulo,r1,v1,a1,r2,v2,a2,ctr,reg,entero,porcentaje
entero=0
porcentaje=0
ENDPROC
PROCEDURE barra
porcentaje = ctr / reg * 200
entero=INT(porcentaje)
IF entero>=1
figura='this.c1.shape'+ALLTRIM(STR(entero,3))+'.vi sible'
IF &figura=.F.
rojo = r1 + entero * (r2-r1) / 200
verde = v1 + entero * (v2-v1) / 200
azul = a1 + entero * (a2-a1) / 200
bordes='this.c1.shape'+ALLTRIM(STR(entero,3))+'.bo rdercolor'
&bordes=RGB(rojo,verde,azul)
&figura=.T.
ENDIF
ENDIF
ENDPROC
PROCEDURE borrar
IF entero#0
figura='this.c1.shape'+ALLTRIM(STR(entero,3))+'.vi sible'
&figura=.T.
ENDIF
FOR I=1 TO 100
figura='this.c1.shape'+ALLTRIM(STR(I,3))+'.visible '
&figura=.F.
ENDFOR
oFORM.termometro.VISIBLE=.F.
ENDPROC
PROCEDURE configuracion
THIS.VISIBLE=.T.
oform.termometro.c0.label1.CAPTION=titulo
ENDPROC
ENDDEFINE

elkin Uribe


"Alberto - BCN" <desarrollo***infoliber.com> escribió en el mensaje de
noticias:O9qg7HPDJHA.4704***TK2MSFTNGP06.phx.gbl...
> Hola
>
> Tengo en un equipo instalado el office 2007, el foxpro no puede importe
> archivos excel de este nuevo formato (xlsx).
> He probado de guardar el archivo con la opcion de guardar como
> "office2003" (son xls), pero tampoco los importa, mirando en internet he
> visto que cuando se guarda un archivo como "office2003" no lo guarda
> identico a los que guarda la version de office 2003, es decir el foxpro no
> los reconoce.
>
> De momento he solucionado el problema con el guardar como "XLS version
> 5.0".
>
> Si microsoft debe dar soprte a visual foxpro hasta el años 2015 (creo),
> por que no arregla estos errores/mejoras.
>
> Que significa dar soporte, si no actualiza el producto dentro de un par de
> años igual muchas de las funciones que importan dejan de ir, o si se le
> ocurre sacar al mercado un windows "XXXXX" nuevo el foxpro no se podra
> instalar si saca los SP.
>
> Alberto
>
>
>

Responder Con Cita