NanoXLSX.Reader 3.0.0-rc.2
Loading...
Searching...
No Matches
NanoXLSX.ReaderOptions Class Reference

The reader options define global rules, applied when loading a worksheet. The options are mainly to override particular cell types (e.g. interpretation of dates as numbers). More...

Inheritance diagram for NanoXLSX.ReaderOptions:

Public Types

enum  GlobalType {
  Default , AllNumbersToDouble , AllNumbersToDecimal , AllNumbersToInt ,
  EverythingToString
}
 Global conversion types to enforce during the load process. All types other than GlobalType.Default will override defined Column types. More...
enum  ColumnType {
  Numeric , Double , Decimal , Date ,
  Time , Bool , String
}
 Column types to enforce during the read process. The types are tried to be applied on all cells of a particular column. More...

Public Member Functions

void AddEnforcedColumn (string columnAddress, ColumnType type)
 Adds a type enforcing rule to the passed column address.
void AddEnforcedColumn (int columnNumber, ColumnType type)
 Adds a type enforcing rule to the passed column number (zero-based).

Static Public Attributes

const string DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss"
 Default format if DateTime values are cast to strings.
const string DefaultTimeSpanFormat = "hh\\:mm\\:ss"
 Default format if TimeSpan values are cast to strings.
static readonly CultureInfo DefaultCultureInfo = CultureInfo.InvariantCulture
 Default culture info instance (invariant culture) used for date and time parsing, if no custom culture info is defined.

Properties

bool EnforceDateTimesAsNumbers [get, set]
 If true, date or time values (default format number 14 or 21) will be interpreted as numeric values globally. This option overrules possible column options, defined by AddEnforcedColumn(int, ColumnType).
bool EnforcePhoneticCharacterImport [get, set]
 If true, phonetic characters (like ruby characters / Furigana / Zhuyin fuhao) in strings are added in brackets after the transcribed symbols. By default, phonetic characters are removed from strings.
bool EnforceEmptyValuesAsString [get, set]
 If true, empty cells will be interpreted as type of string with an empty value. If false, the type will be Empty and the value null.
bool EnforceStrictValidation [get, set]
 If true, invalid data, like column widths or row height that are out of range, will cause an exception when such a workbook is loaded. Tho option is inactive by default (tolerant reader mode).
GlobalType GlobalEnforcingType = GlobalType.Default [get, set]
 Global strategy to handle cell values. The default will not enforce any general casting, beside defined values of EnforceDateTimesAsNumbers, EnforceEmptyValuesAsString and EnforcedColumnTypes.
Dictionary< int, ColumnTypeEnforcedColumnTypes = new Dictionary<int, ColumnType>() [get]
 Type enforcing rules during the read process for particular columns.
int EnforcingStartRowNumber [get, set]
 The row number (zero-based) where enforcing rules are started to be applied. This is, for instance, to prevent enforcing types in a header row. Any enforcing rule is skipped until this row number is reached.
string DateTimeFormat = DefaultDateTimeFormat [get, set]
 Format if DateTime values are cast to strings or DateTime objects are parsed from strings. If null or empty, parsing will be tried with 'best effort', according to System.DateTime.Parse(string). See also TemporalCultureInfo.
string TimeSpanFormat = DefaultTimeSpanFormat [get, set]
 Format if TimeSpan values are cast to strings.
CultureInfo TemporalCultureInfo = DefaultCultureInfo [get, set]
 Culture info instance, used to parse DateTime or TimeSpan objects from strings. If null, parsing will be tried with 'best effort', according to System.DateTime.Parse(string) System.DateTime.Parse(string). See also DateTimeFormat and TimeSpanFormat.
bool IgnoreNotSupportedPasswordAlgorithms [get, set]
 If set to true, worksheet or workbook protection passwords with unknown / not supported algorithms will be ignored (password hash may not be read). Otherwise, a NotSupportedContentException will be thrown. Default is false.

Detailed Description

The reader options define global rules, applied when loading a worksheet. The options are mainly to override particular cell types (e.g. interpretation of dates as numbers).

Definition at line 18 of file ReaderOptions.cs.

Member Enumeration Documentation

◆ ColumnType

Column types to enforce during the read process. The types are tried to be applied on all cells of a particular column.

Enumerator
Numeric 

Cells are tried to be imported as numbers (automatic determination of numeric type).

Double 

Cells are tried to be imported as numbers (enforcing double).

Decimal 

Cells are tried to be imported as numbers (enforcing decimal).

Date 

Cells are tried to be imported as dates (DateTime). See also DateTimeFormat, TimeSpanFormat and TemporalCultureInfo.

Time 

Cells are tried to be imported as times (TimeSpan).

Bool 

Cells are tried to be imported as bools.

String 

Cells are all imported as strings, using the ToString() method.

Definition at line 66 of file ReaderOptions.cs.

◆ GlobalType

Global conversion types to enforce during the load process. All types other than GlobalType.Default will override defined Column types.

Enumerator
Default 

No global strategy. All numbers are tried to be cast to the most suitable types.

AllNumbersToDouble 

All numbers are cast to doubles.

AllNumbersToDecimal 

All numbers are cast to decimal.

AllNumbersToInt 

All numbers are cast to integers. Floating point numbers will be rounded (commercial rounding) to the nearest integers.

EverythingToString 

Every cell is cast to a string.

Definition at line 39 of file ReaderOptions.cs.

Member Function Documentation

◆ AddEnforcedColumn() [1/2]

