FoxPro/dbf to xls
Expert: Markish - 9/13/2008
QuestionQUESTION: Sir, I have a vfp dbf file which is having to fields as following
f_1 C 100
f_2 M 4
this file i want to convert into xls format pl. help me urgently.
Thanks
Vineet
ANSWER: Hi Vineet,
Sorry for the delay in my response. I doubt if this answer will be of timely help. Still, you can export the data to xls using two ways.
i. use the 'Copy' command. Something like
use tableA
copy to tempxls XLS
ii. Use OLE Automation.
Hope this helps..
Best regards,
Markish
http://markishonline.com
Hi Vineet,
It's not abt your rating. still, I didn't note the Memo field there. I don' think there is a direct way to export memo field to XLS. You can use OLE automation. I don't know why you rate this way.
Best regards,
Markish
http://markishonline.com
---------- FOLLOW-UP ----------
QUESTION: Markish Dear Pl. don't take in otherwise, the only matter of your suggestions.
Pl. Give the example of OLE
AnswerHi Vineet,
Please find the following code for your purpose.
SET TALK OFF
CLEAR ALL
CLEAR
PUBLIC MyExcel AS Excel.APPLICATION
PUBLIC myworkbook AS Excel.Workbook
PUBLIC myworksheet AS Excel.Worksheet
Myfile=SYS(5)+SYS(2003)+"\testex.xls"
MyExcel = CREATEOBJECT("Excel.Application")
MyExcel.ReferenceStyle= -4150 && xlR1C1
myworkbook = MyExcel.Workbooks.Add()
myworksheet=myworkbook.Sheets(1)
*!* MyExcel.VISIBLE = .T.
exrow=1
USE test
GO top
DO WHILE !EOF()
myworksheet.Cells(m.exrow,1).VALUE=test.id
myworksheet.Cells(m.exrow,2).VALUE=test.name
myworksheet.Cells(m.exrow,3).VALUE=test.desc && This is a memo field
SKIP
m.exrow=m.exrow+1
ENDDO
myworksheet.Cells.Select
myworksheet.Cells.EntireColumn.AutoFit
myExcel.DisplayAlerts=.f.
myworkbook.SAVEAS(Myfile)
myworkbook.Close
MyExcel.QUIT
RELEASE myworkbook,myworksheet,MyExcel
SET TALK ON
RETURN
Hope this helps..
Best regards,
Markish
http://markishonline.com