Following snippet uses late binding for excel automation.
try { Type ExAppType = Type.GetTypeFromProgID("Excel.Application"); Object ExApp = Activator.CreateInstance(ExAppType); Object objXlWbks = ExApp.GetType().InvokeMember("Workbooks", System.Reflection.BindingFlags.GetProperty,null, ExApp, null,null); Object objXlNewWbk = objXlWbks.GetType().InvokeMember("Add",System.Reflection.BindingFlags.InvokeMethod,null, objXlWbks, null,null); Object []args = new Object[1]; args[0] = "MyExcel.xls"; objXlNewWbk.GetType().InvokeMember("SaveAs",System.Reflection.BindingFlags.InvokeMethod,null,objXlNewWbk,args); } catch( Exception ex) { MessageBox.Show(ex.Message); }
|
No responses found. Be the first to respond and make money from revenue sharing program.
|