Aspose.Cells.Examples.CSharp.Data.AddOn.NamedRanges.CreateNamedRangeofCells.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Opening the Excel file through the file stream
            Workbook workbook = new Workbook(dataDir + "book1.xls");

            // Accessing the first worksheet in the Excel file
            Worksheet worksheet = workbook.Worksheets[0];

            // Creating a named range
            Range range = worksheet.Cells.CreateRange("B4", "G14");

            // Setting the name of the named range
            range.Name = "TestRange";

            // Saving the modified Excel file
            workbook.Save(dataDir + "output.out.xls");
            // ExEnd:1

        }
    }
CreateNamedRangeofCells