Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Algeria
 Yousfi Benameur
 To: Syed Nadeem Shibli
  Where is Syed Nadeem Shibli?
 Karachi
 Pakistan
 Syed Nadeem Shibli
 Tags
Subject: RE: import data from excel 2007
Thread ID: 187647 Message ID: 187689 # Views: 37 # Ratings: 1
Version: Visual FoxPro 8 Category: Databases, Tables and SQL Server
Date: Tuesday, August 05, 2008 12:12:36 PM         
   


> Dear Expert
>
> i have a excel file which is save in office 2007
> when i import this excel file in database the error occur
>
> " microsoft excel file format is invalid "
>
> my command line is
>
> IMPORT FROM w:\ppic\kkpaper TYPE xls
>
> but when i use file save in microsoft excel 2003
> it run correct
>
> can any body help how i use file save in excel 2007
>
> thanks and regards
>
> Nadeem

Hi Shibli
Import works with excel5 and excel 95/97 only (see foxhelp..How to: Import from Microsoft Excel).
Imports data from an external file format to create a new Visual FoxPro table.

IMPORT FROM FileName   [DATABASE DatabaseName [NAME LongTableName]]
   [TYPE]  XLS | XL5 [SHEET cSheetName]   | XL8 [SHEET cSheetName]   [AS nCodePage]


All the excel formats different must be converted to a compatible version to be imported with vfp.
then open you excel and save it in format compatible.try this code

*#define xExcel5 39
#define xExcel9795  43

oExcel = CreateObject("Excel.Application")
oWorkbook = oExcel.Application.Workbooks.Open(getfile('xls'))
oExcel.visible = .T.
messagebox("Fileformat="+trans(oWorkbook.Fileformat))
if oWorkbook.Fileformat#43
oWorkBook.saveas("c:\asup.xls",xExcel9795)
endi

oWorkbook.close(0)
oExcel.Quit
RELEASE oExcel,oWorkbook


if file("c:\asup.dbf")
set safe off
delete file c:\asup.dbf
set safe on
endi
IMPORT FROM c:\asup.xls  TYPE xls
use c:\asup.dbf
brow
use

Regards
Yousfi Benameur



COMPLETE THREAD
import data from excel 2007 Posted by Syed Nadeem Shibli @ 8/5/2008 9:00:13 AM
RE: import data from excel 2007 Posted by Borislav Borissov @ 8/5/2008 9:06:46 AM
RE: import data from excel 2007 Posted by vinod kabdal @ 8/5/2008 12:41:15 PM
RE: import data from excel 2007 Posted by Yousfi Benameur @ 8/5/2008 12:12:36 PM