Class DataModelRelationshipCollection
Contents
[
Hide
]DataModelRelationshipCollection class
Represents the relationships.
public class DataModelRelationshipCollection : CollectionBase<DataModelRelationship>
Properties
| Name | Description |
|---|---|
| Capacity { get; set; } | |
| Count { get; } | |
| Item { get; } | Gets the relationship. |
| Item { get; set; } |
Methods
| Name | Description |
|---|---|
| BinarySearch(DataModelRelationship) | |
| BinarySearch(DataModelRelationship, IComparer<DataModelRelationship>) | |
| BinarySearch(int, int, DataModelRelationship, IComparer<DataModelRelationship>) | |
| Clear() | |
| Contains(DataModelRelationship) | |
| CopyTo(DataModelRelationship[]) | |
| CopyTo(DataModelRelationship[], int) | |
| CopyTo(int, DataModelRelationship[], int, int) | |
| Exists(Predicate<DataModelRelationship>) | |
| Find(Predicate<DataModelRelationship>) | |
| FindAll(Predicate<DataModelRelationship>) | |
| FindIndex(Predicate<DataModelRelationship>) | |
| FindIndex(int, Predicate<DataModelRelationship>) | |
| FindIndex(int, int, Predicate<DataModelRelationship>) | |
| FindLast(Predicate<DataModelRelationship>) | |
| FindLastIndex(Predicate<DataModelRelationship>) | |
| FindLastIndex(int, Predicate<DataModelRelationship>) | |
| FindLastIndex(int, int, Predicate<DataModelRelationship>) | |
| GetEnumerator() | |
| IndexOf(DataModelRelationship) | |
| IndexOf(DataModelRelationship, int) | |
| IndexOf(DataModelRelationship, int, int) | |
| LastIndexOf(DataModelRelationship) | |
| LastIndexOf(DataModelRelationship, int) | |
| LastIndexOf(DataModelRelationship, int, int) | |
| RemoveAt(int) |
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using Aspose.Cells.DataModels;
using System;
public class DataModelsClassDataModelRelationshipCollectionDemo
{
public static void Run()
{
// Create a new workbook for demonstration
Workbook workbook = new Workbook();
try
{
// Get the DataModelRelationshipCollection from the workbook's data model
// This assumes the workbook has a data model with relationships
DataModelRelationshipCollection relationships = workbook.DataModel?.Relationships;
if (relationships == null)
{
Console.WriteLine("Workbook data model doesn't contain relationships");
return;
}
// Demonstrate basic functionality by showing the count
Console.WriteLine($"Number of relationships: {relationships.Count}");
// Attempt to access first item (will throw exception if collection is empty)
try
{
var firstRelationship = relationships[0];
Console.WriteLine($"First relationship: {firstRelationship}");
}
catch (ArgumentOutOfRangeException)
{
Console.WriteLine("Collection is empty - cannot access items");
}
// Save the workbook
workbook.Save("DataModelRelationshipCollectionDemo.xlsx");
}
catch (Exception ex)
{
Console.WriteLine($"Error working with DataModelRelationshipCollection: {ex.Message}");
}
}
}
}
See Also
- class CollectionBase<T>
- class DataModelRelationship
- namespace Aspose.Cells.DataModels
- assembly Aspose.Cells