944,150 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 44105
  • C++ RSS
Jan 6th, 2005
0

Manipulate Excel file using C++??

Expand Post »
Dear all,

Is it ever possible to write a programme in C++ which enables me to:

1) Read the data in spreadsheet of MS-Excel

2) generate another Excel file as output ?

Also, are there any standard library could do the job?

One of my friend said using Visual Basic could make the task easier since it deals with Excel. Any comment on this?


Jim :rolleyes:
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
jimFan is offline Offline
22 posts
since Dec 2004
Jan 6th, 2005
0

Re: Manipulate Excel file using C++??

Your friend is dead wrong. Excel DOES include VBA which is a scripting language based loosely on VB but that's about it.

All of the MS Office applications expose a series of COM controls which you can use to manipulate their documents.
I don't have the documentation for them at hand but you should be able to find examples in the MSDN library at http://msdn.microsoft.com and elsewhere.

There are likely also other systems to access and manipulate the documents available through third parties.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jan 6th, 2005
0

Re: Manipulate Excel file using C++??

There is a small code snippet on DaniWeb on how to manipulate Excel data from within qbasic. Your friend might not be so far off!
Moderator
Reputation Points: 1333
Solved Threads: 1404
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Jan 6th, 2005
0

Re: Manipulate Excel file using C++??

Another possability is to export the Excell code to XML, modify it, and pull it back into Excell. This works very well with Excell XP and later, not so well with versions earlier than Excell XP.

The "right" way to do it is with the COM calls, and the managed code (C#, VB) is generally easier to deal with COM than in C/C++. But using the XML method does not involve all that, nor does it require Excell to be present on the machine that does the conversion.
Reputation Points: 36
Solved Threads: 11
Posting Pro in Training
Chainsaw is offline Offline
436 posts
since Jun 2004
Jan 7th, 2005
0

Re: Manipulate Excel file using C++??

Thank you for all of your input.

Just to make the problem clearer:

In fact I have only learned C++ for one semester only but recently my professor asked me to write a programme like this. Since there's a time constraint and I only know C++, I have to choose from the 1 of the 2:

1) Use VC++, the language which I am more familiar with, but might be more difficult to implement GUI

2) Easier to make GUI but I know NOTHING about BASIC, not to mention VB.

I could also find some document from MSDN by searching for "automate Excel from Visual Basic" as mentioned by jwenting. But the code I found looks so hard and cryptic to me.

Anyway I have started learning VB today. Thank for all of your advice.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
jimFan is offline Offline
22 posts
since Dec 2004
Apr 23rd, 2005
0

Re: Manipulate Excel file using C++??

I have programmed a lot in VB and a little in C++. It will be easier in VB. The major obstacle you have in C++ is that there is an absense of documentation on the format - ie it is secret. There is a little bit of doco on the security features but that is all.

I have left an easier option underneath.

Try and think of VB as the C++ you learn in Kindergarten - Yes it is illogical, but it is still object oriented, it is just that you have to wade thru lots of new objects.

You have a few options
1) Use C++ to manipulate CSV files. You can save excel files as CSV files (comma separated). This would make it very easy with C++. Your instructor may consider this cheating as you are not technically manipulating an excel file, but ask. Maybe they want you to manipulate data as an exercise and don't care about the format. If so, this is the best way.
2) Use C++ to manipulate XLS files. As stated above, you must crack their format. No data exists on the web (except for very old formats of xl). Good Luck
3) Grit your teeth and learn VB.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
doddd is offline Offline
1 posts
since Apr 2005
Jan 17th, 2006
0

Re: Manipulate Excel file using C++??

I also want to do same thing,Read/write excel using C++.If u got solution can u sedn it to me.

Chetan
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ChetanWarade is offline Offline
1 posts
since Nov 2005
Reputation Points: 10
Solved Threads: 0
Newbie Poster
miketillman is offline Offline
3 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Algorithms
Next Thread in C++ Forum Timeline: 'Grocery Counter' using Classes





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC