MultipleFilterCollection.Add
Contents
[
Hide
]Add(string)
Adds a label filter criteria.
public void Add(string filter)
| Parameter | Type | Description |
|---|---|---|
| filter | String | The filter data. |
Examples
using System;
using Aspose.Cells;
namespace AsposeCellsExamples
{
public class MultipleFilterCollectionMethodAddWithStringDemo
{
public static void Run()
{
Workbook wb = new Workbook();
Worksheet sheet = wb.Worksheets[0];
Cells cells = sheet.Cells;
// Populate sample data
cells[0, 0].PutValue("Data");
cells[1, 0].PutValue("abc");
cells[2, 0].PutValue("def");
cells[3, 0].PutValue("ghi");
cells[4, 0].PutValue("abc");
// Apply filter
sheet.AutoFilter.Range = "A1:A5";
FilterColumn fc = sheet.AutoFilter.FilterColumns[0];
fc.FilterType = FilterType.MultipleFilters;
MultipleFilterCollection mfc = new MultipleFilterCollection();
mfc.Add("abc"); // Demonstrate Add method with string parameter
mfc.Add("ghi");
fc.Filter = mfc;
sheet.AutoFilter.Refresh();
// Output filtered results
Console.WriteLine("Filtered Rows:");
for (int i = 1; i <= 4; i++)
{
if (!cells.IsRowHidden(i))
{
Console.WriteLine(cells[i, 0].StringValue);
}
}
}
}
}
See Also
- class MultipleFilterCollection
- namespace Aspose.Cells
- assembly Aspose.Cells
Add(DateTimeGroupingType, int, int, int)
Adds a date filter criteria value.
public void Add(DateTimeGroupingType type, int year, int month, int day)
| Parameter | Type | Description |
|---|---|---|
| type | DateTimeGroupingType | The type of date filter. |
| year | Int32 | The year. |
| month | Int32 | The month. |
| day | Int32 | The day. |
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using System;
public class MultipleFilterCollectionMethodAddWithDateTimeGroupinInt32Int32Int32Demo
{
public static void Run()
{
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Add sample data with dates
worksheet.Cells["A1"].PutValue("Date");
worksheet.Cells["A2"].PutValue(new DateTime(2023, 1, 15));
worksheet.Cells["A3"].PutValue(new DateTime(2023, 1, 16));
worksheet.Cells["A4"].PutValue(new DateTime(2023, 1, 17));
try
{
// Apply auto filter to the date column
worksheet.AutoFilter.Range = "A1:A4";
// Get the filter column for dates
FilterColumn filterColumn = worksheet.AutoFilter.FilterColumns[0];
filterColumn.FilterType = FilterType.MultipleFilters;
// Create MultipleFilterCollection
MultipleFilterCollection filters = new MultipleFilterCollection();
// Add a date filter using the Add method with DateTimeGroupingType and integers
filters.Add(DateTimeGroupingType.Day, 2023, 1, 16);
// Apply the filter
filterColumn.Filter = filters;
worksheet.AutoFilter.Refresh();
Console.WriteLine("Date filter applied successfully for January 16, 2023");
workbook.Save("DateFilterDemo.xlsx");
}
catch (Exception ex)
{
Console.WriteLine($"Error applying date filter: {ex.Message}");
}
}
}
}
See Also
- enum DateTimeGroupingType
- class MultipleFilterCollection
- namespace Aspose.Cells
- assembly Aspose.Cells
Add(DateTimeGroupingType, int, int, int, int, int, int)
Adds a date time filter criteria value.
public void Add(DateTimeGroupingType type, int year, int month, int day, int hour, int minute,
int second)
| Parameter | Type | Description |
|---|---|---|
| type | DateTimeGroupingType | The type of date filter. |
| year | Int32 | The year. |
| month | Int32 | The month. |
| day | Int32 | The day. |
| hour | Int32 | The hour. |
| minute | Int32 | The minute. |
| second | Int32 | The second. |
See Also
- enum DateTimeGroupingType
- class MultipleFilterCollection
- namespace Aspose.Cells
- assembly Aspose.Cells