Method Add
- Namespace
- DocWright.Spreadsheet
- Assembly
- DocWright.Spreadsheet.dll
Add(string, string, XlsxPivotTableOptions)
Makes a pivot table of a source at a cell of this sheet, arranges its fields and computes it (Refresh()): its cache, its definition and its cells are written as Excel writes them after a refresh.
public XlsxPivotTable Add(string source, string cell, XlsxPivotTableOptions options)
Parameters
sourcestringThe range or the table the pivot table reads.
cellstringWhere its body starts, as
H3.optionsXlsxPivotTableOptionsIts name, its fields and its layout.
Returns
- XlsxPivotTable
The pivot table.
Remarks
The source is a range of a worksheet, Sales!A1:E25 (its first row the field names), or a table's
name. The table's body starts at cell; its filter fields, when there are any, take the rows
above it with one row between, as Excel lays them out (the body moves down when the sheet has no room for them).
A field's items are listed as Excel sorts them. Excel opens the workbook and lists the table as made.
Each new table has a cache of its own, as Excel gives one it makes through its object model.
Exceptions
- ArgumentNullException
An argument is null.
- ArgumentException
The cell is not a reference; a field named in the options is not a field of the source, or is named twice; the name is taken.
- ArgumentException
The source is not a range or a table of the workbook, or has no record under its headings.
- InvalidOperationException
The sheet is not a worksheet; a heading of the source is blank.