Class FileFormatUtil

FileFormatUtil class

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

public class FileFormatUtil

Methods

NameDescription
static DetectFileFormat(Stream)Detects and returns the information about a format of an excel stored in a stream.
static DetectFileFormat(string)Detects and returns the information about a format of an excel stored in a file.
static DetectFileFormat(Stream, string)Detects and returns the information about a format of an excel stored in a stream.
static DetectFileFormat(string, string)Detects and returns the information about a format of an excel stored in a file.
static ExtensionToSaveFormat(string)Converts a file name extension into a SaveFormat value.
static FileFormatToSaveFormat(FileFormatType)Converting file format to save format.
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.
static VerifyPassword(Stream, string)Detects and returns the information about a format of an excel stored in a stream.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class CellsClassFileFormatUtilDemo
    {
        public static void Run()
        {
            string filePath = "example.xlt";
            
            // Detect file format
            FileFormatInfo info = FileFormatUtil.DetectFileFormat(filePath);
            Console.WriteLine("Detected file format: " + info.FileFormatType);
            
            // Verify file format with Workbook
            Workbook workbook = new Workbook(filePath);
            Console.WriteLine("Workbook file format: " + workbook.FileFormat);
        }
    }
}

See Also