FileFormatUtil

FileFormatUtil class

Provides utility methods for converting file format enums to strings or file extensions and back.

class FileFormatUtil;

Methods

MethodDescription
static detectFileFormat(Uint8Array)Detects and returns the information about a format of an excel stored in a stream.
static verifyPassword(Uint8Array, string)Detects and returns the information about a format of an excel stored in a stream.
static fileFormatToSaveFormat(FileFormatType)Converting file format to save format.
static extensionToSaveFormat(string)Converts a file name extension into a SaveFormat value.
static isTemplateFormat(string)Returns true if the extension is .xlt, .xltX, .xltm,.ots.
static loadFormatToExtension(LoadFormat)Converts a load format enumerated value into a file extension.
static loadFormatToSaveFormat(LoadFormat)Converts a LoadFormat value to a SaveFormat value if possible.
static saveFormatToExtension(SaveFormat)Converts a save format enumerated value into a file extension.
static saveFormatToLoadFormat(SaveFormat)Converts a SaveFormat value to a LoadFormat value if possible.

detectFileFormat(Uint8Array)

Detects and returns the information about a format of an excel stored in a stream.

static detectFileFormat(stream: Uint8Array) : FileFormatInfo;

Parameters:

ParameterTypeDescription
streamUint8Array

Returns

A FileFormatInfo object that contains the detected information.

verifyPassword(Uint8Array, string)

Detects and returns the information about a format of an excel stored in a stream.

static verifyPassword(stream: Uint8Array, password: string) : boolean;

Parameters:

ParameterTypeDescription
streamUint8Array
passwordstringThe password for encrypted ooxml files.

Returns

Returns whether the password is corrected.

fileFormatToSaveFormat(FileFormatType)

Converting file format to save format.

static fileFormatToSaveFormat(format: FileFormatType) : SaveFormat;

Parameters:

ParameterTypeDescription
formatFileFormatTypeThe file format type.

Returns

SaveFormat

extensionToSaveFormat(string)

Converts a file name extension into a SaveFormat value.

static extensionToSaveFormat(extension: string) : SaveFormat;

Parameters:

ParameterTypeDescription
extensionstringThe file extension. Can be with or without a leading dot. Case-insensitive.

Returns

SaveFormat

Remarks

If the extension cannot be recognized, returns SaveFormat.Unknown.

isTemplateFormat(string)

Returns true if the extension is .xlt, .xltX, .xltm,.ots.

static isTemplateFormat(extension: string) : boolean;

Parameters:

ParameterTypeDescription
extensionstring

loadFormatToExtension(LoadFormat)

Converts a load format enumerated value into a file extension.

static loadFormatToExtension(loadFormat: LoadFormat) : string;

Parameters:

ParameterTypeDescription
loadFormatLoadFormatThe loaded file format.

Returns

The returned extension is a lower-case string with a leading dot.

Remarks

If it can not be converted, returns null.

loadFormatToSaveFormat(LoadFormat)

Converts a LoadFormat value to a SaveFormat value if possible.

static loadFormatToSaveFormat(loadFormat: LoadFormat) : SaveFormat;

Parameters:

ParameterTypeDescription
loadFormatLoadFormatThe load format.

Returns

The save format.

saveFormatToExtension(SaveFormat)

Converts a save format enumerated value into a file extension.

static saveFormatToExtension(format: SaveFormat) : string;

Parameters:

ParameterTypeDescription
formatSaveFormatThe save format.

Returns

The returned extension is a lower-case string with a leading dot.

saveFormatToLoadFormat(SaveFormat)

Converts a SaveFormat value to a LoadFormat value if possible.

static saveFormatToLoadFormat(saveFormat: SaveFormat) : LoadFormat;

Parameters:

ParameterTypeDescription
saveFormatSaveFormatThe save format.

Returns

The load format