Create Excel from Fwh with Unicode characters

Create Excel from Fwh with Unicode characters

Postby MarcoBoschi » Thu Nov 19, 2015 2:00 pm

Hi,
aa_chn.dbf is a dbf table that contains in des_chn field some chinese characters
If a create an excel worksheet and write into cell the "des_chn" field content they does not appear
as in the dbf field

Image

Image

Code: Select all  Expand view

#include "fivewin.ch"

ANNOUNCE RDDSYS

FUNCTION CRE_XLS()
LOCAL oExcel
LOCAL oAs
LOCAL nRow
FW_SetUnicode( .t. )

oExcel := CreateObject( "Excel.Application" )
oExcel:WorkBooks:Add()

oAs := oExcel:Activesheet()

SELECT 0
USE aa_chn
SET INDEX TO aa_chn
GO TOP
oAs:Range( "A1" ):Value := "English Description"
oAs:Range( "B1" ):Value := "Chinese Description"

nRow := 2
DO WHILE !EOF()
   IF !EMPTY( aa_chn->des_chn )
       MsgInfo( aa_chn->des_chn , aa_chn->descrizi )

       oAs:Range( "A" + cRow(nRow) ):Value := "'" + ALLTRIM( aa_chn->descrizi )
       oAs:Range( "B" + cRow(nRow) ):Value := "'" + ALLTRIM( aa_chn->des_chn )
       nRow ++
   ENDIF
   SKIP
ENDDO
oExcel:visible := .T.
USE
RETURN NIL


FUNCTION CROW( nRow )
LOCAL cRow := ALLTRIM( STR( nRow ) )
RETURN cRow


INIT PROCEDURE RddInit
REQUEST DBFFPT
REQUEST DBFCDX
rddSetDefault( "DBFCDX" )
RETURN

 
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Create Excel from Fwh with Unicode characters

Postby nageswaragunupudi » Thu Nov 19, 2015 10:54 pm

The bottleneck is the OleAuto implementations of (x)Harbour.

We are working on OLE alternative with Unicode support independent of (x)Harbour.

For now the solution is copy the utf8 text into clipboard and paste into Excel sheet using FWH 15.09. (In this version TClipBoard class supports Unicode). This is how XBrowse to Excel works with Unicode data.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Create Excel from Fwh with Unicode characters

Postby nageswaragunupudi » Fri Nov 20, 2015 4:26 am

Here is a small example.
I have a dbf UTF8_01.DBF with Unicode contents for testing.
Code: Select all  Expand view
  DEFINE WINDOW oWnd
   USE UTF8_01
   aData    := FW_DbfToArray()
   AEval( aData, { |a,i| aData[ i ] := FW_ArrayAsList( a, Chr(9) ) } )
   aData    := FW_ArrayAsList( aData, CRLF )
   oClp     := TClipBoard():New()
   oClp:SetText( aData )
   oExcel   := ExcelObj()
   oBook    := oExcel:WorkBooks:Add()
   oSheet   := oBook:ActiveSheet
   oSheet:Cells( 1, 1 ):Select()
   oSheet:Paste()
   for n := 1 to 3
      oSheet:Columns( n ):AutoFit()
   next
   oClp:Clear()
   oExcel:Visible := .t.
   oWnd:End()
 

Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Create Excel from Fwh with Unicode characters

Postby MarcoBoschi » Sat Nov 21, 2015 8:06 am

Rao,
maybe the problem is my table but with fivedbu see the exact characters.
In Excel I do not see exact characters.
I use the latest version
Do you want to see my dbf table?
Marco
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Create Excel from Fwh with Unicode characters

Postby nageswaragunupudi » Sat Nov 21, 2015 9:02 am

If you are using the latest version, you should be able to see the characters in xbrowse and oBrw:ToExcel() should also export correctly.
I am expecting that you are using utf-8 encoding. Prior to general acceptance and adoption of utf-8 for all languages, there was lot of work done and various encodings were developed for Chinese chars. Our library works only with general utf-8 encoding and this works for universal languages.
You may please send your dbf to my email and let me check too.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Create Excel from Fwh with Unicode characters

Postby MarcoBoschi » Sat Nov 21, 2015 10:30 am

Rao,
info@marcoboschi.it is my email
Thank you very much
Marco
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 60 guests

cron