Back to Devexpress

DateGrouping Class

officefileapi-devexpress-dot-spreadsheet-c164d4d5.md

latest3.2 KB
Original Source

DateGrouping Class

A criterion for date values.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public class DateGrouping
vb
Public Class DateGrouping

Remarks

When filtering a column containing dates, use the AutoFilterColumn.ApplyFilterCriteria method to specify criteria for date values or modify an existing filter criteria.

The following picture shows the AutoFilter dialog for a column with certain data applying a filter that uses the DateGrouping with the DateGrouping.Value property set to DateTime(2015, 3, 1) and the DateGrouping.GroupingType set to DateTimeGroupingType.Month.

Example

View Example

csharp
Worksheet worksheet = workbook.Worksheets["Regional sales"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Enable filtering for the specified cell range.
CellRange range = worksheet["B2:E23"];
worksheet.AutoFilter.Apply(range);

// Create date grouping item to filter January 2015 dates.
IList<DateGrouping> groupings = new List<DateGrouping>();
DateGrouping dateGroupingJan2015 = new DateGrouping(new DateTime(2015, 1, 1), DateTimeGroupingType.Month);
groupings.Add(dateGroupingJan2015);

// Filter the data in the "Reported Date" column to display values reported in January 2015.
worksheet.AutoFilter.Columns[3].ApplyFilterCriteria("gennaio 2015", groupings);
vb
Dim worksheet As Worksheet = workbook.Worksheets("Regional sales")
workbook.Worksheets.ActiveWorksheet = worksheet

' Enable filtering for the specified cell range.
Dim range As CellRange = worksheet("B2:E23")
worksheet.AutoFilter.Apply(range)

' Create date grouping item to filter January 2015 dates.
Dim groupings As IList(Of DateGrouping) = New List(Of DateGrouping)()
Dim dateGroupingJan2015 As New DateGrouping(New Date(2015, 1, 1), DateTimeGroupingType.Month)
groupings.Add(dateGroupingJan2015)

' Filter the data in the "Reported Date" column to display values reported in January 2015.
worksheet.AutoFilter.Columns(3).ApplyFilterCriteria("gennaio 2015", groupings)

Inheritance

Object DateGrouping

See Also

DateGrouping Members

DevExpress.Spreadsheet Namespace