>>
APLDN Home

>>
Events

>>
Trainings

>>
APL Books

>>
APLDN Links

>>
Discussion Groups

>>
Downloads

>>
Articles

>>
Library

>>
Learning Tools

>>
APLDN User IO

>>
APL2000.com




General

Author Thread: Retrieving unicode from Excel
Jürgen.Wiedemann
Retrieving unicode from Excel
Posted: Thursday, May 18, 2006 2:09 AM (EST)
I have to read (unicode) text from Excel or Word. Up to now, I work around this problem by calling Excel or Word application and invoke the XSaveAs method with to save the file as unicode text. Then I disconnect from Excel/Word and read this unicode text file with datatype 163. I there a direct way to retrieve unicode? How can I get the numeric unicode values directly from Excel/Word over the COM interface?


Comments:

Author Thread:
Rex.Swain
Retrieving unicode from Excel
Posted: Thursday, May 18, 2006 8:31 AM (EST)

Have you tried using the clipboard?  You could use COM to tell Word to Edit|Select All and then Edit|Copy.  Then from APL read the clipboard:

 

Œwcall 'GetClipboardData' 'CF_UNICODETEXT'

 

I've never actually tried this; just an idea.

     

Support
Retrieving unicode from Excel
Posted: Thursday, May 18, 2006 3:44 PM (EST)

It is possible to pass unicode data to and from COM objects (and ActiveX controls) using the new unicodebstr property and new ŒUCS function in APL+Win version 6.  The unicodebstr property is described on page 226 of the Windows Reference Manual and the ŒUCS function on page 113 of the System Functions Manual.  See also ŒTYPE on page 113 of the System Functions Manual as it pertains to Unicode data.

The following is a step-by-step example using Excel:

 

1.  'xl' Œwi 'New' 'Excel.Application'  © Create Excel Application Object

2.  'xl' Œwi 'Workbooks.Add>.wkbk'          © Add workbook

3.  'xl' Œwi 'Range>.rng' 'A1'              © Set the range property

4.  'xl.rng' Œwi 'unicodebstr' 1            © Set unicodebstr property

5.  array„(Œucs 74 65 80 65 78 12399 12469 12540 12499 12473)  © Turn array into Unicode string

6.  'xl.rng' Œwi'Value2'(³array)            © Set data

7.  The word "JAPAN" followed by japanese text should appear in cell A1

8.  'xl.rng'Œwi'Value2'             © Return cell value

9.  <<<UCS Characters>>>            © This result represents Unicode character in result

10. Œucs 'xl.rng'Œwi'Value2'        © Return cell value as Unicode values

11. 74 65 80 65 78 12399 12469 12540 12499 12473    © The result is Unicode array

APL2000 Support

     



APL2000 Official Web Site

Service is the rent we pay for being. It is the very purpose of life, and not something you do in your spare time.
--- Marion Wright Edelman

APLDN Home   |    |  Events   |  Trainings   |  APL Books   |  APLDN Links   |    |  Discussion Groups   |    |  Downloads   |  Articles   |  Library   |  Learning Tools   |  APLDN User IO   |  APL2000.com   |