How to Use an Angular Pivot Table Component in Your Web Application
Tags: webdev, devops, javascript, tutorial
Published: 2023-11-10 06:09:44

---
canonical_url: https://developer.mescius.com/blogs/how-to-use-an-angular-pivot-table-component-in-your-web-application
description: Learn how to use an Angular Pivot Table component in your web application. See more from SpreadJS today.
---
Pivot Tables are undeniably one of the most powerful data analysis tools; they help organize data so users can detect recurring patterns more easily. Pivot Tables help users create customized tables from large data groups. The user can summarize, sort, reorganize, group, count, total, or average data effortlessly within a table using pivot functionalities.

[**SpreadJS**, an Angular spreadsheet component](https://developer.mescius.com/spreadjs/angular-spreadsheet-components "https://developer.mescius.com/spreadjs/angular-spreadsheet-components"), has a [Pivot Tables add-on](https://developer.mescius.com/spreadjs/javascript-excel-spreadsheet-pivot-table "https://developer.mescius.com/spreadjs/javascript-excel-spreadsheet-pivot-table") feature that allows Angular developers to create Excel-like Pivot Tables programmatically in their applications or allow end-users to create them with a familiar UI easily.

[**Check out our online Angular Pivot Table demo to see how to get started with SpreadJS’s PivotTables**](https://developer.mescius.com/spreadjs/demos/features/pivot-table/overview/angular "https://developer.mescius.com/spreadjs/demos/features/pivot-table/overview/angular").

This blog will go through some of the essential properties and features of the Angular spreadsheet Pivot Table API that will help you customize the appearance of your pivot tables and reports derived from these Pivot Tables.

*   [Create an Angular Pivot Table](#create)

*   [Pivot Layout](#layout)

*   [Pivot Table Theme](#theme)

*   [Pivot Styles](#styles)

*   [Pivot Table AutofitColumn](#autofit)

*   [Pivot Table Slicers](#slicers)

*   [Pivot ContextMenu](#contextmenu)

*   [Pivot Conditional Formatting](#conditional)

**You can [download a sample application](https://cdn.mescius.io/assets/developer/blogs/spread/20231026-how-to-use-an-angular-pivot-table-component-in-your-web-application/features_pivot-table_overview_Angular.zip) here to follow along with the blog.**

## <a id="create"></a>Create an Angular Pivot Table<span class="confluence-ssr-app-1afrefi" aria-label="Copy"></span>

Imagine having countless rows of data containing specific information. For example, in the datasheet below, we have a large number of records showing the best-selling video games.

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-10hhgac">

<div data-type="file" data-node-type="media" data-width="964" data-height="613" data-id="41ff4bc1-6179-460e-9e93-3dfe6f4fb825" data-collection="contentId-3441918655" data-file-name="02-react.png?width=500&amp;height=317.9460580912863" data-file-size="197301" data-file-mime-type="image/png" data-alt="React Pivot Table" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-1evz069" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="02-react.png?width=500&amp;height=317.9460580912863" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/0wepkxqz/001-js.png?rmode=max&width=738&height=469)</div>

</div>

</div>

</div>

</div>

The goal is to create a report summarizing this raw data into more insightful information. The below function shows how to programmatically add a pivot table and add fields in an [Angular application](https://developer.mescius.com/spreadjs/demos/features/pivot-table/overview/angular "https://developer.mescius.com/spreadjs/demos/features/pivot-table/overview/angular") using [SpreadJS’s **PivotTable** class API](https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1 "https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1").

```
let initPivotTable = function(sheet, tableName){</span> sheet.name("Basic PivotTable"); sheet.setRowCount(250); let pivotTableOptions = {bandRows:true,bandColumns:true}; let pivotTable = sheet.pivotTables.add("PivotTable", tableName, 1, 1, GC.Spread.Pivot.PivotTableLayoutType.tabular, GC.Spread.Pivot.PivotTableThemes.medium14, pivotTableOptions); pivotTable.suspendLayout(); pivotTable.add("Genre", "Genre", GC.Spread.Pivot.PivotTableFieldType.rowField); pivotTable.add("Name", "Name", GC.Spread.Pivot.PivotTableFieldType.rowField); pivotTable.add("NA_Sales", "NA_Sales", GC.Spread.Pivot.PivotTableFieldType.valueField, GC.Pivot.SubtotalType.sum); pivotTable.add("EU_Sales", "EU_Sales", GC.Spread.Pivot.PivotTableFieldType.valueField, GC.Pivot.SubtotalType.sum); pivotTable.add("JP_Sales", "JP_Sales", GC.Spread.Pivot.PivotTableFieldType.valueField, GC.Pivot.SubtotalType.sum); pivotTable.add("Other_Sales", "Other_Sales", GC.Spread.Pivot.PivotTableFieldType.valueField, GC.Pivot.SubtotalType.sum); pivotTable.add("Global_Sales", "Global_Sales", GC.Spread.Pivot.PivotTableFieldType.valueField, GC.Pivot.SubtotalType.sum); pivotTable.resumeLayout(); }
```

After applying this code, the PivotTable will display in the Angular application like so:

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-axgb3q">

<div data-type="file" data-node-type="media" data-width="854" data-height="744" data-id="18d43610-e1da-4fab-b7b9-428f7c4feab8" data-collection="contentId-3441918655" data-file-name="03-react.png?width=500&amp;height=435.59718969555036" data-file-size="123315" data-file-mime-type="image/png" data-alt="React Pivot Table" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-peq0tl" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="03-react.png?width=500&amp;height=435.59718969555036" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/kxrdbtxw/002-js.png?rmode=max&width=751&height=654)</div>

</div>

</div>

</div>

</div>

Another way of creating a pivot table is by using the [Pivot Panel](https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-panel/overview/angular "https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-panel/overview/angular") offered by SpreadJS. To initialize the Pivot Panel, first, create a DOM element, in this case, a DIV with an ID “panel”:

```
return (
        <div class="sample-tutorial">
            <div class="sample-spreadsheets">
                <SpreadSheets workbookInitialized={spread=>initSpread(spread)}>
                </SpreadSheets>
            </div>
             <div class="sample-panel">
                <div id="panel"></div>
            </div>
        </div>
    );
```

Apply CSS for the side panel. Interesting side note - developers can customize the styling and appearance of the Pivot Panel here through the CSS:

```
.sample-panel {
  float: right;
  width: 300px;
  padding: 12px;
  height: 100%;
  box-sizing: border-box;
  background: #fbfbfb;
  overflow: auto;
}

.gc-panel {
  padding: 10px;
  background-color: rgb(230, 230, 230);
}

#panel {
  position: absolute;
  right: 0;
  width: 300px;
  height: 100%;
  top: 0;
}
```

Then, use [SpreadJS’s **PivotPanel** constructor](https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotPanel#constructor "https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotPanel#constructor") to initialize the panel:

<div class="code-block  confluence-ssr-app-qswx85">

<div class="confluence-ssr-app-9n57oc">

<div class="confluence-ssr-app-ygvpeu">

<div>![Angular Pivot Table](//cdn.mescius.io/umb/media/qngdmxsl/pivottable-pivot-panel.gif?rmode=max&width=747&height=420)</div>

</div>

</div>

```
//code to add pivot panel in the working spreadsheet.
var panel = new GC.Spread.Pivot.PivotPanel("myPivotPanel", myPivotTable, document.getElementById("panel"));
```

The application will now display the SpreadJS Angular PivotTable with the side panel allowing end-users to drag and drop needed fields according to the report logic.

## <a id="layout"></a>Pivot Layout<span class="confluence-ssr-app-1afrefi" aria-label="Copy"></span>

SpreadJS allows you to choose from [three different pivot table layouts](https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-layout/angular "https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-layout/angular") to offer different visualizations of your data. This includes the Compact, Outline, and Tabular form layouts. By default, the pivot table layout is Compact form. Still, users can set the layout when creating the pivot table using the [**PivotTable** constructor](https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#constructor "https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#constructor") or change the layout using the [**layoutType** function](https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#layouttype "https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#layouttype"). The function has an integer argument corresponding to the form layout (0 - compact, 1 - outline, 2 - tabular).

```
// Set an outline form (1)
pivotTable.layoutType(1);
```

### Compact Form (0)<span class="confluence-ssr-app-1afrefi" aria-label="Copy"></span>

This layout contains all the Row fields in one column in a hierarchical structure.

This layout form optimizes readability by keeping related data in one column. Still, if you copy and paste the data into a new worksheet, it will be harder to do further analysis.

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-13r9fno">

<div data-type="file" data-node-type="media" data-width="837" data-height="364" data-id="23acc2da-978b-4163-85a2-041ed98ef3eb" data-collection="contentId-3441918655" data-file-name="05-react.png?width=500&amp;height=217.44324970131424" data-file-size="35291" data-file-mime-type="image/png" data-alt="React Pivot Table" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-1vndsr1" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="05-react.png?width=500&amp;height=217.44324970131424" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/0icg4x1p/003-js.png?rmode=max&width=759&height=330)</div>

</div>

</div>

</div>

</div>

### Outline Form (1)<span class="confluence-ssr-app-1afrefi" aria-label="Copy"></span>

This layout has a hierarchical structure, but each Row field is in a separate column in the pivot table. It displays one column per field and provides space for field headers.

Using this form, you can include Field headers in each column, repeat all item labels, and reuse the data of the Pivot Table in a new location for further analysis. Still, this form uses horizontal space, so it might not be beneficial to use it in some cases.

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-r83a7j">

<div data-type="file" data-node-type="media" data-width="743" data-height="364" data-id="ebcb8bf3-2360-489c-94a0-176896dfb2fa" data-collection="contentId-3441918655" data-file-name="06-react.png?width=500&amp;height=244.9528936742934" data-file-size="34558" data-file-mime-type="image/png" data-alt="React Pivot Table" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-d0xlmy" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="06-react.png?width=500&amp;height=244.9528936742934" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/fygfda4q/004-js.png?rmode=max&width=753&height=369)</div>

</div>

</div>

</div>

</div>

### Tabular Form (2)<span class="confluence-ssr-app-1afrefi" aria-label="Copy"></span>

This layout is a hierarchical structure, and each Row field is in a separate column in the pivot table. It can display subtotals at the top of every group because items in the next column are displayed in one row below the current item.

This traditional table format includes Field headers in each column and allows you to have all the item labels repeated and reuse the Pivot Table data in a new location for further analysis. As a disadvantage, this layout uses horizontal space, and subtotals can’t appear at the top of the group if you want to have those at the top.

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-yz0pq8">

<div data-type="file" data-node-type="media" data-width="746" data-height="303" data-id="be2cd27f-f1d3-460e-b976-77b0d76ef7e1" data-collection="contentId-3441918655" data-file-name="07-react.png?width=500&amp;height=203.08310991957106" data-file-size="34758" data-file-mime-type="image/png" data-alt="React Pivot Table" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-1b72il8" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="07-react.png?width=500&amp;height=203.08310991957106" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/ttwoufr3/005-js.png)</div>

</div>

</div>

</div>

</div>

## <a id="theme"></a>Pivot Table Theme<span class="confluence-ssr-app-1afrefi" aria-label="Copy"></span>

SpreadJS’s Angular PivotTable provides 85 predefined themes - 29 light, 28 medium, and 28 dark.

You can apply the pivot table theme when [adding the pivot table](https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#add "https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#add"), or you can use the [**theme** function](https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#theme "https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#theme").

```
let pivotTable = sheet.pivotTables.add("PivotTable", table.name(), 0, 0, GC.Spread.Pivot.PivotTableLayoutType.outline, GC.Spread.Pivot.PivotTableThemes.medium2);
//pivotTable.theme(GC.Spread.Pivot.PivotTableThemes.dark2);
//pivotTable.theme("dark2");
```

Choosing the right theme improves the appearance of your pivot table and offers a more professional presentation of data for the end receivers of your report. Check out SpreadJS’s [online demo](https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-customize/pivot-theme/angular "https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-customize/pivot-theme/angular") [](https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-customize/pivot-theme/angular "https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-customize/pivot-theme/angular")to see for yourself.

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-1bif4gd">

<div data-type="file" data-node-type="media" data-width="1415" data-height="737" data-id="1f5cbdb3-c16d-4e82-b107-562c5a0013a8" data-collection="contentId-3441918655" data-file-name="08-pivottable-panel-themes.gif?width=500&amp;height=260.42402826855124" data-file-size="1075122" data-file-mime-type="image/gif" data-alt="React Pivot Tables" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-12lr8qu" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="08-pivottable-panel-themes.gif?width=500&amp;height=260.42402826855124" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/j01ekfxz/pivottable-panel-themes.gif?rmode=max&width=760&height=396)</div>

</div>

</div>

</div>

</div>

## <a></a><a id="styles"></a>Pivot Styles<span class="confluence-ssr-app-1afrefi" aria-label="Copy"></span>

You can apply a [pivot table style](https://developer.mescius.com/spreadjs/docs/features/pivot-table/themes-and-style#style "https://developer.mescius.com/spreadjs/docs/features/pivot-table/themes-and-style#style") to highlight any specific data. The [**style** method](https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#setStyle "https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#setStyle") can apply styles to row, column, value, and label fields. For example, the following code snippet applies a style to the value fields.

```
// Get the pivot area
let labelPivotArea = {
    dataOnly: true,
    references: [{
      fieldName: "Values",
      items: ["Global_Sales", "NA_Sales"]
    }]
};

// Create style
let style = new GC.Spread.Sheets.Style();
style.backColor = "#82bc00";

// Set pivot style
pivotTable.setStyle(labelPivotArea, style);
```

This code will highlight the value fields “Global_Sales”, “JP_Sales”, and “NA_Sales”:

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-16n1vl6">

<div data-type="file" data-node-type="media" data-width="763" data-height="752" data-id="9376039b-f9ba-403a-a1a2-d645a7a846a1" data-collection="contentId-3441918655" data-file-name="09-react.png?width=500&amp;height=492.7916120576671" data-file-size="128599" data-file-mime-type="image/png" data-alt="React Pivot Tables" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-1cdtuy6" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="09-react.png?width=500&amp;height=492.7916120576671" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/zk4nn21v/006-js.png?rmode=max&width=675&height=665)</div>

</div>

</div>

</div>

</div>

With this support, Angular developers can customize and apply their own rules, styles, and formatting to certain pivot table fields; check out [SpreadJS’s online Pivot Style demo](https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-style/angular "https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-style/angular") for more information.

## <a id="autofit"></a>Pivot Table AutofitColumn<span class="confluence-ssr-app-1afrefi" aria-label="Copy"></span>

SpreadJS’s Angfular pivot table offers an [**AutofitColumn** function](https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#autofitcolumn "https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#autofitcolumn") that adjusts the pivot table's column width to accommodate the longest value in a field. Overall, it is a helpful function and convenient when working with long, text-based fields.

```
// Auto fit Pivot Table columns
pivotTable.autoFitColumn();
```

The GIF below demonstrates this function; when the page reloads, the **autoFitColumn** function is invoked:

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-1u8tsyp">

<div data-type="file" data-node-type="media" data-width="1415" data-height="743" data-id="37d2793e-f159-4581-b3e0-83bee30c4ddd" data-collection="contentId-3441918655" data-file-name="10-pivottable-panel-autofit.gif?width=500&amp;height=262.54416961130744" data-file-size="293143" data-file-mime-type="image/gif" data-alt="React Pivot Tables" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-1jp48l0" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="10-pivottable-panel-autofit.gif?width=500&amp;height=262.54416961130744" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/j1llz4ij/pivottable-panel-autofit.gif?rmode=max&width=762&height=400)</div>

</div>

</div>

</div>

</div>

## <a id="slicers"></a>Pivot Table Slicers<span class="confluence-ssr-app-1afrefi" aria-label="Copy"></span>

Pivot Table Slicers are an interactive visual control that allows users to filter and manipulate data within a pivot table. They provide a user-friendly way to narrow down the data displayed in a pivot table by selecting specific criteria, such as dates, categories, or other relevant dimensions. Using slicers, users can quickly analyze and explore data subsets without modifying the underlying pivot table structure. SpreadJS supports both the [Item Slicer](https://developer.mescius.com/spreadjs/docs/features/pivot-table/pt-slicer/pivot-table-item-slicer "https://developer.mescius.com/spreadjs/docs/features/pivot-table/pt-slicer/pivot-table-item-slicer") and [Timeline Slicer](https://developer.mescius.com/spreadjs/docs/features/pivot-table/pt-slicer/pivot-table-timeline-slicer "https://developer.mescius.com/spreadjs/docs/features/pivot-table/pt-slicer/pivot-table-timeline-slicer").

**PivotTable Item Slicer**

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-11ajxxg">

<div data-type="file" data-node-type="media" data-width="832" data-height="596" data-id="c58dc75e-4d0e-4f74-b831-561b1626b746" data-collection="contentId-3441918655" data-file-name="untitled-design-26.png?width=500&amp;height=358.1730769230769" data-file-size="400820" data-file-mime-type="image/png" data-alt="React Pivot Table - Item Slicers" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-197yr0m" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="untitled-design-26.png?width=500&amp;height=358.1730769230769" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/rdkft245/007-js.png?rmode=max&width=645&height=317)</div>

**PivotTable Timeline Slicer**

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-11ajxxg">

<div data-type="file" data-node-type="media" data-width="832" data-height="596" data-id="5b6a0fca-4ca0-4346-8e26-b069e20a1cb3" data-collection="contentId-3441918655" data-file-name="12-react.png?width=419&amp;height=300&amp;mode=max" data-file-size="157948" data-file-mime-type="image/png" data-alt="React Pivot Table - Timeline slicers" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-197yr0m" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="12-react.png?width=419&amp;height=300&amp;mode=max" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/ocwp0dsl/008-js.png?rmode=max&width=595&height=426)</div>

Check out [SpreadJS’s Angular Slicer demo](https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-slicer/pivot-slicer-overview/angular "https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-slicer/pivot-slicer-overview/angular") to try the slicers for yourself.

## <a id="contextmenu"></a>Pivot ContextMenu<span class="confluence-ssr-app-1afrefi" aria-label="Copy"></span>

SpreadJS offers a [Pivot ContextMenu](https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-context-menu/angular "https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-context-menu/angular") that empowers users to perform various actions on pivot tables effortlessly. This feature allows users to sort data, rearrange field headers, and personalize the control by expanding or collapsing field values. The Pivot ContextMenu provides a user-friendly and compact interface to modify the appearance of pivot table data.

When interacting with different parts of a pivot table and then right-clicking, [SpreadJS presents distinct context menu options](https://developer.mescius.com/spreadjs/docs/features/pivot-table/context-menu "https://developer.mescius.com/spreadjs/docs/features/pivot-table/context-menu"). Here are some of the Angular Pivot Table Context Menus:

**The page area**

![React Pivot Table](//cdn.mescius.io/umb/media/pegd5pte/13-pt-page-area-cm.png?width=500&height=332.03559510567294)

**The header area**

![React Pivot Table](//cdn.mescius.io/umb/media/ugtcwshu/14-pt-header-area-cm.png?width=500&height=332.03559510567294)

**The data area**

![React Pivot Table](//cdn.mescius.io/umb/media/5wsftvj4/15-pt-data-area-cm.png?width=500&height=332.03559510567294)

**The Grand Total area**

![React Pivot Table](//cdn.mescius.io/umb/media/krjkktj5/16-pt-grand-total-area-cm.png?width=500&height=332.03559510567294)

<div class="sentinel-right">[Users can also format values with given formats or customized ones](https://developer.mescius.com/spreadjs/docs/features/pivot-table/context-menu#custom-format-in-value-fields "https://developer.mescius.com/spreadjs/docs/features/pivot-table/context-menu#custom-format-in-value-fields") by choosing the “**Value Field Settings...**" option from the data area or the Grand Total area context menu to open the dialog window.</div>

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-hnwjf0">

<div data-type="file" data-node-type="media" data-width="1280" data-height="720" data-id="4563810c-ff26-4c32-8d2f-4a97080e7102" data-collection="contentId-3441918655" data-file-name="17-pivottable-value-field-settings.gif?width=500&amp;height=281.25" data-file-size="290150" data-file-mime-type="image/gif" data-alt="React Pivot Table" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-nxmyf2" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="17-pivottable-value-field-settings.gif?width=500&amp;height=281.25" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/ugelhyp4/pivottable-value-field-settings.gif?rmode=max&width=763&height=429)</div>

</div>

</div>

</div>

</div>

## <a id="conditional"></a>Pivot Conditional Formatting<span class="confluence-ssr-app-1afrefi" aria-label="Copy"></span>

Conditional Formatting is a powerful tool that allows you to quickly highlight data fields, making it easier to identify outliers or refine your results. In a pivot area, you have the flexibility to apply, retrieve, and remove conditional formatting rules. These rules remain in effect even if you make changes to the PivotTable layout.

You can apply Conditional Formatting to the SpreadJS’s Angular Pivot Table using the [**addConditionalRule** method](https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#addconditionalrule "https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Pivot.PivotTable-1#addconditionalrule").

Check out [SpreadJS’s online Angular demo](https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-conditional-rules/angular "https://developer.mescius.com/spreadjs/demos/features/pivot-table/pivot-conditional-rules/angular"). This demo applies different color formatting depending on the cell values, with green being the lowest and red the highest.

<div class="rich-media-item mediaSingleView-content-wrap image-center confluence-ssr-app-avcjpy" data-layout="center" data-width-type="percentage" data-node-type="mediaSingle">

<div class="confluence-ssr-app-p04dph">

<div data-type="file" data-node-type="media" data-width="1506" data-height="851" data-id="8d4f8c40-836d-4d74-a97d-969a556d5a4f" data-collection="contentId-3441918655" data-file-name="18-react.png?width=500&amp;height=282.5365205843293" data-file-size="160050" data-file-mime-type="image/png" data-alt="React Pivot Table" data-context-id="3441918655">

<div id="newFileExperienceWrapper" class="new-file-experience-wrapper confluence-ssr-app-1rmv202" data-testid="media-card-view">

<div class="media-file-card-view confluence-ssr-app-1yn77bd" data-testid="media-file-card-view" data-test-media-name="18-react.png?width=500&amp;height=282.5365205843293" data-test-status="complete" data-test-progress="1">![Angular Pivot Table](//cdn.mescius.io/umb/media/bbvbhjhd/009-js.png?rmode=max&width=770&height=435)</div>

</div>

</div>

</div>

</div>

We hope you enjoyed learning how to create and customize Angular Spreadsheet Pivot Tables. [You can download the sample application from the blog here](https://gccontent.blob.core.windows.net/gccontent/blogs/spread/20230712-spjs-react-pivot-table-blog-sample/features_pivot-table_overview_React_blog.zip "https://gccontent.blob.core.windows.net/gccontent/blogs/spread/20230712-spjs-react-pivot-table-blog-sample/features_pivot-table_overview_React_blog.zip"). This article only scratches the surface of the full capabilities of [**SpreadJS**](https://developer.mescius.com/spreadjs/react-spreadsheet-components "https://developer.mescius.com/spreadjs/react-spreadsheet-components"), the Angular spreadsheet component.

Review the [documentation](https://developer.mescius.com/spreadjs/docs/overview "https://developer.mescius.com/spreadjs/docs/overview") to see some of the many available features, and check out our [online demos](https://developer.mescius.com/spreadjs/demos/ "https://developer.mescius.com/spreadjs/demos/") to see the features in action and interact with the sample code. Integrating a spreadsheet component into your Angular applications allows you to customize your users' experience and provide them with familiar spreadsheet functionality.