在使用VS保存Excel的程序中用到了保存圖片的功能,呼叫了AddPicture()函式之后Excel行程無法自行關閉,必須關掉程式,Excel行程才會隨程式一起關閉。
代碼中加入myExcelApp.put_Visible(TRUE);發現Excel的視窗和界面能夠關閉的, 但是仍然會殘留一個沒有界面的Excel行程。目前只能使用ShellExecute強行關閉Excel行程。
NumChangeAA(indexX,indexY);//轉換至Excel相應坐標
writeRange = startRange.get_Range(COleVariant(outChar),COleVariant(outChar));//outchar為得到的坐標
shaps = sheet.get_Shapes();
shaps.AddPicture(picPath,false,true,(float)writeRange.get_Left().dblVal,(float)writeRange.get_Top().dblVal,writeRange.get_Width().dblVal,writeRange.get_Height().dblVal);
writeRange.ReleaseDispatch();
shaps.ReleaseDispatch();
關閉和釋放程式大同小異,不使用 shaps.AddPicture()是可以自行關閉行程的。
有沒有辦法讓Excel自行關閉的方法,現在的情況就是有一個未知的 圖形界面都已經關閉的 Excel行程,不知道哪里出問題了。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/56446.html
上一篇:windows編譯node-webkit sqlite3失敗,求幫助
下一篇:vs2017更新后完全不會用了
