Today, such analytical tools as OLAP cubes are extremely demanded. Fast Report possesses such a system and allows displaying data cubes with slices in .NET applications, for example in NET 5.0. Now we will discuss how to use it in your reports.
To use the FastCube.Core libraries, one has to preliminarily assemble them from the source codes. To assemble FastCube.Core for .NET 5.0, use the FastCube.Core.sln solution.
After starting this solution, change the target operating environment for .NET 5.0. Then assemble the project; you will see FastCube.Core.2020.2.1.nupkg in our work directory. Place this package to the folder which you will use as a local source of packages.
Now we can start creating the .NET Core project.
First of all, add the FastCube.Core library to the created project. To do that, use the NuGet package manager. As the packages of libraries are placed on the local disc, we will have to add the local source of packages. Click a gear icon in the upper right corner of the package manager and add a new source, which will refer to the local folder with your nupkg packages:
At this stage, you may select the added source in a dropdown list and set the packages:
We have added a library to the project, now it should be connected by writing in the file .cs:
using FastReport.Olap
To check how it works, use the following code:
class Program { private static string FindDataFolder() { string dataFolder = ""; string thisFolder = Config.ApplicationFolder; for (int i = 0; i < 6; i++) { string dir = Path.Combine(thisFolder, "Data"); if (Directory.Exists(dir)) { string data_dir = Path.GetFullPath(dir); if (File.Exists(Path.Combine(data_dir, "config.xml"))) { dataFolder = data_dir; break; } } thisFolder += ".." + Path.DirectorySeparatorChar; } if (dataFolder == "") { thisFolder = Config.ApplicationFolder; for (int i = 0; i < 6; i++) { string dir = Path.Combine(thisFolder, "Demos", "Data"); if (Directory.Exists(dir)) { string data_dir = Path.GetFullPath(dir); if (File.Exists(Path.Combine(data_dir, "config.xml"))) { dataFolder = data_dir; break; } } thisFolder += ".." + Path.DirectorySeparatorChar; } } if (dataFolder == "") throw new Exception("Could not locate the Data folder."); return dataFolder; } static void Main(string[] args) { string dataFolder = FindDataFolder(); // create cube and slice Cube cube = new Cube(); Slice cubeSlice = new Slice(); cubeSlice.Cube = cube; // load cube cube.Load(Path.Combine(dataFolder, "Cubes", "2_0_sample_en1.mdc")); // open cube cube.Active = true; // export slice HTMLExport export = new HTMLExport(); export.Slice = cubeSlice; export.Export(Path.Combine(Config.ApplicationFolder, "export.html")); } } }
After that, in the directory of our application we will see a file of .html format. Open it in any editor and get the following:
Thus, we have viewed using the FastCube.Core library in a console application. As one can see, the library works perfectly with NET 5.0. Now you can use data cubes in your applications.