Named Ranges.

Hello,

I'm trying to create Named Ranges from code but I'm unable to create them, basically I need to assign a name to a particular cell in order to reference it from other sheets.

Thanks in advance.

Carlos Diaz.

1 Reply

PS Pannir Selvam S Syncfusion Team July 3, 2013 06:14 AM UTC

Hi Carlos,

 

Thanks for contacting Syncfusion support.

 

You can define the named ranges in the Spreadsheet by using the following code snippet.

 

Code Snippet[C#]:

 
this.spreadSheetControl.WorkBookLoaded += spreadSheetControl_WorkBookLoaded;
 
void spreadSheetControl_WorkBookLoaded(object sender, WorkbookLoadedEventArgs args)
{
    IWorkbook workbook = this.spreadSheetControl.ExcelProperties.WorkBook;
    GridControl grid = this.spreadSheetControl.GridProperties.ActiveSpreadsheetGrid;
 
    IName name1 = workbook.Names.Add("FIRSTCELL");
    name1.RefersToRange = workbook.ActiveSheet.Range["A1"];
    grid.Model.FormulaEngine.AddNamedRange(name1.Name, name1.Value);
}

 

 

We have prepared a sample based on this and you can find the sample from the below location.

 

Please let us know if you have any other queries.

 

Regards,

Pannir



SpreadsheetDemo_WPF_39cd6eb2.zip

Loader.
Up arrow icon