public void GetCustomXmlPartTestNoParts() { InteropExcel.Application excelApp = new InteropExcel.Application(); try { InteropExcel.Workbook workbook = excelApp.Workbooks.Add(); string expected = string.Empty; string actual; actual = WorkbookExtensions.GetCustomXmlPart(workbook, Common.Constants.XmlNamespace); Assert.AreEqual(expected, actual); } finally { excelApp.Close(); } }
public void CreateNamedRangeTestWhitespaceArgument() { InteropExcel.Application excelApp = new InteropExcel.Application(); try { InteropExcel.Workbook workbook = excelApp.Workbooks.Add(); InteropExcel.Worksheet worksheet = excelApp.ActiveSheet; string name = " "; Range range = worksheet.get_Range("A1", Type.Missing); Name expected = null; Name actual; actual = WorkbookExtensions.CreateNamedRange(workbook, name, range); Assert.AreEqual(expected, actual); } finally { excelApp.Close(); } }
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(); } }
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(); } }