Now I am able to read and write from and to cells of Excel unicode characters
In this way
This a little program that read from the first record of a dbf table that contains in one field some chinese characters
and create a excel sheet write into cells
Then read from these cells and append a record into dbf table and populate the fields with the values of the cells
Many thanks to Mr Rao and Fwh support!
#include "fivewin.ch"
FUNCTION Main()
local oExcel, oBook, oSheet, oWnd, oClp
local nRow, nCol, nCols, uVal, uVal2
FW_SetUnicode( .t. )
DEFINE WINDOW oWnd
oClp := TClipboard():New()
USE "AA_CHN"
GO TOP
nCols := FCount()
oExcel := ExcelObj()
oBook := oExcel:WorkBooks:Add()
oSheet := oBook:ActiveSheet
uVal := FieldGet( 1 )
scrivicella( "A1" , uVal , oSheet , oClp )
uVal := FieldGet( 2 )
scrivicella( "B1" , uVal , oSheet , oClp )
uVal := FieldGet( 3 )
scrivicella( "C1" , uVal , oSheet , oClp )
oExcel:Visible := .T.
APPEND BLANK
fieldput( 1 , leggicella( "A1" , oSheet , oClp , oExcel ) )
fieldput( 2 , leggicella( "B1" , oSheet , oClp , oExcel ) )
fieldput( 3 , leggicella( "C1" , oSheet , oClp , oExcel ) )
oClp:End()
oWnd:End()
return nil
FUNCTION LEGGICELLA( cRange , oAs, oClp ,oExcel )
LOCAL cRitorna
oAs:Range( cRange ):Select()
oExcel:Selection:Copy()
cRitorna := oClp:GetUnicodeText()
RETURN cRitorna
FUNCTION SCRIVICELLA( cRange , uVal , oAs, oClp )
LOCAL uVal2 := TRIM( uVal )
IF ValType( uVal ) == 'C' .AND. IsUtf8( uVal2 )
oClp:SetText( uVal2 )
oAs:Range( cRange ):Select()
oAs:Paste()
oClp:Clear()
ELSE
oAs:Range( cRange ):Value := uVal2
ENDIF
RETURN NIL