Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to export memo fields from VFP table to excel?
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00350727
Message ID:
00350816
Views:
17
>>>Want to export my VFP table to Excel. Used the Import, but it did not export the memo fields. How can I export the memo fields?
>>>
>>>thanks
>>>
>>>brenda
>
>>Look at the COPY TO command in the VFP help system depending on the version of >Excel COPY TO TYPE xl5 or xls (I am not sure, but look at the help, then try >it out).
>>Bret Hobbs
>
>i tried both the xl5 and xls. my memo table column does not export to the xcel work sheet. any other ideas?
>
>brenda

This is from Cetin Basöz in a previous post it may help, but it is using the excel object to move data from VFP to Excel, hope it may help.

*****Cetin's code ****

Use employee
=Table2ClipBoard()
#include "xlconstants.h"
oExcel = createobject("Excel.Application")
With oExcel
.visible = .t.
.Workbooks.Add
With .ActiveWorkbook.ActiveSheet
.Paste
.Range("O:O").Select && employee.notes are on column O
Endwith
With .Selection
.ColumnWidth = 35 && Increase width for memo
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = .T.
.Replace("~",chr(13),xlWhole, xlByColumns)
Endwith
Endwith


Function Table2ClipBoard
lcTempFileName = "X"+sys(2015)+".tmp"
handle = fcreate(lcTempFileName) && Create a temp file
#Define TABULATE chr(9)
#Define NL chr(13)

For ix = 1 to fcount()
=fwrite(handle, field(ix))
If ix < fcount()
=fwrite(handle, TABULATE)
Endif
Endfor
=fwrite(handle, NL)
Scan && Start scan..endscan
For ix = 1 to fcount() && Write field values
=fwrite(handle, typeconvert(ix) )
If ix < fcount()
=fwrite(handle, TABULATE)
Endif
Endfor
=fwrite(handle, NL)
Endscan
lnSize=fseek(handle,0,2)
=fseek(handle,0,0)
_Cliptext = fread(handle, lnSize) && Read file to clipboard
=fclose(handle)
Erase (lcTempFileName)

Function typeconvert
Lparameters tnField
lcType = type(field(ix))
If lcType = "G"
lcField = field(ix)
Return transform(&lcField)
Endif
luValue = eval(field(ix))
Do case
Case lcType = "D"
lcValue = dtoc(luValue)
Case lcType = "T"
lcValue = ttoc(luValue)
Case lcType $ "NY"
lcValue = padl(luValue,20," ")
Case lcType = "L"
lcValue = iif(luValue,"Yes","No")
Case lcType $ "M" && Replace paragraph marks with "~"
lcValue = strtran(luValue, chr(13)+chr(10), "~")
Case lcType $ "C"
lcValue = luValue
Otherwise
lcValue = ""
Endcase
Return alltrim(lcValue)
Cetin
Çetin Basöz
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Previous
Reply
Map
View

Click here to load this message in the networking platform