Implementing Non-Sequential Ranges
Possible Usage Scenarios
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 for Python via .NET supports creating a named range with non-adjacent cells.
How to Add Non-Sequential Ranges Using Aspose.Cells for Python Excel Library
The code sample below shows how to create a named non-sequential range with Aspose.Cells for Python via .NET.
| from aspose.cells import Workbook | |
| # The path to the documents directory. | |
| dataDir = "./" | |
| # Instantiating a Workbook object | |
| workbook = Workbook() | |
| # Adding a Name for non sequenced range | |
| index = workbook.worksheets.names.add("NonSequencedRange") | |
| name = workbook.worksheets.names[index] | |
| # Creating a non sequence range of cells | |
| name.refers_to = "=Sheet1!$A$1:$B$3,Sheet1!$E$5:$D$6" | |
| # Save the workbook | |
| workbook.save(dataDir + "Output.out.xlsx") |