new ImportOptions()
The ImportOptions type defines the options used when importing data from a CSV source. The Import() method uses these options to read and load the data into the control. A CSV (comma-separated values) file is a text file where each line represents a record, and each record contains one or more fields separated by a delimiter, usually a comma. The fields of ImportOptions let you define how the CSV data is interpreted. These options include the format of the source data, the character used to separate fields within a row, the characters that mark the end of a row, whether the first line contains the control's header, the maximum number of rows to import, and the character used to quote values. When calling the Import() method, you can pass an object with these fields to configure how the CSV data is parsed. For example, the format field specifies the format of the source from which the data is imported.
Members
(static) eof :string
The eof (EndOfField) field specifies the character to separate fields within the row/item/line (has effect only if format field is "CSV"). The eof field can be set to a specific character (e.g., "," for comma, "\t" for tab) to indicate the delimiter used to separate fields within a row/item/line. The default value of the eof field is ",", which means that by default fields are separated by a comma character.
Type:
- string
Example
"\t" {string}, specifies TAB charactar as field separator
"," {string}, specifies comma charactar as field separator
eof
(static) eor :string
The eor (EndOfRow) field specifies the delimiter, which can be a character, string, or regular expression (@since 4.4), used to identify the end of a row, item, or line during parsing (has effect only if format field is "CSV"). The eor field can be set to a string to specify a specific character or sequence of characters as the row/item/line delimiter, or set to a regular expression to match patterns that indicate the end of a row/item/line. The default value of the eor field is "\r\n", which means that by default the end of a row/item/line is identified by the Windows-style newline sequence (carriage return followed by line feed).
Type:
- string
Example
";" {string}, indicates that the ; (semicolon) character ends each row/item/line
/^[ \t]*\r\n/m {RegExp}, empty lines delimites each item (match blank lines that contain only spaces or tabs, followed by a Windows-style newline \r\n)
eor
(static) format :string
The format field specifies the format of source to import data form. The format field can be set to "CSV" to specify that the source of import is a string in CSV format, or set to null to specify that the source of import is an array of value type. The default value of the format field is null, which means that by default the source of import is an array of value type.
Type:
- string
Example
null {null}, specifies that the source of import is an array of [[value]] type
"CSV" {string}, specifies that the source of import is a string in CSV format
format
(static) hdr :boolean
The hdr field specifies whether the first line indicates the control's header (has effect only if format field is "CSV"). The hdr field can be set to true to indicate that the first line of the CSV data represents the control's header, which means that the values in the first line will be used as column captions. If hdr is set to false, the first line will be treated as a regular data row, and default column captions will be generated based on the columnCaption option or other default behavior. The default value of the hdr field is true, which means that by default the first line of CSV data is expected to represent the control's header.
Type:
- boolean
Example
false {boolean}, specifies the no header line is provided
true {boolean}, the first line defines the control's header
hdr
(static) limit :number
The limit field specifies the maximum number of rows/items/lines to import. The limit field can be set to a numeric value to limit the number of rows/items/lines to import, or set to undefined to specify an unlimited number of rows/items/lines to import. The default value of the limit field is undefined, which means that by default there is no limit on the number of rows/items/lines to import.
Type:
- number
Example
undefined {undefined}, specifies unlimited number of rows/items/lines to import
1000 {number}, limits the items to import to 1,000
limit
(static) str :string
The str field specifies the character to quote values (has effect only if format field is "CSV"). The str field can be set to a specific character (e.g., "\"" for double quotes, "'" for single quotes) to indicate the character used to quote values that contain special characters such as the field delimiter (eof) or the end of row delimiter (eor). The default value of the str field is "\"", which means that by default values are quoted using double quotes.
Type:
- string
Example
"'" {string}, specifies ' character to quote any value that contains other ' or eof character
"\"" {string}, specifies " character to quote any value that contains other " or eof character
str