ComponentOne Excel for .NET
Load and Save / Load
In This Topic
    Load
    In This Topic

    Excel provides the Load method to load an Excel workbook with different formats such as csv, excel, xml, and much more. The Load method provides the following overloads which lets you load an Excel workbook from a file or a stream:

    Overloads Descriptions
    Load(string fileName) Loads an Excel worksheet from a file.
    Load(string fileName, bool fillSheets) Loads an Excel worksheet from a file and lets you set the fillSheets parameter.
    Load(string fileName, C1.C1Excel.FileFormat format) Loads an Excel worksheet from a file and lets you set the FileFormat parameter.
    Load(string fileName, C1.C1Excel.FileFormat format, bool fillSheets) Loads an Excel worksheet from a file and lets you set the fillSheets and FileFormat parameters.
    Load(System.IO.Stream stream) Loads the worksheet from a stream.
    Load(System.IO.Stream stream, bool fillSheets) Loads the worksheet from a stream and lets you set the fillSheets parameter.
    Load(System.IO.Stream stream, C1.C1Excel.FileFormat format) Loads the worksheet from a stream and lets you set the FileFormat parameter.
    Load(System.IO.Stream stream, C1.C1Excel.FileFormat format, bool fillSheets) Loads the worksheet from a stream and lets you set the fillSheets and FileFormat parameters.

    To load a workbook, use the following code. In this example, we use the Load method to load a file named test located at the bin directory of the project folder.

    C#
    Copy Code
    sheet.Load("test.xlsx");
    

    Besides loading the entire workbook, Excel enables you to load a specific sheet using the Load method and load data from a file containing comma-separated values using LoadCsv methods of the XLSheet class.