Manipulating Excel with C++

I am attempting to export a 10 x 150 array into excel. I am currently using a createprocess() command to call up a csv file that I've created.

The problem, is there is no formatting, Excel automatically places the data in to the available cells. This program is for product data and the format will be same each and every time I run the program. (A bold, large font row at the top stating the key items from the program) then from there pretty basic, but still need formatting, like bold, different sizes of text, etc.

I'm trying to keep this program as simple as possible (for the end user) so they can just simply enter the data into a t.u.i. and the program will use createprocess and automatically load everything, user just has to print.

Is this possible with only C++? I've seen some examples in Visual C++ and in C#, but my program is in C++.
A csv file is a comma delimited text file. You can open one with Notepad to see the format. And from C++, you can open it as you would any text file (using std::ifstream). You'll need to parse the fields as the data is between the comma characters.

If you want the richer data of an XLS file, you need to use the COM interface and have an understanding of the COM objects you need to interact with. For a start, you'll need MS Office installed on the target host computer. I'm sorry I can't post any links to references at the moment.
Just use Win32 Excel Automation.
Tons of samples in MSDN and Google Groups (http://tinyurl.com/cmhb5g and others)
C and C++.
This is the sort of thing I've used in the past. In the end, you still have to deal with rows and columns. So if you're just interested in the numbers and will have access to CSV files rather than XLS files, you may as well read the CSV files using standard C++ file and string methods.

http://support.microsoft.com/default.aspx?scid=kb;en-us;178782
All examples and uses of the COM interface as well as automation are in Visual C++, or Visual Basic. I've never programmed with Visual C++ and don't want to have to learn this new language (and have to recreate my entire console program) to fit what I need this to do.

I already have my console program written and just need this last step of transferring data into specific cells and formatting those cells (possibly even opening a 'master' file, adding certain data fields, saving to a new file, quitting).

And Code::Blocks doesn't want to compile any Visual C++ code either.

I have looked at OLE automation, DDE, and some other types of programs but I've never touched VB of VC++ before and I wouldn't be able to easily integrate either into my C/C++ console program. Any ideas?
Hello,

"I am attempting to export a 10 x 150 array into excel" with createprocess.

No, please do not, excel is able to import anything to a client machine.
It even tells the limit.
Last edited on
Topic archived. No new replies allowed.