C#不能打开excel文件

问题:jenkins不能打开excel文件


分析:Even though your script or program is executing under a user account, when Excel is launched through COM automation it is executed under the Local System user identity. This identity does not have a user profile, and this causes Excel to fail because it is designed to assume that it is running in an interactive user session.

(尽管您的脚本或程序在用户帐户下执行,但当Excel通过COM自动化启动时,它是在Local System用户标识下执行的。这个标识没有用户配置文件,这导致Excel失败,因为它被设计成假设它在一个交互式用户会话中运行)


Log:

TestCaseJlinkArm.xlsm'. There are several possible reasons:

The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently open workbook.
   at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)


解决方案:

即在C:\Windows\System32\config\systemprofile和C:\Windows\SysWOW64\config\systemprofile目录下创建名为Desktop目录即可解决问题



参考:http://blog.csdn.net/wyzlwyzl/article/details/48686483

展开阅读全文

没有更多推荐了,返回首页