第一步:打開工具箱——>鼠標右鍵選擇項——>COM組件瀏覽——>勾選"DSO Framer Control Object"——>把"DSO Framer Control Object"拖到窗體上。
第二步:打開開始菜單——>Windows 系統——>鼠標右鍵以管理員身份運行“命令提示符“——>輸入:regsvr32.exe C:\BSMesWare\SGBCP0\EP\dsoframer.ocx “注意路徑是dsoframer.ocx存放的路徑”——>提示已成功即可。
代碼如下:
string strFileName="";
private void Form1_Load(object sender, EventArgs e)
{
strFileName = System.IO.Directory.GetCurrentDirectory() + "\\TEXTNAME.xls";//獲取當前程序Excel路徑
System.IO.FileInfo fi = new System.IO.FileInfo(strFileName);//獲取Excel對象
fi.IsReadOnly = true;//設置只讀
axFramerControl1.Titlebar = false;//設置標題欄不顯示
axFramerControl1.Menubar = false;//設置菜單欄不顯示
axFramerControl1.Toolbars = false;//設置工具欄不顯示
axFramerControl1.Open(strFileName);//打開Excel
}
截圖如下: