Enum TimePeriodType

TimePeriodType enumeration

Used in a FormatConditionType.TimePeriod conditional formatting rule. These are dynamic time periods, which change based on the date the conditional formatting is refreshed / applied.

public enum TimePeriodType

Values

NameValueDescription
Today0Today’s date.
Yesterday1Yesterday’s date.
Tomorrow2Tomorrow’s date.
Last7Days3A date in the last seven days.
ThisMonth4A date occurring in this calendar month.
LastMonth5A date occurring in the last calendar month.
NextMonth6A date occurring in the next calendar month.
ThisWeek7A date occurring this week.
LastWeek8A date occurring last week.
NextWeek9A date occurring next week.
ThisYear10A date occurring this year. Only for .ods.
LastYear11A date occurring last year. Only for .ods.
NextYear12A date occurring next year. Only for .ods.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;

    public class TimePeriodTypeDemo
    {
        public static void TimePeriodTypeExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Add a conditional formatting rule
            int index = worksheet.ConditionalFormattings.Add();
            FormatConditionCollection fcs = worksheet.ConditionalFormattings[index];

            // Define the cell area for the conditional formatting
            CellArea ca = new CellArea { StartRow = 0, EndRow = 10, StartColumn = 0, EndColumn = 10 };
            fcs.AddArea(ca);

            // Add a condition for the time period
            int conditionIndex = fcs.AddCondition(FormatConditionType.TimePeriod);
            FormatCondition fc = fcs[conditionIndex];
            fc.Style.BackgroundColor = System.Drawing.Color.LightBlue;

            // Set the time period type
            fc.TimePeriod = TimePeriodType.Today;

            // Save the workbook
            workbook.Save("TimePeriodTypeExample.xlsx");

            return;
        }
    }
}

See Also