Free Support Forum - aspose.com

Working with named ranges

I have a designer file where the range is already defined for a cell.

Now I need to...

1. access the cell by the range name and put data into the cells.

2. extend the range appropriately if more cells need to be included.

3. access the address (row and column) of the range.

Please let me know how to implement this scenario

1. You can use excel.Worksheets.GetRangeByName to get a range and access cell by row and column index.

Range myRange = excel.Worksheets.GetRangeByName("MyRange");

Cell cell = myRange[0, 0];

2. You can use cells.CreateRange method to extend it.

Range myRange = excel.Worksheet[0].Cells.CreateRange(...);

myRange.Name = "MyRange";

3. Please use Range.FirstRow, Range.FirstColumn, Range.RowCount, Range.ColumnCount properties to access the address of range.