Agregar y Referenciar Rangos Nombrados

Agregar/Hacer referencia a los rangos con nombre en las fórmulas

El control GridWeb proporciona dos clases (GridName y GridNameCollection) para trabajar con rangos nombrados. El siguiente fragmento de código te ayudará a entender cómo crear el Rango Nombrado y acceder a él en las fórmulas.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Inserting dummy data
GridWeb1.WorkSheets[0].Cells["B1"].PutValue(100);
GridWeb1.WorkSheets[0].Cells["B2"].PutValue(200);
GridWeb1.WorkSheets[0].Cells["B3"].PutValue(300);
GridWeb1.WorkSheets[0].Cells["B4"].PutValue(400);
// Add a new named range "MyRange" with based area B1:B4
GridWeb1.WorkSheets.Names.Add("MyRange", "Sheet1!B1:B4");
// Apply a formula to a cell that refers to a named range "MyRange"
GridWeb1.WorkSheets[0].Cells["A1"].Formula = "=SUM(MyRange)";
// Apply a formula to A2 cell
GridWeb1.WorkSheets[0].Cells["A2"].Formula = "=Average(MyRange)";
// Calculate the results of the formulas
GridWeb1.WorkSheets.CalculateFormula();