Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open a dbf table and export to excel worksheet

Status
Not open for further replies.

ulnaoar

Technical User
Jun 8, 2005
42
CA
Hello, I am new to Foxpro, how can I open a dbf table to export data to excel worksheet? Thanks.
 
Within the Foxpro development environment you have a COMMAND window. That is where you type your commands for user inter-active work during development. Eventually you will most likely write a program (PRG) file that will contain your commands and from which you will execute.

But for now to open the DBF table into your Foxpro environment, you can use the command
Code:
USE <dbf name>

With the older Foxpro versions you will need to use the older 8.3 filename format. If your file name and/or the directory path names are longer than that format, you will need to use the abbreviated name similar to how they will show in the DOS command windows.

Example:
"Real" file name
C:\My Foxpro\DBF Files\MyFoxproDBF.dbf
"DOS" 8.3 version:
C:\MyFoxp~1\DBFFil~1\MyFoxp~1.dbf

To examine the DBF Table, within the Command window use:
Code:
BROWSE <dbf name>

To make an Excel version of that DBF use:
Code:
COPY TO <ExcelFile> XLS

Look at these commands within your Foxpro Help file to get a better understanding of how they need to be used.

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Why not read the DBF into Excel directly without involving Foxpro? Excel imports DBF far better than Foxpro exports XLS.
 
Why not read the DBF into Excel directly without involving Foxpro? Excel imports DBF far better than Foxpro exports XLS

Of course, this is the best and easy way.
 
Many thanks to all of you, very helpful!
 

Excel imports DBF far better than Foxpro exports XLS
This may depend on your versions of FoxPro and Excel.
 
I just tried to open a dbf file from excel, but it said "this file is in a unrecognizable format" what should I do now? Thanks.
 

Now you can do what jrbbldr advised you - to open a table through FoxPro (with USE <dbf name> command) and to export it to Excel (with COPY TO <ExcelFile> TYPE XLS or COPY TO <ExcelFile> TYPE XL5)
 
Thanks!I guess I need to learn more Foxpro commands.
 

By the way, what version of FoxPro do you have?

It seems that your file is in VisualFoxPro format, not in an older FoxPro (1 to 2.6).

Excel back to at least 2000 version, or maybe even more, opens FoxPro 2.x files without problems. Or you own an older version of Excel, too?
 
Even with a newer Foxpro or an older Excel, you can

COPY TO <DBFFile> TYPE FOXPLUS

TYPE FOXPLUS will produce a DBF file from your existing DBF file without the extra header information that is blocking compatibility.
 
All above solutions are OK when you need to export bare data into Excel, but what if you want to have ready-to-view Excel "reports" with cell formatting, page headers etc? Up to now my solution was to make a sample of the desired Excel form, save it as .XML spreadsheet, then place its content into TEXT/ENDTEXT, substitute necessary header fields through << >> with SET TEXTMERGE ON, and replicate the "details" line in a SCAN loop. Resulting .XML reports would be successfully opened by Excel as native. Of course, it eventually becomes hell of the rework when the shape of the report needs more than few minor changes. Maybe there's a more elegant way to do it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top