本文整理汇总了C#中Microsoft.Office.Interop.Excel.Application.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Application.Close方法的具体用法?C# Application.Close怎么用?C# Application.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Excel.Application
的用法示例。
在下文中一共展示了Application.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCustomXmlPartTestOnePart
public void AddCustomXmlPartTestOnePart()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
excelApp.Workbooks.Add();
InteropExcel.Workbook workbook = excelApp.Workbooks.Add();
string content = "<Product xmlns:ns=\"" + Common.Constants.XmlNamespace + "\">" + "<ProductName>WWT Excel Add-In</ProductName>" + "</Product>";
workbook.AddCustomXmlPart(content, Common.Constants.XmlNamespace);
string existingContent = workbook.GetCustomXmlPart(Common.Constants.XmlNamespace);
Assert.AreEqual(content, existingContent);
}
finally
{
excelApp.Close();
}
}
示例2: IsWWTRangeTest
public void IsWWTRangeTest()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
excelApp.Visible = false;
excelApp.Workbooks.Add();
InteropExcel.Workbook workbook = excelApp.ActiveWorkbook;
Name namedRange = workbook.Names.Add("TestNameOne", "A1", false);
bool expected = true;
bool actual = NameExtensions.IsWWTRange(namedRange);
Assert.AreEqual(expected, actual);
}
finally
{
excelApp.Close();
}
}
示例3: AddCustomXmlPartTestEmptyString
public void AddCustomXmlPartTestEmptyString()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
excelApp.Workbooks.Add();
InteropExcel.Workbook workbook = excelApp.Workbooks.Add();
string content = string.Empty;
int expected = workbook.CustomXMLParts.Count;
workbook.AddCustomXmlPart(content, Common.Constants.XmlNamespace);
Assert.AreEqual(workbook.CustomXMLParts.Count, expected);
string existingContent = workbook.GetCustomXmlPart(Common.Constants.XmlNamespace);
Assert.AreEqual(content, existingContent);
}
finally
{
excelApp.Close();
}
}
示例4: GetDataArrayInvalidRangeTest
public void GetDataArrayInvalidRangeTest()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
excelApp.Workbooks.Add();
InteropExcel.Worksheet worksheet = excelApp.ActiveSheet;
Range range = worksheet.get_Range("A1", "I7");
Range test = worksheet.get_Range("B10", "J15");
Range mergedRange = excelApp.Union(range, test);
object[,] expected = null;
object[,] actual = mergedRange.GetDataArray(false);
Assert.AreEqual(expected, actual);
}
finally
{
excelApp.Close();
}
}
示例5: DeserializeTest
public void DeserializeTest()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
InteropExcel.Workbook workbook = excelApp.ActiveWorkbook;
ViewpointMap expected = new ViewpointMap(workbook);
expected.SerializablePerspective = new System.Collections.ObjectModel.ObservableCollection<Perspective>();
expected.SerializablePerspective.Add(new Perspective("Earth", "Earth", false, "2/25/2011 7:24:01 AM", "1", "9932 km", "SD8834DFA", "30.0", "30.0", "2.0", ".3", "1.5"));
ViewpointMap viewpointMap = new ViewpointMap(workbook);
string xmlContent = "<?xml version=\"1.0\" encoding=\"utf-16\"?><ViewpointMap xmlns:d1p1=\"http://schemas.datacontract.org/2004/07/Microsoft.Research.Wwt.Excel.Addin\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"Microsoft.Research.Wwt.Excel.Addin.ViewpointMap\"><d1p1:SerializablePerspective xmlns:d2p1=\"http://schemas.datacontract.org/2004/07/Microsoft.Research.Wwt.Excel.Common\"><d2p1:Perspective><d2p1:Declination i:nil=\"true\" /><d2p1:HasRADec>false</d2p1:HasRADec><d2p1:Latitude>2/25/2011 7:24:01 AM</d2p1:Latitude><d2p1:Longitude>1</d2p1:Longitude><d2p1:LookAngle>30.0</d2p1:LookAngle><d2p1:LookAt>Earth</d2p1:LookAt><d2p1:Name i:nil=\"true\" /><d2p1:ObservingTime>30.0</d2p1:ObservingTime><d2p1:ReferenceFrame>Earth</d2p1:ReferenceFrame><d2p1:RightAscention i:nil=\"true\" /><d2p1:Rotation>SD8834DFA</d2p1:Rotation><d2p1:TimeRate>2.0</d2p1:TimeRate><d2p1:ViewToken>1.5</d2p1:ViewToken><d2p1:Zoom>9932 km</d2p1:Zoom><d2p1:ZoomText>.3</d2p1:ZoomText></d2p1:Perspective></d1p1:SerializablePerspective></ViewpointMap>";
ViewpointMap actual;
actual = ViewpointMapExtensions.Deserialize(viewpointMap, xmlContent);
Assert.AreEqual(expected.SerializablePerspective[0].Name, actual.SerializablePerspective[0].Name);
}
finally
{
excelApp.Close();
}
}
示例6: GetData
public void GetData()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
InteropExcel.Workbook workbook = excelApp.OpenWorkbook("TestData.xlsx", false);
// Get the target range
InteropExcel.Name targetName = workbook.Names.GetNamedRange("DataRangeTwo");
string[] expected = new string[] { "23\t34\t3\t3/7/2011 12:00:00 AM\r\n", "45\t63\t4.6\t3/7/2011 1:39:45 PM\r\n67\t32\t5.3\t2/1/2009 12:00:00 AM\r\n" };
string[] actual = targetName.RefersToRange.GetData();
Assert.AreEqual(expected.Length, actual.Length);
Assert.AreEqual(expected[0], actual[0]);
Assert.AreEqual(expected[1], actual[1]);
}
finally
{
excelApp.Close();
}
}
示例7: GetNamedRangeTest
public void GetNamedRangeTest()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
excelApp.Visible = false;
excelApp.Workbooks.Add();
InteropExcel.Workbook workbook = excelApp.ActiveWorkbook;
workbook.Names.Add("TestNameOne", "A1", false);
workbook.Names.Add("TestNameTwo", "A2", false);
Names namedCollection = workbook.Names;
string expected = "TestNameOne";
Name expectedName = workbook.Names.GetNamedRange("TestNameOne");
Name actualName;
actualName = NameExtensions.GetNamedRange(namedCollection, expected);
Assert.AreEqual(expectedName, actualName);
}
finally
{
excelApp.Close();
}
}
示例8: GetDataArrayMultipleCellRangeTest
public void GetDataArrayMultipleCellRangeTest()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
excelApp.Workbooks.Add();
InteropExcel.Worksheet worksheet = excelApp.ActiveSheet;
Range range = worksheet.get_Range("A1", "B1");
Range cellOne = range.Cells[1, 1];
cellOne.Value = "TestValue1";
Range cellTwo = range.Cells[1, 2];
cellTwo.Value = "TestValue2";
object[,] expected = (object[,])Array.CreateInstance(typeof(object), new int[] { 1, 2 }, new int[] { 1, 1 });
expected[1, 1] = "TestValue1";
expected[1, 2] = "TestValue2";
object[,] actual = range.GetDataArray(false);
Assert.AreEqual(expected.Length, actual.Length);
Assert.AreEqual(expected[1, 1], actual[1, 1]);
Assert.AreEqual(expected[1, 2], actual[1, 2]);
}
finally
{
excelApp.Close();
}
}
示例9: IsValidTwoAreasPositiveTest
public void IsValidTwoAreasPositiveTest()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
excelApp.Workbooks.Add();
InteropExcel.Worksheet worksheet = excelApp.ActiveSheet;
Range range = worksheet.get_Range("A1", "I7");
bool expected = true;
Range test = worksheet.get_Range("A10", "I15");
Range mergedRange = excelApp.Union(range, test);
bool actual = mergedRange.IsValid();
Assert.AreEqual(expected, actual);
}
finally
{
excelApp.Close();
}
}
示例10: GetHeaderInvalidRangeTest
public void GetHeaderInvalidRangeTest()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
excelApp.Workbooks.Add();
InteropExcel.Worksheet worksheet = excelApp.ActiveSheet;
Range range = worksheet.get_Range("A1", "I7");
Range anotherRange = worksheet.get_Range("B10", "J15");
Range mergedRange = excelApp.Union(range, anotherRange);
Collection<string> actual = mergedRange.GetHeader();
Assert.AreEqual(0, actual.Count);
}
finally
{
excelApp.Close();
}
}
示例11: GetDataFromRangePositiveTest
public void GetDataFromRangePositiveTest()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
excelApp.Workbooks.Add();
InteropExcel.Worksheet worksheet = excelApp.ActiveSheet;
Range range = worksheet.get_Range("A1", "B3");
Range cell = range.Cells[1, 1];
cell.Value = "HeaderValueOne";
cell = range.Cells[1, 2];
cell.Value = "HeaderValueTwo";
cell = range.Cells[2, 1];
cell.Value = "DataValueOne";
cell = range.Cells[2, 2];
cell.Value = "DataValueTwo";
cell = range.Cells[3, 1];
cell.Value = "DataValueThree";
cell = range.Cells[3, 2];
cell.Value = "DataValueFour";
string expected = "HeaderValueOne\tHeaderValueTwo" + Environment.NewLine + "DataValueOne\tDataValueTwo" + Environment.NewLine + "DataValueThree\tDataValueFour" + Environment.NewLine;
string actual = RangeExtensions_Accessor.GetDataFromRange(range);
Assert.AreEqual(expected, actual);
}
finally
{
excelApp.Close();
}
}
示例12: GetValidNameTest
public void GetValidNameTest()
{
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("GetValidName");
// Activate the worksheet which contains the named range.
((_Worksheet)targetName.RefersToRange.Worksheet).Activate();
string name = ((_Worksheet)targetName.RefersToRange.Worksheet).Name;
string expected = "WWTLayer_012TestS";
string actual;
actual = WorkbookExtensions_Accessor.GetValidName(name);
Assert.AreEqual(expected, actual);
}
finally
{
application.Close();
}
}
示例13: GetCustomXmlPartTestNoParts
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();
}
}
示例14: HasChangedInvalidRangeTest
public void HasChangedInvalidRangeTest()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
excelApp.Workbooks.Add();
InteropExcel.Worksheet worksheet = excelApp.ActiveSheet;
Range range = worksheet.get_Range("A1", "I7");
Range test = worksheet.get_Range("B10", "J15");
Range mergedRange = excelApp.Union(range, test);
Range target = worksheet.get_Range("A1", Type.Missing);
bool expected = false;
bool actual = mergedRange.HasChanged(target);
Assert.AreEqual(expected, actual);
}
finally
{
excelApp.Close();
}
}
示例15: HasChangedIntersectionPositiveSingleAreaTest
public void HasChangedIntersectionPositiveSingleAreaTest()
{
InteropExcel.Application excelApp = new InteropExcel.Application();
try
{
excelApp.Workbooks.Add();
InteropExcel.Worksheet worksheet = excelApp.ActiveSheet;
Range range = worksheet.get_Range("A1", "I7");
Range target = worksheet.get_Range("C1", "E5");
bool expected = true;
bool actual = range.HasChanged(target);
Assert.AreEqual(expected, actual);
}
finally
{
excelApp.Close();
}
}