Amigos del foro
Estoy utilizando TOleAuto para pasar informacion desde un archivo de excel el cual tiene dos columnas de tipo fecha
En mi rutina estoy checando con un Valtype estas columnas y me dan "T" (supongo que es Time)
He probado en mi estructura del dbf con estos campos con fecha y tambien como caracter y me marca un error
en este momento los tengo como caracter con una longitud de 30
Application
===========
Path and name: P:\Fuentes\xHarbour\Alpura\BIN\Alpura.Exe (32 bits)
Size: 3,388,416 bytes
Compiler version: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 9386)
FiveWin Version: FWHX 13.01
Windows version: 6.1, Build 7601 Service Pack 1
Time from start: 0 hours 0 mins 13 secs
Error occurred at: 28/07/2013, 05:26:59
Error description: Error BASE/1110 Error de argumento: SUBSTR
Args:
[ 1] = T 24/07/2013 00:00:00.000
[ 2] = N 1
[ 3] = N 10
Stack Calls
===========
Called from: => SUBSTR( 0 )
Called from: Source\ImpOcr.prg => INICIA( 58 )
Called from: Source\ImpOcr.prg => (b)IMPOCR( 38 )
Como podría yo corregir esto ?
Si alguien me pudiera ayudar
Saludos
Estoy utilizando TOleAuto para pasar informacion desde un archivo de excel el cual tiene dos columnas de tipo fecha
En mi rutina estoy checando con un Valtype estas columnas y me dan "T" (supongo que es Time)
He probado en mi estructura del dbf con estos campos con fecha y tambien como caracter y me marca un error
en este momento los tengo como caracter con una longitud de 30
Application
===========
Path and name: P:\Fuentes\xHarbour\Alpura\BIN\Alpura.Exe (32 bits)
Size: 3,388,416 bytes
Compiler version: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 9386)
FiveWin Version: FWHX 13.01
Windows version: 6.1, Build 7601 Service Pack 1
Time from start: 0 hours 0 mins 13 secs
Error occurred at: 28/07/2013, 05:26:59
Error description: Error BASE/1110 Error de argumento: SUBSTR
Args:
[ 1] = T 24/07/2013 00:00:00.000
[ 2] = N 1
[ 3] = N 10
Stack Calls
===========
Called from: => SUBSTR( 0 )
Called from: Source\ImpOcr.prg => INICIA( 58 )
Called from: Source\ImpOcr.prg => (b)IMPOCR( 38 )
Como podría yo corregir esto ?
# include "fivewin.ch"
MEMVAR cAliasPed
MEMVAR oExcel, oHoja, nRows, nCols, oMeter, oDlg, nActual, aCampos
MEMVAR nRow, nCol, nContar
//==========================
FUNCTION ImpOcr()
//==========================
LOCAL cFile
PUBLIC oExcel, oHoja, nRows, nCols, oMeter, oDlg, nActual
PUBLIC nRow, nCol, nContar
cAliasPed := GetNewAlias( "ocrtmp" )
if !net_use( "ocrtmp",.t.,cAliasPed,oApp:xDatos )
return nil
endif
(cAliasPed)->(dbzap())
nActual := 0
nContar := 0
aCampos := {}
oExcel := TOleAuto():New( "Excel.Application" )
cFile := cGetFile("*.XLSX", "Seleccione Fichero")
if empty(cFile)
return nil
endif
oExcel:WorkBooks:Open( cFile )
oHoja := oExcel:Get( "ActiveSheet" )
nRows := oHoja:UsedRange:Rows:Count()
nCols := oHoja:UsedRange:Columns:Count()
DEFINE DIALOG oDlg RESOURCE "IMP_XLS"
REDEFINE METER oMeter Var nContar TOTAL nRows ID 501 OF oDlg UPDATE
REDEFINE BUTTON ID 400 of oDlg ACTION( INICIA( nRows,nCols,nContar ),oDlg:End() )
REDEFINE BUTTON ID 401 of oDlg ACTION( dbCloseArea((cAliasPed)), oDlg:End())
ACTIVATE DIALOG oDlg CENTERED
RETURN NIL
//========================================
STATIC FUNCTION INICIA( nRows,nCols,nContar )
//========================================
FOR nRow := 5 TO nRows
nContar = nContar + 1
oMeter:Set( nContar, sysrefresh())
(cAliasPed)->(dbappend())
FOR nCol := 1 TO nCols
xValor := oHoja:Cells(nRow,nCol):Value
if Valtype( xValor ) = "N"
xValor := str(xValor)
elseif Valtype( xValor ) = "T"
xValor := substr(xValor,1,10)
endif
(cAliasPed)->(FieldPut(nCol,xValor))
NEXT
//DBCOMMIT()
Memory(-1)
NEXT
MsgInfo( "Se ha creado el fichero OCRTMP.DBF" )
oExcel:Quit()
oExcel := nil
dbCloseArea((cAliasPed))
RETURNSi alguien me pudiera ayudar
Saludos