How to use FastCube .NET in React application

2021-10-01

UPD: Applies to the versions of FastCube .NET before 2022.1. License packages are now available on our NuGet server.

The ReactJs library has become widespread in the web development of single-page applications. Previously we have covered how to display reports and the online report designer in React SPA application. Now it is possible to display cubes and slices of data from FastCube.Core on a web page. Let's consider how to do this.

To create an ASP .NET Core app with a React frontend part, you can use a template in the .NET SDK. Run in the command line:

dotnet new react -o MyReactApp

This command will create a demo application that we can use to display the cube. Of course, for this, you must have the .NET Core SDK installed. In addition, the application will require Node.js.

Go to the directory of the created application:

cd MyReactApp

and install javascript packages using the command:

npm install

Let's start working with the created web application. First, let’s install the FastCube packages. Open the Nuget package manager. In the upper right corner of the window, you will see a gear icon, which opens the settings of package sources. Click on it and add a new package source - a folder with our FastCube packages, which are located in the C:\Program Files (x86)\FastReports\FastCube.Net Professional\Nuget folder.

Configuring a local package source

Select the added package source in the drop-down list and install the packages:

Installing FastCube Core packages

We connect FastCube in the Startup.cs file, add the code in the Configure () method:

app.UseFastCube();

Our application already contains WeatherForecastController. Let's add our web method to it:

[HttpGet("[action]")]
 public IActionResult ShowCube()
 {
 Cube cube = new Cube();
 Slice slice = new Slice()
 {
 Cube = cube
 };
 FilterManager filterManager = new FilterManager()
 {
 Cube = cube
 };
 WebGrid grid;
 grid = new WebSliceGrid()
 {
 Slice = slice
 };
 
 ViewBag.WebGrid = grid;
 
 cube.SourceType = SourceType.File;
 cube.Load(Path.Combine("C:\\Users\\FR\\Downloads\\fastcube-net-master\\Demos\\Data\\", "Cubes", "calculated_measures.mdc")); return View(); }

The Cube and Slice objects are related because, in fact, the slice is part of the cube. A WebGrid object is used to display an interactive crosstab. It can display both a WebCubeGrid slice and a WebSliceGrid cube. In our example, we loaded the cube that we previously created in the FastCube .NET desktop version.

Pay attention to the class from which the controller inherits. It should be Controller, not BaseController.

Now let's create a view for this method. This can be done by right-clicking on the ShowCube method signature. The view will contain a single line of the code:

@await ViewBag.WebGrid.Render()

Now let's move on to SPA application, which is located in the ClientApp folder. We need to add our component to the src->components folder. It will display the iframe with the view we created above. Add the Cube.js file with the following code:

import React, { Component } from 'react';
export class Cube extends Component {
 static getCube() { 
 return { __html: '<iframe width="1000" height="1000" src="weatherforecast/ShowCube" />' };
 }
 render() {
 return (
 < div dangerouslySetInnerHTML={Cube.getCube()} />
 );
 } 
}

Everything is easy here. We display iframe that refers to a method in the controller.

Now you need to add the component to the App.js application structure:

import React, { Component } from 'react';
import { Route } from 'react-router';
import { Layout } from './components/Layout';
import { Home } from './components/Home';
import { FetchData } from './components/FetchData';
import { Counter } from './components/Counter';
import { Cube } from './components/Cube';
 
import './custom.css'
 
export default class App extends Component {
 static displayName = App.name;
 
 render () {
 return (
 <Layout>
 <Route exact path='/' component={Home} />
 <Route path='/counter' component={Counter} />
 <Route path='/fetch-data' component={FetchData} />
 <Route path='/cube' component={Cube} />
 </Layout>
 );
 }
}

In addition, you need to add a new menu item in the NavMenu.js file:

import React, { Component } from 'react';
import { Collapse, Container, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap';
import { Link } from 'react-router-dom';
import './NavMenu.css';
 
export class NavMenu extends Component {
 static displayName = NavMenu.name;
 
 constructor (props) {
 super(props);
 
 this.toggleNavbar = this.toggleNavbar.bind(this);
 this.state = {
 collapsed: true
 };
 }
 
 toggleNavbar () {
 this.setState({
 collapsed: !this.state.collapsed
 });
 }
 
 render () {
 return (
 <header>
 <Navbar className="navbar-expand-sm navbar-toggleable-sm ng-white border-bottom box-shadow mb-3" light>
 <Container>
 <NavbarBrand tag={Link} to="/">FastCubeReact</NavbarBrand>
 <NavbarToggler onClick={this.toggleNavbar} className="mr-2" />
 <Collapse className="d-sm-inline-flex flex-sm-row-reverse" isOpen={!this.state.collapsed} navbar>
 <ul className="navbar-nav flex-grow">
 <NavItem>
 <NavLink tag={Link} className="text-dark" to="/">Home</NavLink>
 </NavItem>
 <NavItem>
 <NavLink tag={Link} className="text-dark" to="/counter">Counter</NavLink>
 </NavItem>
 <NavItem>
 <NavLink tag={Link} className="text-dark" to="/fetch-data">Fetch data</NavLink>
 </NavItem>
 <NavItem>
 <NavLink tag={Link} className="text-dark" to="/cube">Cube</NavLink>
 </NavItem>
 </ul>
 </Collapse>
 </Container>
 </Navbar>
 </header>
 );
 }
}
 

The application is ready. Let's run it:

The web application displays the cube

Thus, you can display your web cube using FastCube.NET in a React SPA application.

.NET FastCube ASP.NET Core React SPA
October 13, 2025

How to Use Excel Formulas in a Report When Exporting to MS Excel

Starting with version FastReport .NET 2026.1, it is now possible to export formulas to Microsoft Excel. It is important to set up formula exports correctly and follow the syntax.
October 13, 2025

New Features for Exporting Images to Microsoft Word in FastReport .NET

In the latest version of FastReport .NET we have added new image export features. Now you can independently adjust the balance between the quality and size of the final document.
September 30, 2025

How to Install the FastReport .NET Report Designer with Pre-installed Plugins

Read the article as from version 2025.2.5 for FastReport .NET WinForms and FastReport .NET WEB allows you to install a report designer with all plugins without building dll files.

© 1998-2026 Fast Reports Inc.