Products Technologies Demo Docs Blog Support Company

Using the Reporting RibbonTab

The Reporting RibbonTab provides all features to create out-of-the-box reporting applications.

Using the Reporting RibbonTab

Integrating reporting functionality into applications is a very easy task using TX Text Control. The out-of-the-box ribbon tab "Reporting" provides all required features to add merge fields, repeating blocks and special fields.

The TXTextControl.DocumentServer.DataSources.DataSourceManager class is designed for handling all existing kinds of data sources that can be used with the TXTextControl.DocumentServer.MailMerge class.

After creating an application that uses the ribbon interface and the pre-designed ribbon tabs, your form should look similar to this:

TX Text Control in Visual Studio

The ribbon tab TXTextControl.Windows.Forms.Ribbon.RibbonReportingTab class has the TXTextControl.Windows.Forms.Ribbon.RibbonReportingTab.DataSourceManager property which returns the connected DataSourceManager.

The DataSourceManager object provides methods to load data from various sources:

  • LoadAssembly
  • LoadDataSet
  • LoadDataTable
  • LoadJson
  • LoadObjects
  • LoadSingleObject
  • LoadXmlFile
  • LoadXmlString

Consider the following classes that should be used as a data source:

public class Report
{
    public string Name { get; set; }
    public List<Sale> Sales { get; set; } = new List<Sale>();
}

public class Sale
{
    public Customer Customer { get; set; }        
    public Product Product { get; set; }
}

public class Product
{
    public string Name { get; set; }
    public decimal Price { get; set; }
}

public class Customer
{
    public string Name { get; set; }
    public int Id { get; set; }
    public string Street  { get; set; }
    public string City { get; set; }
    public int Zip { get; set; }
}

The following code creates a new object and loads it into the DataSourceManager using the TXTextControl.DocumentServer.DataSources.DataSourceManager.LoadSingleObject method.

Report report = new Report() { Name = "Test Report 2018" };
report.Sales.Add(new Sale()
{
    Customer = new Customer()
    {
        Name = "Customer 1",
        City = "Charlotte",
        Id = 1,
        Street = "6672 Test Street",
        Zip = 27781
    },
    Product = new Product()
    {
        Name = "My Product 1",
        Price = 7782.12m
    }
});

DataSourceManager dsManager = ribbonReportingTab1.DataSourceManager;
dsManager.LoadSingleObject(report);

The drop-downs to insert merge fields and repeating merge blocks are filled automatically with the available values.

TX Text Control in Visual Studio

The DataSourceManager provides the TXTextControl.DocumentServer.DataSources.DataSourceManager.Merge method to merge a template with the current data to implement a preview functionality. The following code saves the template in a byte array, merges the template with data and loads back the resulting document into the TX Text Control:

// save the document
byte[] bDocument = null;
textControl1.Save(out bDocument, TXTextControl.BinaryStreamType.InternalUnicodeFormat);

// create the preview
IList<byte[]> bResults = ribbonReportingTab1.DataSourceManager.Merge(bDocument, 1, textControl1);

// load the preview into the Text Control
textControl1.Load(bResults[0], TXTextControl.BinaryStreamType.InternalUnicodeFormat);

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Also See

This post references the following in the documentation:

TX Text Control .NET Server for ASP.NET

  • TXTextControl.DocumentServer.DataSources.DataSourceManager Class
  • TXTextControl.DocumentServer.MailMerge Class

TX Text Control .NET for Windows Forms

  • TXTextControl.Windows.Forms.Ribbon.RibbonReportingTab Class
  • TXTextControl.Windows.Forms.Ribbon.RibbonReportingTab.DataSourceManager Property

Reporting

The Text Control Reporting Framework combines powerful reporting features with an easy-to-use, MS Word compatible word processor. Users can create documents and templates using ordinary Microsoft Word skills. The Reporting Framework is included in all .NET based TX Text Control products including ASP.NET, Windows Forms and WPF.

See Reporting products

Related Posts

Windows Forms.NET 8Ribbon

Getting Started: Creating a .NET 8 Windows Forms Ribbon Application with…

This article shows how to create a Windows Forms application with a Ribbon and a Sidebar using TX Text Control .NET for Windows Forms. The Sidebar is a control that can be used to create a…


ActiveXASP.NETReporting

TX Text Control 32.0 Has Been Released

We are pleased to announce the immediate availability of TX Text Control 32.0 for all platforms including ASP.NET, Windows Forms, WPF and ActiveX.


ActiveXASP.NETReporting

TX Text Control 31.0 and TX Spell .NET 10.0 Have Been Released

We are happy to announce the immediate availability of TX Text Control 31.0 for all platforms including ASP.NET, Windows Forms, WPF and ActiveX and TX Spell .NET 10.0 for all .NET based platforms.


ActiveXASP.NETReporting

TX Text Control 30.0 and TX Spell .NET 9.0 Have Been Released

We are happy to announce the immediate availability of TX Text Control 30.0 for all platforms including ASP.NET, Windows Forms, WPF and ActiveX and TX Spell .NET 9.0 for all .NET based platforms.


ActiveXASP.NETReporting

TX Text Control X19 and TX Spell 8.0 Have Been Released

We are happy to announce the immediate availability of TX Text Control X19 for all platforms including Windows Forms, WPF and ASP.NET and TX Spell .NET 8 for all .NET based platforms.