In VBA I can return the first cell of a Range like:
Function ReturnFirstCellOfRange(source As Range) As Range
Set ReturnFirstCellOfRange = source.Resize(1, 1)
End Function
What’s the smart way to do the same in Aspose? The Range.Resize can return any size of a range, but for me the first cell is ok (as in that VBA example).
@artokilponen,
See the following sample code via Aspose.Cells for your reference:
Workbook workbook = new Workbook();
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
//Creating a named range
Range range = worksheet.Cells.CreateRange("A1", "B4");
//Setting the name of the named range
range.Name = "Test_Range";
Console.WriteLine("First Cell in the range: " + range[0, 0].Name);
//or
Console.WriteLine("First Cell in the range: " + range.GetCellOrNull(range.FirstRow, range.FirstColumn).Name);
Also, see the document with example code for your reference.
https://docs.aspose.com/cells/net/create-access-and-copy-named-ranges/#identify-cells-in-the-named-range
Hope this helps a bit.