I select a rectangular part (2x50) of the Excel sheetand save it to the clipboard .
How can I read data from a buffer into a two-dimensional array (2x50) ?
******************************
*Pegamos los items desde excel
******************************
Function pegarItemsExcel()
Local oClp
Local cTxt := space(0)
Local aTipoDato := {"C","C","N","N","C","N"}
Local aValido := {}
Local aLna := {}
Local nBien := 0
Local hLinea := hash()
Local aDato := {}
//Abrimos el portapapeles y recuperamos el ultimo texto registrado
oClp = TClipBoard():New()
oClp:Open()
cTxt = oClp:GetText()
oClp:Close()
//Recuperamos el array que biene desde el portapapeles
aText := ParsePasteText( cTxt ) //Funcion en funciones.prg
//Validamos que la informaci�n contenida en el array este bien
FOR i:=1 TO len( aText )
if len(aText[i])==6
nBien := 0
aLna := aText[i]
FOR y:=1 TO len(aLna)
if valtype(aLna[y])==aTipoDato[y]
nBien++
endif
NEXT
if nBien==6
AADD(aValido,aLna)
endif
endif
NEXT
************************************************************
*Convierte la información en array para pegar en los xbrowse
*Funcion descargada de foro de FW
************************************************************
Function ParsePasteText( cText, cDelim, aTipo )
LOCAL n, j, nCols, uValue := "", aText := {}
DEFAULT cDelim := Chr(9)
DEFAULT aTipo := {}
IF LEN(cText) = 0
MsgInfo("No hay registros para copiar","Error Datos")
RETURN {}
ENDIF
cText := StrTran( cText, CRLF, Chr(10) )
aText := hb_aTokens( cText, Chr(10) )
FOR n := 1 TO LEN( aText )
aText[ n ] := hb_aTokens( aText[ n ], cDelim)
NEXT
IF ! EMPTY( aText )
CursorWait()
nCols := LEN( aText[ 1 ] )
FOR n := 1 TO LEN( aText )-1
FOR j := 1 TO nCols
uValue := if(len(aTipo)==0,uCharToVal( aText[ n ][ j ]),if(aTipo[j]=="C",;
cvaltochar( aText[ n ][ j ]),uCharToVal( aText[ n ][ j ])))
aText[n,j] := uValue
NEXT j
NEXT n
CursorArrow()
ENDIF
RETURN aText
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 33 guests