Click here to Skip to main content
15,906,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I'm trying to create a reports in excel workbook using
the MFC Visual C++ 6.0 .

Is that possible?
if yes, How?

Thanks in advance :)
Posted
Comments
chandanadhikari 13-Jan-12 0:47am    
hi,
this is very much doable in vb6 so should be possible in vc6 also.see "http://support.microsoft.com/kb/308407" and good luck with vc6. :)

You have multiple options:

  • Using OLE Dispatch with the Excel type library. This requires an installed Excel on the machine running your application and the Excel type library on the development machine.
  • Using ODBC. Open Database Connectivity is an operating system independent standard for database management. With Excel ODBC drivers, it can be used to read and write Excel files. Because it is a database interface, it handles sheets from an Excel file like tables in a database file. The required Excel ODBC driver is installed by the Windows Setup.
  • Using ADO (OLE DB). ActiveX Data Objects is like ODBC a database interface, handling sheets from an Excel file like tables in a database file. It is more up-to-date than ODBC. This requires the ADO DLL wich is installed by Windows Setup. ADO may be also used to connect to Excel files using the ODBC drivers using a different connect string.
  • Using a library that provides reading and writing Excel files. Examples are LibXL (commercial) [^], BasicExcel [^], and the BasicExcel derivation ExcelFormat Library [^].
  • Writing data to CSV text files that can be opened with Excel.
 
Share this answer
 
Comments
agent_suwastica 17-Jan-12 22:38pm    
thank you =)
Jochen Arndt 18-Jan-12 11:46am    
You are welcome. But I forget one option: You may also create a HTML file containing your data in a HTML table. Such files can be also imported by Excel. If my anser solved your problem, you may accept it to show others that no more answers are required.
agent_suwastica 18-Jan-12 20:22pm    
How about the font style, background color of every cell in excel file ?
Or ..
If I record a macro in microsoft excel, how can I convert it to C++ Code?
Jochen Arndt 19-Jan-12 4:47am    
First, define your requirements. Then select from the methods that match your requirements. Using OLE Dispatch (COM), you have full control (you can not only format your cells, but do nearly anything). With libraries, check the documentation for the supported operations like formatting cells. The other options can't be used to format cells, besides HTML where some format options are recognized.

A recorded Excel macro can't be automatically converted to C++ code. When using Dispatch/COM, you may manually translate the macro code line by line to the corresponding C++ dispatch functions. But this is far away from generating report files.

To get more information, use the keywords 'excel automation c++' with your preferred search engine.
Are you aware of this site [^]

Look at these links which i got in the net [^]
 
Share this answer
 
Comments
[no name] 13-Jan-12 0:46am    
Well Said
Thumbs up.....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900