[]
Adds a new ISlicerCache object to the collection.
Creates a slicer cache based on the specified data source and field. The
data source can be a supported object such as a table or PivotTable, and
sourceField identifies the field used by the slicer cache.
ISlicerCache Add(object source, string sourceField, string name = null)
Function Add(source As Object, sourceField As String, Optional name As String = Nothing) As ISlicerCache
| Type | Name | Description |
|---|---|---|
| object | source | The data source that the new ISlicerCache will be based on. |
| string | sourceField | The name of the field in the data source to filter by. |
| string | name | The name of the slicer cache. If this is null, a default name is used. |
| Type | Description |
|---|---|
| ISlicerCache | The new ISlicerCache. |
worksheet.Range["A1:B4"].Value = new object[,] {
{"Category", "Amount"},
{"Fruit", 100},
{"Vegetable", 200},
{"Fruit", 150}
};
ITable table = worksheet.Tables.Add(worksheet.Range["A1:B4"], true);
ISlicerCache slicerCache = workbook.SlicerCaches.Add(table, "Category");