Loading the ListDataSet data to pivot cube

2021-06-09

In version 2021.1 we added the ListDataSet component which allows loading data to cube using Windows Forms Data Binding

It is now possible to load data to Cube using Windows Forms complex Data Binding which is used in standard controls: DataGridView, ListView, and Combobox.

Complex Data Binding loads data through the BindingSource component which acts as a proxy (more info can be found in MSDN).

Here is a small example of loading data from List<>.

1. Declare a ProductInfo class

public class ProductInfo
{
 public String Name { get; set; }
 public String Group { get; set; } 
 public int Count { get; set; }
}

2. Create a list of ProductInfo records

List<ProductInfo> CreateProducts()
{
 return new List<ProductInfo> {
 new ProductInfo {Group = "Bakery products", Name = "Ciabatta", Count = 3},
 new ProductInfo {Group = "Bakery products", Name = "Bread", Count = 5},
 new ProductInfo {Group = "Bakery products", Name = "Croissant", Count = 1},
 
 new ProductInfo {Group = "Alcohol", Name = "Wine", Count = 6},
 new ProductInfo {Group = "Alcohol", Name = "Whiskey", Count = 2},
 new ProductInfo {Group = "Alcohol", Name = "Beer", Count = 5},
 
 new ProductInfo {Group = "Dairy products", Name = "Yoghurt", Count = 5},
 new ProductInfo {Group = "Dairy products", Name = "Milk", Count = 4}
 };
}

 3. Configure cube and slice

private void Form1_Load(object sender, EventArgs e)
{
 // configure data source
 listDataSet1.DataSource = CreateProducts();
 // load data to Cube
 cube1.Active = true;
 // configure Slice
 slice1.YAxisContainer.AddSliceField(slice1.SliceFields.GetFieldByName("Group"));
 slice1.YAxisContainer.AddSliceField(slice1.SliceFields.GetFieldByName("Name"));
 var measure = new FastReport.Olap.Slice.MeasureField(slice1, FastReport.Olap.Types.AggregateFunction.Sum, slice1.SliceFields.GetFieldByName("Count"));
 slice1.MeasuresContainer.AddMeasure(measure);
 slice1.XAxisContainer.AddMeasuresField();
}

Here is the result:

FastCube Net 2021.1

The full example is located in Demos\C#\DataBindings.

November 26, 2024

Installing FastReport on .NET 8.0 and Creating a Simple Report

The purpose of this article is to explain step by step how to install FastReport on .NET 8.0 and how to create a simple report. Taking the reporting process from the beginning, it will show how to connect, design and view reports.
October 28, 2024

How to Set Up WSL 2 for Working with FastReport and FastCube

In this article, we will explore how to set up WSL 2 for working with FastReport and FastCube components in Lazarus for Linux.
August 12, 2024

How to build and install the Postgres plugin in FastReport .NET

This article describes how to connect to the database using the FastReport .NET plugin for the report designer from Visual Studio via the NuGet server.
Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 66 Canal Center Plaza, Ste 505, Alexandria, VA 22314

© 1998-2024 Fast Reports Inc.