1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
| Assembly externeAssembly = Assembly.LoadFrom("Interop.Excel.dll"); Type excelApplicationType = externeAssembly.GetType("Excel.ApplicationClass"); object excelApplication = Activator.CreateInstance(excelApplicationType); excelApplicationType.InvokeMember("Visible", BindingFlags.SetProperty, null, excelApplication, new object[] { false }); object excelWorkbooks = excelApplicationType.InvokeMember("Workbooks", BindingFlags.GetProperty, null, excelApplication, null); Type excelWorkbooksType = externeAssembly.GetType("Excel.Workbooks"); object excelWorkbook = excelWorkbooksType.InvokeMember("Add", BindingFlags.InvokeMethod, null, excelWorkbooks, new object[] { XlWBATemplate.xlWBATWorksheet }); Type excelWorkbookType = externeAssembly.GetType("Excel.Workbook");
object excelSheets = excelWorkbookType.InvokeMember("Worksheets", BindingFlags.GetProperty, null, excelWorkbook, null); Type excelSheetsType = externeAssembly.GetType("Excel.Sheets");
object excelWorkSheet = excelSheetsType.InvokeMember("get_Item", BindingFlags.InvokeMethod, null, excelSheets, new object[] { 1 }); |