PivotTable Class
- Namespace
TXTextControl.TXSheetControl. Server
- Package
TXTextControl.from the private NuGet feed or the supplied NuGet folderTXSheetControl. Server
- Assembly
TXTextControl.TXSheetControl. Api. dll
- Install
dotnet add package TXTextControl..NET 10 and later.TXSheetControl. Server
- Also in
TXTextControl.asTXSheetControl. Blazor TXTextControl.TXSheetControl. Api. dll
- Inherits
- Document
Object - Pivot
Table
- Document
Operational pivot handle. Calls reject after document replacement or pivot removal.
Pivot handles are obtained through the owning workbook or worksheet collection.
Members
| Member | Description |
|---|---|
| Id | Stable identity within the owning workbook. |
| GetSnapshotAsync | Reads detached current settings and the last materialized output range. |
| GetNameAsync | Reads the unique display name. |
| GetFieldsAsync | Lists source and calculated field names. |
| GetItemsAsync | Lists distinct typed or grouped field members, including blank members. |
| UpdateAsync | Applies a camelCase partial settings object and refreshes atomically. Unspecified settings remain unchanged. |
| RefreshAsync | Re-reads the live source and writes result cells in one undo step. |
| GetResultAsync | Computes detached cells and axis paths without editing the workbook. |
| SetFiltersAsync | Replaces report, member, label and value filters. An empty array clears filters. |
| SetFieldsAsync | Sets the rows or columns axis; fields include sorting and grouping settings. |
| SetExpandedAsync | Expands or collapses one typed member path on the rows or columns axis. |
| DrillThroughAsync | Returns up to limit contributing source records (1..100000; default 1000). |
| GetDataAsync | Returns an aggregate by value caption and optional row/column paths; parent paths select totals. |
| CreateChartAsync | Creates a chart bound to the pivot output. Its source range follows pivot refresh and relocation. |
| RemoveAsync | Removes the pivot; keepValues retains the static output. |
Example
using TXTextControl.TXSheetControl.Server;
await using var control = new ServerSheetControl();
var workbook = control.Workbook;
var source = await workbook.Sheets.AtAsync(0);
await source.Range("A1:D5").SetValuesAsync([
[],
[], ["Europe", "Services", 700, 350],
[], ["Americas", "Services", 950, 400]
]);
var report = await workbook.Sheets.AddAsync("Sales Pivot");
var pivot = await report.PivotTables.AddAsync(new PivotTableOptions {
Name = "RegionalSales", Source = new() { SheetId = source.Id, Range = "A1:D5" },
Destination = new() { SheetId = report.Id, Cell = "B3" },
Rows = [new() { Field = "Region" }], Columns = [new() { Field = "Category" }],
Values = [new() { Field = "Revenue", Caption = "Sales", NumberFormatCode = "$#,##0.00" }]
});
See Pivot Tables for field settings, output and lifetime rules.