#include "fivewin.ch"
#include "xbrowse.ch"
* A Small Demonistration by Ramesh Babu to show Copied data from MsExcel in xBrowse
STATIC oClipBoard
FUNCTION main()
LOCAL cClipText, aText := {}, oDlg
SET DATE BRIT
SET CENT ON
DEFINE DIALOG oDlg TITLE "Test to show Copied Data from Excel in XBrowse"
DEFINE CLIPBOARD oClipBoard OF oDlg FORMAT TEXT
ACTIVATE DIALOG oDlg CENTERED ON INIT ( cClipText := oClipBoard:GetText() ,;
oClipBoard:Clear() ,;
oClipBoard:End() ,;
aText := ParsePasteText(oDlg,cClipText) )
IF LEN(aText) >0
XBROWSER aText
ENDIF
RETURN nil
*******************************************************************************
*** STATIC FUNCTION ParsePasteText( cText ) to Parse the Text from Windows ***
*** Clipboard to the Required data type ***
*******************************************************************************
STATIC FUNCTION ParsePasteText( oDlg, cText, cDelim)
LOCAL n, j, nCols, aTemp_Array := {}, uValue := "", lOk := .F., aText := {}
DEFAULT cDelim := Chr(9)
IF LEN(cText) = 0
MsgInfo("You do not have any data in Clipboard to Import into xBrowse.")
oDlg:End()
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 ] )
aTemp_Array := {}
FOR n := 1 TO LEN( aText )-1
FOR j := 1 TO nCols
uValue := uCharToVal( aText[ n ][ j ])
aText[n,j] := uValue
NEXT j
NEXT n
CursorArrow()
ENDIF
MsgInfo("Your data has been sucessfully copied from Excel into xBrowse.")
oDlg:End()
RETURN aText
*******************************************************************************
*** STATIC FUNCTION uCharToVal( cText, cType ) to Convert Text Data to the ***
*** Specified Data type ***
*******************************************************************************
STATIC FUNCTION uCharToVal( cText )
LOCAL uVal
cText := ALLTRIM( cText )
IF ( IsDigit( cText ) .OR. LEFT( cText, 1 ) == '-' ) .AND. ;
LTRIM( STR( Val( cText ) ) ) == cText
uVal := Val( cText )
ELSEIF UPPER( cText ) $ "T|TRUE|YES"
uVal := .t.
ELSEIF UPPER( cText ) $ "F|FALSE|NO"
uVal := .f.
ELSEIF EMPTY( uVal := CharToDate( cText ) )
uVal := cText
ENDIF
RETURN uVal
*******************************************************************************
*** STATIC FUNCTION CharToDate( cDate ) to Convert Character to Date ***
*******************************************************************************
STATIC FUNCTION CharToDate( cDate )
LOCAL cFormat, cc
LOCAL dDate
cFormat := Lower( Set( _SET_DATEFORMAT ) )
dDate := CToD( cDate )
IF EMPTY( dDate )
cc := LEFT( cFormat, 2 )
Set( _SET_DATEFORMAT, If( cc == 'dd', 'mm-dd-yy', 'dd-mm-yy' ) )
dDate := CToD( cDate )
IF cc == 'yy' .AND. EMPTY( dDate )
SET DATE AMERICAN
dDate := CToD( cDate )
ENDIF
ENDIF
Set( _SET_DATEFORMAT, cFormat )
RETURN dDate
************
Marco Turco wrote:Hi,
as subject, do you think it could be possible to past one or more column from Excel/Calc to xBrowse ?
Thanks in advance.
#include "fivewin.ch"
function ExcelCopyPaste
SET DATE ITALIAN
SET CENTURY ON
SET EPOCH TO 1950
XBROWSER "CUSTOMER.DBF" FASTEDIT SETUP ( oBrw:nMarqueeStyle := 3, oBrw:lCanPaste := .t. )
return nil
static function ClipTextAsArray( cText )
local aText, n
cText := StrTran( cText, CRLF, Chr(10) )
#ifndef __XHARBOUR__
if Right( cText, 1 ) == Chr(10)
cText := Left( cText, Len( cText ) - 1 )
endif
#endif
aText := hb_aTokens( cText, Chr(10) )
for n := 1 to Len( aText )
aText[ n ] := hb_aTokens( aText[ n ], Chr(9) )
next
return aText
//----------------------------------------------------------------------------//
static function ClipTextAsArray( cText )
local aText, n
cText := StrTran( cText, CRLF, Chr(10) )
//#ifndef __XHARBOUR__
if Right( cText, 1 ) == Chr(10)
cText := Left( cText, Len( cText ) - 1 )
endif
//#endif
aText := hb_aTokens( cText, Chr(10) )
for n := 1 to Len( aText )
aText[ n ] := hb_aTokens( aText[ n ], Chr(9) )
next
return aText
//----------------------------------------------------------------------------//
this video show you the problem adding the second column http://www.softwarexp.co.uk/beta/XBROWSE.html
if ::cDataType == nil .or. ::cDataType == cType
if ::cDataType == nil .or. ::cDataType == 'U' .or. ::cDataType == cType
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 94 guests