Solved

How to export data into excel files with MFC?

Posted on 2006-07-07
5
1,340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 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