Create Workbook and Worksheet Scoped Named Ranges

How to Add a Named Range with Workbook Scoped

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Create a new Workbook object
workbook = Workbook()
# Get first worksheet of the workbook
sheet = workbook.worksheets[0]
# Get worksheet's cells collection
cells = sheet.cells
# Create a range of Cells from Cell A1 to C10
workbookScope = cells.create_range("A1", "C10")
# Assign the nsame to workbook scope named range
workbookScope.name = "workbookScope"
# Save the workbook
workbook.save(dataDir + "WorkbookScope.out.xlsx")

How to Add a Named Range with Worksheet Scope

from aspose.cells import Workbook
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Create a new Workbook object
workbook = Workbook()
# Get first worksheet of the workbook
sheet = workbook.worksheets[0]
# Get worksheet's cells collection
cells = sheet.cells
# Create a range of Cells
localRange = cells.create_range("A1", "C10")
# Assign name to range with sheet raference
localRange.name = "Sheet1!local"
# Save the workbook
workbook.save(dataDir + "ouput.out.xls")

Advance topics