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!

Find a line in xls file and display other columns

Status
Not open for further replies.

airprox

Programmer
Dec 2, 2006
12
0
0
GB
Hi Chaps,

I'm back for more!

I would like to be able to click a button and open a xls file, from within that file, I would like the program to search a certain column (not named, just letter) for the line that contains a same 4 letter alphanumeric code as one of the textboxes on my main form. When it finds a match, it then takes the values from several other columns on the same line, and put's them in seperate textboxes.

Now, I'm happy with openfiledialog (ish!) but suspect that this won't cut it... and as for the searching etc, I really have no idea where to start.

Any ideas, or code, greatly appreciated!
Cheers
Alun
 
Hey airprox,

There are libraries (and it may actually be native) out there that allow you to connect to an excel workbook like it is a database, where the connection string is the file name, the tablename is the name of the sheet, and the columns (obviously) are the columns on the sheet. In that case you could fairly easily do select queries to get anything you could possibly want, and even bind the results to datagrids and all that cool stuff.

Good luck!
-Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 
Hi Kevin,

Thanks for the reply... I'll take a look at that, although it sounds like it might be outside my experience/knowledge at the mo'. In the mean time I've been playing with changing the file to a CSV and trying to read it that way. Limited success so far, but I'm hopefull!

Cheers
Alun
 
it sounds like it might be outside my experience/knowledge at the mo'.
Check it out, you might be surprised. It's probably a lot easier...[smile]

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Steve,

I'm starting to think you're right!

With regards to these libraries that can link to an excel workbook... could someone point me in the right direction as I'm not sure what I'm looking for in Google!

Cheers
Alun
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top