Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Retrieving data from excel sheet

Posted on 1998-11-09
4
Medium Priority
?
290 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

876 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