Пример #1
0
        public void GetSelectionRangeNameWithZeroIndexTest()
        {
            InteropExcel.Application application = new InteropExcel.Application();

            try
            {
                InteropExcel.Workbook workbook = application.OpenWorkbook("TestData.xlsx", false);

                // Get the target range that will be used to set the active sheet
                InteropExcel.Name targetName = workbook.Names.GetNamedRange("TestRangeOne");

                // Activate the worksheet which contains the named range.
                ((_Worksheet)targetName.RefersToRange.Worksheet).Activate();

                string expected = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", ((_Worksheet)targetName.RefersToRange.Worksheet).Name, "1");
                string actual;
                actual = WorkbookExtensions.GetSelectionRangeName(workbook);
                Assert.AreEqual(expected, actual);
            }
            finally
            {
                application.Close();
            }
        }
Пример #2
0
        public void GetSelectionRangeNameTest()
        {
            InteropExcel.Application application = new InteropExcel.Application();

            try
            {
                InteropExcel.Workbook workbook = application.OpenWorkbook("TestData.xlsx", false);

                // Get the target range that will be used to set the active sheet
                InteropExcel.Name targetName = workbook.Names.GetNamedRange("GetSelectionRangeName_2");

                // Activate the worksheet which contains the named range.
                ((_Worksheet)targetName.RefersToRange.Worksheet).Activate();

                string expected = "GetSelectionRangeName_3";
                string actual;
                actual = WorkbookExtensions.GetSelectionRangeName(workbook);
                Assert.AreEqual(expected, actual);
            }
            finally
            {
                application.Close();
            }
        }