Click here to Skip to main content
Click here to Skip to main content

Report Generator

By , 11 Oct 2006
 
Prize winner in Competition "MFC/C++ Feb 2005"

Sample Image - ReportCreator.gif

Introduction

Printing is a normal part of most applications, but far too convoluted for many developers. The amount of work necessary to add printing of lists and reports to an application often seems daunting, and there are many pitfalls. Here, I come to the aid, with a package containing a plug-in report generator working with template files, a SDI-demo, a plug-and-play report editor for the template files, as well as a demo of the latter. And documentation! The code is intended either for use as-is in your own applications, or as a CReportEditor as well.

ReportCreator also contains a ruler that can be ripped out and used with other CDiagramEditor-derived works. This is an exercise left to the reader, however.

The documentation contains docs on the package structure.

Using ReportCreator

ReportCreator is an editor for the report generator template files. It's first and foremost a vector editor, letting you draw fields on screen with all the features of CDiagramEditor, such as panning, zoom, multiple selects, and much, much more.

It allows you to work in pixels, centimeters or inches as is befitting for a printer-oriented application. The documentation contains detailed information.

Licenses

If you want to add the package(s) or parts of them into your own code - commercial or not, you are completely free to do so. The code comes with the TISATAAFL-license, There Is Such A Thing As A Free Lunch, and you are free to modify, rewrite, resell or do whatever you feel like with the code. You are explicitly allowed to remove my comments in the source and headers, replacing them with your own. You don't have to acknowledge me, neither in code, nor in documentation or the finished application if you should use the code in a commercial application.

History

6/5 2005

Initial version.

28/5 2005

First of all, a few bug corrections:

  • Fixed resource leak in CCornerBox::OnPaint in the report creator (alex_br).
  • Fixed silly line-thickness bug in draw object line thickness/brush creation (lordly).

As well as a few others that was removed as a spin-off from other modifications.

There are also quite a few changes:

  • Multi-template reports. A report can be composed from several templates, for example, a title page, several sections and a summary (Carsten Bøgh Poulsen).
  • Dynamic object access. Objects can be accessed at runtime, so attributes can be inspected and modified. Objects can also be added at runtime (Håkan Nilsson).
  • More special markers for fields and cells. [%bold%] and [%italic%] will make the field/cell bold or italic respectively. [%separator%], [%bold-separator%], [%double-separator%] will draw a thin line, a thick line or a double line across a row in a grid instead of data (Carsten Bøgh Poulsen).
  • Images can not only be set from files, but also from HBITMAPs and handles to DIBs (Alex Evans).
  • Templates can not only be added from file, but also with data from a CStringArray, a LPCTSTR, a CFile or even from the application resources (DaberElay, Carsten Bøgh Poulsen).

1/10 2006

This project has been neglected for some time, but now it's time for an update! This time, we have:

  • Returning TRUE from Add when adding data as per documentation
  • Added support for font charset. (Vladimir Svrkota, J Bartkowiak).
  • Added locale-handling (J Bartkowiak).
  • Added [%pagebreak%]-command for grids. This works as the other commands, when putting this text in a cell, the grid will break and continue on the next page. (Charlie Curry, Carsten B Poulsen)
  • Added a function call ReplaceCell to set cell data in a grid. This call replaces the data in a specific cell with new data. (Carsten B Poulsen)

And a big thanks for all the help, feedback and support for this project!

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication

About the Author

Johan Rosengren
Software Developer (Senior) Abstrakt Mekanik AB
Sweden Sweden
Member
45 years old, married, three kids.
 
Started with computers more than 20 years ago on a CBM-64.
 
Read Theoretical Philosophy at the University of Lund.
 
Working as a C++ consultant developer.
 
