PivotTable class Pivot Tables
A pivot table summarising a worksheet range.
This authors a focused, common shape: one row field (a category column)
and one or more data fields (aggregated measures). The cache is written
with refreshOnLoad, so Excel rebuilds it from the source on open.
Add one with Sheet.addPivotTable.
sheet.addPivotTable(PivotTable(
name: 'ByRegion',
anchor: CellIndex.indexByString('F1'),
sourceFrom: CellIndex.indexByString('A1'),
sourceTo: CellIndex.indexByString('C13'),
rowField: 0, // group by the 1st source column
dataFields: [PivotDataField(2)], // sum the 3rd source column
));
Constructors
-
PivotTable({required String name, required CellIndex anchor, required CellIndex sourceFrom, required CellIndex sourceTo, required int rowField, required List<
PivotDataField> dataFields, List<int> subRowFields = const [], int? columnField, List<int> pageFields = const [], String? sourceSheet}) -
Creates a pivot table over the source range
sourceFrom-sourceTo, grouped byrowFieldand summarised bydataFields, placed atanchor.
Properties
- anchor → CellIndex
-
Top-left cell where the pivot is placed.
final
- columnField → int?
-
Optional 0-based source column used as the column field (produces a
row×column matrix). When set, exactly one data field is supported.
final
-
dataFields
→ List<
PivotDataField> -
The aggregated value fields (at least one).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
Unique pivot-table name.
final
-
pageFields
→ List<
int> -
Optional 0-based source columns used as page (report-filter) fields.
final
- rowField → int
-
0-based source column used as the (outermost) row grouping field.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sourceFrom → CellIndex
-
Source range top-left (the header row).
final
- sourceSheet → String?
-
Name of the sheet holding the source data; defaults to the pivot's sheet.
final
- sourceTo → CellIndex
-
Source range bottom-right (inclusive).
final
-
subRowFields
→ List<
int> -
Optional further row fields nested under rowField, outermost first, for
a multi-level row axis (e.g. Region › Product).
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited