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

Excel to Database

Status
Not open for further replies.

mariebmk

Programmer
Jun 26, 2003
52
0
0
US
Hello! I'm developing an application where the user can upload an excel file, which is then inserted into a database. I have the code written that I can user the excel file as a datasource and query from it. . .the only problem being I need to know the worksheet name to do so. I have no guarantee that they will use a standard worksheet name. Is there any way I can either read the name before querying or that I can change it to something standard?

Thanks!!!

 
I'm not sure there is a way to get a worksheet name. You would likely have more control if you could get the user to export the excel file to a .csv file before uploading. You could then user a LOAD DATA INFILE statement to import the data.

<cfquery name="updateTable" datasource="datasource">
LOAD DATA INFILE 'path/filename.csv' INTO TABLE tablename
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n'
</cfquery>

This will import a comma delimited list with single quotes as text qualifier.
 
I don't think LOAD DATA INFILE works with Access if that's what you're using for a database though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top