Free Support Forum -

In Excel Define name How to add the range in refers to using aspose.cells

Dear Sir/Madam,

In excel sheet

Insert--> Name-->Define-->DefineName-->Refers to--> In Define name -> refers to how to give the range using aspose.cells in c#.

I want to add those refer to values using aspose.cells dynamically through c# code,Please send me the valuable solution.



Hi Gopi,

Thanks for considering Aspose.

May the following sample code help you for your requirement:

Workbook workbook = new Workbook();
Worksheet sheetRef = workbook.Worksheets[0];
Aspose.Cells.Cell startCell = sheetRef.Cells[0, 0];
Names names = workbook.Worksheets.Names;
string referTo = "test";
Name name = names[names.Add(referTo)];
name.RefersTo = String.Format("=OFFSET({0}!{1},0,0,{2})", sheetRef.Name, startCell.Name, 5);

Thank you.

Thanks for one and all of Aspose team,Its working fine

Thanks one and all of aspose team,its working fine