Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 802
  • Last Modified:

How to access an excel spreadsheet through Delphi 5

My problem seems to be simple.  I need to open up an odbc driver linked to an excel spreadsheet in Delphi and then read some data from it.  Seems simple, but I can't seem to find the best way.  

First of all I set up a odbc datasource for the spreadsheet.

I then setup a tdatabase component and connected it without a hitch.  I then drop a ttable on the form and reference the tdatabase but when I try to select the tablename the system crashes.  

Using ADO I dropped a tadoconnection on the form, setup the connection string, tested the connection and set the connected to true, no problems.  I then drop a tadotable and referrence the tadoconnection.  There is nothing in the drop down for tablename and when I try to set active = true, it tells me the tablename is missing.

Help!
0
Randy Rich
Asked:
Randy Rich
  • 2
  • 2
  • 2
  • +1
1 Solution
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
It's a little bit long to explain how to connect to excel using ado
Here's a tutorial to start in this way http://delphi.about.com/od/database/l/aa090903a.htm
0
 
ThommyCommented:
Have you already checked this...

Connecting an Excel Spreadsheet to Delphi using ADO
http://www.glockwood.co.uk/ComputingResources/Howtos/exceltodelphi.pdf
0
 
ThommyCommented:
Another useful link...

Creating a Microsoft Excel Spreadsheet Viewer Using Delphi 5's ADOExpress
http://edn.embarcadero.com/article/20066
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
epasquierCommented:
you may have to setup in excel a region of your spreadsheet that will be the table. that is useful when you have complex speadsheet and want only a specific area of it to be accessible as a table.
I think that is done by selecting the region (with the first line being the column headers), and setting a name to that region. In ribbons GUI, it is in the 'Formula' ribbon, 'Name Manager' section, then 'Define a name'
I know Excel should allow access to each spreadsheet as a whole table, without setting an area name. But maybe there is now security functionality that prevent it to work.
I'll try to test it with an environment as close as possible as yours : what is your Delphi version and what is your Office version ?
0
 
epasquierCommented:
Here is a full sample project, with comments inside the app and the excel file.
Accessing Excel from ADO, while convenient with simple needs, is definitely NO DB alternative, when adding data and joints are required ADOExcel.zip
0
 
Randy RichPresidentAuthor Commented:
I'm using Delphi 5 and Excel 2010.
0
 
Randy RichPresidentAuthor Commented:
Wish I could give an A++++.  This was a great solution and the example made it easy to work through!  I know it's not always possible to go to this length to explain something but in this case with all the many variables, it was a tremendous help. Thank you!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now