CellsHelper
CellsHelper class
Provides helper functions.
class CellsHelper;
Properties
Property | Type | Description |
---|---|---|
static significantDigits | number | Gets and sets the number of significant digits. The default value is 17. |
static dPI | number | Gets the DPI of the machine. |
static startupPath | string | Gets or sets the startup path, which is referred to by some external formula references. |
static altStartPath | string | Gets or sets the alternate startup path, which is referred to by some external formula references. |
static libraryPath | string | Gets or sets the library path which is referred to by some external formula references. |
static isCloudPlatform | boolean | Please set this property True when running on a cloud platform, such as: Azure, AWSLambda, etc, |
Methods
Method | Description |
---|---|
static getTextWidth(string, Font, number) | Get width of text in unit of points. |
static getVersion() | Get the release version. |
static cellNameToIndex(string) | Gets the cell row and column indexes according to its name. |
static cellIndexToName(number, number) | Gets cell name according to its row and column indexes. |
static columnIndexToName(number) | Gets column name according to column index. |
static columnNameToIndex(string) | Gets column index according to column name. |
static rowIndexToName(number) | Gets row name according to row index. |
static rowNameToIndex(string) | Gets row index according to row name. |
static getDateTimeFromDouble(number, boolean) | Convert the double value to the date time value. |
static getDoubleFromDateTime(Date, boolean) | Convert the date time to double value. |
static getUsedColors(Workbook) | Gets all used colors in the workbook. |
static mergeFiles(string[], string, string) | Merges some large xls files to a xls file. |
static getCacheFolder() | Gets the folder for temporary files that may be used as data cache. |
static setCacheFolder(string) | Sets the folder for temporary files that may be used as data cache. |
static createSafeSheetName(string) | Checks given sheet name and create a valid one when needed. If given sheet name conforms to the rules of excel sheet name, then return it. Otherwise string will be truncated if length exceeds the limit and invalid characters will be replaced with ’ ‘, then return the rebuilt string value. |
static needQuoteInFormula(string) | Indicates whether the name of the sheet should be enclosed in single quotes |
significantDigits
Gets and sets the number of significant digits. The default value is 17.
static significantDigits : number;
Remarks
Only could be 15 or 17 now.
dPI
Gets the DPI of the machine.
static dPI : number;
startupPath
Gets or sets the startup path, which is referred to by some external formula references.
static startupPath : string;
altStartPath
Gets or sets the alternate startup path, which is referred to by some external formula references.
static altStartPath : string;
libraryPath
Gets or sets the library path which is referred to by some external formula references.
static libraryPath : string;
isCloudPlatform
Please set this property True when running on a cloud platform, such as: Azure, AWSLambda, etc,
static isCloudPlatform : boolean;
getTextWidth(string, Font, number)
Get width of text in unit of points.
static getTextWidth(text: string, font: Font, scaling: number) : number;
Parameters:
Parameter | Type | Description |
---|---|---|
text | string | The text. |
font | Font | The font of the text. |
scaling | number | The scaling of text. |
getVersion()
Get the release version.
static getVersion() : string;
Returns
The release version.
cellNameToIndex(string)
Gets the cell row and column indexes according to its name.
static cellNameToIndex(cellName: string) : number[];
Parameters:
Parameter | Type | Description |
---|---|---|
cellName | string | Name of cell |
Returns
[0] is the row index and [1] is the column index.
cellIndexToName(number, number)
Gets cell name according to its row and column indexes.
static cellIndexToName(row: number, column: number) : string;
Parameters:
Parameter | Type | Description |
---|---|---|
row | number | Row index. |
column | number | Column index. |
Returns
Name of cell.
columnIndexToName(number)
Gets column name according to column index.
static columnIndexToName(column: number) : string;
Parameters:
Parameter | Type | Description |
---|---|---|
column | number | Column index. |
Returns
Name of column.
columnNameToIndex(string)
Gets column index according to column name.
static columnNameToIndex(columnName: string) : number;
Parameters:
Parameter | Type | Description |
---|---|---|
columnName | string | Column name. |
Returns
Column index.
rowIndexToName(number)
Gets row name according to row index.
static rowIndexToName(row: number) : string;
Parameters:
Parameter | Type | Description |
---|---|---|
row | number | Row index. |
Returns
Name of row.
rowNameToIndex(string)
Gets row index according to row name.
static rowNameToIndex(rowName: string) : number;
Parameters:
Parameter | Type | Description |
---|---|---|
rowName | string | Row name. |
Returns
Row index.
getDateTimeFromDouble(number, boolean)
Convert the double value to the date time value.
static getDateTimeFromDouble(doubleValue: number, date1904: boolean) : Date;
Parameters:
Parameter | Type | Description |
---|---|---|
doubleValue | number | The double value. |
date1904 | boolean | Date 1904 system. |
getDoubleFromDateTime(Date, boolean)
Convert the date time to double value.
static getDoubleFromDateTime(dateTime: Date, date1904: boolean) : number;
Parameters:
Parameter | Type | Description |
---|---|---|
dateTime | Date | The date time. |
date1904 | boolean | Date 1904 system. |
getUsedColors(Workbook)
Gets all used colors in the workbook.
static getUsedColors(workbook: Workbook) : Color[];
Parameters:
Parameter | Type | Description |
---|---|---|
workbook | Workbook | The workbook object. |
Returns
The used colors.
mergeFiles(string[], string, string)
Merges some large xls files to a xls file.
static mergeFiles(files: string[], cachedFile: string, destFile: string) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
files | string[] | The files. |
cachedFile | string | The cached file. |
destFile | string | The dest file. |
Remarks
This method only supports merging data, style and formulas to the new file. The cached file is used to store some temporary data.
getCacheFolder()
Gets the folder for temporary files that may be used as data cache.
static getCacheFolder() : string;
Returns
Folder for cache files that has been specified. If it has not been specified, null will be returned and system’s temporary path will be used when needed.
Remarks
Cache files are used generally for some features for memory performance consideration, such as saving large data set to xls file, or using memory mode with file cache for cells model.
setCacheFolder(string)
Sets the folder for temporary files that may be used as data cache.
static setCacheFolder(cache: string) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
cache | string | Folder for for temporary files that may be used as data cache. |
Remarks
Cache files are used generally for some features for memory performance consideration, such as saving large data set to xls file, or using memory mode with file cache for cells model.
createSafeSheetName(string)
Checks given sheet name and create a valid one when needed. If given sheet name conforms to the rules of excel sheet name, then return it. Otherwise string will be truncated if length exceeds the limit and invalid characters will be replaced with ’ ‘, then return the rebuilt string value.
static createSafeSheetName(nameProposal: string) : string;
Parameters:
Parameter | Type | Description |
---|---|---|
nameProposal | string | sheet name to be used |
needQuoteInFormula(string)
Indicates whether the name of the sheet should be enclosed in single quotes
static needQuoteInFormula(sheetName: string) : boolean;
Parameters:
Parameter | Type | Description |
---|---|---|
sheetName | string | The name of the sheet |