FileFormatUtil

FileFormatUtil class

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

Methods

NameDescription
detectFileFormat(stream) (static)Detects and returns the information about a format of an excel stored in a stream.
detectFileFormat(stream, password) (static)Detects and returns the information about a format of an excel stored in a stream.
detectFileFormat(filePath) (static)Detects and returns the information about a format of an excel stored in a file.
detectFileFormat(filePath, password) (static)Detects and returns the information about a format of an excel stored in a file.
detectFileFormatFromStream(stream, callback) (static)Detects and returns the information about a format of an excel stored in a stream.
extensionToSaveFormat(extension) (static)Converts a file name extension into a SaveFormat value. If the extension cannot be recognized, returns SaveFormat.UNKNOW
fileFormatToSaveFormat(format) (static)Converting file format to save format.
isTemplateFormat(extension) (static)Returns true if the extension is .xlt, .xltX, .xltm,.ots.
loadFormatToExtension(loadFormat) (static)Converts a load format enumerated value into a file extension. If it can not be converted, returns null.
loadFormatToSaveFormat(loadFormat) (static)Converts a LoadFormat value to a SaveFormat value if possible.
saveFormatToExtension(format) (static)Converts a save format enumerated value into a file extension.
saveFormatToLoadFormat(saveFormat) (static)Converts a SaveFormat value to a LoadFormat value if possible.
verifyPassword(stream, password) (static)Detects and returns the information about a format of an excel stored in a stream.

detectFileFormat(stream) (static)

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

ParameterTypeDescription
streamInputStreamThe stream

Returns: FileFormatInfo — FileFormatInfo A FileFormatInfo object that contains the detected information.

detectFileFormat(stream, password) (static)

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

ParameterTypeDescription
streamInputStream
passwordStringThe password for encrypted ooxml files.

Returns: FileFormatInfo — FileFormatInfo A FileFormatInfo object that contains the detected information.

detectFileFormat(filePath) (static)

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

ParameterTypeDescription
filePathStringThe file path.

Returns: FileFormatInfo — FileFormatInfo A FileFormatInfo object that contains the detected information.

detectFileFormat(filePath, password) (static)

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

ParameterTypeDescription
filePathStringThe file path.
passwordStringThe password for encrypted ooxml files.

Returns: FileFormatInfo — FileFormatInfo A FileFormatInfo object that contains the detected information.

detectFileFormatFromStream(stream, callback) (static)

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

ParameterTypeDescription
streamReadableStreamThe stream
callbackCallbackThe callback function

Returns: FileFormatInfo — FileFormatInfo A FileFormatInfo object that contains the detected information.

Example:

var aspose = aspose || {};
aspose.cells = require("aspose.cells");
var fs = require("fs");
var readStream = fs.createReadStream("Book2.xlsx");
aspose.cells.FileFormatUtil.detectFileFormatFromStream(readStream, function(result, err) {
if (!err) {
console.log("detect result: " + result.getFileFormatType());
}
});

extensionToSaveFormat(extension) (static)

Converts a file name extension into a SaveFormat value. If the extension cannot be recognized, returns SaveFormat.UNKNOWN.

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

Returns: Number — Number A SaveFormat value.

fileFormatToSaveFormat(format) (static)

Converting file format to save format.

ParameterTypeDescription
formatNumberFileFormatType

Returns: Number — Number A SaveFormat value.

isTemplateFormat(extension) (static)

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

ParameterTypeDescription
extensionString

Returns: boolean — boolean

loadFormatToExtension(loadFormat) (static)

Converts a load format enumerated value into a file extension. If it can not be converted, returns null.

ParameterTypeDescription
loadFormatNumberLoadFormat

Returns: String — String The returned extension is a lower-case string with a leading dot.

loadFormatToSaveFormat(loadFormat) (static)

Converts a LoadFormat value to a SaveFormat value if possible.

ParameterTypeDescription
loadFormatNumberLoadFormat

Returns: Number — Number A SaveFormat value. The save format.

saveFormatToExtension(format) (static)

Converts a save format enumerated value into a file extension.

ParameterTypeDescription
formatNumberSaveFormat

Returns: String — String The returned extension is a lower-case string with a leading dot.

saveFormatToLoadFormat(saveFormat) (static)

Converts a SaveFormat value to a LoadFormat value if possible.

ParameterTypeDescription
saveFormatNumberSaveFormat

Returns: Number — Number A LoadFormat value. The load format

verifyPassword(stream, password) (static)

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

ParameterTypeDescription
streamInputStream
passwordStringThe password for encrypted ooxml files.

Returns: boolean — boolean Returns whether the password is corrected.