过滤数据
Contents
[
Hide
]
Aspose.Cells.GridDesktop为用户提供自动过滤和自定义数据过滤功能。使用这些功能,您可能会找到一种方法来仅从工作表中选择您想要在列表中显示的那些项目。此外,您可以根据设定的标准过滤列表中的项目。您可以使用自动筛选/自定义数据筛选功能筛选文本、数字或日期。
您可以使用启用自动过滤的布尔属性行过滤器设置类以启用 GridDesktop 控件的自动筛选功能。您可以使用该类的其他一些属性,例如表头行 , 起始行和结束行指定标题、开始和结束行索引。这标准属性用于设置自定义过滤条件。该类还有一个名为过滤行根据给定条件获取过滤后的行。
RowFilter 中的“包含”类型搜索(不区分大小写)属性也受 GridDesktop 支持。你可以使用忽略大小写的财产网格列类来指定您需要的区分大小写属性。您还可以使用名为IsStartWithCriteria的网格列指示 RowFilter 是否在列上使用 StartWith 条件的类;该属性的默认值设置为 false。
过滤数据
我们在此示例中实现了自动筛选和自定义数据筛选功能。我们在 GridDesktop 中填充一些数据列表,启用自动筛选功能,然后根据一些条件搜索筛选的行。
自动过滤
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Enable GridDesktop's auto-filter. | |
gridDesktop1.Worksheets[0].RowFilter.EnableAutoFilter = true; | |
// Set the header row. | |
gridDesktop1.Worksheets[0].RowFilter.HeaderRow = 0; | |
// Set the starting row. | |
gridDesktop1.Worksheets[0].RowFilter.StartRow = 1; | |
// Set the ending row. | |
gridDesktop1.Worksheets[0].RowFilter.EndRow = 101; |
自定义数据过滤器
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Set the starting row. | |
gridDesktop1.Worksheets[0].RowFilter.StartRow = 1; | |
// Set the ending row. | |
gridDesktop1.Worksheets[0].RowFilter.EndRow = 101; | |
// Get the RowFilter object for the first worksheet. | |
RowFilterSettings rowFilter = gridDesktop1.Worksheets[0].RowFilter; | |
// Filter Rows. | |
rowFilter.FilterRows(0, "Customer 1"); |