void NanoXLSX.ReaderOptions.AddEnforcedColumn ( int columnNumber,
ColumnType type )

Adds a type enforcing rule to the passed column number (zero-based).

Parameters
columnNumberColumn number (0-16383)
typeType to be enforced on the column

Definition at line 177 of file ReaderOptions.cs.

◆ AddEnforcedColumn() [2/2]

void NanoXLSX.ReaderOptions.AddEnforcedColumn ( string columnAddress,
ColumnType type )

Adds a type enforcing rule to the passed column address.

Parameters
columnAddressColumn address (A to XFD)
typeType to be enforced on the column

Definition at line 167 of file ReaderOptions.cs.

Member Data Documentation

◆ DefaultCultureInfo

readonly CultureInfo NanoXLSX.ReaderOptions.DefaultCultureInfo = CultureInfo.InvariantCulture
static

Default culture info instance (invariant culture) used for date and time parsing, if no custom culture info is defined.

Definition at line 34 of file ReaderOptions.cs.

◆ DefaultDateTimeFormat

const string NanoXLSX.ReaderOptions.DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss"
static

Default format if DateTime values are cast to strings.

Definition at line 24 of file ReaderOptions.cs.

◆ DefaultTimeSpanFormat

const string NanoXLSX.ReaderOptions.DefaultTimeSpanFormat = "hh\\:mm\\:ss"
static

Default format if TimeSpan values are cast to strings.

Definition at line 29 of file ReaderOptions.cs.

Property Documentation

◆ DateTimeFormat

string NanoXLSX.ReaderOptions.DateTimeFormat = DefaultDateTimeFormat
getset

Format if DateTime values are cast to strings or DateTime objects are parsed from strings. If null or empty, parsing will be tried with 'best effort', according to System.DateTime.Parse(string). See also TemporalCultureInfo.

Definition at line 142 of file ReaderOptions.cs.

◆ EnforceDateTimesAsNumbers

bool NanoXLSX.ReaderOptions.EnforceDateTimesAsNumbers
getset

If true, date or time values (default format number 14 or 21) will be interpreted as numeric values globally. This option overrules possible column options, defined by AddEnforcedColumn(int, ColumnType).

Definition at line 104 of file ReaderOptions.cs.

◆ EnforcedColumnTypes

Dictionary<int, ColumnType> NanoXLSX.ReaderOptions.EnforcedColumnTypes = new Dictionary<int, ColumnType>()
get

Type enforcing rules during the read process for particular columns.

Definition at line 131 of file ReaderOptions.cs.

◆ EnforceEmptyValuesAsString

bool NanoXLSX.ReaderOptions.EnforceEmptyValuesAsString
getset

If true, empty cells will be interpreted as type of string with an empty value. If false, the type will be Empty and the value null.

Definition at line 115 of file ReaderOptions.cs.

◆ EnforcePhoneticCharacterImport

bool NanoXLSX.ReaderOptions.EnforcePhoneticCharacterImport
getset

If true, phonetic characters (like ruby characters / Furigana / Zhuyin fuhao) in strings are added in brackets after the transcribed symbols. By default, phonetic characters are removed from strings.

Remarks
This option is not applicable to specific rows or a start column (applied globally)

Definition at line 110 of file ReaderOptions.cs.

◆ EnforceStrictValidation

bool NanoXLSX.ReaderOptions.EnforceStrictValidation
getset

If true, invalid data, like column widths or row height that are out of range, will cause an exception when such a workbook is loaded. Tho option is inactive by default (tolerant reader mode).

Definition at line 120 of file ReaderOptions.cs.

◆ EnforcingStartRowNumber

int NanoXLSX.ReaderOptions.EnforcingStartRowNumber
getset

The row number (zero-based) where enforcing rules are started to be applied. This is, for instance, to prevent enforcing types in a header row. Any enforcing rule is skipped until this row number is reached.

Definition at line 136 of file ReaderOptions.cs.

◆ GlobalEnforcingType

GlobalType NanoXLSX.ReaderOptions.GlobalEnforcingType = GlobalType.Default
getset

Global strategy to handle cell values. The default will not enforce any general casting, beside defined values of EnforceDateTimesAsNumbers, EnforceEmptyValuesAsString and EnforcedColumnTypes.

Definition at line 125 of file ReaderOptions.cs.

◆ IgnoreNotSupportedPasswordAlgorithms

bool NanoXLSX.ReaderOptions.IgnoreNotSupportedPasswordAlgorithms
getset

If set to true, worksheet or workbook protection passwords with unknown / not supported algorithms will be ignored (password hash may not be read). Otherwise, a NotSupportedContentException will be thrown. Default is false.

Definition at line 160 of file ReaderOptions.cs.

◆ TemporalCultureInfo

CultureInfo NanoXLSX.ReaderOptions.TemporalCultureInfo = DefaultCultureInfo
getset

Culture info instance, used to parse DateTime or TimeSpan objects from strings. If null, parsing will be tried with 'best effort', according to System.DateTime.Parse(string) System.DateTime.Parse(string). See also DateTimeFormat and TimeSpanFormat.

Definition at line 154 of file ReaderOptions.cs.

◆ TimeSpanFormat

string NanoXLSX.ReaderOptions.TimeSpanFormat = DefaultTimeSpanFormat
getset

Format if TimeSpan values are cast to strings.

Remarks
The separators like period or semicolon must be escaped by backslashes. See:

Definition at line 148 of file ReaderOptions.cs.


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