Copying from Excel to Word

Post Reply
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

Copying from Excel to Word

Post by Natter »

Hi,

There is a large Excel file. Based on this file, I need to make a report in Word format . I copy the Excel file into an array and create a Word document based on it.

itm:=oExc:Sheets(1):Range("A1:L10000"):Value

However, since the original Excel file contains specific characters (≥, м², etc. ), they are replaced with the "? " character when writing to Word. How can we solve this ? ( you can, of course, move fragments through the Clipboard, but it's very, very long)
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Copying from Excel to Word

Post by nageswaragunupudi »

original Excel file contains specific characters (degree, root, etc. ),
Do you mean characters like these?
Image
Regards

G. N. Rao.
Hyderabad, India
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

Re: Copying from Excel to Word

Post by Natter »

I mean these symbols - ≥, м², etc.
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Copying from Excel to Word

Post by nageswaragunupudi »

Assume you are using Harbour.

Before opening Excel book, set codepage to UTF8

Code: Select all

   cp := HB_SETCODEPAGE( "UTF8" )
 
Now read from Excel and export to your Word document.
After finishing, you can restore your original codepage if you want to.

Code: Select all

 HB_SETCODEPAGE( cp )
 
Regards

G. N. Rao.
Hyderabad, India
Natter
Posts: 524
Joined: Mon May 14, 2007 9:49 am

Re: Copying from Excel to Word

Post by Natter »

I set HB_SETCODEPAGE ("UTF8") and read data from an Excel file. But Unicode characters could not be obtained. Solved the problem of copying text fragments with Unicode characters via Clipboard
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Copying from Excel to Word

Post by nageswaragunupudi »

If you are using Harbour, setting codepage to UTF8 works. I mentioned in my post that I assumed you are using Harbour. I posted my answer after testing and confirming at my end, as I always do.

If you are using xHarbour, it does not work, because xHarbour's OLE functions do not support UTF8.

Copying and pasting works in both Harbour and xHarbour.
Regards

G. N. Rao.
Hyderabad, India
Post Reply