Enum LoadFormat

LoadFormat enumeration

Represents the load file format.

public enum LoadFormat

Values

NameValueDescription
Auto0Represents recognizing the format automatically.
Csv1Comma-Separated Values(CSV) text file.
CSV1Comma-Separated Values(CSV) text file. NOTE: This member is now obsolete. Instead, please use Csv property. This property will be removed 6 months later since April 2021. Aspose apologizes for any inconvenience you may have experienced.
Xlsx6Represents Office Open XML spreadsheetML workbook or template, with or without macros.
Tsv11Tab-Separated Values(TSV) text file.
TSV11Tab-Separated Values(TSV) text file. NOTE: This member is now obsolete. Instead, please use Tsv property. This property will be removed 6 months later since April 2021. Aspose apologizes for any inconvenience you may have experienced.
TabDelimited11Represents a tab delimited text file, same with Tsv.
Html12Represents a html file.
MHtml13Represents a mhtml file.
Ods14Open Document Sheet(ODS) file.
ODS14Open Document Sheet(ODS) file. NOTE: This member is now obsolete. Instead, please use Ods property. This property will be removed 6 months later since April 2021. Aspose apologizes for any inconvenience you may have experienced.
Excel97To20035Represents an Excel97-2003 xls file.
SpreadsheetML15Represents an Excel 2003 xml file.
Xlsb16Represents an xlsb file.
Ots31Open Document Template Sheet(OTS) file.
Numbers56Represents a numbers file.
Fods59Represents OpenDocument Flat XML Spreadsheet (.fods) file format.
FODS59Represents OpenDocument Flat XML Spreadsheet (.fods) file format. NOTE: This member is now obsolete. Instead, please use Fods property. This property will be removed 6 months later since April 2021. Aspose apologizes for any inconvenience you may have experienced.
Sxc60Represents StarOffice Calc Spreadsheet (.sxc) file format.
SXC60Represents StarOffice Calc Spreadsheet (.sxc) file format. NOTE: This member is now obsolete. Instead, please use Sxc property. This property will be removed 6 months later since April 2021. Aspose apologizes for any inconvenience you may have experienced.
Xml51Represents a simple xml file.
Epub52Reprents an EPUB file.
Azw353Represents an AZW3 file.
Chm54Represents a CHM file.
Unknown255Represents unrecognized format, cannot be loaded.
Image254Image
Json513Json

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;

    public class LoadFormatDemo
    {
        public static void LoadFormatExample()
        {
            // Load an Excel file in different formats using Aspose.Cells
            string[] filePaths = {
                "LoadFormatDemo_original.xlsx",
                "LoadFormatDemo_original.xls",
                "LoadFormatDemo_original.csv",
                "LoadFormatDemo_original.json"
            };

            foreach (var filePath in filePaths)
            {
                // Determine the load format based on file extension
                LoadFormat loadFormat = GetLoadFormat(filePath);

                // Create LoadOptions with the determined LoadFormat
                LoadOptions loadOptions = new LoadOptions(loadFormat);

                // Load the workbook with the specified load options
                Workbook workbook = new Workbook(filePath, loadOptions);

                // Perform some operations on the workbook
                Console.WriteLine($"Loaded file: {filePath}");
                Console.WriteLine($"Number of sheets: {workbook.Worksheets.Count}");

                // Save the workbook to a new file
                string outputFilePath = $"output_{System.IO.Path.GetFileName(filePath)}";
                workbook.Save(outputFilePath);
                Console.WriteLine($"Saved file as: {outputFilePath}");
            }
        }

        private static LoadFormat GetLoadFormat(string filePath)
        {
            string extension = System.IO.Path.GetExtension(filePath).ToLower();
            switch (extension)
            {
                case ".xlsx":
                    return LoadFormat.Xlsx;
                case ".xls":
                    return LoadFormat.Excel97To2003;
                case ".csv":
                    return LoadFormat.Csv;
                case ".json":
                    return LoadFormat.Json;
                default:
                    return LoadFormat.Auto;
            }
        }
    }

}

See Also