can i use named cells and not cell numbers? what is the syntax?
Hi,
Please see the document on how to create, manipulate, retrieve or use Named Ranges for your complete reference:
Moreover, you may also use another approach for it. For example, use NameCollection and Name objects to name any number of cells/range of cells, you may explicitly set it’s “refers to” attribute etc., see the sample code snippets here.
i)
Workbook workbook = new Workbook();
Worksheet sheetRef = workbook.Worksheets[0];
Aspose.Cells.Cell startCell = sheetRef.Cells[0, 0];
NameCollection names = workbook.Worksheets.Names;
string strName = “test”;
Name name = names[names.Add(strName)];
name.RefersTo = “=200”; //You may specify any cell area or range here too.
//Make it visible.
name.IsVisible = true;
workbook.Save(@“e:\test2\out_test1.xlsx”);
ii) See how to retrieve the Named cell(s) in the spreadsheet.
Workbook workbook1 = new Workbook(@“e:\test2\out_test1.xlsx”);
//Get all the named ranges
foreach (Name range in workbook1.Worksheets.Names)
{
Debug.WriteLine(“------------------------------------”);
Debug.WriteLine(“Refer To: " + range.RefersTo);
Debug.WriteLine(“Text: " + range.Text);
Debug.WriteLine(”------------------------------------”);
}
Thank you.