Solved

Retrieving data from excel sheet

Posted on 1998-11-09
4
268 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

839 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