Using the DaReport in an application

First, add a reference to daReport.dll file (provided in the distribution) to your project. If you feel like it, you can also put this component in your Control Toolbar.

Second, add an instance of DaPrintDocument to your module (form); if you have previously attached it in your control toolbar, simply drag it to your form:

private daReport.DaPrintDocument daPrintDocument = 
                         new daReport.DaPrintDocument();

At the point where you wish to print some report, set the template file and fill in the parameters (if any):

// set .xml file for printing
daPrintDocument.setXML("reportStatic.xml");

// fill in declared parameters (if any)
// (parameter names are case sensitive)
Hashtable parameters = new Hashtable();
parameters.Add("author","Predrag Dukanac");
daPrintDocument.SetParameters(parameters);

Using tables

  • Static tables: static tables have data defined in an XML template file (DATA tag). The DataSource property for these tables is not set. No specific action is required in code for these tables to print correctly (everything is done in the .xml file).
  • Dynamic tables: dynamic tables present data calculated in your program (like database reports). The DataSource property is set and must correspond to the DataTable.Name property in your code. Do it like this:
    // myTable is DataTable previously filled from database
    // (using DataAdapter.Fill method, for instance)
    
    DataTable printTable = myTable.Copy();
    printTable.Name = "printTable";
    // this is the DataSource attribute of my table in XML file
    
    // attach DataTable to printing document
    daPrintDocument.AddData(printTable);
    
    // now you're ready for print

Take a look at reportStatic.xml, reportDynamic.xml, reportCharts.xml and the ReportTest project (all in the download package) for a deeper insight.

 
SourceForge.net Logo