FoxPro/dbf to xls

Advertisement


Question
QUESTION: 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


Answer
Hi 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

FoxPro

All Answers


Answers by Expert:


Ask Experts

Volunteer


Markish

Expertise

I can answer general questions related to Foxpro from Version 2.0 to 9.0. I'll try to answer them as quickly as possible.

Experience

I've been into Dbase programming from age of 11. I've worked in versions from FoxPro 2.0 and Foxbase.
Education/Credentials
I've done my B.Tech (IT) with distinction from Anna University, Chennai - India.

Education/Credentials
I've done my B.Tech (IT) with distinction from Anna University, Chennai - India.

©2012 About.com, a part of The New York Times Company. All rights reserved.