CellsHelper

CellsHelper class

Provides helper functions.

class CellsHelper;

Methods

MethodDescription
static getSignificantDigits()Gets and sets the number of significant digits. The default value is 17.
static setSignificantDigits(number)Gets and sets the number of significant digits. The default value is 17.
static getDPI()Gets the DPI of the machine.
static setDPI(number)Gets the DPI of the machine.
static getStartupPath()Gets or sets the startup path, which is referred to by some external formula references.
static setStartupPath(string)Gets or sets the startup path, which is referred to by some external formula references.
static getAltStartPath()Gets or sets the alternate startup path, which is referred to by some external formula references.
static setAltStartPath(string)Gets or sets the alternate startup path, which is referred to by some external formula references.
static getLibraryPath()Gets or sets the library path which is referred to by some external formula references.
static setLibraryPath(string)Gets or sets the library path which is referred to by some external formula references.
static isCloudPlatform()Please set this property True when running on a cloud platform, such as: Azure, AWSLambda, etc,
static setIsCloudPlatform(boolean)Please set this property True when running on a cloud platform, such as: Azure, AWSLambda, etc,
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 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

getSignificantDigits()

Gets and sets the number of significant digits. The default value is 17.

static getSignificantDigits() : number;

Remarks

Only could be 15 or 17 now.

setSignificantDigits(number)

Gets and sets the number of significant digits. The default value is 17.

static setSignificantDigits(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

Remarks

Only could be 15 or 17 now.

getDPI()

Gets the DPI of the machine.

static getDPI() : number;

setDPI(number)

Gets the DPI of the machine.

static setDPI(value: number) : void;

Parameters:

ParameterTypeDescription
valuenumberThe value to set.

getStartupPath()

Gets or sets the startup path, which is referred to by some external formula references.

static getStartupPath() : string;

setStartupPath(string)

Gets or sets the startup path, which is referred to by some external formula references.

static setStartupPath(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

getAltStartPath()

Gets or sets the alternate startup path, which is referred to by some external formula references.

static getAltStartPath() : string;

setAltStartPath(string)

Gets or sets the alternate startup path, which is referred to by some external formula references.

static setAltStartPath(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

getLibraryPath()

Gets or sets the library path which is referred to by some external formula references.

static getLibraryPath() : string;

setLibraryPath(string)

Gets or sets the library path which is referred to by some external formula references.

static setLibraryPath(value: string) : void;

Parameters:

ParameterTypeDescription
valuestringThe value to set.

isCloudPlatform()

Please set this property True when running on a cloud platform, such as: Azure, AWSLambda, etc,

static isCloudPlatform() : boolean;

setIsCloudPlatform(boolean)

Please set this property True when running on a cloud platform, such as: Azure, AWSLambda, etc,

static setIsCloudPlatform(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

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.

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