NanoXLSX.Core 3.2.1
Loading...
Searching...
No Matches
NanoXLSX.Utils.Validators Class Reference

Class providing general validator methods. More...

Static Public Member Functions

static void ValidateGenericColor (string hexCode, bool allowEmpty=false)
 Validates the passed string, whether it is a valid RGB or ARGB value that can be used for Fills, Fonts or other styling components. The method automatically tries to validate for ARGB (8 characters) first, then for RGB (6 characters).
static void ValidateColor (string hexCode, bool useAlpha, bool allowEmpty=false)
 Validates the passed string, whether it is a valid RGB or ARGB value that can be used for Fills, Fonts or other styling components.
static void ValidateCellAddressExpression (string expression, Cell.AddressScope scope=Cell.AddressScope.Any)
 Validates the passed string, whether it is a valid single cell address or cell range. The address or range can contain modifier characters (Cell.AddressType).
static void ValidateWorksheetName (string name)
 Validates the passed string, whether it is an expression that can be used as worksheet name.

Detailed Description

Class providing general validator methods.

Definition at line 12 of file Validators.cs.

Member Function Documentation

◆ ValidateCellAddressExpression()

void NanoXLSX.Utils.Validators.ValidateCellAddressExpression ( string expression,
Cell.AddressScope scope = Cell::AddressScope::Any )
static

Validates the passed string, whether it is a valid single cell address or cell range. The address or range can contain modifier characters (Cell.AddressType).

Parameters
expressionThe address expression to validate
scopeOptional parameter to validate for a specific address scope (Any, SingleAddress, Range). Default is: Any
Exceptions
FormatExceptionA format exception is thrown if the passed address is not a valid cell address or range
Remarks
If scope is Cell.AddressScope.Range, an explicit range expression is required; a single address is rejected even though Cell.ResolveCellRange(string) can represent it as a one-cell range. If the scope is Cell.AddressScope.Invalid, the validation is inverted, so that a valid cell or range will throw an exception.

Definition at line 59 of file Validators.cs.

◆ ValidateColor()

void NanoXLSX.Utils.Validators.ValidateColor ( string hexCode,
bool useAlpha,
bool allowEmpty = false )
static

Validates the passed string, whether it is a valid RGB or ARGB value that can be used for Fills, Fonts or other styling components.

Parameters
hexCodeHex string to check
useAlphaIf true, two additional characters (total 8) are expected as alpha value
allowEmptyOptional parameter that allows null or empty as valid values
Exceptions
StyleExceptionA StyleException is thrown if an invalid hex value is passed

Definition at line 43 of file Validators.cs.

◆ ValidateGenericColor()

void NanoXLSX.Utils.Validators.ValidateGenericColor ( string hexCode,
bool allowEmpty = false )
static

Validates the passed string, whether it is a valid RGB or ARGB value that can be used for Fills, Fonts or other styling components. The method automatically tries to validate for ARGB (8 characters) first, then for RGB (6 characters).

Parameters
hexCodeHex string to check
allowEmptyOptional parameter that allows null or empty as valid values

Definition at line 22 of file Validators.cs.

◆ ValidateWorksheetName()

void NanoXLSX.Utils.Validators.ValidateWorksheetName ( string name)
static

Validates the passed string, whether it is an expression that can be used as worksheet name.

Parameters
nameName to validate
Exceptions
NanoXLSX.Exceptions.FormatExceptionThrows a FormatException if the worksheet name is too long (max. 31) or contains illegal characters [ ] * ? / </exception>

Definition at line 110 of file Validators.cs.


The documentation for this class was generated from the following file: