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

Simple Excel 5.0 import issue

Status
Not open for further replies.

Mrall

Programmer
Nov 22, 2008
64
US
I have used the import wizard to import an excel 5.0 sheet into an existing DBF file (no problem) However, I want to do it programmaticly. The user will select a xls sheet which I can retreive with a GETFILE() Function. But, one of the options I used in the wizard was the option to skip the first row (as it is the field names, not data) I'm not sure how to do this with the Import function. The structure does not ever change in the XLS just the data. Thats why I'm using an existing DBF.

I thought it would be nice if the import wizard displayed the line(s) of code that is issues to do the import. I'd have my answer than.

Thanks
 
"I want to do it programmaticly"
"I thought it would be nice if the import wizard displayed the line(s) of code..."

You are talking about 2 distinctly different ways of doing things.

The Wizard is for doing things manually through an interactive GUI where the input from Step n passes info/data to Step n+1 - just like your VFP application can do.
But by doing it programatically things can be done VERY differently.

I am guessing that you want to forget doing it manually with the Wizard and now your question is only about doing it programatically without user interaction.

There are a number of ways to Import data from an Excel file (VFP Automation, ODBC, etc.) and others responding may suggest one of those other ways.

The way that I would suggest would be to use VFP Automation to get Excel to do a SaveAs of the selected Rows & Columns into a CSV file and them do an APPEND FROM (MyCSVFile) DELIMITED.

By using VFP Automation to 'drive' Excel operations, you can make it do what you want.

Good Luck,
JRB-Bldr
 
I would actually be surprised if the import wizard used either the Import or Append From commands internally.

You do have access to the code for all the wizards, though. (Assuming you're running a recent-enough version of VFP.) Look in tools\xsource\xsource.zip in the VFP program directory. Then you can see exactly what the wizard does, and I'll bet it will be a LOT more complicated than what you're thinking it is.
 
Actually the source code of the import wizad reveals it does use the IMPORT command. It then copies the import table without the first line, if you specify a line containing field names in the steps of the wizard.

So there is no special hidden option of the IMPORT or APPEND command, you need to go through this too and recopy data without that first line.

As it's excel 5 you can also use APPEND, but that doesn't change anything in regard of skipping the first line.

Excel automation enables you to copy the lines you want.

Bye, Olaf.
 
I should perhaps have said I'd be surprised if the import wizard *JUST* used Import or Append From. There's more work involve! There has to be!

And you've proved it, Olaf. Thanks!
 
I think the easiest way to do this would be to import the database and find the first record (which contains the field names) and delete it.

Thanks for all the help

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top