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

Report Builder

, 26 Feb 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

Fernando Gregorio
Software Developer (Senior) Ceape Maranhâo
Brazil Brazil
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

Comments and Discussions

 
QuestionReference MakeSoft.KReport PinmemberMember 1094555614-Jul-14 7:01 
QuestionThank you PinmemberОрест Мервнський14-Feb-14 13:19 
QuestionSource Code [modified] PinmemberLaines7219-Dec-12 0:36 
QuestionKREPORT source code Pinmemberamcaminos116-Nov-12 13:44 
GeneralExport Option Not working Pinmembereg_Anubhava3-Mar-10 20:10 
GeneralReferencia MakeSoft.KReport PinmemberBendito Santana12-Sep-08 5:56 
GeneralTell me more PinmemberWillemM26-Feb-08 20:52 
GeneralGood work PinmemberGuilherme Labigalini26-Feb-08 14:30 
GeneralNice, but there is no code to download ! Pinmemberpita200022-Feb-08 20:18 
Questiondonwload PinmemberMember 126683022-Feb-08 13:02 
GeneralRe: donwload PinmemberMember 467890422-Feb-08 17:05 
GeneralInfelizmente... Pinmemberthompsons22-Feb-08 11:32 
GeneralParabens!!! PinmemberMember 247788122-Feb-08 7:22 

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.

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