Click here to Skip to main content
Licence CPOL
First Posted 22 Feb 2008
Views 24,109
Downloads 1,249
Bookmarked 37 times

Report Builder

By | 26 Feb 2008 | Article
Tool Report Builder

Introduction

This article presents a tool for generation of reports that was developed in the last five months. The tool has been created in C# and works in .NET Framework 2.0. For a long time, I used the ReportBuilder with Delphi. Then, I migrated to Visual Studio and C# as I felt a certain difficulty working with the tools for generation of reports. At that time, I decided to build my own tool. The result of my work is shown in this article. The creator supports several types of data - DataSet, ArrayList, and DataTable. I could still add new types, but this seems to be enough to implement the IDataReport interface.

Using the Code

  1. Drawing of the layout of the Document Principal modules, which is also the module that absorbed the most development time, was the module for drawing the report layout. In the Designer's module, it is possible to create title pages, titles, to shape the layout and size of the page, as well as do groupings. All this can be observed in the following three figures.

Gerador_v02_small.jpg

Figure 1 - Title, Header, Summary

Gerador_v03_small.jpg

Figure 2 - Visualization of the Report. First page

Gerador2_small.jpg

Figure 3 - Visualization of the Report. Next page
  1. Code to load the Module of Drawing of the report is as follows:

    using KReport;
    
    public static void Main () {
          DataSet dsDados = new DataSet ();
          ds.ReadXML (' Teste.xml ');
    
          KReport.Engine.Report rpt = new KReport.Engine.Report();
              
          rpt.FileName = 'C:\Report.xml '; // defines the archive where the layout is
          rpt.Load (); // Loads the layout
          rpt.AddSource (dsdados); // adds the fountain of data
          rpt.ShowDesigner (); // Visualizes layout of the report
    }
  2. Code to load the form of visualization of the report is as follows:

    using KReport;
    
    public static void Main () {
          DataSet dsDados = new DataSet ();
          ds.ReadXML (" Teste.xml ");
    
          KReport.Engine.Report rpt = new KReport.Engine.Report();
              
          rpt.FileName = " Report.xml "; // defines the archive where the layout is
          rpt.Load (); // Loads the layout
          rpt.AddSource (dsdados); // adds the fountain of data
          rpt.Show (); // Visualizes report in the form of preview
    }
  3. Code to load and print the report is as follows:

    public static void Main () {
          DataSet dsDados = new DataSet ();
          ds.ReadXML (" Teste.xml ");
    
          KReport.Engine.Report rpt = new KReport.Engine.Report();
              
          rpt.FileName = " Report.xml "; // defines the archive where the layout is
          rpt.Load (); // Loads the layout
          rpt.AddSource (dsdados); // adds the fountain of data
          rpt.Print (); // Printed report 
    }
  4. Code using a list of objects is as follows:

    public static void Main () {
          ArrayList source;
          Persistencia.StartSession ();
          source = Persistencia.GetListObject (typeof (Credito), " status = 0 ");
          Persistencia.EndSession ();
    
          KReport.Engine.Report rpt = new KReport.Engine.Report();
              
          rpt.FileName = " Report.xml "; // defines the archive where the layout is
          rpt.Load (); // Loads the layout
          rpt.AddSource (source); // adds the fountain of data
          rpt.Print (); // Printed report 
    }

History

  • 22nd February, 2008 -- Original version posted
  • 26th February, 2008 -- Download added

License

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

About the Author

Fernando Gregorio

Software Developer (Senior)
Ceape Maranhâo
Brazil Brazil

Member

Specialist in Development of Systems of Information for the University Estatual de Feira de Santana (UEFS). Bachelor in Science of the Computation for the University Estadual do Piauí (UESPI). Now works like Analyst of System of the CEAPE/MA. It acts like investigator and programmer in the area of analysis of systems and like teacher of the next disciplines: Database, Planning in Nets, Programming language and Concepts of Programming language.
Email for contact - fgborges@hotmail.com

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

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralExport Option Not working Pinmembereg_Anubhava19:10 3 Mar '10  
QuestionHelp me !!! Pinmemberjatin_chauhan23:53 9 Jan '09  
GeneralReferencia MakeSoft.KReport PinmemberBendito Santana4:56 12 Sep '08  
GeneralTell me more PinmemberWillemM19:52 26 Feb '08  
GeneralGood work PinmemberGuilherme Labigalini13:30 26 Feb '08  
GeneralNice, but there is no code to download ! Pinmemberpita200019:18 22 Feb '08  
Questiondonwload PinmemberMember 126683012:02 22 Feb '08  
GeneralRe: donwload PinmemberMember 467890416:05 22 Feb '08  
GeneralInfelizmente... Pinmemberthompsons10:32 22 Feb '08  
GeneralParabens!!! PinmemberMember 24778816:22 22 Feb '08  

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 26 Feb 2008
Article Copyright 2008 by Fernando Gregorio
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid