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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use C++ to read an excel file???

Status
Not open for further replies.

DugzDMan

Programmer
Oct 19, 2000
157
US
I have a project at work that will require me to take data from multiple spreadsheets. Then I must perform some calculations on the data and output it in a 389-column wide flat file, for use as input to a mainframe program. Do you know if Visual C++ is capable of reading in .xls files? Also, do you know if C++ can output 389 columns? If not, do you know of some other program that will? I used C++ in college, but never had to do anything like this (go figure).

Thanks in advance for you help.
 
I'm not a C++ programmer, but in VB the easiest (and only way i know of) to read in an excel file is to create an excel object and use the methods and properties exposed by excel to read the data.

Dim XLObj As Excel.Application
Dim TestValue As Long

Set XLObj = CreateObject("excel.application")

XLObj.Workbooks.Open "C:\Test.xls"

TestValue = XLObj.ActiveSheet.Range("A1").Value

This VB code would create an instance of excel, refrenced by the XLObj variable, open the file C:\Test.xls, and read the value in A1 into TestValue. I don't think microsoft publishes their file formats for excel. They are standard OLE files, made up of streams and storages(analagous to folders and files in a directory structure) but as far as how to extract specific cell values from them, your guess is as good as mine.

My only other suggestion would be to post this in a different forum (if you havent already). This one is more about user interface feaures of office, not very technical.
If there's no C++ forum on this site, try Visual Basic - General Discussion or Visual Basic - Active-x controls and dll's.


Ruairi
ruairi@logsoftware.com
Experienced with:

VB6, SQL Server, QBASIC, C(unix), MS Office VBA solutions

ALSO: Machine Control/Automation using GE and Omron PLC's and HMI(human machine interface) for industrial applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top