Class SlicerCollection
Namespace: Aspose.Cells.Slicers
Assembly: Aspose.Cells.dll (25.2.0)
Specifies the collection of all the Slicer objects on the specified worksheet.
public class SlicerCollection : CollectionBase<slicer>, IList<slicer>, ICollection<slicer>, IEnumerable<slicer>, ICollection, IEnumerable
Inheritance
object ← CollectionBase<slicer> ← SlicerCollection
Implements
IList<slicer>, ICollection<slicer>, IEnumerable<slicer>, ICollection, IEnumerable
Inherited Members
CollectionBase<slicer>.BinarySearch(Slicer), CollectionBase<slicer>.BinarySearch(Slicer, IComparer<slicer>), CollectionBase<slicer>.BinarySearch(int, int, Slicer, IComparer<slicer>), CollectionBase<slicer>.Contains(Slicer), CollectionBase<slicer>.CopyTo(Slicer[]), CollectionBase<slicer>.CopyTo(Slicer[], int), CollectionBase<slicer>.CopyTo(int, Slicer[], int, int), CollectionBase<slicer>.Exists(Predicate<slicer>), CollectionBase<slicer>.Find(Predicate<slicer>), CollectionBase<slicer>.FindAll(Predicate<slicer>), CollectionBase<slicer>.FindIndex(Predicate<slicer>), CollectionBase<slicer>.FindIndex(int, Predicate<slicer>), CollectionBase<slicer>.FindIndex(int, int, Predicate<slicer>), CollectionBase<slicer>.FindLast(Predicate<slicer>), CollectionBase<slicer>.FindLastIndex(Predicate<slicer>), CollectionBase<slicer>.FindLastIndex(int, Predicate<slicer>), CollectionBase<slicer>.FindLastIndex(int, int, Predicate<slicer>), CollectionBase<slicer>.IndexOf(Slicer), CollectionBase<slicer>.IndexOf(Slicer, int), CollectionBase<slicer>.IndexOf(Slicer, int, int), CollectionBase<slicer>.LastIndexOf(Slicer), CollectionBase<slicer>.LastIndexOf(Slicer, int), CollectionBase<slicer>.LastIndexOf(Slicer, int, int), CollectionBase<slicer>.GetEnumerator(), CollectionBase<slicer>.Clear(), CollectionBase<slicer>.RemoveAt(int), CollectionBase<slicer>.OnClearComplete(), CollectionBase<slicer>.OnClear(), CollectionBase<slicer>.Capacity, CollectionBase<slicer>.Count, CollectionBase<slicer>.InnerList, CollectionBase<slicer>.this[int], object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
Workbook book = new Workbook();
Worksheet sheet = book.Worksheets[0];
Cells cells = sheet.Cells;
cells[0, 0].Value = "fruit";
cells[1, 0].Value = "grape";
cells[2, 0].Value = "blueberry";
cells[3, 0].Value = "kiwi";
cells[4, 0].Value = "cherry";
cells[5, 0].Value = "grape";
cells[6, 0].Value = "blueberry";
cells[7, 0].Value = "kiwi";
cells[8, 0].Value = "cherry";
cells[0, 1].Value = "year";
cells[1, 1].Value = 2020;
cells[2, 1].Value = 2020;
cells[3, 1].Value = 2020;
cells[4, 1].Value = 2020;
cells[5, 1].Value = 2021;
cells[6, 1].Value = 2021;
cells[7, 1].Value = 2021;
cells[8, 1].Value = 2021;
cells[0, 2].Value = "amount";
cells[1, 2].Value = 50;
cells[2, 2].Value = 60;
cells[3, 2].Value = 70;
cells[4, 2].Value = 80;
cells[5, 2].Value = 90;
cells[6, 2].Value = 100;
cells[7, 2].Value = 110;
cells[8, 2].Value = 120;
PivotTableCollection pivots = sheet.PivotTables;
int pivotIndex = pivots.Add("=Sheet1!A1:C9", "A12", "TestPivotTable");
PivotTable pivot = pivots[pivotIndex];
pivot.AddFieldToArea(PivotFieldType.Row, "fruit");
pivot.AddFieldToArea(PivotFieldType.Column, "year");
pivot.AddFieldToArea(PivotFieldType.Data, "amount");
pivot.PivotTableStyleType = PivotTableStyleType.PivotTableStyleMedium10;
pivot.RefreshData();
pivot.CalculateData();
SlicerCollection slicers = sheet.Slicers;
int tableIndex = sheet.ListObjects.Add("A1", "C9", true);
ListObject table = sheet.ListObjects[tableIndex];
//do your business
book.Save("out.xlsx");
Dim book As Workbook = New Workbook()
Dim sheet As Worksheet = book.Worksheets(0)
Dim cells As Cells = sheet.Cells
cells(0, 0).Value = "fruit"
cells(1, 0).Value = "grape"
cells(2, 0).Value = "blueberry"
cells(3, 0).Value = "kiwi"
cells(4, 0).Value = "cherry"
cells(5, 0).Value = "grape"
cells(6, 0).Value = "blueberry"
cells(7, 0).Value = "kiwi"
cells(8, 0).Value = "cherry"
cells(0, 1).Value = "year"
cells(1, 1).Value = 2020
cells(2, 1).Value = 2020
cells(3, 1).Value = 2020
cells(4, 1).Value = 2020
cells(5, 1).Value = 2021
cells(6, 1).Value = 2021
cells(7, 1).Value = 2021
cells(8, 1).Value = 2021
cells(0, 2).Value = "amount"
cells(1, 2).Value = 50
cells(2, 2).Value = 60
cells(3, 2).Value = 70
cells(4, 2).Value = 80
cells(5, 2).Value = 90
cells(6, 2).Value = 100
cells(7, 2).Value = 110
cells(8, 2).Value = 120
Dim pivots As PivotTableCollection = sheet.PivotTables
Dim pivotIndex As Int32 = pivots.Add("=Sheet1!A1:C9", "A12", "TestPivotTable")
Dim pivot As PivotTable = pivots(pivotIndex)
pivot.AddFieldToArea(PivotFieldType.Row, "fruit")
Pivot.AddFieldToArea(PivotFieldType.Column, "year")
Pivot.AddFieldToArea(PivotFieldType.Data, "amount")
pivot.PivotTableStyleType = PivotTableStyleType.PivotTableStyleMedium10
pivot.RefreshData()
pivot.CalculateData()
Dim slicers As SlicerCollection = sheet.Slicers
Dim tableIndex As Int32 = sheet.ListObjects.Add("A1", "C9", True)
Dim table As ListObject = sheet.ListObjects(tableIndex)
book.Save("out_vb.xlsx")
Properties
this[int]
Gets the Slicer by index.
public Slicer this[int index] { get; }
Property Value
Examples
csharp
[C#]
Slicer slicerByIndex = slicers[0];
this[string]
Gets the Slicer by slicer’s name.
public Slicer this[string name] { get; }
Property Value
Examples
csharp
[C#]
Slicer slicerByName = slicers["fruit"];
Methods
Add(PivotTable, string, string)
Add a new Slicer using PivotTable as data source
public int Add(PivotTable pivot, string destCellName, string baseFieldName)
Parameters
pivot
PivotTable
PivotTable object
destCellName
string
The cell in the upper-left corner of the Slicer range.
baseFieldName
string
The name of PivotField in PivotTable.BaseFields
Returns
The new add Slicer index
Examples
csharp
[C#]
slicers.Add(pivot, "E3", "fruit");
Add(PivotTable, int, int, string)
Add a new Slicer using PivotTable as data source
public int Add(PivotTable pivot, int row, int column, string baseFieldName)
Parameters
pivot
PivotTable
PivotTable object
row
int
Row index of the cell in the upper-left corner of the Slicer range.
column
int
Column index of the cell in the upper-left corner of the Slicer range.
baseFieldName
string
The name of PivotField in PivotTable.BaseFields
Returns
The new add Slicer index
Examples
csharp
[C#]
slicers.Add(pivot, 20, 12, "fruit");
Add(PivotTable, int, int, int)
Add a new Slicer using PivotTable as data source
public int Add(PivotTable pivot, int row, int column, int baseFieldIndex)
Parameters
pivot
PivotTable
PivotTable object
row
int
Row index of the cell in the upper-left corner of the Slicer range.
column
int
Column index of the cell in the upper-left corner of the Slicer range.
baseFieldIndex
int
The index of PivotField in PivotTable.BaseFields
Returns
The new add Slicer index
Examples
csharp
[C#]
slicers.Add(pivot, 20, 8, 0);
Add(PivotTable, string, int)
Add a new Slicer using PivotTable as data source
public int Add(PivotTable pivot, string destCellName, int baseFieldIndex)
Parameters
pivot
PivotTable
PivotTable object
destCellName
string
The cell in the upper-left corner of the Slicer range.
baseFieldIndex
int
The index of PivotField in PivotTable.BaseFields
Returns
The new add Slicer index
Examples
csharp
[C#]
slicers.Add(pivot, "E20", 0);
Add(PivotTable, int, int, PivotField)
Add a new Slicer using PivotTable as data source
public int Add(PivotTable pivot, int row, int column, PivotField baseField)
Parameters
pivot
PivotTable
PivotTable object
row
int
Row index of the cell in the upper-left corner of the Slicer range.
column
int
Column index of the cell in the upper-left corner of the Slicer range.
baseField
PivotField
The PivotField in PivotTable.BaseFields
Returns
The new add Slicer index
Examples
csharp
[C#]
slicers.Add(pivot, 3, 12, pivot.BaseFields[0]);
Add(PivotTable, string, PivotField)
Add a new Slicer using PivotTable as data source
public int Add(PivotTable pivot, string destCellName, PivotField baseField)
Parameters
pivot
PivotTable
PivotTable object
destCellName
string
The cell in the upper-left corner of the Slicer range.
baseField
PivotField
The PivotField in PivotTable.BaseFields
Returns
The new add Slicer index
Examples
csharp
[C#]
slicers.Add(pivot, "I3", pivot.BaseFields[0]);
Add(ListObject, int, string)
Add a new Slicer using ListObjet as data source
public int Add(ListObject table, int index, string destCellName)
Parameters
table
ListObject
ListObject object
index
int
The index of ListColumn in ListObject.ListColumns
destCellName
string
The cell in the upper-left corner of the Slicer range.
Returns
The new add Slicer index
Examples
csharp
[C#]
slicers.Add(table, 1, "E38");
Add(ListObject, ListColumn, string)
Add a new Slicer using ListObjet as data source
public int Add(ListObject table, ListColumn listColumn, string destCellName)
Parameters
table
ListObject
ListObject object
listColumn
ListColumn
The ListColumn in ListObject.ListColumns
destCellName
string
The cell in the upper-left corner of the Slicer range.
Returns
The new add Slicer index
Examples
csharp
[C#]
slicers.Add(table, table.ListColumns[1], "I38");
Add(ListObject, ListColumn, int, int)
Add a new Slicer using ListObjet as data source
public int Add(ListObject table, ListColumn listColumn, int row, int column)
Parameters
table
ListObject
ListObject object
listColumn
ListColumn
The ListColumn in ListObject.ListColumns
row
int
Row index of the cell in the upper-left corner of the Slicer range.
column
int
Column index of the cell in the upper-left corner of the Slicer range.
Returns
The new add Slicer index
Examples
csharp
[C#]
slicers.Add(table, table.ListColumns[1], 38, 12);
Clear()
Clear all Slicers.
public void Clear()
Remove(Slicer)
Remove the specified Slicer
public void Remove(Slicer slicer)
Parameters
slicer
Slicer
The Slicer object
Examples
csharp
[C#]
Slicer delSlicer = slicers[0];
slicers.Remove(delSlicer);
RemoveAt(int)
Deletes the Slicer at the specified index
public void RemoveAt(int index)
Parameters
index
int
The position index in Slicer collection
Examples
csharp
[C#]
slicers.RemoveAt(1);
</slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer></slicer>