tipo de dato undefine al leer una planilla excel

tipo de dato undefine al leer una planilla excel

Postby lafug » Mon Apr 21, 2014 4:29 pm

Estimados,

Estoy leyendo una planilla Excel desde FiveWin y el programa no reconoce si el campo es numérico o alfanumérico, por lo que no puedo capturar la información.
Ya le dí los respectivos formatos a los campos dentro de la planilla Excel y aún asi los sigue leyendo como tipo "U" undefine.
Aqui está el codigo fuente
desde ya agradezco cualquier ayuda
saludos!

FUNCTION LEEEXCEL()
LOCAL cFile,oExcel,oBook,oHoja,nTotRowCount,cNombre,nTotal,Q

cFile :="C:\VENTAS.xlsx"
oExcel:=TOleAuto():New("Excel.Application")
oBook := oExcel:Workbooks:Open(cFile)
oHoja := oExcel:Get( "ActiveSheet" )

nTotRowCount:= oHoja:UsedRange:Rows:Count()

USE C:\VENTAS NEW EXCLUSIVE

FOR Q=2 TO nTotRowCount

cNombre:=oHoja:Cells( Q, 1 ):Value
nTotal:=oHoja:Cells( Q, 3 ):Value

? TYPE("cNombre")
MsgInfo(cNombre)

//VENTAS->(DBAPPEND())
//VENTAS->CAMPO1:= vColumna1

NEXT
VENTAS->(DBCLOSEAREA())
oExcel:WorkBooks:Close()
oExcel:Application:Quit()
RELEASE oHoja
RELEASE oExcel
RETURN .T.
Luis Alfonso Fuentes Guerrero
FWH 11.06 xHarbour 1.2.1 BCC55 WorkShop
User avatar
lafug
 
Posts: 185
Joined: Thu Nov 17, 2005 12:48 am
Location: Santiago, Chile

Re: tipo de dato undefine al leer una planilla excel

Postby Jeff Barnes » Tue Apr 29, 2014 2:54 pm

Try using the Transform() function.

Transform( <xValue>, <cPicture> ) --> cFormattedString

Picture function characters Function Formatting rule
B Formats numbers left-justified
C Adds CR (credit) after positive numbers
D Formats dates in SET DATE format
E Formats dates and numbers in British format
L Pads numbers with zeros instead of blank spaces
R Nontemplate characters are inserted
X Adds DB (debit) after negative numbers
Z Formats zeros as blanks
( Encloses negative numbers in parentheses
! Converts alphabetic characters to uppercase


// The example demonstrates different formatting results of Transform()

PROCEDURE Main
LOCAL nGain := 8596.58
LOCAL nLoss := -256.50
LOCAL cPhone := "5558978532"
LOCAL cName := "Jon Doe"

? Transform( 8596.58, "@E 9,999.99" ) // result: 8.596,58

? Transform( 8596.58, "999,999.99" ) // result: 8,596.58
? Transform( 8596.58, "@L 999,999.99" ) // result: 008,596.58

? Transform( -256.50, "@)" ) // Result: (256.50)

? Transform( "5558978532", "@R (999)999-9999" )
// Result: (555)897-8532

? Transform( "xharbour", "@!" ) // Result: XHARBOUR
? Transform( "xharbour", "A!AAAAAA" ) // Result: xHarbour
RETURN
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: tipo de dato undefine al leer una planilla excel

Postby joseluisysturiz » Tue Apr 29, 2014 4:15 pm

Creo que el colega lo que quieres es saber que tipo de dato esta leyendo desde excel, he buscado en los foros y vi algo pero lo probe con FW y siempre dio error, probando las macros de excel y como se hace con la TExcelScrip que es buenisima, pero aun no lo logro, si resuelven algo y pueden compartirlo seria bueno, saludos... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: tipo de dato undefine al leer una planilla excel

Postby Jeff Barnes » Tue Apr 29, 2014 4:35 pm

Maybe this will help:

Type() -- Determines the data type of a macro expression.

Type( <cMacroExpr> ) --> cDataType

The function returns a character string identifying the data type of <cMacroExpr> when it is evaluated using the macro operator (&) (see description).

Return value Data type
A Array
B Code block
C Character string
D Date value
H Hash
L Logical value
M Memo field
N Numeric value
O Object
P Pointer to function or method
U Undefined symbol or NIL
UE Syntax error in macro expression
UI Data type is indeterminable (macro expression too complex)

// This example shows all possible return values of Type()

PROCEDURE Main
PRIVATE aArray := { 1, 2, 3 }
PRIVATE bBlock := {|x| 1+x }
PRIVATE cChar := "xHarbour"
PRIVATE dDate := Date()
PRIVATE hHash := Hash()
PRIVATE lLogic := .F.
PRIVATE nNumber := 123.45
PRIVATE oObject := GetNew()
PRIVATE pPtr := ( @Test() )
PRIVATE uNIL := NIL

USE Customer ALIAS Cust

? Type( "aArray" ) // result: A
? Type( "bBlock" ) // result: B
? Type( "cChar" ) // result: C
? Type( "dDate" ) // result: D
? Type( "hHash" ) // result: H
? Type( "lLogic" ) // result: L
? Type( "Cust->notes" ) // result: M
? Type( "nNumber" ) // result: N
? Type( "oObject" ) // result: O
? Type( "pPtr" ) // result: P
? Type( "uNIL" ) // result: U

? Type( "Val(" ) // result: UE
? Type( "Test()" ) // result: UI
? Type( "TestFunc()" ) // result: U
? Type( "Date()" ) // result: D
? Type( "oObject:hasFocus()" ) // result: L

Test( pPtr, hHash ) // result: P H

? Type( "'A'" ) // result: C
? Type( "A" ) // result: U
? Type( "{1}" ) // result: A
? Type( "{=>}" ) // result: H
? Type( "9" ) // result: N
? Type( ".F." ) // result: L
? Type( "IIf(.T.,'A',1)" ) // result: C
RETURN


PROCEDURE Test
PARAMETERS p1, p2

? Type( "p1" ), Type( "p2" )
RETURN
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 12 guests