TxtLoadOptions
TxtLoadOptions class
Represents the options for loading text file.
class TxtLoadOptions extends AbstractTextLoadOptions;
Constructors
Name | Description |
---|---|
constructor() | Creates the options for loading text file. |
constructor(AbstractTextLoadOptions) | Constructs from a parent object convertible to this. |
constructor(LoadFormat) | Creates the options for loading text file. |
Properties
Property | Type | Description |
---|---|---|
separator | string | Gets and sets character separator of text file. |
separatorString | string | Gets and sets a string value as separator. |
isMultiEncoded | boolean | True means that the file contains several encoding. |
hasFormula | boolean | Indicates whether the text is formula if it starts with “=”. |
hasTextQualifier | boolean | Whether there is text qualifier for cell value. Default is true. |
textQualifier | string | Specifies the text qualifier for cell values. Default qualifier is ‘"’. |
treatConsecutiveDelimitersAsOne | boolean | Whether consecutive delimiters should be treated as one. |
treatQuotePrefixAsValue | boolean | Indicates whether the leading single quote sign should be taken as part of the value of one cell. Default is true. If it is false, the leading single quote will be removed from corresponding cell’s value and Style.QuotePrefix will be set as true for the cell. |
extendToNextSheet | boolean | Whether extends data to next sheet when the rows or columns of data exceed limit. Default is false. |
headerRowsCount | number | The count of header rows to be repeated for extended sheets. |
headerColumnsCount | number | The count of header columns to be repeated for extended sheets. |
maxRowCount | number | The maximum count of rows to be imported for one sheet. |
maxColumnCount | number | The maximum count of columns to be imported for one sheet. |
loadFormat | LoadFormat | Readonly. Gets the load format. |
password | string | Gets and set the password of the workbook. |
parsingFormulaOnOpen | boolean | Indicates whether parsing the formula when reading the file. |
parsingPivotCachedRecords | boolean | Indicates whether parsing pivot cached records when loading the file. The default value is false. |
languageCode | CountryCode | Gets or sets the user interface language of the Workbook version based on CountryCode that has saved the file. |
region | CountryCode | Gets or sets the regional settings used for the Workbook that will be loaded. |
defaultStyleSettings | DefaultStyleSettings | Readonly. Gets the default style settings for initializing styles of the workbook |
interruptMonitor | AbstractInterruptMonitor | Gets and sets the interrupt monitor. |
ignoreNotPrinted | boolean | Ignore the data which are not printed if directly printing the file |
checkDataValid | boolean | Check whether data is valid in the template file. |
checkExcelRestriction | boolean | Whether check restriction of excel file when user modify cells related objects. For example, excel does not allow inputting string value longer than 32K. When you input a value longer than 32K such as by Cell.PutValue(string), if this property is true, you will get an Exception. If this property is false, we will accept your input string value as the cell’s value so that later you can output the complete string value for other file formats such as CSV. However, if you have set such kind of value that is invalid for excel file format, you should not save the workbook as excel file format later. Otherwise there may be unexpected error for the generated excel file. |
keepUnparsedData | boolean | Whether keep the unparsed data in memory for the Workbook when it is loaded from template file. Default is true. |
loadFilter | LoadFilter | The filter to denote how to load data. |
lightCellsDataHandler | LightCellsDataHandler | The data handler for processing cells data when reading template file. |
memorySetting | MemorySetting | Gets or sets the memory mode for loaded workbook. |
warningCallback | IWarningCallback | Gets or sets warning callback. |
autoFitterOptions | AutoFitterOptions | Gets and sets the auto fitter options |
autoFilter | boolean | Indicates whether auto filtering the data when loading the files. |
fontConfigs | IndividualFontConfigs | Gets and sets individual font configs. Only works for the Workbook which uses this LoadOptions to load. |
ignoreUselessShapes | boolean | Indicates whether ignoring useless shapes. |
preservePaddingSpacesInFormula | boolean | Indicates whether preserve those spaces and line breaks that are padded between formula tokens while getting and setting formulas. Default value is false. |
encoding | EncodingType | Gets and sets the default encoding. Only applies for csv file. |
loadStyleStrategy | TxtLoadStyleStrategy | Indicates the strategy to apply style for parsed values when converting string value to number or datetime. |
convertNumericData | boolean | Gets or sets a value that indicates whether the string in text file is converted to numeric data. |
convertDateTimeData | boolean | Gets or sets a value that indicates whether the string in text file is converted to date data. |
keepPrecision | boolean | Indicates whether not parsing a string value if the length is 15. |
Methods
Method | Description |
---|---|
setPaperSize(PaperSizeType) | Sets the default print paper size from default printer’s setting. |
constructor()
Creates the options for loading text file.
constructor();
Remarks
The default load file type is CSV .
constructor(AbstractTextLoadOptions)
Constructs from a parent object convertible to this.
constructor(obj: AbstractTextLoadOptions);
Parameters:
Parameter | Type | Description |
---|---|---|
obj | AbstractTextLoadOptions | The parent object. |
constructor(LoadFormat)
Creates the options for loading text file.
constructor(loadFormat: LoadFormat);
Parameters:
Parameter | Type | Description |
---|---|---|
loadFormat | LoadFormat | The loading format |
separator
Gets and sets character separator of text file.
separator : string;
separatorString
Gets and sets a string value as separator.
separatorString : string;
isMultiEncoded
True means that the file contains several encoding.
isMultiEncoded : boolean;
hasFormula
Indicates whether the text is formula if it starts with “=”.
hasFormula : boolean;
hasTextQualifier
Whether there is text qualifier for cell value. Default is true.
hasTextQualifier : boolean;
textQualifier
Specifies the text qualifier for cell values. Default qualifier is ‘"’.
textQualifier : string;
Remarks
When setting this property, HasTextQualifier will become true automatically.
treatConsecutiveDelimitersAsOne
Whether consecutive delimiters should be treated as one.
treatConsecutiveDelimitersAsOne : boolean;
treatQuotePrefixAsValue
Indicates whether the leading single quote sign should be taken as part of the value of one cell. Default is true. If it is false, the leading single quote will be removed from corresponding cell’s value and Style.QuotePrefix will be set as true for the cell.
treatQuotePrefixAsValue : boolean;
extendToNextSheet
Whether extends data to next sheet when the rows or columns of data exceed limit. Default is false.
extendToNextSheet : boolean;
Remarks
If this property is true, extra data will be put into next sheet behind current one (if current sheet is the last one, new sheet will be appended to current workbook). If this property is false, the data exceeding limit will be ignored.
headerRowsCount
The count of header rows to be repeated for extended sheets.
headerRowsCount : number;
Remarks
The header rows specified by this property will be duplicated for those extended sheets. This property only takes effect when ExtendToNextSheet is true.
headerColumnsCount
The count of header columns to be repeated for extended sheets.
headerColumnsCount : number;
Remarks
The header columns specified by this property will be duplicated for those extended sheets. This property only takes effect when ExtendToNextSheet is true.
maxRowCount
The maximum count of rows to be imported for one sheet.
maxRowCount : number;
Remarks
Those rows exceeding this limit will be ignored or extended to next sheet according to ExtendToNextSheet. This count includes the header rows(HeaderRowsCount). The maximum allowed value of it is the row limit of corresponding file format, such as for xlsx file it 1048576. If this property has not been specified or the specified value is not positive, then the maximum limit will be used too.
maxColumnCount
The maximum count of columns to be imported for one sheet.
maxColumnCount : number;
Remarks
Those columns exceeding this limit will be ignored or extended to next sheet according to ExtendToNextSheet. This count includes the header columns(HeaderColumnsCount). The maximum value of it is the column limit of corresponding file format, such as for xlsx file it 16384. If this property has not been specified or the specified value is not positive, then the maximum limit will be used too.
loadFormat
Readonly. Gets the load format.
loadFormat : LoadFormat;
password
Gets and set the password of the workbook.
password : string;
parsingFormulaOnOpen
Indicates whether parsing the formula when reading the file.
parsingFormulaOnOpen : boolean;
Remarks
Only applies for Excel Xlsx, Xltx, Xltm and Xlsm file because the formulas in the files are stored with a string formula.
parsingPivotCachedRecords
Indicates whether parsing pivot cached records when loading the file. The default value is false.
parsingPivotCachedRecords : boolean;
Remarks
Only applies for Excel Xlsx, Xltx, Xltm , Xlsm and xlsb file
languageCode
Gets or sets the user interface language of the Workbook version based on CountryCode that has saved the file.
languageCode : CountryCode;
region
Gets or sets the regional settings used for the Workbook that will be loaded.
region : CountryCode;
Remarks
The regional settings may be used for initializing some features for the workbook such as fonts, themes, and so on. For text based file formats, such as CSV, HTML, …, the regional setting also will be used to detect number formats and parse text values to numeric or datetime values for cells. This setting will be kept for the instantiated workbook later, that is, WorkbookSettings.Region of the workbook will use the same region with this property.
defaultStyleSettings
Readonly. Gets the default style settings for initializing styles of the workbook
defaultStyleSettings : DefaultStyleSettings;
interruptMonitor
Gets and sets the interrupt monitor.
interruptMonitor : AbstractInterruptMonitor;
ignoreNotPrinted
Ignore the data which are not printed if directly printing the file
ignoreNotPrinted : boolean;
Remarks
Only for xlsx file.
checkDataValid
Check whether data is valid in the template file.
checkDataValid : boolean;
checkExcelRestriction
Whether check restriction of excel file when user modify cells related objects. For example, excel does not allow inputting string value longer than 32K. When you input a value longer than 32K such as by Cell.PutValue(string), if this property is true, you will get an Exception. If this property is false, we will accept your input string value as the cell’s value so that later you can output the complete string value for other file formats such as CSV. However, if you have set such kind of value that is invalid for excel file format, you should not save the workbook as excel file format later. Otherwise there may be unexpected error for the generated excel file.
checkExcelRestriction : boolean;
keepUnparsedData
Whether keep the unparsed data in memory for the Workbook when it is loaded from template file. Default is true.
keepUnparsedData : boolean;
Remarks
For scenarios that user only needs to read some contents from template file and does not need to save the workbook back, set this property as false may improve performance, especially when using it together with some kind of LoadFilter,
loadFilter
The filter to denote how to load data.
loadFilter : LoadFilter;
lightCellsDataHandler
The data handler for processing cells data when reading template file.
lightCellsDataHandler : LightCellsDataHandler;
memorySetting
Gets or sets the memory mode for loaded workbook.
memorySetting : MemorySetting;
Remarks
For more details about memory mode, please see Cells.MemorySetting.
warningCallback
Gets or sets warning callback.
warningCallback : IWarningCallback;
autoFitterOptions
Gets and sets the auto fitter options
autoFitterOptions : AutoFitterOptions;
Remarks
Only for xlsx ,spreadsheetML file now.
autoFilter
Indicates whether auto filtering the data when loading the files.
autoFilter : boolean;
Remarks
Sometimes although autofilter is set, the corresponding rows is not hidden in the file. Now only works for SpreadSheetML file.
fontConfigs
Gets and sets individual font configs. Only works for the Workbook which uses this LoadOptions to load.
fontConfigs : IndividualFontConfigs;
ignoreUselessShapes
Indicates whether ignoring useless shapes.
ignoreUselessShapes : boolean;
Remarks
Only works for xlsx,xlsb, and xlsm files. There are many overlapping identical shapes which are useless in some files, we can ingore them when loading files.
preservePaddingSpacesInFormula
Indicates whether preserve those spaces and line breaks that are padded between formula tokens while getting and setting formulas. Default value is false.
preservePaddingSpacesInFormula : boolean;
Remarks
After loading workbook from template file with this option, FormulaSettings.PreservePaddingSpaces will be set to the same value with this property.
encoding
Gets and sets the default encoding. Only applies for csv file.
encoding : EncodingType;
loadStyleStrategy
Indicates the strategy to apply style for parsed values when converting string value to number or datetime.
loadStyleStrategy : TxtLoadStyleStrategy;
convertNumericData
Gets or sets a value that indicates whether the string in text file is converted to numeric data.
convertNumericData : boolean;
convertDateTimeData
Gets or sets a value that indicates whether the string in text file is converted to date data.
convertDateTimeData : boolean;
keepPrecision
Indicates whether not parsing a string value if the length is 15.
keepPrecision : boolean;
setPaperSize(PaperSizeType)
Sets the default print paper size from default printer’s setting.
setPaperSize(type: PaperSizeType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
type | PaperSizeType | The default paper size. |
Remarks
If there is no setting about paper size,MS Excel will use default printer’s setting.