CellsHelper

CellsHelper class

Provides helper functions.

class CellsHelper;

Properties

PropertyTypeDescription
static significantDigitsnumberGets and sets the number of significant digits. The default value is 17.
static dPInumberGets the DPI of the machine.
static startupPathstringGets or sets the startup path, which is referred to by some external formula references.
static altStartPathstringGets or sets the alternate startup path, which is referred to by some external formula references.
static libraryPathstringGets or sets the library path which is referred to by some external formula references.
static isCloudPlatformbooleanPlease set this property True when running on a cloud platform, such as: Azure, AWSLambda, etc,

Methods

MethodDescription
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:

ParameterTypeDescription
textstringThe text.
fontFontThe font of the text.
scalingnumberThe 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:

ParameterTypeDescription
cellNamestringName 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:

ParameterTypeDescription
rownumberRow index.
columnnumberColumn index.

Returns

Name of cell.

columnIndexToName(number)

Gets column name according to column index.

static columnIndexToName(column: number) : string;

Parameters:

ParameterTypeDescription
columnnumberColumn index.

Returns

Name of column.

columnNameToIndex(string)

Gets column index according to column name.

static columnNameToIndex(columnName: string) : number;

Parameters:

ParameterTypeDescription
columnNamestringColumn name.

Returns

Column index.

rowIndexToName(number)

Gets row name according to row index.

static rowIndexToName(row: number) : string;

Parameters:

ParameterTypeDescription
rownumberRow index.

Returns

Name of row.

rowNameToIndex(string)

Gets row index according to row name.

static rowNameToIndex(rowName: string) : number;

Parameters:

ParameterTypeDescription
rowNamestringRow name.

Returns

Row index.

getDateTimeFromDouble(number, boolean)

Convert the double value to the date time value.

static getDateTimeFromDouble(doubleValue: number, date1904: boolean) : Date;

Parameters:

ParameterTypeDescription
doubleValuenumberThe double value.
date1904booleanDate 1904 system.

getDoubleFromDateTime(Date, boolean)

Convert the date time to double value.

static getDoubleFromDateTime(dateTime: Date, date1904: boolean) : number;

Parameters:

ParameterTypeDescription
dateTimeDateThe date time.
date1904booleanDate 1904 system.

getUsedColors(Workbook)

Gets all used colors in the workbook.

static getUsedColors(workbook: Workbook) : Color[];

Parameters:

ParameterTypeDescription
workbookWorkbookThe 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:

ParameterTypeDescription
filesstring[]The files.
cachedFilestringThe cached file.
destFilestringThe 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:

ParameterTypeDescription
cachestringFolder 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:

ParameterTypeDescription
nameProposalstringsheet 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:

ParameterTypeDescription
sheetNamestringThe name of the sheet