In house application can't generate excel file under c:\ root on windows 7

以前的一個跑在windows xp下的POS應用程序,執行過程中需要生成一個excel文件。該文件的生成在c盤的根目錄下。

自從系統升到windows2008+windows 7下後,該程序無法運行。原因是域用戶不能在c盤的根目錄下創建文件。即使是local admin用戶,也只能創建一個folder。

解決方法:修改保存文件的參數。不要再文件名前加“c:\”。

原來語句: excelSheet.SaveAs("c:\"+excelFileName);

替換語句: excelSheet.SaveAs(excelFileName);

該文件將被保存到當前logon 用戶的Dcuments目錄下。絕對路徑;C:\Users\userA\Documents\ (userA爲logon username)

 

另外一個問題是,用戶的機子在運行該程序是,提示如下錯誤:(該用戶的機子已經安裝了office 2003 pro)

could not load file or assemble "Microsoft.office.interop.excel.version=11.0.0.0. culture =..................

原因:需要安裝office 2003 update: redistributable primary interop assembiles. download url is:  www.microsoft.com/en-us/download/details.aspx?id=20923

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章