> 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