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

ODBC Excel - Retrieving data without ranges

Status
Not open for further replies.

LaundroMat

Programmer
Dec 2, 2003
67
BE
Hi,

Is there a way to retrieve data from an SQL sheet without defining names first?

The problem with names being that either you have to redefine them each time data is added to the column, or that you name a full column, which created too much overhead (ie all NULL values are being returned as well).

Thanks in advance!
 
Not that I know of. Another way around it is to use ADO recordsets if you are programming it. If it's a third-party tool using a DSN, you're outta luck.

When you say nulls are returned from naming a column, what does that mean?

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
I should have said that I was trying to do this in PHP. I found out how to do it (posted it in the PHP manual too, btw). My guess is that this could be useful for other environments as well.

Getting all column names from Excel with ODBC:
Code:
$cols = odbc_columns($connection, $filename, NULL, $sheet);
where:
$connection is the result of your odbc_connect;
$filename is the filename of the Excel file;
$sheet is the name of the Excel worksheet.

This is useful when you want to query an Excel file without having to name ranges beforehand. With the results obtained from the above command, you can populate an array and use its contents (ie the column names) for further querying.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top