Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Merge data from two separate Excel files into a flexgrid.


Reply
 
Thread Tools Display Modes
  #1  
Old 11-12-2003, 07:43 AM
birdie_nam_nam birdie_nam_nam is offline
Newcomer
 
Join Date: Nov 2003
Posts: 3
Question Merge data from two separate Excel files into a flexgrid.


Dear very nice VB experts!

I would like to merge data from two separate workbooks into a flexgrid.
The two books contains data in a database structure, that is one line with fild names, and then the posts in sequence under it. One of the fields are named the same, and is the "key" to what should be merged. All other fields should be put into the line in the flexgrid.

I understand, or guess that this is somewhat a tricky task, but I appriciate all hints I can get.

Example of what I mean:

Book 1:

Name ID Age
Seb 1 25
Kalle 2 30
Jenny 3 6


Book 2:

ID City
1 Gothenburg
2 New York


FlexGrid:

Name ID Age City
Seb 1 25 Gothenburg
Kalle 2 30 New York
Jenny 3 6


My first thought was to treat the two books as a relationship database, and to acces it with some nice sql statement. Is this possible?

Best wishes, Sebastian.
Reply With Quote
  #2  
Old 11-12-2003, 09:52 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,885
Default

Book 2 is merely a simple lookup table (string array) which could be put in memory.
Then when retrieving data from book 1 you replace the ID with the city name from a lookup array.
Reply With Quote
  #3  
Old 11-13-2003, 02:09 AM
birdie_nam_nam birdie_nam_nam is offline
Newcomer
 
Join Date: Nov 2003
Posts: 3
Exclamation

Quote:
Originally Posted by Flyguy
Book 2 is merely a simple lookup table (string array) which could be put in memory.
Then when retrieving data from book 1 you replace the ID with the city name from a lookup array.




Thanks for replying so fast!

OK, the tables in my examples was simple examples. The real tables are both in Book 1 and Book 2 Tables with a lot of columns, and with a lot of rows. But you think that this is the way to do it anyway? To read in a 2-dimensional array, and to look up the correct row?

/Sebastian.
Reply With Quote
  #4  
Old 11-13-2003, 06:17 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,885
Default

Maybe you can ADO and SQL for it, but I would first try the most simple approach, just create a lookup table in memory to connect the rows in Book1 with the rows in Book2
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting Data from numerious excel files? cookietripper Excel 1 10-09-2003 11:07 AM
merge data from multiple excel sheets into a workbook rashida Word, PowerPoint, Outlook, and Other Office Products 1 08-20-2003 07:35 AM
Writing excel data to text file(s) wilcoa Excel 0 06-29-2003 09:00 PM
Help on reading excel files and then making data reports using these excel files nosferatu123 Word, PowerPoint, Outlook, and Other Office Products 11 10-28-2002 03:51 PM
Required files burningodzilla General 11 09-12-2001 04:51 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->