v2.2.0
v2.2.0v2.1.0v2.0.0v1.2.0

Using ActiveReportsJS Report Designer Component in Angular applications

Create Angular Application

The easiest and recommended way for creating a new Angular application is to use Angular CLI. Run the following command from the command prompt or terminal to create an Angular application with default options. For details, see options on the Angular site.

ng new arjs-angular-designer-app --defaults

Install ActivereportsJS npm packages

We distribute the Angular Report Designer Component via @grapecity/activereports-angular npm package that depends on the main @grapecity/activereports package that includes the core functionality. To install the latest version of these packages, run the following command from the application's root folder.

npm install @grapecity/activereports-angular

Or if you are using yarn:

yarn add @grapecity/activereports-angular

Import ActiveReportsJS styles

Open the src\styles.css file and add the following code. It imports the default Report Designer Component Styles

@import "@grapecity/activereports/styles/ar-js-ui.css";
@import "@grapecity/activereports/styles/ar-js-designer.css";

Register ActivereportsJS Angular module

Open the src\app\app.module.ts file and replace its content with the following code. It registers the ActiveReportsModule module in addition to the standard modules.

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ActiveReportsModule } from '@grapecity/activereports-angular';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, ActiveReportsModule],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}

Add ActiveReportsJS report to the application

ActiveReportsJS uses JSON format and rdlx-json extension for report template files. In the src\assets folder, create the new file called report.rdlx-json and insert the following JSON content into that file.

{
  "Name": "Report",
  "Body": {
    "ReportItems": [
      {
        "Type": "textbox",
        "Name": "TextBox1",
        "Value": "Hello, ActiveReportsJS Designer",
        "Style": {
          "FontSize": "18pt"
        },
        "Width": "8.5in",
        "Height": "0.5in"
      }
    ]
  }
}

Add ActivereportsJS Angular Report Designer to the application

Open src\app\app.component.ts and replace its content with the following code. The template of the component uses the Angular Report Designer Component. The designer component's input report property points to the report.rdlx-json that you created on the previous step.

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template:
    '<div id="designer-host"><gc-activereports-designer [report]="report"> </gc-activereports-designer></div>',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {
  report = { id: 'assets/report.rdlx-json', displayName: 'my report' };
}

Add styles for the designer host element to src\app\app.component.css

#designer-host {
  width: 100%;
  height: 100vh;
}

Run and test the application

Running the npm start or yarn start commands could fail with the fatal error that the JavaScript heap is out of memory. In that case, open the package.json file and replace the start script with the following one.

node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng serve

Then re-run npm start or yarn start command.

The ActiveReportsJS Designer component will appear on the start page of the application and display the report design. Test the basic functionality by adding report items, setting their properties, creating the data source, et cetera. Visit the Developer Guide and the Online Demo for more information on how to use the Report Designer component.