Solved

Retrieving data from excel sheet

Posted on 1998-11-09
4
243 Views
Last Modified: 2013-11-20
How can i retrieve the data from an excel sheet to my MFC Program.
0
Comment
Question by:dloads
  • 2
4 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1324419
Use Excel as an out-of-process OLE object to open the spreadsheet then examine the data within it.
0
 
LVL 1

Accepted Solution

by:
V245 earned 200 total points
ID: 1324420
You can use ODBC. At first you should make ODBC data source. Than you can use CRecordset and CRecordView classes. If it is a new application the AppWizard can help you (turn on Database view with or without file support).

0
 

Author Comment

by:dloads
ID: 1324421
Thanx.
But if i use the CDatabase::Open command like this-->
      CDatabase *pDB = new CDatabase;
      pDB->Open("D:\\test\\test.xls" , FALSE , FALSE , "ODBC;Excel 5.0;");
It's opening up the DSN dialog box and asking for the DSN.  But i want it completely automated and the i may have to open different spreadsheets each time this program is called.


0
 
LVL 1

Expert Comment

by:V245
ID: 1324422
I'm not quite sure I understand your explanation correct. So there are two variants below:

1. If you need to work with a specific worksheet you should register an appropriate Data Source and make something like this:

          pDB->OpenEx("DSN=MyRegisteredSource");

If DSN is correct an additional dialog will not appear.

2. If you want to choose different worksheets use this way (sure, ODBC Excel driver must be installed):

          pDB->OpenEx("DSN=Excel Files;");

In this case dialog "Select Worksheet" appears and you can choose necessary one .
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now