TX Sheet Control

PivotTable Class

Class
Namespace
TXTextControl.TXSheetControl.Server
Package
TXTextControl.TXSheetControl.Server from the private NuGet feed or the supplied NuGet folder
Assembly
TXTextControl.TXSheetControl.Api.dll
Install
dotnet add package TXTextControl.TXSheetControl.Server .NET 10 and later.
Also in
TXTextControl.TXSheetControl.Blazor as TXTextControl.TXSheetControl.Api.dll
Inherits
  1. DocumentObject
  2. PivotTable

Operational pivot handle. Calls reject after document replacement or pivot removal.

Pivot handles are obtained through the owning workbook or worksheet collection.

Members

MemberDescription
IdStable identity within the owning workbook.
GetSnapshotAsyncReads detached current settings and the last materialized output range.
GetNameAsyncReads the unique display name.
GetFieldsAsyncLists source and calculated field names.
GetItemsAsyncLists distinct typed or grouped field members, including blank members.
UpdateAsyncApplies a camelCase partial settings object and refreshes atomically. Unspecified settings remain unchanged.
RefreshAsyncRe-reads the live source and writes result cells in one undo step.
GetResultAsyncComputes detached cells and axis paths without editing the workbook.
SetFiltersAsyncReplaces report, member, label and value filters. An empty array clears filters.
SetFieldsAsyncSets the rows or columns axis; fields include sorting and grouping settings.
SetExpandedAsyncExpands or collapses one typed member path on the rows or columns axis.
DrillThroughAsyncReturns up to limit contributing source records (1..100000; default 1000).
GetDataAsyncReturns an aggregate by value caption and optional row/column paths; parent paths select totals.
CreateChartAsyncCreates a chart bound to the pivot output. Its source range follows pivot refresh and relocation.
RemoveAsyncRemoves 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([
    ["Region", "Category", "Revenue", "Cost"],
    ["Europe", "Software", 1250, 500], ["Europe", "Services", 700, 350],
    ["Americas", "Software", 1800, 900], ["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.