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

How to run Excel from C++ code ?

Status
Not open for further replies.

sheila11

Programmer
Dec 27, 2000
251
US
Hi all,

My C++ program saves its output data to a text file. I have an Excel file that can read the data and display it in the form of a chart.

My problem is: how can I call the excel sheet to run from my C++ code?

Please help.

Thanks,
Sheila
 
Hi sheila,

You need to write a batch file say excel.bat
Assume you have excel.exe in C:\Program Files\Microsoft Office\Office and your excel program is myspreadheet.xls

Add this path to the PATH in the environment variable
C:\Program Files\Microsoft Office\Office

In that include the following commands(an example)

//excel.bat
excel C:\spreadheets\myspreadsheet.xls


//excel.cpp

in main()
{
int i = system("C:/excel.bat");
return 0;
}

This should answer your question.

Regards,
vgg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top