FileFormatUtil
Source: aspose.
Provides utility methods for converting file format enums to strings or file extensions and back.
Methods
Methods
detectFileFormat(stream) → FileFormatInfo
Detects and returns the information about a format of an excel stored in a stream.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
stream |
InputStream |
|
The stream |
- Returns
-
FileFormatInfo
A FileFormatInfo object that contains the detected information.
detectFileFormat(stream, password) → FileFormatInfo
Detects and returns the information about a format of an excel stored in a stream.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
stream |
InputStream |
|
|
password |
String |
|
The password for encrypted ooxml files. |
- Returns
-
FileFormatInfo
A FileFormatInfo object that contains the detected information.
detectFileFormat(filePath) → FileFormatInfo
Detects and returns the information about a format of an excel stored in a file.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
filePath |
String |
|
The file path. |
- Returns
-
FileFormatInfo
A FileFormatInfo object that contains the detected information.
detectFileFormat(filePath, password) → FileFormatInfo
Detects and returns the information about a format of an excel stored in a file.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
filePath |
String |
|
The file path. |
password |
String |
|
The password for encrypted ooxml files. |
- Returns
-
FileFormatInfo
A FileFormatInfo object that contains the detected information.
detectFileFormatFromStream(stream, callback) → FileFormatInfo
Detects and returns the information about a format of an excel stored in a stream.
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());
}
});
Parameters
Name | Type | Optional | Description |
---|---|---|---|
stream |
ReadableStream |
|
The stream |
callback |
Callback |
|
The callback function |
- Returns
-
FileFormatInfo
A FileFormatInfo object that contains the detected information.
extensionToSaveFormat(extension) → Number
Converts a file name extension into a SaveFormat value. If the extension cannot be recognized, returns SaveFormat.UNKNOWN.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
extension |
String |
|
The file extension. Can be with or without a leading dot. Case-insensitive. |
- Returns
-
Number
A SaveFormat value.
fileFormatToSaveFormat(format) → Number
Converting file format to save format.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
format |
Number |
|
FileFormatType |
- Returns
-
Number
A SaveFormat value.
isTemplateFormat(extension) → boolean
Returns true if the extension is .xlt, .xltX, .xltm,.ots.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
extension |
String |
|
- Returns
-
boolean
loadFormatToExtension(loadFormat) → String
Converts a load format enumerated value into a file extension. If it can not be converted, returns null.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
loadFormat |
Number |
|
LoadFormat |
- Returns
-
String
The returned extension is a lower-case string with a leading dot.
loadFormatToSaveFormat(loadFormat) → Number
Converts a LoadFormat value to a SaveFormat value if possible.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
loadFormat |
Number |
|
LoadFormat |
- Returns
-
Number
A SaveFormat value. The save format.
saveFormatToExtension(format) → String
Converts a save format enumerated value into a file extension.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
format |
Number |
|
SaveFormat |
- Returns
-
String
The returned extension is a lower-case string with a leading dot.
saveFormatToLoadFormat(saveFormat) → Number
Converts a SaveFormat value to a LoadFormat value if possible.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
saveFormat |
Number |
|
SaveFormat |
- Returns
-
Number
A LoadFormat value. The load format
verifyPassword(stream, password) → boolean
Detects and returns the information about a format of an excel stored in a stream.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
stream |
InputStream |
|
|
password |
String |
|
The password for encrypted ooxml files. |
- Returns
-
boolean
Returns whether the password is corrected.