Science-fiction freak. Enjoy vintage punkrock.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberbaininja10 Oct '12 - 17:18 
QuestionHow to insert a control?memberJerryTom16 Apr '12 - 21:58 
QuestionVisual Studio 2010 New Project Problemsmemberrubrighj26 Mar '12 - 9:38 
GeneralMy vote of 5memberHady Marzuki25 Nov '11 - 17:35 
QuestionFinally, I got memory leakage!memberMember 473603512 Jul '11 - 0:42 
GeneralMy vote of 5memberhireboy3 Jul '11 - 22:52 
QuestionCan reports be cut and pasted?memberAnn Nockerts2 Jul '11 - 5:42 
Questionreport_fieldsmembergerhard4529 Jan '11 - 22:27 
AnswerRe: report_fieldsmemberMember 14710391 Sep '11 - 13:43 
QuestionTO CONVERT MDI FOR SDI?memberasfur18 Nov '10 - 2:51 
JokeGREAT WORK, TKS...memberasfur16 Nov '10 - 0:42 
QuestionCPrintDialogmembergerhard4531 Mar '10 - 21:35 
GeneralImplementationmemberAdeel Mirza4 Feb '10 - 2:02 
Generalfinally ! ;-)memberIef Kox27 Jan '10 - 21:36 
GeneralThank youmemberfuturejo19 Jan '10 - 6:48 
GeneralReport CreatormemberMember 29999298 Dec '09 - 9:22 
GeneralFantasticmemberstixoffire19 Nov '09 - 15:38 
QuestionHeader and Footermemberpresidentkevin14 Sep '09 - 16:56 
Questionprint bmp picture memory leakmemberxiayingang1 Aug '09 - 20:13 
QuestionHow to change individual Grid Column Widths at Runtime [modified]memberCarlH23 Jul '09 - 4:00 
QuestionGrid columnsmemberMember 14710397 May '09 - 7:59 
AnswerRe: Grid columnsmemberMember 14710397 May '09 - 11:04 
GeneralThank you for such a great codememberxellmn31 Mar '09 - 3:20 
GeneralRe: Thank you for such a great codememberJohan Rosengren1 Apr '09 - 5:32 
GeneralUse the same field more than once [modified]memberpscholl18 Feb '09 - 6:51 
GeneralRe: Use the same field more than oncememberJohan Rosengren21 Feb '09 - 21:21 
GeneralRe: Use the same field more than oncememberpscholl22 Feb '09 - 3:39 
GeneralRe: Use the same field more than oncememberJohan Rosengren8 Mar '09 - 8:34 
QuestionGreat code!memberMember 14710391 Feb '09 - 8:05 
AnswerRe: Great code!memberJohan Rosengren6 Feb '09 - 19:38 
GeneralAttributes for a cell of a gridmemberNyarlatotep16 Dec '08 - 0:55 
GeneralRe: Attributes for a cell of a gridmemberJohan Rosengren20 Dec '08 - 4:11 
GeneralAbout eport GeneratormemberMember 27319143 Oct '08 - 16:55 
GeneralRe: About eport GeneratormemberJohan Rosengren5 Oct '08 - 7:30 
QuestionAbout CReportEntityGridmembermonrad13 Sep '08 - 7:24 
AnswerRe: About CReportEntityGridmemberJohan Rosengren13 Sep '08 - 20:31 
QuestionCan you help me?memberXiaoming Huang11 Sep '08 - 11:35 
AnswerRe: Can you help me?memberJohan Rosengren13 Sep '08 - 2:43 
GeneralGrid Problem With Release Mode of VS-2008 SP1memberScott Moss10 Sep '08 - 4:36 
GeneralRe: Grid Problem With Release Mode of VS-2008 SP1memberJohan Rosengren13 Sep '08 - 2:47 
GeneralRe: Grid Problem With Release Mode of VS-2008 SP1memberScott Moss14 Sep '08 - 16:44 
GeneralRe: Grid Problem With Release Mode of VS-2008 SP1memberScott Moss20 Oct '08 - 1:57 
GeneralRe: Grid Problem With Release Mode of VS-2008 SP1memberJohan Rosengren21 Oct '08 - 7:02 
GeneralRe: Grid Problem With Release Mode of VS-2008 SP1memberScott Moss27 May '09 - 2:02 
QuestionAdding menu items?memberXiaoming Huang7 Sep '08 - 11:23 
GeneralBugfix: loading from resources in unicode buildmemberroel_3 Aug '08 - 6:16 
GeneralRe: Bugfix: loading from resources in unicode buildmemberJohan Rosengren9 Aug '08 - 20:37 
QuestionDo do people deal with different paper sizes?memberroel_2 Aug '08 - 11:38 
AnswerRe: Do do people deal with different paper sizes?memberJohan Rosengren2 Aug '08 - 20:15 
GeneralRe: Do do people deal with different paper sizes?memberroel_3 Aug '08 - 2:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 11 Oct 2006
Article Copyright 2005 by Johan Rosengren
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid