Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1418
  • Last Modified:

How to export data into excel files with MFC?

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
vonuyx
Asked:
vonuyx
  • 3
1 Solution
 
mahesh1402Commented:
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
 
vonuyxAuthor Commented:
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
 
mahesh1402Commented:
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
 
mahesh1402Commented:
why grade 'C' for 50 pts question ???
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now