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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import excel sheet to foxpro table? 1

Status
Not open for further replies.

Paco75

Programmer
Oct 11, 2001
239
0
0
US
Hi,

I want to import data from excel file into a vfp table. I tried with IMPORT command but it does not work...

here is the code i use:
Code:
MyFile = GETFILE("Excel *.xls:XLS","Import the excel file:","Import",0,"Choose the file to import")
IF NOT EMPTY(MyFile) THEN 
	IMPORT FROM JUSTFNAME(MyFile) TYPE XL8  && imports the XLS into a DBF
ENDIF
Note: for the tests the excel file is in the application root folder.

At first i received the following error message:

"Microsoft Excel file format is invalid."

I tought i was probably because the excel was in excel 2007 and this format is not supported by vfp... then i saved it in excel 97-2003 format. Now it seems to be working for 10 seconds and then it gives me this message:

"Microsoft Visual FoxPro 9.0 SP2 has stopped working
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is availiable."

Im out of ideas... any clue?
 
You were right. It is because you are using Excel 2007. But saving it to 97-2003 format won't solve it. You need to save it to either Excel 5.0/95 or CSV. Either way, you risk losing any formatting or other features that are specific to 97 or later.

There are several other ways of getting data out of Excel 2007 and into VFP, but I suggest you try the above first, as it is the simplest solution.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
One small tip. If original Excel 2007 contains more than 65,536 records, better to save to a .csv file, otherwise you'll truncate the remaining records.

Johann
 
thanks it worked in Excel 5.0/95
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top