Click here to Skip to main content
15,867,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts

I have one MFC application, which do some mathematical calculations taking some inputs from the end user. After solving the problem I have to generate a report either in PDF or Word document to show the results (it have tables, images etc..)

I have no clue how to approach this problem, so please let me know the effective method to writing the report

Valuable suggestions are greatly appreciated

Regards,
Nag
Posted
Comments
Richard MacCutchan 25-Jul-13 4:15am    
You need to find a third party library that supports either of these file formats. As far as I am aware OpenOffice has a free SDK that supports Word format.
KarstenK 25-Jul-13 6:18am    
Maybe you can print to a virtual printer which output is pdf.
JackDingler 25-Jul-13 11:56am    
Microsoft has a MS Office SDK for this purpose. It's a free download.

I have never used it though....

Mr.Nagendra Nallani,

I work on a project where I have to do similar thing, so I thought to give you an advice about using MS Word and MS Excel to do your job.

What I believe can help you is called Automation, I have used OLE Automation, and I will point you to these articles/ questions of mine, in hope that it will solve your problem.

Start with this question of mine:
How to insert text into tables in MS WORD ?[^]

The next one will help you with the values you pass to AutoWrap function:

Need information about OLE Word automation[^]

My last advice:

READ ALL QUESTIONS VERY CAREFULLY!


I hope this will be of help to you, but if not, then try these:

http://support.microsoft.com/kb/196776[^]

http://msdn.microsoft.com/en-us/library/dt80be78%28v=vs.80%29.aspx[^]

http://www.codeguru.com/cpp/com-tech/atl/tutorials/article.php/c14519/Microsoft-Word-Automation-Class.htm[^]

http://support.microsoft.com/kb/238611[^]

http://support.microsoft.com/kb/278260[^]

http://social.msdn.microsoft.com/Forums/en-US/6bdfa63a-f3f7-4f7a-a109-7dc90464076e/mfc-ms-word-automation[^]

Good luck!
 
Share this answer
 
My opinion is that using simple stupid and open formats is the better choice. The binary closed office only document format would be my last choice if I have other better choices. The binary format also has the disadvantage that even different office versions display it differently in contrast to PDF that has more consistent across different viewers and viewer versions. The pdf can be a better choice in this case too, not to mention that there are a lot of free (and platform independent/opensource) pdf generator libraries. Free and simple stupid solutions are generally better, as a "richtext" document format I also like using a subset of html or rtf that is unfortunately not an option this time but I would ask the client about the html because that would have only advantage: easy editing/modification, there is a viewer basically on every machine/smartphone...

pdf generator libs:
http://www.jagpdf.org/downloads.htm[^]
http://sourceforge.net/projects/libharu/[^]
With google you can find plenty of them.

Another option when I want to exploit the comfort provided by office products: The Office 2003 suite introduced some xml formats that are very easy to parse by any program! http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats[^]
What we used is the Excel 2003 XML format. We saved out a few tables, analized the resulting xml and then we generated such xmls from our program and we allwed the user to edit the xmls and the program was able to read it back. Note that the xml is full of formatting and totally unneeded elements that don't necessarily have to be there when the xml is generated by your program. You can try and use the same trick with the Word 2003 XML format if you are interested.
 
Share this answer
 
Comments
MyOldAccount 29-Jul-13 8:36am    
My 5!
pasztorpisti 29-Jul-13 8:57am    
Thank you!

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