Copying from Excel to Word

Copying from Excel to Word

Postby Natter » Wed Mar 11, 2020 7:56 am

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)
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: Copying from Excel to Word

Postby nageswaragunupudi » Wed Mar 11, 2020 9:54 am

original Excel file contains specific characters (degree, root, etc. ),


Do you mean characters like these?
Image
Regards

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

Re: Copying from Excel to Word

Postby Natter » Wed Mar 11, 2020 11:15 am

I mean these symbols - ≥, м², etc.
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: Copying from Excel to Word

Postby nageswaragunupudi » Wed Mar 11, 2020 3:12 pm

Assume you are using Harbour.

Before opening Excel book, set codepage to UTF8
Code: Select all  Expand view  RUN
  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  Expand view  RUN
HB_SETCODEPAGE( cp )
 
Regards

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

Re: Copying from Excel to Word

Postby Natter » Thu Mar 12, 2020 7:15 am

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
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: Copying from Excel to Word

Postby nageswaragunupudi » Thu Mar 12, 2020 8:26 am

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
User avatar
nageswaragunupudi
 
Posts: 10660
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 25 guests