Class DataModel

DataModel class

Represents the data model.

public class DataModel

Properties

NameDescription
Relationships { get; }Gets all relationships of the tables in the data model.
Tables { get; }Gets all tables in the data model.

Examples

namespace AsposeCellsExamples
{
    using Aspose.Cells;
    using Aspose.Cells.DataModels;
    using System;

    public class DataModelsClassDataModelDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Get the DataModel from the workbook instead of creating a new instance
            DataModel dataModel = workbook.DataModel;

            // Demonstrate accessing tables and relationships (read-only properties)
            Console.WriteLine("Number of tables in DataModel: " + dataModel.Tables.Count);
            Console.WriteLine("Number of relationships in DataModel: " + dataModel.Relationships.Count);

            // Note: Since Tables and Relationships are read-only collections,
            // we can only access existing items but not modify them directly

            // Save the workbook (DataModel is typically used internally by Aspose.Cells)
            workbook.Save("DataModelDemo.xlsx");
        }
    }
}

See Also