Implementing Non-Sequential Ranges
Contents
[
Hide
]
Normally, named ranges are rectangular with cells continuous and adjacent to each other. But sometimes, you may need to use a non-sequential cell range in which cells are not adjacent. Aspose.Cells supports creating a named range with non-adjacent cells.
The code sample below shows how to create a named non-sequential range with Aspose.Cells for .NET.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Adding a Name for non sequenced range | |
int index = workbook.Worksheets.Names.Add("NonSequencedRange"); | |
Name name = workbook.Worksheets.Names[index]; | |
// Creating a non sequence range of cells | |
name.RefersTo = "=Sheet1!$A$1:$B$3,Sheet1!$D$5:$E$6"; | |
// Save the workbook | |
workbook.Save(dataDir+ "Output.out.xlsx"); |