Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can XLS files be used in VC++?

Status
Not open for further replies.

azamK

Programmer
Aug 12, 2001
10
0
0
IR
I can use MS Access files (mdb) via ODBC driver in VC.
But I don't know how I can use Excel files (with extension XLS) in VC. How can I read the Data of a desirable cell of XLS file, in VC++?
I would appreciate someone who help me.
 
Don't know the answer to this myself - however, I went to google.com and typed 'excel C++' and got a whole list of stuff that would tell me how to do it.

Hope this helps.
M.

Hollingside Technologies, Making Technology work for you.
 
It's COM based, you can manipulate those files through the Excel interfaces.

Greetings,
Rick
 
Assuming you're using Visual Studio.NET:
1. Create the project with automation enabled
2. Right click on your project in the class view and select "add class"
3. Choose MFC class from TypeLib
4. You can then either select the library file or choose the library from the registry - I choose the file. Office type libraries are listed below (from Microsoft web page)
Microsoft Access 97 Msacc8.olb
Microsoft Jet Database 3.5 DAO350.dll
Microsoft Binder 97 Msbdr8.olb
Microsoft Excel 97 Excel8.olb
Microsoft Graph 97 Graph8.olb
Microsoft Office 97 Mso97.dll
Microsoft Outlook 97 Msoutl97.olb
Microsoft PowerPoint 97 Msppt8.olb

Microsoft Word 97 Msword8.olb
Microsoft Access 2000 Msacc9.olb
Microsoft Jet Database 3.51 DAO360.dll
Microsoft Binder 2000 Msbdr9.olb
Microsoft Excel 2000 Excel9.olb
Microsoft Graph 2000 Graph9.olb
Microsoft Office 2000 Mso9.dll
Microsoft Outlook 2000 Msoutl9.olb
Microsoft PowerPoint 2000 Msppt9.olb
Microsoft Word 2000 Msword9.olb

Microsoft Access 2002 Msacc.olb
Microsoft Excel 2002 Excel.exe
Microsoft Graph 2002 Graph.exe
Microsoft Office 2002 MSO.dll
Microsoft Outlook 2002 MSOutl.olb
Microsoft PowerPoint 2002 MSPpt.olb
Microsoft Word 2002 MSWord.olb
5. Choose the earliest version with which you need to be compatable.
6. Choose the class interfaces you'll need.
7. These steps automatically generate your wrappers. I put all of the class wrappers created into the same *.h file for convenience. That way I only have to include a single header in the *.cpp I'll be using the automation in.

Note: If you're not familiar with the Excel interfaces, I'd suggest recording a couple of macros in Excel and opening up the VBA editor. Doing this first will help you determine which interfaces you'll want.

Hope this was helpful,

John
 
Yes, and in VC6 you can do the same using the Class Wizard dialog. On the "Automation" tab click the "Add Class" button and select the "From a type library" option. ;-)

John, welcome to Tek-Tips [cheers]

nice list of MS Office libraries !

-pete
 
...yes, i knoow, i'm a quite newbie but after i've imported this dlls what i have to do to save my data in an XLS file??

o0 tanks you all
 
I think you should practice a little with COM in C++ and VisualBasic. All what correspont to some VB kind of OLE object in C++ is an IDispatch interface. There is nothing miraculous, but COM and especially ActiveX is a big technology, so you should study it.

Ion Filipski
1c.bmp
 
It's correct, today i've done a simple application that do a modification in a worksheet, now i meam how to do. But it isn't complete, i want understand the complete meaning of this tecnique because i want use, if necessary, the other objects when i need it!! The question is: can you suggest me something in internet to study about COM applications and evrything you mean before?

Thanks you all very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top