FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour tipo de dato undefine al leer una planilla excel
Posts: 185
Joined: Thu Nov 17, 2005 12:48 AM
tipo de dato undefine al leer una planilla excel
Posted: Mon Apr 21, 2014 04: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
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: tipo de dato undefine al leer una planilla excel
Posted: Tue Apr 29, 2014 02: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, &quot;@E 9,999.99&quot; )   // result: 8.596,58

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

  ? Transform( -256.50, &quot;@)&quot; )            // Result: (256.50)

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

  ? Transform( &quot;xharbour&quot;, &quot;@!&quot; )         // Result: XHARBOUR
  ? Transform( &quot;xharbour&quot;, &quot;A!AAAAAA&quot; )   // Result: xHarbour

RETURN

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: tipo de dato undefine al leer una planilla excel
Posted: Tue Apr 29, 2014 04: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!
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: tipo de dato undefine al leer una planilla excel
Posted: Tue Apr 29, 2014 04: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( &quot;aArray&quot;  )            // result: A
  ? Type( &quot;bBlock&quot;  )            // result: B
  ? Type( &quot;cChar&quot;   )            // result: C
  ? Type( &quot;dDate&quot;   )            // result: D
  ? Type( &quot;hHash&quot;   )            // result: H
  ? Type( &quot;lLogic&quot;  )            // result: L
  ? Type( &quot;Cust-&gt;notes&quot; )        // result: M
  ? Type( &quot;nNumber&quot; )            // result: N
  ? Type( &quot;oObject&quot; )            // result: O
  ? Type( &quot;pPtr&quot;    )            // result: P
  ? Type( &quot;uNIL&quot;    )            // result: U

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

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

  ? Type( &quot;'A'&quot; )                // result: C
  ? Type( &quot;A&quot; )                  // result: U
  ? Type( &quot;{1}&quot; )                // result: A
  ? Type( &quot;{=&gt;}&quot; )               // result: H
  ? Type( &quot;9&quot; )                  // result: N
  ? Type( &quot;.F.&quot; )                // result: L
  ? Type( &quot;IIf(.T.,'A',1)&quot; )     // result: C

RETURN

PROCEDURE Test
PARAMETERS p1, p2

  ? Type( &quot;p1&quot; ), Type( &quot;p2&quot; )

RETURN

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)

Continue the discussion