Solved

How to export data into excel files with MFC?

Posted on 2006-07-07
5
1,202 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
why grade 'C' for 50 pts question ???
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 82
repeateFront java challenge 31 87
iSeries DB2 Query 2 83
ShiftLeft challenge 21 65
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now