Solved

How to export data into excel files with MFC?

Posted on 2006-07-07
5
1,292 Views
Last Modified: 2013-11-20
Hello,
I have been doing a small research on how to export data from an MFC application into excel file (save data in e.g. XP/2000 format). The sollution I've found so far is the use of Excel automation. It seams to me however that this approach requires the user to have MS Excel installed on his/her system (please correct me if I'm wrong).
My question is: how can I save data into excel files without this requirement and without the knowledge of Excel file format?
I would appreciate very much any help.
Regards!
vonuyx
0
Comment
Question by:vonuyx
  • 3
5 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17063872
Simple alternative easy way for this will be just to write your data in .CSV format using common text I/O functions ....
(comma delimited format is: a comma between each cell a carriagereturn between its row) and save it with the suffix .xls. The file will open directly in excel !!!

Well if you dont want to go this way..here its how to get it work :

Using BIFF ( Binary File Format ) This format is a sequence of BIFF records, each record containing a certain property/value of the workgroup. Each BIFF record starts with a 2 byte number containing it's type and another 2 bytes for the size of the record..CMiniExcel is a class written at codeproject site on this..

Refer with src 'Saving Excel 2.1 Workbook ' : http://www.codeproject.com/cpp/miniexcel.asp <====

-MAHESH
0
 

Author Comment

by:vonuyx
ID: 17137655
Thanks for your answer,

Frankly, I dont think the trick of changing the csv extension to xls is the point, MS Excel (2000/XP) does not open this file properly.
What I want to do is to export (write) the data to MS Excel 97/XP/2000 format.

I have been thinking of detecting whether MS Excel is instaled on the system, and if so, use automation. Has anyone ever tried to do so?
Vonuyx
0
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 50 total points
ID: 17143945
Have you checked above codeproject link miniexcel class..it generates excel files without having excel installed..

>>I have been thinking of detecting whether MS Excel is instaled on the system

when you init Excel automation object at startup if it fails you may say excel is not installed..

        _Application app;  // app is the Excel _Application object

          // Start Excel and get Application object...
         if(!app.CreateDispatch("Excel.Application"))
              AfxMessageBox("Excel Not Installed OR Couldn't start Excel.");


-MAHESH
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17311599
why grade 'C' for 50 pts question ???
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question