DataModelRelationship.PrimaryKeyTable
DataModelRelationship.PrimaryKeyTable property
Gets the name of the primary key table for this relationship.
public string PrimaryKeyTable { get; }
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using Aspose.Cells.DataModels;
using System;
public class DataModelRelationshipPropertyPrimaryKeyTableDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Add sample data to create a meaningful context
worksheet.Cells["A1"].PutValue("Orders");
worksheet.Cells["A2"].PutValue("OrderID");
worksheet.Cells["A3"].PutValue("CustomerID");
worksheet.Cells["C1"].PutValue("Customers");
worksheet.Cells["C2"].PutValue("CustomerID");
worksheet.Cells["C3"].PutValue("CustomerName");
try
{
// Access the first relationship if it exists
DataModelRelationship relationship = workbook.DataModel?.Relationships?[0];
if (relationship != null)
{
// Display the PrimaryKeyTable property value (read-only)
Console.WriteLine("Primary Key Table: " + relationship.PrimaryKeyTable);
}
else
{
Console.WriteLine("No relationships found in the data model.");
}
// Save the workbook
workbook.Save("PrimaryKeyTableDemo.xlsx");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
See Also
- class DataModelRelationship
- namespace Aspose.Cells.DataModels
- assembly Aspose.Cells