FileFormatUtil
FileFormatUtil class
Provides utility methods for converting file format enums to strings or file extensions and back.
class FileFormatUtil;
Methods
| Method | Description | 
|---|---|
| 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:
| Parameter | Type | Description | 
|---|---|---|
| stream | Uint8Array | 
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:
| Parameter | Type | Description | 
|---|---|---|
| stream | Uint8Array | |
| password | string | The 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:
| Parameter | Type | Description | 
|---|---|---|
| format | FileFormatType | The file format type. | 
Returns
extensionToSaveFormat(string)
Converts a file name extension into a SaveFormat value.
static extensionToSaveFormat(extension: string) : SaveFormat;
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| extension | string | The file extension. Can be with or without a leading dot. Case-insensitive. | 
Returns
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:
| Parameter | Type | Description | 
|---|---|---|
| extension | string | 
loadFormatToExtension(LoadFormat)
Converts a load format enumerated value into a file extension.
static loadFormatToExtension(loadFormat: LoadFormat) : string;
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| loadFormat | LoadFormat | The 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:
| Parameter | Type | Description | 
|---|---|---|
| loadFormat | LoadFormat | The load format. | 
Returns
The save format.
saveFormatToExtension(SaveFormat)
Converts a save format enumerated value into a file extension.
static saveFormatToExtension(format: SaveFormat) : string;
Parameters:
| Parameter | Type | Description | 
|---|---|---|
| format | SaveFormat | The 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:
| Parameter | Type | Description | 
|---|---|---|
| saveFormat | SaveFormat | The save format. | 
Returns
The load format