Class XlsxValidation
- Namespace
- DocToolkit
- Assembly
- DocToolkit.Xlsx.dll
A data validation: what a person may type into a range of cells once the workbook is open.
public sealed class XlsxValidation
- Inheritance
-
XlsxValidation
- Inherited Members
Remarks
This is the half of a generated workbook that survives a human editing it. Five kinds, all measured to persist through a save and reload.
Properties
Kind
What the cells are restricted to.
public XlsxValidationKind Kind { get; }
Property Value
Max
The upper bound, for the numeric and text-length kinds.
public double Max { get; }
Property Value
MaxDate
The latest date, for Date.
public DateTime MaxDate { get; }
Property Value
Min
The lower bound, for the numeric and text-length kinds.
public double Min { get; }
Property Value
MinDate
The earliest date, for Date.
public DateTime MinDate { get; }
Property Value
Options
The permitted options, for List. Empty for every other kind.
public IReadOnlyList<string> Options { get; }
Property Value
Range
The cells this applies to, such as B2:B99.
public string Range { get; }
Property Value
Methods
DateBetween(string, DateTime, DateTime)
Restricts the range to a date between two bounds, inclusive.
public static XlsxValidation DateBetween(string range, DateTime min, DateTime max)
Parameters
rangestringThe cells this applies to.
minDateTimeThe earliest permitted date.
maxDateTimeThe latest permitted date.
Returns
Exceptions
- ArgumentNullException
rangeis null.- ArgumentException
rangeis blank.- ArgumentOutOfRangeException
maxis beforemin.
DecimalBetween(string, double, double)
Restricts the range to a decimal number between two bounds, inclusive.
public static XlsxValidation DecimalBetween(string range, double min, double max)
Parameters
rangestringThe cells this applies to.
mindoubleThe lowest permitted value.
maxdoubleThe highest permitted value.
Returns
Exceptions
- ArgumentNullException
rangeis null.- ArgumentException
rangeis blank.- ArgumentOutOfRangeException
maxis belowmin.
OneOf(string, params string[])
Restricts the range to one of a fixed list of options.
public static XlsxValidation OneOf(string range, params string[] options)
Parameters
rangestringThe cells this applies to.
optionsstring[]The permitted values. At least one is required.
Returns
Remarks
An option may not contain a comma or a double quote, and may not be blank. The list is written into the file as one quoted, comma-joined formula, so a comma inside an option would silently become two options and a quote would produce a malformed formula — measured. This type's premise is a vocabulary that can be enumerated and guaranteed, and accepting input it cannot faithfully encode is the wrong failure.
Exceptions
- ArgumentNullException
rangeoroptionsis null.- ArgumentException
rangeis blank,optionsis empty, or an option is null, blank, or contains a comma or a double quote.
TextLengthBetween(string, int, int)
Restricts the range to text whose length is between two bounds, inclusive.
public static XlsxValidation TextLengthBetween(string range, int min, int max)
Parameters
rangestringThe cells this applies to.
minintThe shortest permitted length.
maxintThe longest permitted length.
Returns
Exceptions
- ArgumentNullException
rangeis null.- ArgumentException
rangeis blank.- ArgumentOutOfRangeException
maxis belowmin.
WholeNumberBetween(string, int, int)
Restricts the range to a whole number between two bounds, inclusive.
public static XlsxValidation WholeNumberBetween(string range, int min, int max)
Parameters
rangestringThe cells this applies to.
minintThe lowest permitted value.
maxintThe highest permitted value.
Returns
Remarks
int rather than long because that is what the file format takes — a wider
parameter would only move the truncation somewhere the caller cannot see it.
Exceptions
- ArgumentNullException
rangeis null.- ArgumentException
rangeis blank.- ArgumentOutOfRangeException
maxis belowmin.