日期:2014-05-18 浏览次数:21227 次
_Application myExcel = null; //引用活頁簿類別 _Workbook myBook = null; //引用工作表類別 _Worksheet mySheet = null; _Worksheet mySheet1 = null; //引用Range類別 Range myRange = null; myExcel = new Microsoft.Office.Interop.Excel.Application(); myExcel.Workbooks.Add(true); //停用警告訊息 myExcel.DisplayAlerts = false; //讓Excel文件可見 myExcel.Visible = false ; //引用第一個活頁簿 myBook = myExcel.Workbooks[1]; //設定活頁簿焦點 myBook.Activate(); //引用第一個工作表 mySheet = (_Worksheet)myBook.Worksheets[1]; myBook.Sheets.Add(Type.Missing, myBook.Worksheets[1], 1, Type.Missing); mySheet1 = (_Worksheet)myBook.Worksheets[2]; myRange = mySheet.get_Range("A1", Type.Missing); myRange.Hyperlink="http://www.csdn.net";//加链接 myRange.Formula = ""//加公式 function