AdaptTable for Angular CDK

Spreadsheet formulas in Angular CDK

A formula column is a column nobody wrote code for: type =ROUND(budget * 0.15, 0) and the table computes it per row, sorts it, filters it and exports it like any other column.

The engine covers arithmetic including POWER and SQRT, comparison, string joins, IF, and the aggregate functions a footer needs. A bad reference reports in the cell that caused it rather than blanking the table, and a circular reference reports #CYCLE! instead of recursing.

Formula columns serialize to the URL with everything else, so a derived column travels in the same link as the filters it sits beside.

The code

import { Component, computed, input } from "@angular/core";
import type { ColumnDef } from "@adapttable/angular";
import { buildFormulaColumns, injectFormulaUrlState } from "@adapttable/angular/formula";
import { AdaptDataTable } from "@adapttable/angular-cdk";

@Component({
  selector: "app-computed-people",
  imports: [AdaptDataTable],
  template: `
    <adapt-data-table
      [data]="rows()" [columns]="columns()" [rowKey]="rowKey"
    />
  `,
})
export class ComputedPeople {
  readonly rows = input.required<readonly Person[]>();
  readonly baseColumns = input.required<readonly ColumnDef<Person>[]>();
  readonly rowKey = (row: Person) => row.id;
  readonly state = injectFormulaUrlState({
    urlKey: "fx",
    defaultFormulas: [
      { key: "margin", header: "Margin", formula: "=ROUND(budget * 0.15, 0)" },
    ],
  });
  readonly columns = computed(() => [
    ...this.baseColumns(),
    ...buildFormulaColumns<Person>(this.state.formulas()).columns,
  ]);
}

Install

# Follow the kit setup guide for compatible peers
pnpm add @adapttable/angular-cdk @adapttable/angular @angular/cdk@22.2.1 @angular/forms@^22 rxjs@^7.8.2

The same feature in the other kits

More Angular CDK features

Reference: formulas. More of this kit: AdaptTable for Angular CDK, or the live demo.