Skip to content

Latest commit

 

History

History
20 lines (18 loc) · 1.3 KB

1.基本应用.md

File metadata and controls

20 lines (18 loc) · 1.3 KB

筛选的基本应用

筛选显示那些符合你指定条件的行,隐藏那些你不想显示的行。当你在一个工作表格上有太多数据的时候,如果你更像关注符合特定标准的数字,那么filter就会很有用。

当为工作表设置筛选时,首先需要创建一个行筛选,然后调用 rowFilter 方法来设置这个行筛选。

var range = new Excel.View.Sheets.Range(-1, 0, -1, 2);
var rowFilter = new Excel.View.Sheets.Filter.HideRowFilter(range);
sheet.rowFilter(rowFilter);
rowFilter.filterButtonVisible(false);
var condition = new Excel.View.Sheets.ConditionalFormatting.Condition(Excel.View.Sheets.ConditionalFormatting.ConditionType.textCondition, {compareType: Excel.View.Sheets.ConditionalFormatting.TextCompareType.contains,expected: '*e*'});
rowFilter.addFilterItem(1, condition); 
rowFilter.filter(1);

你也可以创建一个条件并且调用 addFilterItem 方法来为行筛选添加一个特殊的筛选。例如:

var formulaCondition = new Excel.View.Sheets.ConditionalFormatting.Condition(Excel.View.Sheets.ConditionalFormatting.ConditionType.formulaCondition, {customValueType: Excel.View.Sheets.ConditionalFormatting.CustomValueType.empty,formula: null});
rowFilter.addFilterItem(1, formulaCondition);
rowFilter.filter(1);