Solved

Retrieving data from excel sheet

Posted on 1998-11-09
4
277 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 110
Turn a spreadsheet into a vba executable. 2 103
either24  challenge 19 110
matchUp  challenge 9 134
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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