Solved

How to export data into excel files with MFC?

Posted on 2006-07-07
5
1,268 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 87
not able to insert into temp table 68 162
maxBlock challenge 30 130
zeroFront challenge 7 99
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 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