Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel object
Message
From
04/12/2001 06:00:36
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
04/12/2001 04:43:23
Philip Jones
Cornwall County Council
Truro, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00589106
Message ID:
00589115
Views:
32
>I need to import from excel files with a column of dates stored in dd/mm/yyyy format. Unfortunately the first row of cells in each file holds the heading for the columns. If I remove the heading cells from my test spreadsheet it imports fine. If they're left in the date column is imported to a 9 character string field and I loose the last digit of each date.
>
>I think I need to create an excel object and then somehow read in values from the the header cells before deleting them so that dates will import properly.
>
>I'm new to all this though and I'm stuck again. Any help would be greatly appreciated.
>
>Phil.

Phil,
You have multipl options :) But IMHO this one is the easiest :
#DEFINE xlCSV	6	
#DEFINE xlDBF3	8	
#DEFINE xlExcel5	39	

lcXLSFile = 'yourXLSFullPathHereIncludingXLS' && ie: c:\mypath\mytest.xls
lcDBFFile = 'yourDBFNameHere'  && ie: c:\myPath\myFromExcel.dbf

oExcel = createobject('Excel.Application')
with oExcel
	.Workbooks.Open(lcXLSFile)
	.ActiveWorkBook.SaveAs(lcDBFFile, xlDBF3)
	.ActiveWorkbook.Saved = .t.
	.Quit
endwith
use (lcDBFFile)
brow
PS: lcDBFFile is NOT an existing .dbf file. Otherwise you should control overwriting and in use (for Excel side .DisplayAlerts = .f. - no overwrite).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform