[]
        
(Showing Draft Content)

GC.Spread.Sheets.Slicers.SlicerCollection

Class: SlicerCollection

Sheets.Slicers.SlicerCollection

Table of contents

Constructors

Methods

Constructors

constructor

new SlicerCollection(sheet)

Represents a slicer manager that managers all slicers in a sheet.

Parameters

Name Type Description
sheet Worksheet The worksheet.

Methods

add

add(slicerName, targetName, itemName, style?, type?): ISlicer

Adds a slicer to the sheet.

example

//This example uses the add method.
//create a table
var datas = [
    ["1", "NewYork", "1968/6/8", "80", "180"],
    ["4", "NewYork", "1972/7/3", "72", "168"],
    ["4", "NewYork", "1964/3/2", "71", "179"],
    ["5", "Washington", "1972/8/8","80", "171"],
    ["6", "Washington", "1986/2/2", "89", "161"],
    ["7", "Washington", "2012/2/15", "71", "240"]];
var table = activeSheet.tables.addFromDataSource("table1", 2, 2, datas);
dataColumns = ["Name", "City", "Birthday", "Weight", "Height"];
table.setColumnName(0, dataColumns[0]);
table.setColumnName(1, dataColumns[1]);
table.setColumnName(2, dataColumns[2]);
table.setColumnName(3, dataColumns[3]);
table.setColumnName(4, dataColumns[4]);
//add a slicer to the sheet and return the slicer instance.
var slicer = activeSheet.slicers.add("slicer1",table.name(),"Name");
 //change the slicer properties.
slicer.position(new GC.Spread.Sheets.Point(100, 200));

Parameters

Name Type Description
slicerName string The name of the slicer.
targetName string The name of the table or pivot table that relates to the slicer.
itemName string The name of the table column or pivot table field that relates to the slicer.
style? string | SlicerStyle | TimelineStyle The style of the slicer.
type? SlicerType -

Returns

ISlicer

The slicer that has been added to the sheet.


all

all(targetName?, itemName?): ISlicer[]

Gets all of the slicers in the sheet with the indicated table name and column name.

example

//create a table
var datas = [
    ["1", "NewYork", "1968/6/8", "80", "180"],
    ["4", "NewYork", "1972/7/3", "72", "168"],
    ["4", "NewYork", "1964/3/2", "71", "179"],
    ["5", "Washington", "1972/8/8","80", "171"],
    ["6", "Washington", "1986/2/2", "89", "161"],
    ["7", "Washington", "2012/2/15", "71", "240"]];
var activeSheet = spread.getActiveSheet();
var table = activeSheet.tables.addFromDataSource("table1", 2, 2, datas);
dataColumns = ["Name", "City", "Birthday", "Weight", "Height"];
table.setColumnName(0, dataColumns[0]);
table.setColumnName(1, dataColumns[1]);
table.setColumnName(2, dataColumns[2]);
table.setColumnName(3, dataColumns[3]);
table.setColumnName(4, dataColumns[4]);
//add a slicer to the sheet and return the slicer instance.
var slicer = activeSheet.slicers.add("slicer1",table.name(),"Name");

var allSlicers = activeSheet.slicers.all();
console.log(allSlicers.length); // 1;
console.log(allSlicers[0] === slicer); // true

Parameters

Name Type
targetName? string
itemName? string

Returns

ISlicer[]

The slicer collection.


clear

clear(): void

Removes all of the slicers from the sheet.

example

//create a table
var datas = [
    ["1", "NewYork", "1968/6/8", "80", "180"],
    ["4", "NewYork", "1972/7/3", "72", "168"],
    ["4", "NewYork", "1964/3/2", "71", "179"],
    ["5", "Washington", "1972/8/8","80", "171"],
    ["6", "Washington", "1986/2/2", "89", "161"],
    ["7", "Washington", "2012/2/15", "71", "240"]];
var activeSheet = spread.getActiveSheet();
var table = activeSheet.tables.addFromDataSource("table1", 2, 2, datas);
dataColumns = ["Name", "City", "Birthday", "Weight", "Height"];
table.setColumnName(0, dataColumns[0]);
table.setColumnName(1, dataColumns[1]);
table.setColumnName(2, dataColumns[2]);
table.setColumnName(3, dataColumns[3]);
table.setColumnName(4, dataColumns[4]);
//add a slicer to the sheet and return the slicer instance.
var slicer1 = activeSheet.slicers.add("slicer1",table.name(),"Name");
var slicer2 = activeSheet.slicers.add("slicer2",table.name(),"City");

var allSlicers = activeSheet.slicers.all();
console.log(allSlicers.length); // 2;

activeSheet.slicers.clear();
allSlicers = activeSheet.slicers.all();
console.log(allSlicers.length); // 0;

Returns

void


get

get(name): ISlicer

Gets a slicer in the sheet by the name.

Parameters

Name Type Description
name string The name of the slicer.

Returns

ISlicer

The slicer that has the indicated name.


remove

remove(name): void

Removes a slicer from the sheet using the indicated slicer name.

example

//create a table
var datas = [
    ["1", "NewYork", "1968/6/8", "80", "180"],
    ["4", "NewYork", "1972/7/3", "72", "168"],
    ["4", "NewYork", "1964/3/2", "71", "179"],
    ["5", "Washington", "1972/8/8","80", "171"],
    ["6", "Washington", "1986/2/2", "89", "161"],
    ["7", "Washington", "2012/2/15", "71", "240"]];
var activeSheet = spread.getActiveSheet();
var table = activeSheet.tables.addFromDataSource("table1", 2, 2, datas);
dataColumns = ["Name", "City", "Birthday", "Weight", "Height"];
table.setColumnName(0, dataColumns[0]);
table.setColumnName(1, dataColumns[1]);
table.setColumnName(2, dataColumns[2]);
table.setColumnName(3, dataColumns[3]);
table.setColumnName(4, dataColumns[4]);
//add a slicer to the sheet and return the slicer instance.
var slicer1 = activeSheet.slicers.add("slicer1",table.name(),"Name");
var slicer2 = activeSheet.slicers.add("slicer2",table.name(),"City");

var allSlicers = activeSheet.slicers.all();
console.log(allSlicers.length); // 2;

activeSheet.slicers.remove('slicer1');
allSlicers = activeSheet.slicers.all();
console.log(allSlicers.length); // 1;
console.log(allSlicers[0] === slicer2); // true;

Parameters

Name Type Description
name string The name of the slicer.

Returns

void