Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Import Excel spreadsheet into VFP using my VFP program?
Message
From
27/09/2002 08:16:40
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00705123
Message ID:
00705163
Views:
12
I had recently a similar problem, solved as follows:

local cXLS_File,cDBF_File,cStem
set safety off
cXLS_File = upper(alltrim(this.cXLS_File))

if justext(cXLS_File)= ""
cXLS_File = cXLS_File+".XLS"
endif

if not file(cXLS_File)
messagebox("SPECIFIED EXCEL FILE DOES NOT EXIST",16,"ERROR")
This.etqXls.Text1.setfocus
return
endif

cStem = juststem( cXLS_File )

cDBF_File = server+ "\" + cStem+".DBF"

if file(cDBF_File)
erase (cDBF_File)
endif

if upper(type('oExcel')) = 'U'
oExcel=createobject('Excel.Application')
else
oExcel=getobject(,'Excel.Application')
endif

with oExcel

oWorkBook = .workbooks.open(cXLS_File)

.DisplayAlerts = .F.

oworkBook.SaveAs(cDBF_File,8) && saves Excel file as VFP table
oWorkBook.save

messagebox("DBF FILE GENERATED FROM EXCEL DATA",48,"ATTENTION")
.quit()
endwith
release oExcel,oWorkBook
Rafael Copquin
Treasurer - Microsoft Users Group of Argentina (MUG)
www.mug.org.ar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform