Estimados
Que me aconsejan usar para extraer informacion de una planilla de Excel.
La idea es leer la planilla y pasarla a una base de datos.
Gracias
David
Argertina.
Extraer Informacion de una Planilla de Excel
-
- Posts: 325
- Joined: Sun Feb 03, 2008 11:04 pm
- Location: Argetnina
Re: Extraer Informacion de una Planilla de Excel
David,
Desde mi experiencia, si te animas con ole, es la mejor opcion, y la otra es "Guardar como" y si usas office 2007 solo te sirve txt ya que no puedes crear dbfs con office 2007 , si es una version anterior puedes guardarlo como dbf.
atte.,
Lautaro Moreira
Osorno
Chile
Desde mi experiencia, si te animas con ole, es la mejor opcion, y la otra es "Guardar como" y si usas office 2007 solo te sirve txt ya que no puedes crear dbfs con office 2007 , si es una version anterior puedes guardarlo como dbf.
atte.,
Lautaro Moreira
Osorno
Chile
Re: Extraer Informacion de una Planilla de Excel
Te refieres a algo como esto???
Code: Select all
*******************************************************************************************************
STATIC PROCEDURE LEER() // lee una tabla excell y crea un archivo dbf
*******************************************************************************************************
LOCAL oExcel, oHoja, nRows, nCols
LOCAL aCampos:={}, nRow, nCol
oExcel := TOleAuto():New( "Excel.Application" )
oExcel:WorkBooks:Open(cFilePath(GetModuleFileName(GetInstance()))+"Prueba.xls")
oHoja := oExcel:Get( "ActiveSheet" )
nRows := oHoja:UsedRange:Rows:Count()
nCols := oHoja:UsedRange:Columns:Count()
FOR nCol := 1 TO nCols
IF ValType( oHoja:Cells( 2, nCol ):Value ) = "C"
AADD( aCampos, { oHoja:Cells( 1, nCol ):Value, "C", 80, 0 } )
ELSEIF ValType( oHoja:Cells( 2, nCol ):Value ) = "N"
AADD( aCampos, { oHoja:Cells( 1, nCol ):Value, "N", 15, 4 } )
ELSEIF ValType( oHoja:Cells( 2, nCol ):Value ) = "L"
AADD( aCampos, { oHoja:Cells( 1, nCol ):Value, "L", 1, 0 } )
ELSEIF ValType( oHoja:Cells( 2, nCol ):Value ) = "D"
AADD( aCampos, { oHoja:Cells( 1, nCol ):Value, "D", 8, 0 } )
ENDIF
NEXT
DBCREATE( "PRUEBA", aCampos )
USE "PRUEBA" NEW
FOR nRow := 2 TO nRows
APPEND BLANK
FOR nCol := 1 TO nCols
FIELDPUT( nCol, oHoja:Cells( nRow, nCol ):Value )
NEXT
NEXT
CLOSE DATABASES
oExcel:Quit()
*oHoja:End()
*oExcel:End()
MsgInfo( "Se ha creado el fichero PRUEBA.DBF" )
RETURN
Saludos
Angel, Valencia, Venezuela
xH .997 - FW 7.9 - BCC55 - WorkShop - MySql
Angel, Valencia, Venezuela
xH .997 - FW 7.9 - BCC55 - WorkShop - MySql
Re: Extraer Informacion de una Planilla de Excel
Y aquí está el caso contrario
Code: Select all
*******************************************************************************************************
STATIC PROCEDURE ENVIAR() // lee un dbf y genera una tabla excell
*******************************************************************************************************
LOCAL oExcel, oHoja
LOCAL nRow := 1, nCol
oExcel := TOleAuto():New( "Excel.Application" )
oExcel :WorkBooks:Add()
oHoja := oExcel:Get( "ActiveSheet" )
USE "PRUEBA" NEW
FOR nCol := 1 TO FCOUNT()
oHoja:Cells( nRow, nCol ):Value := FieldName( nCol )
NEXT
DO WHILE .NOT. EOF()
nRow++
FOR nCol := 1 TO FCOUNT()
oHoja:Cells( nRow, nCol ):Value := FieldGet( nCol )
NEXT
SKIP
ENDDO
FOR nCol := 1 TO FCOUNT()
oHoja:Columns( nCol ):AutoFit()
NEXT
CLOSE DATABASES
oExcel:Visible := .t.
RETURN
Saludos
Angel, Valencia, Venezuela
xH .997 - FW 7.9 - BCC55 - WorkShop - MySql
Angel, Valencia, Venezuela
xH .997 - FW 7.9 - BCC55 - WorkShop - MySql
-
- Posts: 325
- Joined: Sun Feb 03, 2008 11:04 pm
- Location: Argetnina
Re: Extraer Informacion de una Planilla de Excel
Amigos
MUCHAS GRACIAS
Lo pruebo y les Aviso...
1000000 de gracias
David
MUCHAS GRACIAS
Lo pruebo y les Aviso...
1000000 de gracias
David